file_name
stringlengths
71
779k
comments
stringlengths
20
182k
code_string
stringlengths
20
36.9M
__index_level_0__
int64
0
17.2M
input_ids
sequence
attention_mask
sequence
labels
sequence
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "../libraries/utils/Strings.sol"; import "../interfaces/IRouting.sol"; import "../interfaces/IModule.sol"; import "../interfaces/IAccessManager.sol"; contract MockRoutingUpgrade is Initializable, OwnableUpgradeable, IRouting { using Strings for *; struct Rule { string val; bool isValue; } mapping(string => IModule) public modules; mapping(string => Rule) public router; // access control contract IAccessManager public accessManager; bytes32 public constant SET_ROUTING_RULES_ROLE = keccak256("SET_ROUTING_RULES_ROLE"); bytes32 public constant ADD_ROUTING_ROLE = keccak256("ADD_ROUTING_ROLE"); uint256 public version; // only authorized accounts can perform related transactions modifier onlyAuthorizee(bytes32 role) { require(accessManager.hasRole(role, _msgSender()), "not authorized"); _; } function setVersion(uint256 _version) public { version = _version; } function initialize(address accessManagerContract) public initializer { accessManager = IAccessManager(accessManagerContract); } /** * @notice return the module contract instance with the specified name * @param moduleName the module name */ function getModule(string calldata moduleName) external view override returns (IModule) { return modules[moduleName]; } /** * @notice verify that the routing rules are correct * @param sourceChain source chain name * @param destChain destination chain name * @param port application module name */ function authenticate( string calldata sourceChain, string calldata destChain, string calldata port ) external view override returns (bool) { string memory wildcard = "*"; // 1. *,*,* if (_isExistRule(_genCondition(wildcard, wildcard, wildcard))) { return true; } // 2. source,dest,moudle if (_isExistRule(_genCondition(sourceChain, destChain, port))) { return true; } //3. source,*,model if (_isExistRule(_genCondition(sourceChain, wildcard, port))) { return true; } //4. source,dest,* if (_isExistRule(_genCondition(sourceChain, destChain, wildcard))) { return true; } //5. source,*,* if (_isExistRule(_genCondition(sourceChain, wildcard, wildcard))) { return true; } //6. *,dest,model if (_isExistRule(_genCondition(sourceChain, destChain, port))) { return true; } //7. *,dest,*, if (_isExistRule(_genCondition(wildcard, sourceChain, wildcard))) { return true; } // 8. *,*,model if (_isExistRule(_genCondition(wildcard, wildcard, port))) { return true; } return false; } /** * @notice add new routing rules * @param _rules routing rules */ function setRoutingRules(string[] calldata _rules) external onlyAuthorizee(SET_ROUTING_RULES_ROLE) { string[] memory mRules = new string[](_rules.length); for (uint256 i = 0; i < _rules.length; i++) { mRules[i] = _rules[i]; } _setRuleMap(mRules); } /** * @notice add a module: * @param moduleName module name * @param moduleContract module contract address */ function addRouting(string calldata moduleName, address moduleContract) external onlyAuthorizee(ADD_ROUTING_ROLE) { modules[moduleName] = IModule(moduleContract); } function _setRuleMap(string[] memory _rules) private { for (uint256 i = 0; i < _rules.length; i++) { router[_rules[i]].val = _rules[i]; router[_rules[i]].isValue = true; } } function _isExistRule(string memory _rule) private view returns (bool) { return router[_rule].isValue; } function _genCondition( string memory prefix, string memory mid, string memory suffix ) private pure returns (string memory) { Strings.slice[] memory parts = new Strings.slice[](3); parts[0] = prefix.toSlice(); parts[1] = mid.toSlice(); parts[2] = suffix.toSlice(); string memory condition = ",".toSlice().join(parts); return condition; } }
only authorized accounts can perform related transactions
modifier onlyAuthorizee(bytes32 role) { require(accessManager.hasRole(role, _msgSender()), "not authorized"); _; }
14,037,609
[ 1, 4625, 348, 7953, 560, 30, 225, 1338, 10799, 9484, 848, 3073, 3746, 8938, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 9606, 1338, 18987, 73, 12, 3890, 1578, 2478, 13, 288, 203, 3639, 2583, 12, 3860, 1318, 18, 5332, 2996, 12, 4615, 16, 389, 3576, 12021, 1435, 3631, 315, 902, 10799, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity >=0.7.1; /** * @title RLPEncode * @dev A simple RLP encoding library. * @author Bakaoh */ library RLPEncode { /* * Internal functions */ /** * @dev RLP encodes a byte string. * @param self The byte string to encode. * @return The RLP encoded string in bytes. */ function encodeBytes(bytes memory self) internal pure returns (bytes memory) { bytes memory encoded; if (self.length == 1 && uint8(self[0]) <= 128) { encoded = self; } else { encoded = concat(encodeLength(self.length, 128), self); } return encoded; } /** * @dev RLP encodes a list of RLP encoded byte byte strings. * @param self The list of RLP encoded byte strings. * @return The RLP encoded list of items in bytes. */ function encodeList(bytes[] memory self) internal pure returns (bytes memory) { bytes memory list = flatten(self); return concat(encodeLength(list.length, 192), list); } /** * @dev RLP encodes a string. * @param self The string to encode. * @return The RLP encoded string in bytes. */ function encodeString(string memory self) internal pure returns (bytes memory) { return encodeBytes(bytes(self)); } /** * @dev RLP encodes an address. * @param self The address to encode. * @return The RLP encoded address in bytes. */ function encodeAddress(address self) internal pure returns (bytes memory) { bytes memory inputBytes; assembly { let m := mload(0x40) mstore( add(m, 20), xor(0x140000000000000000000000000000000000000000, self) ) mstore(0x40, add(m, 52)) inputBytes := m } return encodeBytes(inputBytes); } /** * @dev RLP encodes a uint. * @param self The uint to encode. * @return The RLP encoded uint in bytes. */ function encodeUint(uint256 self) internal pure returns (bytes memory) { return encodeBytes(toBinary(self)); } /** * @dev RLP encodes an int. * @param self The int to encode. * @return The RLP encoded int in bytes. */ function encodeInt(int256 self) internal pure returns (bytes memory) { return encodeUint(uint256(self)); } /** * @dev RLP encodes a bool. * @param self The bool to encode. * @return The RLP encoded bool in bytes. */ function encodeBool(bool self) internal pure returns (bytes memory) { bytes memory encoded = new bytes(1); encoded[0] = (self ? bytes1(0x01) : bytes1(0x80)); return encoded; } /* * Private functions */ /** * @dev Encode the first byte, followed by the `len` in binary form if `length` is more than 55. * @param len The length of the string or the payload. * @param offset 128 if item is string, 192 if item is list. * @return RLP encoded bytes. */ function encodeLength(uint256 len, uint256 offset) private pure returns (bytes memory) { bytes memory encoded; if (len < 56) { encoded = new bytes(1); encoded[0] = bytes32(len + offset)[31]; } else { uint256 lenLen; uint256 i = 1; while (len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes32(lenLen + offset + 55)[31]; for (i = 1; i <= lenLen; i++) { encoded[i] = bytes32((len / (256**(lenLen - i))) % 256)[31]; } } return encoded; } /** * @dev Encode integer in big endian binary form with no leading zeroes. * @notice TODO: This should be optimized with assembly to save gas costs. * @param _x The integer to encode. * @return RLP encoded bytes. */ function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } /** * @dev Copies a piece of memory to another location. * @notice From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol. * @param _dest Destination location. * @param _src Source location. * @param _len Length of memory to copy. */ function memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /** * @dev Flattens a list of byte strings into one byte string. * @notice From: https://github.com/sammayo/solidity-rlp-encoder/blob/master/RLPEncode.sol. * @param _list List of byte strings to flatten. * @return The flattened byte string. */ function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } /** * @dev Concatenates two bytes. * @notice From: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol. * @param _preBytes First byte string. * @param _postBytes Second byte string. * @return Both byte string combined. */ function concat(bytes memory _preBytes, bytes memory _postBytes) private pure returns (bytes memory) { bytes memory tempBytes; assembly { tempBytes := mload(0x40) let length := mload(_preBytes) mstore(tempBytes, length) let mc := add(tempBytes, 0x20) let end := add(mc, length) for { let cc := add(_preBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) mc := end end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) ) ) } return tempBytes; } }
* @title RLPEncode @dev A simple RLP encoding library. @author Bakaoh/
library RLPEncode { function encodeBytes(bytes memory self) internal pure returns (bytes memory) { bytes memory encoded; if (self.length == 1 && uint8(self[0]) <= 128) { encoded = self; encoded = concat(encodeLength(self.length, 128), self); } return encoded; } { bytes memory encoded; if (self.length == 1 && uint8(self[0]) <= 128) { encoded = self; encoded = concat(encodeLength(self.length, 128), self); } return encoded; } } else { function encodeList(bytes[] memory self) internal pure returns (bytes memory) { bytes memory list = flatten(self); return concat(encodeLength(list.length, 192), list); } function encodeString(string memory self) internal pure returns (bytes memory) { return encodeBytes(bytes(self)); } function encodeAddress(address self) internal pure returns (bytes memory) { bytes memory inputBytes; assembly { let m := mload(0x40) mstore( add(m, 20), xor(0x140000000000000000000000000000000000000000, self) ) mstore(0x40, add(m, 52)) inputBytes := m } return encodeBytes(inputBytes); } function encodeAddress(address self) internal pure returns (bytes memory) { bytes memory inputBytes; assembly { let m := mload(0x40) mstore( add(m, 20), xor(0x140000000000000000000000000000000000000000, self) ) mstore(0x40, add(m, 52)) inputBytes := m } return encodeBytes(inputBytes); } function encodeUint(uint256 self) internal pure returns (bytes memory) { return encodeBytes(toBinary(self)); } function encodeInt(int256 self) internal pure returns (bytes memory) { return encodeUint(uint256(self)); } function encodeBool(bool self) internal pure returns (bytes memory) { bytes memory encoded = new bytes(1); encoded[0] = (self ? bytes1(0x01) : bytes1(0x80)); return encoded; } function encodeLength(uint256 len, uint256 offset) private pure returns (bytes memory) { bytes memory encoded; if (len < 56) { encoded = new bytes(1); encoded[0] = bytes32(len + offset)[31]; uint256 lenLen; uint256 i = 1; while (len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes32(lenLen + offset + 55)[31]; for (i = 1; i <= lenLen; i++) { encoded[i] = bytes32((len / (256**(lenLen - i))) % 256)[31]; } } return encoded; } function encodeLength(uint256 len, uint256 offset) private pure returns (bytes memory) { bytes memory encoded; if (len < 56) { encoded = new bytes(1); encoded[0] = bytes32(len + offset)[31]; uint256 lenLen; uint256 i = 1; while (len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes32(lenLen + offset + 55)[31]; for (i = 1; i <= lenLen; i++) { encoded[i] = bytes32((len / (256**(lenLen - i))) % 256)[31]; } } return encoded; } } else { function encodeLength(uint256 len, uint256 offset) private pure returns (bytes memory) { bytes memory encoded; if (len < 56) { encoded = new bytes(1); encoded[0] = bytes32(len + offset)[31]; uint256 lenLen; uint256 i = 1; while (len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes32(lenLen + offset + 55)[31]; for (i = 1; i <= lenLen; i++) { encoded[i] = bytes32((len / (256**(lenLen - i))) % 256)[31]; } } return encoded; } function encodeLength(uint256 len, uint256 offset) private pure returns (bytes memory) { bytes memory encoded; if (len < 56) { encoded = new bytes(1); encoded[0] = bytes32(len + offset)[31]; uint256 lenLen; uint256 i = 1; while (len / i != 0) { lenLen++; i *= 256; } encoded = new bytes(lenLen + 1); encoded[0] = bytes32(lenLen + offset + 55)[31]; for (i = 1; i <= lenLen; i++) { encoded[i] = bytes32((len / (256**(lenLen - i))) % 256)[31]; } } return encoded; } function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } function toBinary(uint256 _x) private pure returns (bytes memory) { bytes memory b = new bytes(32); assembly { mstore(add(b, 32), _x) } uint256 i; for (i = 0; i < 32; i++) { if (b[i] != 0) { break; } } bytes memory res = new bytes(32 - i); for (uint256 j = 0; j < res.length; j++) { res[j] = b[i++]; } return res; } function memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function memcpy( uint256 _dest, uint256 _src, uint256 _len ) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function flatten(bytes[] memory _list) private pure returns (bytes memory) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i; for (i = 0; i < _list.length; i++) { len += _list[i].length; } bytes memory flattened = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(flattened, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } return flattened; } function concat(bytes memory _preBytes, bytes memory _postBytes) private pure returns (bytes memory) { bytes memory tempBytes; assembly { tempBytes := mload(0x40) let length := mload(_preBytes) mstore(tempBytes, length) let mc := add(tempBytes, 0x20) let end := add(mc, length) for { let cc := add(_preBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) mc := end end := add(mc, length) for { let cc := add(_postBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) ) ) } return tempBytes; } function concat(bytes memory _preBytes, bytes memory _postBytes) private pure returns (bytes memory) { bytes memory tempBytes; assembly { tempBytes := mload(0x40) let length := mload(_preBytes) mstore(tempBytes, length) let mc := add(tempBytes, 0x20) let end := add(mc, length) for { let cc := add(_preBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) mc := end end := add(mc, length) for { let cc := add(_postBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) ) ) } return tempBytes; } function concat(bytes memory _preBytes, bytes memory _postBytes) private pure returns (bytes memory) { bytes memory tempBytes; assembly { tempBytes := mload(0x40) let length := mload(_preBytes) mstore(tempBytes, length) let mc := add(tempBytes, 0x20) let end := add(mc, length) for { let cc := add(_preBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) mc := end end := add(mc, length) for { let cc := add(_postBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) ) ) } return tempBytes; } } lt(mc, end) { } { function concat(bytes memory _preBytes, bytes memory _postBytes) private pure returns (bytes memory) { bytes memory tempBytes; assembly { tempBytes := mload(0x40) let length := mload(_preBytes) mstore(tempBytes, length) let mc := add(tempBytes, 0x20) let end := add(mc, length) for { let cc := add(_preBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) mc := end end := add(mc, length) for { let cc := add(_postBytes, 0x20) mc := add(mc, 0x20) cc := add(cc, 0x20) mstore(mc, mload(cc)) } mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) ) ) } return tempBytes; } } lt(mc, end) { } { }
1,786,206
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 534, 14461, 5509, 632, 5206, 432, 4143, 534, 14461, 2688, 5313, 18, 632, 4161, 605, 581, 6033, 76, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 12083, 534, 14461, 5509, 288, 203, 203, 565, 445, 2017, 2160, 12, 3890, 3778, 365, 13, 203, 3639, 2713, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 3778, 13, 203, 203, 565, 288, 203, 3639, 1731, 3778, 3749, 31, 203, 3639, 309, 261, 2890, 18, 2469, 422, 404, 597, 2254, 28, 12, 2890, 63, 20, 5717, 1648, 8038, 13, 288, 203, 5411, 3749, 273, 365, 31, 203, 5411, 3749, 273, 3835, 12, 3015, 1782, 12, 2890, 18, 2469, 16, 8038, 3631, 365, 1769, 203, 3639, 289, 203, 3639, 327, 3749, 31, 203, 565, 289, 203, 203, 565, 288, 203, 3639, 1731, 3778, 3749, 31, 203, 3639, 309, 261, 2890, 18, 2469, 422, 404, 597, 2254, 28, 12, 2890, 63, 20, 5717, 1648, 8038, 13, 288, 203, 5411, 3749, 273, 365, 31, 203, 5411, 3749, 273, 3835, 12, 3015, 1782, 12, 2890, 18, 2469, 16, 8038, 3631, 365, 1769, 203, 3639, 289, 203, 3639, 327, 3749, 31, 203, 565, 289, 203, 203, 3639, 289, 469, 288, 203, 565, 445, 2017, 682, 12, 3890, 8526, 3778, 365, 13, 203, 3639, 2713, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 3778, 13, 203, 565, 288, 203, 3639, 1731, 3778, 666, 273, 5341, 12, 2890, 1769, 203, 3639, 327, 3835, 12, 3015, 1782, 12, 1098, 18, 2469, 16, 20217, 3631, 666, 1769, 203, 565, 289, 203, 203, 565, 445, 2017, 780, 12, 1080, 3778, 365, 13, 203, 3639, 2713, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 3778, 13, 203, 565, 288, 203, 3639, 327, 2017, 2160, 12, 3890, 12, 2890, 10019, 203, 565, 289, 203, 203, 565, 445, 2017, 1887, 12, 2867, 365, 13, 2713, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 3639, 1731, 3778, 810, 2160, 31, 203, 3639, 19931, 288, 203, 5411, 2231, 312, 519, 312, 945, 12, 20, 92, 7132, 13, 203, 5411, 312, 2233, 12, 203, 7734, 527, 12, 81, 16, 4200, 3631, 203, 7734, 17586, 12, 20, 92, 3461, 12648, 12648, 12648, 12648, 12648, 16, 365, 13, 203, 5411, 262, 203, 5411, 312, 2233, 12, 20, 92, 7132, 16, 527, 12, 81, 16, 18106, 3719, 203, 5411, 810, 2160, 519, 312, 203, 3639, 289, 203, 3639, 327, 2017, 2160, 12, 2630, 2160, 1769, 203, 565, 289, 203, 203, 565, 445, 2017, 1887, 12, 2867, 365, 13, 2713, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 3639, 1731, 3778, 810, 2160, 31, 203, 3639, 19931, 288, 203, 5411, 2231, 312, 519, 312, 945, 12, 20, 92, 7132, 13, 203, 5411, 312, 2233, 12, 203, 7734, 527, 12, 81, 16, 4200, 3631, 203, 7734, 17586, 12, 20, 92, 3461, 12648, 12648, 12648, 12648, 12648, 16, 365, 13, 203, 5411, 262, 203, 5411, 312, 2233, 12, 20, 92, 7132, 16, 527, 12, 81, 16, 18106, 3719, 203, 5411, 810, 2160, 519, 312, 203, 3639, 289, 203, 3639, 327, 2017, 2160, 12, 2630, 2160, 1769, 203, 565, 289, 203, 203, 565, 445, 2017, 5487, 12, 11890, 5034, 365, 13, 2713, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 3639, 327, 2017, 2160, 12, 869, 5905, 12, 2890, 10019, 203, 565, 289, 203, 203, 565, 445, 2017, 1702, 12, 474, 5034, 365, 13, 2713, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 3639, 327, 2017, 5487, 12, 11890, 5034, 12, 2890, 10019, 203, 565, 289, 203, 203, 565, 445, 2017, 7464, 12, 6430, 365, 13, 2713, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 3639, 1731, 3778, 3749, 273, 394, 1731, 12, 21, 1769, 203, 3639, 3749, 63, 20, 65, 273, 261, 2890, 692, 1731, 21, 12, 20, 92, 1611, 13, 294, 1731, 21, 12, 20, 92, 3672, 10019, 203, 3639, 327, 3749, 31, 203, 565, 289, 203, 203, 203, 565, 445, 2017, 1782, 12, 11890, 5034, 562, 16, 2254, 5034, 1384, 13, 203, 3639, 3238, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 3778, 13, 203, 565, 288, 203, 3639, 1731, 3778, 3749, 31, 203, 3639, 309, 261, 1897, 411, 13850, 13, 288, 203, 5411, 3749, 273, 394, 1731, 12, 21, 1769, 203, 5411, 3749, 63, 20, 65, 273, 1731, 1578, 12, 1897, 397, 1384, 25146, 6938, 15533, 203, 5411, 2254, 5034, 562, 2891, 31, 203, 5411, 2254, 5034, 277, 273, 404, 31, 203, 5411, 1323, 261, 1897, 342, 277, 480, 374, 13, 288, 203, 7734, 562, 2891, 9904, 31, 203, 7734, 277, 6413, 8303, 31, 203, 5411, 289, 203, 203, 5411, 3749, 273, 394, 1731, 12, 1897, 2891, 397, 404, 1769, 203, 5411, 3749, 63, 20, 65, 273, 1731, 1578, 12, 1897, 2891, 397, 1384, 397, 21483, 25146, 6938, 15533, 203, 5411, 364, 261, 77, 273, 404, 31, 277, 1648, 562, 2891, 31, 277, 27245, 288, 203, 7734, 3749, 63, 77, 65, 273, 1731, 1578, 12443, 1897, 342, 261, 5034, 636, 12, 1897, 2891, 300, 277, 20349, 738, 8303, 25146, 6938, 15533, 203, 5411, 289, 203, 3639, 289, 203, 3639, 327, 3749, 31, 203, 565, 289, 203, 203, 565, 445, 2017, 1782, 12, 11890, 5034, 562, 16, 2254, 5034, 1384, 13, 203, 3639, 3238, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 3778, 13, 203, 565, 288, 203, 3639, 1731, 3778, 3749, 31, 203, 3639, 309, 261, 1897, 411, 13850, 13, 288, 203, 5411, 3749, 273, 394, 1731, 12, 21, 1769, 203, 5411, 3749, 63, 20, 65, 273, 1731, 1578, 12, 1897, 397, 1384, 25146, 6938, 15533, 203, 5411, 2254, 5034, 562, 2891, 31, 203, 5411, 2254, 5034, 277, 273, 404, 31, 203, 5411, 1323, 261, 1897, 342, 277, 480, 374, 13, 288, 203, 7734, 562, 2891, 9904, 31, 203, 7734, 277, 6413, 8303, 31, 203, 5411, 289, 203, 203, 5411, 3749, 273, 394, 1731, 12, 1897, 2891, 397, 404, 1769, 203, 5411, 3749, 63, 20, 65, 273, 1731, 1578, 12, 1897, 2891, 397, 1384, 397, 21483, 25146, 6938, 15533, 203, 5411, 364, 261, 77, 273, 404, 31, 277, 1648, 562, 2891, 31, 277, 27245, 288, 203, 7734, 3749, 63, 77, 65, 273, 1731, 1578, 12443, 1897, 342, 261, 5034, 636, 12, 1897, 2891, 300, 277, 20349, 738, 8303, 25146, 6938, 15533, 203, 5411, 289, 203, 3639, 289, 203, 3639, 327, 3749, 31, 203, 565, 289, 203, 203, 3639, 289, 469, 288, 203, 565, 445, 2017, 1782, 12, 11890, 5034, 562, 16, 2 ]
pragma solidity 0.4.25; // produced by the Solididy File Flattener (c) David Appleton 2018 // contact : [email protected] // released under Apache 2.0 licence library ECDSA { /** * @dev Recover signer address from a message by using their signature * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param signature bytes signature, the signature is generated using web3.eth.sign() */ function recover(bytes32 hash, bytes signature) internal pure returns (address) { bytes32 r; bytes32 s; uint8 v; // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solium-disable-next-line security/no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions if (v < 27) { v += 27; } // If the version is correct return the signer address if (v != 27 && v != 28) { return (address(0)); } else { // solium-disable-next-line arg-overflow return ecrecover(hash, v, r, s); } } /** * toEthSignedMessageHash * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * and hash the result */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) ); } } contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract DecoBaseProjectsMarketplace is Ownable { using SafeMath for uint256; // `DecoRelay` contract address. address public relayContractAddress; /** * @dev Payble fallback for reverting transactions of any incoming ETH. */ function () public payable { require(msg.value == 0, "Blocking any incoming ETH."); } /** * @dev Set the new address of the `DecoRelay` contract. * @param _newAddress An address of the new contract. */ function setRelayContractAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Relay address must not be 0x0."); relayContractAddress = _newAddress; } /** * @dev Allows to trasnfer any ERC20 tokens from the contract balance to owner's address. * @param _tokenAddress An `address` of an ERC20 token. * @param _tokens An `uint` tokens amount. * @return A `bool` operation result state. */ function transferAnyERC20Token( address _tokenAddress, uint _tokens ) public onlyOwner returns (bool success) { IERC20 token = IERC20(_tokenAddress); return token.transfer(owner(), _tokens); } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } /// @title Contract to store other contracts newest versions addresses and service information. contract DecoRelay is DecoBaseProjectsMarketplace { address public projectsContractAddress; address public milestonesContractAddress; address public escrowFactoryContractAddress; address public arbitrationContractAddress; address public feesWithdrawalAddress; uint8 public shareFee; function setProjectsContractAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Address should not be 0x0."); projectsContractAddress = _newAddress; } function setMilestonesContractAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Address should not be 0x0."); milestonesContractAddress = _newAddress; } function setEscrowFactoryContractAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Address should not be 0x0."); escrowFactoryContractAddress = _newAddress; } function setArbitrationContractAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Address should not be 0x0."); arbitrationContractAddress = _newAddress; } function setFeesWithdrawalAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0x0), "Address should not be 0x0."); feesWithdrawalAddress = _newAddress; } function setShareFee(uint8 _shareFee) external onlyOwner { require(_shareFee <= 100, "Deconet share fee must be less than 100%."); shareFee = _shareFee; } } /** * @title Escrow contract, every project deploys a clone and transfer ownership to the project client, so all * funds not reserved to pay for a milestone can be safely moved in/out. */ contract DecoEscrow is DecoBaseProjectsMarketplace { using SafeMath for uint256; // Indicates if the current clone has been initialized. bool internal isInitialized; // Stores share fee that should apply on any successful distribution. uint8 public shareFee; // Authorized party for executing funds distribution operations. address public authorizedAddress; // State variable to track available ETH Escrow owner balance. // Anything that is not blocked or distributed in favor of any party can be withdrawn by the owner. uint public balance; // Mapping of available for withdrawal funds by the address. // Accounted amounts are excluded from the `balance`. mapping (address => uint) public withdrawalAllowanceForAddress; // Maps information about the amount of deposited ERC20 token to the token address. mapping(address => uint) public tokensBalance; /** * Mapping of ERC20 tokens amounts to token addresses that are available for withdrawal for a given address. * Accounted here amounts are excluded from the `tokensBalance`. */ mapping(address => mapping(address => uint)) public tokensWithdrawalAllowanceForAddress; // ETH amount blocked in Escrow. // `balance` excludes this amount. uint public blockedBalance; // Mapping of the amount of ERC20 tokens to the the token address that are blocked in Escrow. // A token value in `tokensBalance` excludes stored here amount. mapping(address => uint) public blockedTokensBalance; // Logged when an operation with funds occurred. event FundsOperation ( address indexed sender, address indexed target, address tokenAddress, uint amount, PaymentType paymentType, OperationType indexed operationType ); // Logged when the given address authorization to distribute Escrow funds changed. event FundsDistributionAuthorization ( address targetAddress, bool isAuthorized ); // Accepted types of payments. enum PaymentType { Ether, Erc20 } // Possible operations with funds. enum OperationType { Receive, Send, Block, Unblock, Distribute } // Restrict function call to be originated from an address that was authorized to distribute funds. modifier onlyAuthorized() { require(authorizedAddress == msg.sender, "Only authorized addresses allowed."); _; } /** * @dev Default `payable` fallback to accept incoming ETH from any address. */ function () public payable { deposit(); } /** * @dev Initialize the Escrow clone with default values. * @param _newOwner An address of a new escrow owner. * @param _authorizedAddress An address that will be stored as authorized. */ function initialize( address _newOwner, address _authorizedAddress, uint8 _shareFee, address _relayContractAddress ) external { require(!isInitialized, "Only uninitialized contracts allowed."); isInitialized = true; authorizedAddress = _authorizedAddress; emit FundsDistributionAuthorization(_authorizedAddress, true); _transferOwnership(_newOwner); shareFee = _shareFee; relayContractAddress = _relayContractAddress; } /** * @dev Start transfering the given amount of the ERC20 tokens available by provided address. * @param _tokenAddress ERC20 token contract address. * @param _amount Amount to transfer from sender`s address. */ function depositErc20(address _tokenAddress, uint _amount) external { require(_tokenAddress != address(0x0), "Token Address shouldn't be 0x0."); IERC20 token = IERC20(_tokenAddress); require( token.transferFrom(msg.sender, address(this), _amount), "Transfer operation should be successful." ); tokensBalance[_tokenAddress] = tokensBalance[_tokenAddress].add(_amount); emit FundsOperation ( msg.sender, address(this), _tokenAddress, _amount, PaymentType.Erc20, OperationType.Receive ); } /** * @dev Withdraw the given amount of ETH to sender`s address if allowance or contract balance is sufficient. * @param _amount Amount to withdraw. */ function withdraw(uint _amount) external { withdrawForAddress(msg.sender, _amount); } /** * @dev Withdraw the given amount of ERC20 token to sender`s address if allowance or contract balance is sufficient. * @param _tokenAddress ERC20 token address. * @param _amount Amount to withdraw. */ function withdrawErc20(address _tokenAddress, uint _amount) external { withdrawErc20ForAddress(msg.sender, _tokenAddress, _amount); } /** * @dev Block funds for future use by authorized party stored in `authorizedAddress`. * @param _amount An uint of Wei to be blocked. */ function blockFunds(uint _amount) external onlyAuthorized { require(_amount <= balance, "Amount to block should be less or equal than balance."); balance = balance.sub(_amount); blockedBalance = blockedBalance.add(_amount); emit FundsOperation ( address(this), msg.sender, address(0x0), _amount, PaymentType.Ether, OperationType.Block ); } /** * @dev Blocks ERC20 tokens funds for future use by authorized party listed in `authorizedAddress`. * @param _tokenAddress An address of ERC20 token. * @param _amount An uint of tokens to be blocked. */ function blockTokenFunds(address _tokenAddress, uint _amount) external onlyAuthorized { uint accountedTokensBalance = tokensBalance[_tokenAddress]; require( _amount <= accountedTokensBalance, "Tokens mount to block should be less or equal than balance." ); tokensBalance[_tokenAddress] = accountedTokensBalance.sub(_amount); blockedTokensBalance[_tokenAddress] = blockedTokensBalance[_tokenAddress].add(_amount); emit FundsOperation ( address(this), msg.sender, _tokenAddress, _amount, PaymentType.Erc20, OperationType.Block ); } /** * @dev Distribute funds between contract`s balance and allowance for some address. * Deposit may be returned back to the contract address, i.e. to the escrow owner. * Or deposit may flow to the allowance for an address as a result of an evidence * given by an authorized party about fullfilled obligations. * **IMPORTANT** This operation includes fees deduction. * @param _destination Destination address for funds distribution. * @param _amount Amount to distribute in favor of a destination address. */ function distributeFunds( address _destination, uint _amount ) external onlyAuthorized { require( _amount <= blockedBalance, "Amount to distribute should be less or equal than blocked balance." ); uint amount = _amount; if (shareFee > 0 && relayContractAddress != address(0x0)) { DecoRelay relayContract = DecoRelay(relayContractAddress); address feeDestination = relayContract.feesWithdrawalAddress(); uint fee = amount.mul(shareFee).div(100); amount = amount.sub(fee); blockedBalance = blockedBalance.sub(fee); withdrawalAllowanceForAddress[feeDestination] = withdrawalAllowanceForAddress[feeDestination].add(fee); emit FundsOperation( msg.sender, feeDestination, address(0x0), fee, PaymentType.Ether, OperationType.Distribute ); } if (_destination == owner()) { unblockFunds(amount); return; } blockedBalance = blockedBalance.sub(amount); withdrawalAllowanceForAddress[_destination] = withdrawalAllowanceForAddress[_destination].add(amount); emit FundsOperation( msg.sender, _destination, address(0x0), amount, PaymentType.Ether, OperationType.Distribute ); } /** * @dev Distribute ERC20 token funds between contract`s balance and allowanc for some address. * Deposit may be returned back to the contract address, i.e. to the escrow owner. * Or deposit may flow to the allowance for an address as a result of an evidence * given by authorized party about fullfilled obligations. * **IMPORTANT** This operation includes fees deduction. * @param _destination Destination address for funds distribution. * @param _tokenAddress ERC20 Token address. * @param _amount Amount to distribute in favor of a destination address. */ function distributeTokenFunds( address _destination, address _tokenAddress, uint _amount ) external onlyAuthorized { require( _amount <= blockedTokensBalance[_tokenAddress], "Amount to distribute should be less or equal than blocked balance." ); uint amount = _amount; if (shareFee > 0 && relayContractAddress != address(0x0)) { DecoRelay relayContract = DecoRelay(relayContractAddress); address feeDestination = relayContract.feesWithdrawalAddress(); uint fee = amount.mul(shareFee).div(100); amount = amount.sub(fee); blockedTokensBalance[_tokenAddress] = blockedTokensBalance[_tokenAddress].sub(fee); uint allowance = tokensWithdrawalAllowanceForAddress[feeDestination][_tokenAddress]; tokensWithdrawalAllowanceForAddress[feeDestination][_tokenAddress] = allowance.add(fee); emit FundsOperation( msg.sender, feeDestination, _tokenAddress, fee, PaymentType.Erc20, OperationType.Distribute ); } if (_destination == owner()) { unblockTokenFunds(_tokenAddress, amount); return; } blockedTokensBalance[_tokenAddress] = blockedTokensBalance[_tokenAddress].sub(amount); uint allowanceForSender = tokensWithdrawalAllowanceForAddress[_destination][_tokenAddress]; tokensWithdrawalAllowanceForAddress[_destination][_tokenAddress] = allowanceForSender.add(amount); emit FundsOperation( msg.sender, _destination, _tokenAddress, amount, PaymentType.Erc20, OperationType.Distribute ); } /** * @dev Withdraws ETH amount from the contract's balance to the provided address. * @param _targetAddress An `address` for transfer ETH to. * @param _amount An `uint` amount to be transfered. */ function withdrawForAddress(address _targetAddress, uint _amount) public { require( _amount <= address(this).balance, "Amount to withdraw should be less or equal than balance." ); if (_targetAddress == owner()) { balance = balance.sub(_amount); } else { uint withdrawalAllowance = withdrawalAllowanceForAddress[_targetAddress]; withdrawalAllowanceForAddress[_targetAddress] = withdrawalAllowance.sub(_amount); } _targetAddress.transfer(_amount); emit FundsOperation ( address(this), _targetAddress, address(0x0), _amount, PaymentType.Ether, OperationType.Send ); } /** * @dev Withdraws ERC20 token amount from the contract's balance to the provided address. * @param _targetAddress An `address` for transfer tokens to. * @param _tokenAddress An `address` of ERC20 token. * @param _amount An `uint` amount of ERC20 tokens to be transfered. */ function withdrawErc20ForAddress(address _targetAddress, address _tokenAddress, uint _amount) public { IERC20 token = IERC20(_tokenAddress); require( _amount <= token.balanceOf(this), "Token amount to withdraw should be less or equal than balance." ); if (_targetAddress == owner()) { tokensBalance[_tokenAddress] = tokensBalance[_tokenAddress].sub(_amount); } else { uint tokenWithdrawalAllowance = getTokenWithdrawalAllowance(_targetAddress, _tokenAddress); tokensWithdrawalAllowanceForAddress[_targetAddress][_tokenAddress] = tokenWithdrawalAllowance.sub( _amount ); } token.transfer(_targetAddress, _amount); emit FundsOperation ( address(this), _targetAddress, _tokenAddress, _amount, PaymentType.Erc20, OperationType.Send ); } /** * @dev Returns allowance for withdrawing the given token for sender address. * @param _tokenAddress An address of ERC20 token. * @return An uint value of allowance. */ function getTokenWithdrawalAllowance(address _account, address _tokenAddress) public view returns(uint) { return tokensWithdrawalAllowanceForAddress[_account][_tokenAddress]; } /** * @dev Accept and account incoming deposit in contract state. */ function deposit() public payable { require(msg.value > 0, "Deposited amount should be greater than 0."); balance = balance.add(msg.value); emit FundsOperation ( msg.sender, address(this), address(0x0), msg.value, PaymentType.Ether, OperationType.Receive ); } /** * @dev Unblock blocked funds and make them available to the contract owner. * @param _amount An uint of Wei to be unblocked. */ function unblockFunds(uint _amount) public onlyAuthorized { require( _amount <= blockedBalance, "Amount to unblock should be less or equal than balance" ); blockedBalance = blockedBalance.sub(_amount); balance = balance.add(_amount); emit FundsOperation ( msg.sender, address(this), address(0x0), _amount, PaymentType.Ether, OperationType.Unblock ); } /** * @dev Unblock blocked token funds and make them available to the contract owner. * @param _amount An uint of Wei to be unblocked. */ function unblockTokenFunds(address _tokenAddress, uint _amount) public onlyAuthorized { uint accountedBlockedTokensAmount = blockedTokensBalance[_tokenAddress]; require( _amount <= accountedBlockedTokensAmount, "Tokens amount to unblock should be less or equal than balance" ); blockedTokensBalance[_tokenAddress] = accountedBlockedTokensAmount.sub(_amount); tokensBalance[_tokenAddress] = tokensBalance[_tokenAddress].add(_amount); emit FundsOperation ( msg.sender, address(this), _tokenAddress, _amount, PaymentType.Erc20, OperationType.Unblock ); } /** * @dev Override base contract logic to block this operation for Escrow contract. * @param _tokenAddress An `address` of an ERC20 token. * @param _tokens An `uint` tokens amount. * @return A `bool` operation result state. */ function transferAnyERC20Token( address _tokenAddress, uint _tokens ) public onlyOwner returns (bool success) { return false; } } contract CloneFactory { event CloneCreated(address indexed target, address clone); function createClone(address target) internal returns (address result) { bytes memory clone = hex"600034603b57603080600f833981f36000368180378080368173bebebebebebebebebebebebebebebebebebebebe5af43d82803e15602c573d90f35b3d90fd"; bytes20 targetBytes = bytes20(target); for (uint i = 0; i < 20; i++) { clone[26 + i] = targetBytes[i]; } assembly { let len := mload(clone) let data := add(clone, 0x20) result := create(0, data, len) } } } /** * @title Utility contract that provides a way to execute cheap clone deployment of the DecoEscrow contract * on chain. */ contract DecoEscrowFactory is DecoBaseProjectsMarketplace, CloneFactory { // Escrow master-contract address. address public libraryAddress; // Logged when a new Escrow clone is deployed to the chain. event EscrowCreated(address newEscrowAddress); /** * @dev Constructor for the contract. * @param _libraryAddress Escrow master-contract address. */ constructor(address _libraryAddress) public { libraryAddress = _libraryAddress; } /** * @dev Updates library address with the given value. * @param _libraryAddress Address of a new base contract. */ function setLibraryAddress(address _libraryAddress) external onlyOwner { require(libraryAddress != _libraryAddress); require(_libraryAddress != address(0x0)); libraryAddress = _libraryAddress; } /** * @dev Create Escrow clone. * @param _ownerAddress An address of the Escrow contract owner. * @param _authorizedAddress An addresses that is going to be authorized in Escrow contract. */ function createEscrow( address _ownerAddress, address _authorizedAddress ) external returns(address) { address clone = createClone(libraryAddress); DecoRelay relay = DecoRelay(relayContractAddress); DecoEscrow(clone).initialize( _ownerAddress, _authorizedAddress, relay.shareFee(), relayContractAddress ); emit EscrowCreated(clone); return clone; } } contract IDecoArbitrationTarget { /** * @dev Prepare arbitration target for a started dispute. * @param _idHash A `bytes32` hash of id. */ function disputeStartedFreeze(bytes32 _idHash) public; /** * @dev React to an active dispute settlement with given parameters. * @param _idHash A `bytes32` hash of id. * @param _respondent An `address` of a respondent. * @param _respondentShare An `uint8` share for the respondent. * @param _initiator An `address` of a dispute initiator. * @param _initiatorShare An `uint8` share for the initiator. * @param _isInternal A `bool` indicating if dispute was settled by participants without an arbiter. * @param _arbiterWithdrawalAddress An `address` for sending out arbiter compensation. */ function disputeSettledTerminate( bytes32 _idHash, address _respondent, uint8 _respondentShare, address _initiator, uint8 _initiatorShare, bool _isInternal, address _arbiterWithdrawalAddress ) public; /** * @dev Check eligibility of a given address to perform operations. * @param _idHash A `bytes32` hash of id. * @param _addressToCheck An `address` to check. * @return A `bool` check status. */ function checkEligibility(bytes32 _idHash, address _addressToCheck) public view returns(bool); /** * @dev Check if target is ready for a dispute. * @param _idHash A `bytes32` hash of id. * @return A `bool` check status. */ function canStartDispute(bytes32 _idHash) public view returns(bool); } library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } interface IDecoArbitration { /** * @dev Should be logged upon dispute start. */ event LogStartedDispute( address indexed sender, bytes32 indexed idHash, uint timestamp, int respondentShareProposal ); /** * @dev Should be logged upon proposal rejection. */ event LogRejectedProposal( address indexed sender, bytes32 indexed idHash, uint timestamp, uint8 rejectedProposal ); /** * @dev Should be logged upon dispute settlement. */ event LogSettledDispute( address indexed sender, bytes32 indexed idHash, uint timestamp, uint8 respondentShare, uint8 initiatorShare ); /** * @dev Should be logged when contract owner updates fees. */ event LogFeesUpdated( uint timestamp, uint fixedFee, uint8 shareFee ); /** * @dev Should be logged when time limit to accept/reject proposal for respondent is updated. */ event LogProposalTimeLimitUpdated( uint timestamp, uint proposalActionTimeLimit ); /** * @dev Should be logged when the withdrawal address for the contract owner changed. */ event LogWithdrawalAddressChanged( uint timestamp, address newWithdrawalAddress ); /** * @notice Start dispute for the given project. * @dev This call should log event and save dispute information and notify `IDecoArbitrationTarget` object * about started dispute. Dipsute can be started only if target instance call of * `canStartDispute` method confirms that state is valid. Also, txn sender and respondent addresses * eligibility must be confirmed by arbitation target `checkEligibility` method call. * @param _idHash A `bytes32` hash of a project id. * @param _respondent An `address` of the second paty involved in the dispute. * @param _respondentShareProposal An `int` value indicating percentage of disputed funds * proposed to the respondent. Valid values range is 0-100, different values are considered as 'No Proposal'. * When provided percentage is 100 then this dispute is processed automatically, * and all funds are distributed in favor of the respondent. */ function startDispute(bytes32 _idHash, address _respondent, int _respondentShareProposal) external; /** * @notice Accept active dispute proposal, sender should be the respondent. * @dev Respondent of a dispute can accept existing proposal and if proposal exists then `settleDispute` * method should be called with proposal value. Time limit for respondent to accept/reject proposal * must not be exceeded. * @param _idHash A `bytes32` hash of a project id. */ function acceptProposal(bytes32 _idHash) external; /** * @notice Reject active dispute proposal and escalate dispute. * @dev Txn sender should be dispute's respondent. Dispute automatically gets escalated to this contract * owner aka arbiter. Proposal must exist, otherwise this method should do nothing. When respondent * rejects proposal then it should get removed and corresponding event should be logged. * There should be a time limit for a respondent to reject a given proposal, and if it is overdue * then arbiter should take on a dispute to settle it. * @param _idHash A `bytes32` hash of a project id. */ function rejectProposal(bytes32 _idHash) external; /** * @notice Settle active dispute. * @dev Sender should be the current contract or its owner(arbiter). Action is possible only when there is no active * proposal or time to accept the proposal is over. Sum of shares should be 100%. Should notify target * instance about a dispute settlement via `disputeSettledTerminate` method call. Also corresponding * event must be emitted. * @param _idHash A `bytes32` hash of a project id. * @param _respondentShare An `uint` percents of respondent share. * @param _initiatorShare An `uint` percents of initiator share. */ function settleDispute(bytes32 _idHash, uint _respondentShare, uint _initiatorShare) external; /** * @return Retuns this arbitration contract withdrawal `address`. */ function getWithdrawalAddress() external view returns(address); /** * @return The arbitration contract fixed `uint` fee and `uint8` share of all disputed funds fee. */ function getFixedAndShareFees() external view returns(uint, uint8); /** * @return An `uint` time limit for accepting/rejecting a proposal by respondent. */ function getTimeLimitForReplyOnProposal() external view returns(uint); } pragma solidity 0.4.25; /// @title Contract for Project events and actions handling. contract DecoProjects is DecoBaseProjectsMarketplace { using SafeMath for uint256; using ECDSA for bytes32; // struct for project details struct Project { string agreementId; address client; address maker; address arbiter; address escrowContractAddress; uint startDate; uint endDate; uint8 milestoneStartWindow; uint8 feedbackWindow; uint8 milestonesCount; uint8 customerSatisfaction; uint8 makerSatisfaction; bool agreementsEncrypted; } struct EIP712Domain { string name; string version; uint256 chainId; address verifyingContract; } struct Proposal { string agreementId; address arbiter; } bytes32 constant private EIP712DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); bytes32 constant private PROPOSAL_TYPEHASH = keccak256( "Proposal(string agreementId,address arbiter)" ); bytes32 private DOMAIN_SEPARATOR; // enumeration to describe possible project states for easier state changes reporting. enum ProjectState { Active, Completed, Terminated } // enumeration to describe possible satisfaction score types. enum ScoreType { CustomerSatisfaction, MakerSatisfaction } // Logged when a project state changes. event LogProjectStateUpdate ( bytes32 indexed agreementHash, address updatedBy, uint timestamp, ProjectState state ); // Logged when either party sets satisfaction score after the completion of a project. event LogProjectRated ( bytes32 indexed agreementHash, address indexed ratedBy, address indexed ratingTarget, uint8 rating, uint timestamp ); // maps the agreement`s unique hash to the project details. mapping (bytes32 => Project) public projects; // maps hashes of all maker's projects to the maker's address. mapping (address => bytes32[]) public makerProjects; // maps hashes of all client's projects to the client's address. mapping (address => bytes32[]) public clientProjects; // maps arbiter's fixed fee to a project. mapping (bytes32 => uint) public projectArbiterFixedFee; // maps arbiter's share fee to a project. mapping (bytes32 => uint8) public projectArbiterShareFee; // Modifier to restrict method to be called either by project`s owner or maker modifier eitherClientOrMaker(bytes32 _agreementHash) { Project memory project = projects[_agreementHash]; require( project.client == msg.sender || project.maker == msg.sender, "Only project owner or maker can perform this operation." ); _; } // Modifier to restrict method to be called either by project`s owner or maker modifier eitherClientOrMakerOrMilestoneContract(bytes32 _agreementHash) { Project memory project = projects[_agreementHash]; DecoRelay relay = DecoRelay(relayContractAddress); require( project.client == msg.sender || project.maker == msg.sender || relay.milestonesContractAddress() == msg.sender, "Only project owner or maker can perform this operation." ); _; } // Modifier to restrict method to be called by the milestones contract. modifier onlyMilestonesContract(bytes32 _agreementHash) { DecoRelay relay = DecoRelay(relayContractAddress); require( msg.sender == relay.milestonesContractAddress(), "Only milestones contract can perform this operation." ); Project memory project = projects[_agreementHash]; _; } constructor (uint256 _chainId) public { require(_chainId != 0, "You must specify a nonzero chainId"); DOMAIN_SEPARATOR = hash(EIP712Domain({ name: "Deco.Network", version: "1", chainId: _chainId, verifyingContract: address(this) })); } /** * @dev Creates a new milestone-based project with pre-selected maker and owner. All parameters are required. * @param _agreementId A `string` unique id of the agreement document for that project. * @param _client An `address` of the project owner. * @param _arbiter An `address` of the referee to settle all escalated disputes between parties. * @param _maker An `address` of the project`s maker. * @param _makersSignature A `bytes` digital signature of the maker to proof the agreement acceptance. * @param _milestonesCount An `uint8` count of planned milestones for the project. * @param _milestoneStartWindow An `uint8` count of days project`s owner has to start the next milestone. * If this time is exceeded then the maker can terminate the project. * @param _feedbackWindow An `uint8` time in days project`s owner has to provide feedback for the last milestone. * If that time is exceeded then maker can terminate the project and get paid for awaited * milestone. * @param _agreementEncrypted A `bool` flag indicating whether or not the agreement is encrypted. */ function startProject( string _agreementId, address _client, address _arbiter, address _maker, bytes _makersSignature, uint8 _milestonesCount, uint8 _milestoneStartWindow, uint8 _feedbackWindow, bool _agreementEncrypted ) external { require(msg.sender == _client, "Only the client can kick off the project."); require(_client != _maker, "Client can`t be a maker on her own project."); require(_arbiter != _maker && _arbiter != _client, "Arbiter must not be a client nor a maker."); require( isMakersSignatureValid(_maker, _makersSignature, _agreementId, _arbiter), "Maker should sign the hash of immutable agreement doc." ); require(_milestonesCount >= 1 && _milestonesCount <= 24, "Milestones count is not in the allowed 1-24 range."); bytes32 hash = keccak256(_agreementId); require(projects[hash].client == address(0x0), "Project shouldn't exist yet."); saveCurrentArbitrationFees(_arbiter, hash); address newEscrowCloneAddress = deployEscrowClone(msg.sender); projects[hash] = Project( _agreementId, msg.sender, _maker, _arbiter, newEscrowCloneAddress, now, 0, // end date is unknown yet _milestoneStartWindow, _feedbackWindow, _milestonesCount, 0, // CSAT is 0 to indicate that it isn't set by maker yet 0, // MSAT is 0 to indicate that it isn't set by client yet _agreementEncrypted ); makerProjects[_maker].push(hash); clientProjects[_client].push(hash); emit LogProjectStateUpdate(hash, msg.sender, now, ProjectState.Active); } /** * @dev Terminate the project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. */ function terminateProject(bytes32 _agreementHash) external eitherClientOrMakerOrMilestoneContract(_agreementHash) { Project storage project = projects[_agreementHash]; require(project.client != address(0x0), "Only allowed for existing projects."); require(project.endDate == 0, "Only allowed for active projects."); address milestoneContractAddress = DecoRelay(relayContractAddress).milestonesContractAddress(); if (msg.sender != milestoneContractAddress) { DecoMilestones milestonesContract = DecoMilestones(milestoneContractAddress); milestonesContract.terminateLastMilestone(_agreementHash, msg.sender); } project.endDate = now; emit LogProjectStateUpdate(_agreementHash, msg.sender, now, ProjectState.Terminated); } /** * @dev Complete the project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. */ function completeProject( bytes32 _agreementHash ) external onlyMilestonesContract(_agreementHash) { Project storage project = projects[_agreementHash]; require(project.client != address(0x0), "Only allowed for existing projects."); require(project.endDate == 0, "Only allowed for active projects."); projects[_agreementHash].endDate = now; DecoMilestones milestonesContract = DecoMilestones( DecoRelay(relayContractAddress).milestonesContractAddress() ); bool isLastMilestoneAccepted; uint8 milestoneNumber; (isLastMilestoneAccepted, milestoneNumber) = milestonesContract.isLastMilestoneAccepted( _agreementHash ); require( milestoneNumber == projects[_agreementHash].milestonesCount, "The last milestone should be the last for that project." ); require(isLastMilestoneAccepted, "Only allowed when all milestones are completed."); emit LogProjectStateUpdate(_agreementHash, msg.sender, now, ProjectState.Completed); } /** * @dev Rate the second party on the project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @param _rating An `uint8` satisfaction score of either client or maker. Min value is 1, max is 10. */ function rateProjectSecondParty( bytes32 _agreementHash, uint8 _rating ) external eitherClientOrMaker(_agreementHash) { require(_rating >= 1 && _rating <= 10, "Project rating should be in the range 1-10."); Project storage project = projects[_agreementHash]; require(project.endDate != 0, "Only allowed for active projects."); address ratingTarget; if (msg.sender == project.client) { require(project.customerSatisfaction == 0, "CSAT is allowed to provide only once."); project.customerSatisfaction = _rating; ratingTarget = project.maker; } else { require(project.makerSatisfaction == 0, "MSAT is allowed to provide only once."); project.makerSatisfaction = _rating; ratingTarget = project.client; } emit LogProjectRated(_agreementHash, msg.sender, ratingTarget, _rating, now); } /** * @dev Query for getting the address of Escrow contract clone deployed for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `address` of a clone. */ function getProjectEscrowAddress(bytes32 _agreementHash) public view returns(address) { return projects[_agreementHash].escrowContractAddress; } /** * @dev Query for getting the address of a client for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `address` of a client. */ function getProjectClient(bytes32 _agreementHash) public view returns(address) { return projects[_agreementHash].client; } /** * @dev Query for getting the address of a maker for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `address` of a maker. */ function getProjectMaker(bytes32 _agreementHash) public view returns(address) { return projects[_agreementHash].maker; } /** * @dev Query for getting the address of an arbiter for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `address` of an arbiter. */ function getProjectArbiter(bytes32 _agreementHash) public view returns(address) { return projects[_agreementHash].arbiter; } /** * @dev Query for getting the feedback window for a client for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint8` feedback window in days. */ function getProjectFeedbackWindow(bytes32 _agreementHash) public view returns(uint8) { return projects[_agreementHash].feedbackWindow; } /** * @dev Query for getting the milestone start window for a client for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint8` milestone start window in days. */ function getProjectMilestoneStartWindow(bytes32 _agreementHash) public view returns(uint8) { return projects[_agreementHash].milestoneStartWindow; } /** * @dev Query for getting the start date for the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint` start date. */ function getProjectStartDate(bytes32 _agreementHash) public view returns(uint) { return projects[_agreementHash].startDate; } /** * @dev Calculates sum and number of CSAT scores of ended & rated projects for the given maker`s address. * @param _maker An `address` of the maker to look up. * @return An `uint` sum of all scores and an `uint` number of projects counted in sum. */ function makersAverageRating(address _maker) public view returns(uint, uint) { return calculateScore(_maker, ScoreType.CustomerSatisfaction); } /** * @dev Calculates sum and number of MSAT scores of ended & rated projects for the given client`s address. * @param _client An `address` of the client to look up. * @return An `uint` sum of all scores and an `uint` number of projects counted in sum. */ function clientsAverageRating(address _client) public view returns(uint, uint) { return calculateScore(_client, ScoreType.MakerSatisfaction); } /** * @dev Returns hashes of all client`s projects * @param _client An `address` to look up. * @return `bytes32[]` of projects hashes. */ function getClientProjects(address _client) public view returns(bytes32[]) { return clientProjects[_client]; } /** @dev Returns hashes of all maker`s projects * @param _maker An `address` to look up. * @return `bytes32[]` of projects hashes. */ function getMakerProjects(address _maker) public view returns(bytes32[]) { return makerProjects[_maker]; } /** * @dev Checks if a project with the given hash exists. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return A `bool` stating for the project`s existence. */ function checkIfProjectExists(bytes32 _agreementHash) public view returns(bool) { return projects[_agreementHash].client != address(0x0); } /** * @dev Query for getting end date of the given project. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint` end time of the project */ function getProjectEndDate(bytes32 _agreementHash) public view returns(uint) { return projects[_agreementHash].endDate; } /** * @dev Returns preconfigured count of milestones for a project with the given hash. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint8` count of milestones set upon the project creation. */ function getProjectMilestonesCount(bytes32 _agreementHash) public view returns(uint8) { return projects[_agreementHash].milestonesCount; } /** * @dev Returns configured for the given project arbiter fees. * @param _agreementHash A `bytes32` hash of the project`s agreement id. * @return An `uint` fixed fee and an `uint8` share fee of the project's arbiter. */ function getProjectArbitrationFees(bytes32 _agreementHash) public view returns(uint, uint8) { return ( projectArbiterFixedFee[_agreementHash], projectArbiterShareFee[_agreementHash] ); } function getInfoForDisputeAndValidate( bytes32 _agreementHash, address _respondent, address _initiator, address _arbiter ) public view returns(uint, uint8, address) { require(checkIfProjectExists(_agreementHash), "Project must exist."); Project memory project = projects[_agreementHash]; address client = project.client; address maker = project.maker; require(project.arbiter == _arbiter, "Arbiter should be same as saved in project."); require( (_initiator == client && _respondent == maker) || (_initiator == maker && _respondent == client), "Initiator and respondent must be different and equal to maker/client addresses." ); (uint fixedFee, uint8 shareFee) = getProjectArbitrationFees(_agreementHash); return (fixedFee, shareFee, project.escrowContractAddress); } /** * @dev Pulls the current arbitration contract fixed & share fees and save them for a project. * @param _arbiter An `address` of arbitration contract. * @param _agreementHash A `bytes32` hash of agreement id. */ function saveCurrentArbitrationFees(address _arbiter, bytes32 _agreementHash) internal { IDecoArbitration arbitration = IDecoArbitration(_arbiter); uint fixedFee; uint8 shareFee; (fixedFee, shareFee) = arbitration.getFixedAndShareFees(); projectArbiterFixedFee[_agreementHash] = fixedFee; projectArbiterShareFee[_agreementHash] = shareFee; } /** * @dev Calculates the sum of scores and the number of ended and rated projects for the given client`s or * maker`s address. * @param _address An `address` to look up. * @param _scoreType A `ScoreType` indicating what score should be calculated. * `CustomerSatisfaction` type means that CSAT score for the given address as a maker should be calculated. * `MakerSatisfaction` type means that MSAT score for the given address as a client should be calculated. * @return An `uint` sum of all scores and an `uint` number of projects counted in sum. */ function calculateScore( address _address, ScoreType _scoreType ) internal view returns(uint, uint) { bytes32[] memory allProjectsHashes = getProjectsByScoreType(_address, _scoreType); uint rating = 0; uint endedProjectsCount = 0; for (uint index = 0; index < allProjectsHashes.length; index++) { bytes32 agreementHash = allProjectsHashes[index]; if (projects[agreementHash].endDate == 0) { continue; } uint8 score = getProjectScoreByType(agreementHash, _scoreType); if (score == 0) { continue; } endedProjectsCount++; rating = rating.add(score); } return (rating, endedProjectsCount); } /** * @dev Returns all projects for the given address depending on the provided score type. * @param _address An `address` to look up. * @param _scoreType A `ScoreType` to identify projects source. * @return `bytes32[]` of projects hashes either from `clientProjects` or `makerProjects` storage arrays. */ function getProjectsByScoreType(address _address, ScoreType _scoreType) internal view returns(bytes32[]) { if (_scoreType == ScoreType.CustomerSatisfaction) { return makerProjects[_address]; } else { return clientProjects[_address]; } } /** * @dev Returns project score by the given type. * @param _agreementHash A `bytes32` hash of a project`s agreement id. * @param _scoreType A `ScoreType` to identify what score is requested. * @return An `uint8` score of the given project and of the given type. */ function getProjectScoreByType(bytes32 _agreementHash, ScoreType _scoreType) internal view returns(uint8) { if (_scoreType == ScoreType.CustomerSatisfaction) { return projects[_agreementHash].customerSatisfaction; } else { return projects[_agreementHash].makerSatisfaction; } } /** * @dev Deploy DecoEscrow contract clone for the newly created project. * @param _newContractOwner An `address` of a new contract owner. * @return An `address` of a new deployed escrow contract. */ function deployEscrowClone(address _newContractOwner) internal returns(address) { DecoRelay relay = DecoRelay(relayContractAddress); DecoEscrowFactory factory = DecoEscrowFactory(relay.escrowFactoryContractAddress()); return factory.createEscrow(_newContractOwner, relay.milestonesContractAddress()); } /** * @dev Check validness of maker's signature on project creation. * @param _maker An `address` of a maker. * @param _signature A `bytes` digital signature generated by a maker. * @param _agreementId A unique id of the agreement document for a project * @param _arbiter An `address` of a referee to settle all escalated disputes between parties. * @return A `bool` indicating validity of the signature. */ function isMakersSignatureValid(address _maker, bytes _signature, string _agreementId, address _arbiter) internal view returns (bool) { bytes32 digest = keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, hash(Proposal(_agreementId, _arbiter)) )); address signatureAddress = digest.recover(_signature); return signatureAddress == _maker; } function hash(EIP712Domain eip712Domain) internal view returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(eip712Domain.name)), keccak256(bytes(eip712Domain.version)), eip712Domain.chainId, eip712Domain.verifyingContract )); } function hash(Proposal proposal) internal view returns (bytes32) { return keccak256(abi.encode( PROPOSAL_TYPEHASH, keccak256(bytes(proposal.agreementId)), proposal.arbiter )); } } /// @title Contract for Milesotone events and actions handling. contract DecoMilestones is IDecoArbitrationTarget, DecoBaseProjectsMarketplace { address public constant ETH_TOKEN_ADDRESS = address(0x0); // struct to describe Milestone struct Milestone { uint8 milestoneNumber; // original duration of a milestone. uint32 duration; // track all adjustments caused by state changes Active <-> Delivered <-> Rejected // `adjustedDuration` time gets increased by the time that is spent by client // to provide a feedback when agreed milestone time is not exceeded yet. // Initial value is the same as duration. uint32 adjustedDuration; uint depositAmount; address tokenAddress; uint startedTime; uint deliveredTime; uint acceptedTime; // indicates that a milestone progress was paused. bool isOnHold; } // enumeration to describe possible milestone states. enum MilestoneState { Active, Delivered, Accepted, Rejected, Terminated, Paused } // map agreement id hash to milestones list. mapping (bytes32 => Milestone[]) public projectMilestones; // Logged when milestone state changes. event LogMilestoneStateUpdated ( bytes32 indexed agreementHash, address indexed sender, uint timestamp, uint8 milestoneNumber, MilestoneState indexed state ); event LogMilestoneDurationAdjusted ( bytes32 indexed agreementHash, address indexed sender, uint32 amountAdded, uint8 milestoneNumber ); /** * @dev Starts a new milestone for the project and deposit ETH in smart contract`s escrow. * @param _agreementHash A `bytes32` hash of the agreement id. * @param _depositAmount An `uint` of wei that are going to be deposited for a new milestone. * @param _duration An `uint` seconds of a milestone duration. */ function startMilestone( bytes32 _agreementHash, uint _depositAmount, address _tokenAddress, uint32 _duration ) external { uint8 completedMilestonesCount = uint8(projectMilestones[_agreementHash].length); if (completedMilestonesCount > 0) { Milestone memory lastMilestone = projectMilestones[_agreementHash][completedMilestonesCount - 1]; require(lastMilestone.acceptedTime > 0, "All milestones must be accepted prior starting a new one."); } DecoProjects projectsContract = DecoProjects( DecoRelay(relayContractAddress).projectsContractAddress() ); require(projectsContract.checkIfProjectExists(_agreementHash), "Project must exist."); require( projectsContract.getProjectClient(_agreementHash) == msg.sender, "Only project's client starts a miestone" ); require( projectsContract.getProjectMilestonesCount(_agreementHash) > completedMilestonesCount, "Milestones count should not exceed the number configured in the project." ); require( projectsContract.getProjectEndDate(_agreementHash) == 0, "Project should be active." ); blockFundsInEscrow( projectsContract.getProjectEscrowAddress(_agreementHash), _depositAmount, _tokenAddress ); uint nowTimestamp = now; projectMilestones[_agreementHash].push( Milestone( completedMilestonesCount + 1, _duration, _duration, _depositAmount, _tokenAddress, nowTimestamp, 0, 0, false ) ); emit LogMilestoneStateUpdated( _agreementHash, msg.sender, nowTimestamp, completedMilestonesCount + 1, MilestoneState.Active ); } /** * @dev Maker delivers the current active milestone. * @param _agreementHash Project`s unique hash. */ function deliverLastMilestone(bytes32 _agreementHash) external { DecoProjects projectsContract = DecoProjects( DecoRelay(relayContractAddress).projectsContractAddress() ); require(projectsContract.checkIfProjectExists(_agreementHash), "Project must exist."); require(projectsContract.getProjectEndDate(_agreementHash) == 0, "Project should be active."); require(projectsContract.getProjectMaker(_agreementHash) == msg.sender, "Sender must be a maker."); uint nowTimestamp = now; uint8 milestonesCount = uint8(projectMilestones[_agreementHash].length); require(milestonesCount > 0, "There must be milestones to make a delivery."); Milestone storage milestone = projectMilestones[_agreementHash][milestonesCount - 1]; require( milestone.startedTime > 0 && milestone.deliveredTime == 0 && milestone.acceptedTime == 0, "Milestone must be active, not delivered and not accepted." ); require(!milestone.isOnHold, "Milestone must not be paused."); milestone.deliveredTime = nowTimestamp; emit LogMilestoneStateUpdated( _agreementHash, msg.sender, nowTimestamp, milestonesCount, MilestoneState.Delivered ); } /** * @dev Project owner accepts the current delivered milestone. * @param _agreementHash Project`s unique hash. */ function acceptLastMilestone(bytes32 _agreementHash) external { DecoProjects projectsContract = DecoProjects( DecoRelay(relayContractAddress).projectsContractAddress() ); require(projectsContract.checkIfProjectExists(_agreementHash), "Project must exist."); require(projectsContract.getProjectEndDate(_agreementHash) == 0, "Project should be active."); require(projectsContract.getProjectClient(_agreementHash) == msg.sender, "Sender must be a client."); uint8 milestonesCount = uint8(projectMilestones[_agreementHash].length); require(milestonesCount > 0, "There must be milestones to accept a delivery."); Milestone storage milestone = projectMilestones[_agreementHash][milestonesCount - 1]; require( milestone.startedTime > 0 && milestone.acceptedTime == 0 && milestone.deliveredTime > 0 && milestone.isOnHold == false, "Milestone should be active and delivered, but not rejected, or already accepted, or put on hold." ); uint nowTimestamp = now; milestone.acceptedTime = nowTimestamp; if (projectsContract.getProjectMilestonesCount(_agreementHash) == milestonesCount) { projectsContract.completeProject(_agreementHash); } distributeFundsInEscrow( projectsContract.getProjectEscrowAddress(_agreementHash), projectsContract.getProjectMaker(_agreementHash), milestone.depositAmount, milestone.tokenAddress ); emit LogMilestoneStateUpdated( _agreementHash, msg.sender, nowTimestamp, milestonesCount, MilestoneState.Accepted ); } /** * @dev Project owner rejects the current active milestone. * @param _agreementHash Project`s unique hash. */ function rejectLastDeliverable(bytes32 _agreementHash) external { DecoProjects projectsContract = DecoProjects( DecoRelay(relayContractAddress).projectsContractAddress() ); require(projectsContract.checkIfProjectExists(_agreementHash), "Project must exist."); require(projectsContract.getProjectEndDate(_agreementHash) == 0, "Project should be active."); require(projectsContract.getProjectClient(_agreementHash) == msg.sender, "Sender must be a client."); uint8 milestonesCount = uint8(projectMilestones[_agreementHash].length); require(milestonesCount > 0, "There must be milestones to reject a delivery."); Milestone storage milestone = projectMilestones[_agreementHash][milestonesCount - 1]; require( milestone.startedTime > 0 && milestone.acceptedTime == 0 && milestone.deliveredTime > 0 && milestone.isOnHold == false, "Milestone should be active and delivered, but not rejected, or already accepted, or on hold." ); uint nowTimestamp = now; if (milestone.startedTime.add(milestone.adjustedDuration) > milestone.deliveredTime) { uint32 timeToAdd = uint32(nowTimestamp.sub(milestone.deliveredTime)); milestone.adjustedDuration += timeToAdd; emit LogMilestoneDurationAdjusted ( _agreementHash, msg.sender, timeToAdd, milestonesCount ); } milestone.deliveredTime = 0; emit LogMilestoneStateUpdated( _agreementHash, msg.sender, nowTimestamp, milestonesCount, MilestoneState.Rejected ); } /** * @dev Prepare arbitration target for a started dispute. * @param _idHash A `bytes32` hash of id. */ function disputeStartedFreeze(bytes32 _idHash) public { address projectsContractAddress = DecoRelay(relayContractAddress).projectsContractAddress(); DecoProjects projectsContract = DecoProjects(projectsContractAddress); require( projectsContract.getProjectArbiter(_idHash) == msg.sender, "Freezing upon dispute start can be sent only by arbiter." ); uint milestonesCount = projectMilestones[_idHash].length; require(milestonesCount > 0, "There must be active milestone."); Milestone storage lastMilestone = projectMilestones[_idHash][milestonesCount - 1]; lastMilestone.isOnHold = true; emit LogMilestoneStateUpdated( _idHash, msg.sender, now, uint8(milestonesCount), MilestoneState.Paused ); } /** * @dev React to an active dispute settlement with given parameters. * @param _idHash A `bytes32` hash of id. * @param _respondent An `address` of a respondent. * @param _respondentShare An `uint8` share for the respondent. * @param _initiator An `address` of a dispute initiator. * @param _initiatorShare An `uint8` share for the initiator. * @param _isInternal A `bool` indicating if dispute was settled by participants without an arbiter. * @param _arbiterWithdrawalAddress An `address` for sending out arbiter compensation. */ function disputeSettledTerminate( bytes32 _idHash, address _respondent, uint8 _respondentShare, address _initiator, uint8 _initiatorShare, bool _isInternal, address _arbiterWithdrawalAddress ) public { uint milestonesCount = projectMilestones[_idHash].length; require(milestonesCount > 0, "There must be at least one milestone."); Milestone memory lastMilestone = projectMilestones[_idHash][milestonesCount - 1]; require(lastMilestone.isOnHold, "Last milestone must be on hold."); require(uint(_respondentShare).add(uint(_initiatorShare)) == 100, "Shares must be 100% in sum."); DecoProjects projectsContract = DecoProjects( DecoRelay(relayContractAddress).projectsContractAddress() ); ( uint fixedFee, uint8 shareFee, address escrowAddress ) = projectsContract.getInfoForDisputeAndValidate ( _idHash, _respondent, _initiator, msg.sender ); distributeDisputeFunds( escrowAddress, lastMilestone.tokenAddress, _respondent, _initiator, _initiatorShare, _isInternal, _arbiterWithdrawalAddress, lastMilestone.depositAmount, fixedFee, shareFee ); projectsContract.terminateProject(_idHash); emit LogMilestoneStateUpdated( _idHash, msg.sender, now, uint8(milestonesCount), MilestoneState.Terminated ); } /** * @dev Check eligibility of a given address to perform operations, * basically the address should be either client or maker. * @param _idHash A `bytes32` hash of id. * @param _addressToCheck An `address` to check. * @return A `bool` check status. */ function checkEligibility(bytes32 _idHash, address _addressToCheck) public view returns(bool) { address projectsContractAddress = DecoRelay(relayContractAddress).projectsContractAddress(); DecoProjects projectsContract = DecoProjects(projectsContractAddress); return _addressToCheck == projectsContract.getProjectClient(_idHash) || _addressToCheck == projectsContract.getProjectMaker(_idHash); } /** * @dev Check if target is ready for a dispute. * @param _idHash A `bytes32` hash of id. * @return A `bool` check status. */ function canStartDispute(bytes32 _idHash) public view returns(bool) { uint milestonesCount = projectMilestones[_idHash].length; if (milestonesCount == 0) return false; Milestone memory lastMilestone = projectMilestones[_idHash][milestonesCount - 1]; if (lastMilestone.isOnHold || lastMilestone.acceptedTime > 0) return false; address projectsContractAddress = DecoRelay(relayContractAddress).projectsContractAddress(); DecoProjects projectsContract = DecoProjects(projectsContractAddress); uint feedbackWindow = uint(projectsContract.getProjectFeedbackWindow(_idHash)).mul(24 hours); uint nowTimestamp = now; uint plannedDeliveryTime = lastMilestone.startedTime.add(uint(lastMilestone.adjustedDuration)); if (plannedDeliveryTime < lastMilestone.deliveredTime || plannedDeliveryTime < nowTimestamp) { return false; } if (lastMilestone.deliveredTime > 0 && lastMilestone.deliveredTime.add(feedbackWindow) < nowTimestamp) return false; return true; } /** * @dev Either project owner or maker can terminate the project in certain cases * and the current active milestone must be marked as terminated for records-keeping. * All blocked funds should be distributed in favor of eligible project party. * The termination with this method initiated only by project contract. * @param _agreementHash Project`s unique hash. * @param _initiator An `address` of the termination initiator. */ function terminateLastMilestone(bytes32 _agreementHash, address _initiator) public { address projectsContractAddress = DecoRelay(relayContractAddress).projectsContractAddress(); require(msg.sender == projectsContractAddress, "Method should be called by Project contract."); DecoProjects projectsContract = DecoProjects(projectsContractAddress); require(projectsContract.checkIfProjectExists(_agreementHash), "Project must exist."); address projectClient = projectsContract.getProjectClient(_agreementHash); address projectMaker = projectsContract.getProjectMaker(_agreementHash); require( _initiator == projectClient || _initiator == projectMaker, "Initiator should be either maker or client address." ); if (_initiator == projectClient) { require(canClientTerminate(_agreementHash)); } else { require(canMakerTerminate(_agreementHash)); } uint milestonesCount = projectMilestones[_agreementHash].length; if (milestonesCount == 0) return; Milestone memory lastMilestone = projectMilestones[_agreementHash][milestonesCount - 1]; if (lastMilestone.acceptedTime > 0) return; address projectEscrowContractAddress = projectsContract.getProjectEscrowAddress(_agreementHash); if (_initiator == projectClient) { unblockFundsInEscrow( projectEscrowContractAddress, lastMilestone.depositAmount, lastMilestone.tokenAddress ); } else { distributeFundsInEscrow( projectEscrowContractAddress, _initiator, lastMilestone.depositAmount, lastMilestone.tokenAddress ); } emit LogMilestoneStateUpdated( _agreementHash, msg.sender, now, uint8(milestonesCount), MilestoneState.Terminated ); } /** * @dev Returns the last project milestone completion status and number. * @param _agreementHash Project's unique hash. * @return isAccepted A boolean flag for acceptance state, and milestoneNumber for the last milestone. */ function isLastMilestoneAccepted( bytes32 _agreementHash ) public view returns(bool isAccepted, uint8 milestoneNumber) { milestoneNumber = uint8(projectMilestones[_agreementHash].length); if (milestoneNumber > 0) { isAccepted = projectMilestones[_agreementHash][milestoneNumber - 1].acceptedTime > 0; } else { isAccepted = false; } } /** * @dev Client can terminate milestone if the last milestone delivery is overdue and * milestone is not on hold. By default termination is not available. * @param _agreementHash Project`s unique hash. * @return `true` if the last project's milestone could be terminated by client. */ function canClientTerminate(bytes32 _agreementHash) public view returns(bool) { uint milestonesCount = projectMilestones[_agreementHash].length; if (milestonesCount == 0) return false; Milestone memory lastMilestone = projectMilestones[_agreementHash][milestonesCount - 1]; return lastMilestone.acceptedTime == 0 && !lastMilestone.isOnHold && lastMilestone.startedTime.add(uint(lastMilestone.adjustedDuration)) < now; } /** * @dev Maker can terminate milestone if delivery review is taking longer than project feedback window and * milestone is not on hold, or if client doesn't start the next milestone for a period longer than * project's milestone start window. By default termination is not available. * @param _agreementHash Project`s unique hash. * @return `true` if the last project's milestone could be terminated by maker. */ function canMakerTerminate(bytes32 _agreementHash) public view returns(bool) { address projectsContractAddress = DecoRelay(relayContractAddress).projectsContractAddress(); DecoProjects projectsContract = DecoProjects(projectsContractAddress); uint feedbackWindow = uint(projectsContract.getProjectFeedbackWindow(_agreementHash)).mul(24 hours); uint milestoneStartWindow = uint(projectsContract.getProjectMilestoneStartWindow( _agreementHash )).mul(24 hours); uint projectStartDate = projectsContract.getProjectStartDate(_agreementHash); uint milestonesCount = projectMilestones[_agreementHash].length; if (milestonesCount == 0) return now.sub(projectStartDate) > milestoneStartWindow; Milestone memory lastMilestone = projectMilestones[_agreementHash][milestonesCount - 1]; uint nowTimestamp = now; if (!lastMilestone.isOnHold && lastMilestone.acceptedTime > 0 && nowTimestamp.sub(lastMilestone.acceptedTime) > milestoneStartWindow) return true; return !lastMilestone.isOnHold && lastMilestone.acceptedTime == 0 && lastMilestone.deliveredTime > 0 && nowTimestamp.sub(feedbackWindow) > lastMilestone.deliveredTime; } /* * @dev Block funds in escrow from balance to the blocked balance. * @param _projectEscrowContractAddress An `address` of project`s escrow. * @param _amount An `uint` amount to distribute. * @param _tokenAddress An `address` of a token. */ function blockFundsInEscrow( address _projectEscrowContractAddress, uint _amount, address _tokenAddress ) internal { if (_amount == 0) return; DecoEscrow escrow = DecoEscrow(_projectEscrowContractAddress); if (_tokenAddress == ETH_TOKEN_ADDRESS) { escrow.blockFunds(_amount); } else { escrow.blockTokenFunds(_tokenAddress, _amount); } } /* * @dev Unblock funds in escrow from blocked balance to the balance. * @param _projectEscrowContractAddress An `address` of project`s escrow. * @param _amount An `uint` amount to distribute. * @param _tokenAddress An `address` of a token. */ function unblockFundsInEscrow( address _projectEscrowContractAddress, uint _amount, address _tokenAddress ) internal { if (_amount == 0) return; DecoEscrow escrow = DecoEscrow(_projectEscrowContractAddress); if (_tokenAddress == ETH_TOKEN_ADDRESS) { escrow.unblockFunds(_amount); } else { escrow.unblockTokenFunds(_tokenAddress, _amount); } } /** * @dev Distribute funds in escrow from blocked balance to the target address. * @param _projectEscrowContractAddress An `address` of project`s escrow. * @param _distributionTargetAddress Target `address`. * @param _amount An `uint` amount to distribute. * @param _tokenAddress An `address` of a token. */ function distributeFundsInEscrow( address _projectEscrowContractAddress, address _distributionTargetAddress, uint _amount, address _tokenAddress ) internal { if (_amount == 0) return; DecoEscrow escrow = DecoEscrow(_projectEscrowContractAddress); if (_tokenAddress == ETH_TOKEN_ADDRESS) { escrow.distributeFunds(_distributionTargetAddress, _amount); } else { escrow.distributeTokenFunds(_distributionTargetAddress, _tokenAddress, _amount); } } /** * @dev Distribute project funds between arbiter and project parties. * @param _projectEscrowContractAddress An `address` of project`s escrow. * @param _tokenAddress An `address` of a token. * @param _respondent An `address` of a respondent. * @param _initiator An `address` of an initiator. * @param _initiatorShare An `uint8` iniator`s share. * @param _isInternal A `bool` indicating if dispute was settled solely by project parties. * @param _arbiterWithdrawalAddress A withdrawal `address` of an arbiter. * @param _amount An `uint` amount for distributing between project parties and arbiter. * @param _fixedFee An `uint` fixed fee of an arbiter. * @param _shareFee An `uint8` share fee of an arbiter. */ function distributeDisputeFunds( address _projectEscrowContractAddress, address _tokenAddress, address _respondent, address _initiator, uint8 _initiatorShare, bool _isInternal, address _arbiterWithdrawalAddress, uint _amount, uint _fixedFee, uint8 _shareFee ) internal { if (!_isInternal && _arbiterWithdrawalAddress != address(0x0)) { uint arbiterFee = getArbiterFeeAmount(_fixedFee, _shareFee, _amount, _tokenAddress); distributeFundsInEscrow( _projectEscrowContractAddress, _arbiterWithdrawalAddress, arbiterFee, _tokenAddress ); _amount = _amount.sub(arbiterFee); } uint initiatorAmount = _amount.mul(_initiatorShare).div(100); distributeFundsInEscrow( _projectEscrowContractAddress, _initiator, initiatorAmount, _tokenAddress ); distributeFundsInEscrow( _projectEscrowContractAddress, _respondent, _amount.sub(initiatorAmount), _tokenAddress ); } /** * @dev Calculates arbiter`s fee. * @param _fixedFee An `uint` fixed fee of an arbiter. * @param _shareFee An `uint8` share fee of an arbiter. * @param _amount An `uint` amount for distributing between project parties and arbiter. * @param _tokenAddress An `address` of a token. * @return An `uint` amount allotted to the arbiter. */ function getArbiterFeeAmount(uint _fixedFee, uint8 _shareFee, uint _amount, address _tokenAddress) internal pure returns(uint) { if (_tokenAddress != ETH_TOKEN_ADDRESS) { _fixedFee = 0; } return _amount.sub(_fixedFee).mul(uint(_shareFee)).div(100).add(_fixedFee); } } contract DecoProxy { using ECDSA for bytes32; /// Emitted when incoming ETH funds land into account. event Received (address indexed sender, uint value); /// Emitted when transaction forwarded to the next destination. event Forwarded ( bytes signature, address indexed signer, address indexed destination, uint value, bytes data, bytes32 _hash ); /// Emitted when owner is changed event OwnerChanged ( address indexed newOwner ); bool internal isInitialized; // Keep track to avoid replay attack. uint public nonce; /// Proxy owner. address public owner; /** * @dev Initialize the Proxy clone with default values. * @param _owner An address that orders forwarding of transactions. */ function initialize(address _owner) public { require(!isInitialized, "Clone must be initialized only once."); isInitialized = true; owner = _owner; } /** * @dev Payable fallback to accept incoming payments. */ function () external payable { emit Received(msg.sender, msg.value); } /** * @dev Change the owner of this proxy. Used when the user forgets their key, and we can recover it via SSSS split key. This will be the final txn of the forgotten key as it transfers ownership of the proxy to the new replacement key. Note that this is also callable by the contract itself, which would be used in the case that a user is changing their owner address via a metatxn * @param _newOwner An `address` of the new proxy owner. */ function changeOwner(address _newOwner) public { require(owner == msg.sender || address(this) == msg.sender, "Only owner can change owner"); owner = _newOwner; emit OwnerChanged(_newOwner); } /** * @dev Forward a regular (non meta) transaction to the destination address. * @param _destination An `address` where txn should be forwarded to. * @param _value An `uint` of Wei value to be sent out. * @param _data A `bytes` data array of the given transaction. */ function forwardFromOwner(address _destination, uint _value, bytes memory _data) public { require(owner == msg.sender, "Only owner can use forwardFromOwner method"); require(executeCall(_destination, _value, _data), "Call must be successfull."); emit Forwarded("", owner, _destination, _value, _data, ""); } /** * @dev Returns hash for the given transaction. * @param _signer An `address` of transaction signer. * @param _destination An `address` where txn should be forwarded to. * @param _value An `uint` of Wei value to be sent out. * @param _data A `bytes` data array of the given transaction. * @return A `bytes32` hash calculated for all incoming parameters. */ function getHash( address _signer, address _destination, uint _value, bytes memory _data ) public view returns(bytes32) { return keccak256(abi.encodePacked(address(this), _signer, _destination, _value, _data, nonce)); } /** * @dev Forward a meta transaction to the destination address. * @param _signature A `bytes` array cotaining signature generated by owner. * @param _signer An `address` of transaction signer. * @param _destination An `address` where txn should be forwarded to. * @param _value An `uint` of Wei value to be sent out. * @param _data A `bytes` data array of the given transaction. */ function forward(bytes memory _signature, address _signer, address _destination, uint _value, bytes memory _data) public { bytes32 hash = getHash(_signer, _destination, _value, _data); nonce++; require(owner == hash.toEthSignedMessageHash().recover(_signature), "Signer must be owner."); require(executeCall(_destination, _value, _data), "Call must be successfull."); emit Forwarded(_signature, _signer, _destination, _value, _data, hash); } /** * @dev Withdraw given amount of wei to the specified address. * @param _to An `address` of where to send the wei. * @param _value An `uint` amount to withdraw from the contract balance. */ function withdraw(address _to, uint _value) public { require(owner == msg.sender || address(this) == msg.sender, "Only owner can withdraw"); _to.transfer(_value); } /** * @dev Withdraw any ERC20 tokens from the contract balance to owner's address. * @param _tokenAddress An `address` of an ERC20 token. * @param _to An `address` of where to send the tokens. * @param _tokens An `uint` tokens amount. */ function withdrawERC20Token(address _tokenAddress, address _to, uint _tokens) public { require(owner == msg.sender || address(this) == msg.sender, "Only owner can withdraw"); IERC20 token = IERC20(_tokenAddress); require(token.transfer(_to, _tokens), "Tokens transfer must complete successfully."); } /** * @dev Forward txn by executing a call. * @param _to Destination `address`. * @param _value An `uint256` Wei value to be sent out. * @param _data A `bytes` array with txn data. * @return A `bool` completion status. */ function executeCall(address _to, uint256 _value, bytes memory _data) internal returns (bool success) { assembly { let x := mload(0x40) success := call(gas, _to, _value, add(_data, 0x20), mload(_data), 0, 0) } } } contract DecoProxyFactory is DecoBaseProjectsMarketplace, CloneFactory { // Proxy master-contract address. address public libraryAddress; // Logged when a new Escrow clone is deployed to the chain. event ProxyCreated(address newProxyAddress); /** * @dev Constructor for the contract. * @param _libraryAddress Proxy master-contract address. */ constructor(address _libraryAddress) public { libraryAddress = _libraryAddress; } /** * @dev Updates library address with the given value. * @param _libraryAddress Address of a new base contract. */ function setLibraryAddress(address _libraryAddress) external onlyOwner { require(libraryAddress != _libraryAddress); require(_libraryAddress != address(0x0)); libraryAddress = _libraryAddress; } /** * @dev Create Proxy clone. * @param _ownerAddress An address of the Proxy contract owner. */ function createProxy( address _ownerAddress ) external returns(address) { address clone = createClone(libraryAddress); DecoProxy(clone).initialize( _ownerAddress ); emit ProxyCreated(clone); return clone; } }
* @dev Returns configured for the given project arbiter fees. @param _agreementHash A `bytes32` hash of the project`s agreement id. @return An `uint` fixed fee and an `uint8` share fee of the project's arbiter./
function getProjectArbitrationFees(bytes32 _agreementHash) public view returns(uint, uint8) { return ( projectArbiterFixedFee[_agreementHash], projectArbiterShareFee[_agreementHash] ); }
1,084,691
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 4351, 364, 326, 864, 1984, 419, 70, 2165, 1656, 281, 18, 632, 891, 389, 31135, 2310, 432, 1375, 3890, 1578, 68, 1651, 434, 326, 1984, 68, 87, 19602, 612, 18, 632, 2463, 1922, 1375, 11890, 68, 5499, 14036, 471, 392, 1375, 11890, 28, 68, 7433, 14036, 434, 326, 1984, 1807, 419, 70, 2165, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 11080, 686, 3682, 7034, 2954, 281, 12, 3890, 1578, 389, 31135, 2310, 13, 1071, 1476, 1135, 12, 11890, 16, 2254, 28, 13, 288, 203, 3639, 327, 261, 203, 5411, 1984, 686, 70, 2165, 7505, 14667, 63, 67, 31135, 2310, 6487, 203, 5411, 1984, 686, 70, 2165, 9535, 14667, 63, 67, 31135, 2310, 65, 203, 3639, 11272, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2021-03-11 */ /** *Submitted for verification at Etherscan.io on 2020-12-22 */ // SPDX-License-Identifier: MIT pragma solidity 0.7.6; /** * @title Proxy * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ abstract contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ fallback() external payable { _fallback(); } /** * @dev Receive function. * Implemented entirely in `_fallback`. */ receive() external payable { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal virtual {} /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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 in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @title UpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if (_data.length > 0) { (bool success, ) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable UpgradeabilityProxy(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
* Contract constructor. @param _logic address of the initial implementation. @param _admin_ Address of the proxy administrator. @param _data Data to send as msg.data to the implementation to initialize the proxied contract. It should include the signature and the parameters of the function to be called, as described in This parameter is optional, if no data is given the initialization call to proxied contract will be skipped./
) payable UpgradeabilityProxy(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
5,924,213
[ 1, 4625, 348, 7953, 560, 30, 380, 13456, 3885, 18, 632, 891, 389, 28339, 1758, 434, 326, 2172, 4471, 18, 632, 891, 389, 3666, 67, 5267, 434, 326, 2889, 22330, 18, 632, 891, 389, 892, 1910, 358, 1366, 487, 1234, 18, 892, 358, 326, 4471, 358, 4046, 326, 21875, 6835, 18, 2597, 1410, 2341, 326, 3372, 471, 326, 1472, 434, 326, 445, 358, 506, 2566, 16, 487, 11893, 316, 1220, 1569, 353, 3129, 16, 309, 1158, 501, 353, 864, 326, 10313, 745, 358, 21875, 6835, 903, 506, 9700, 18, 19, 2, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 262, 8843, 429, 17699, 2967, 3886, 24899, 28339, 16, 389, 892, 13, 288, 203, 3639, 1815, 12, 15468, 67, 55, 1502, 56, 422, 1731, 1578, 12, 11890, 5034, 12, 79, 24410, 581, 5034, 2932, 73, 625, 3657, 9599, 18, 5656, 18, 3666, 6, 3719, 300, 404, 10019, 203, 3639, 389, 542, 4446, 24899, 3666, 67, 1769, 203, 565, 289, 203, 203, 203, 565, 1731, 1578, 2713, 5381, 25969, 67, 55, 1502, 56, 273, 374, 6114, 8643, 2138, 6669, 5193, 69, 4313, 28, 70, 23, 31331, 8906, 3437, 70, 29, 74, 28, 69, 26, 24171, 73, 3247, 23, 73, 4449, 70, 26, 73, 28, 1340, 2499, 8285, 72, 26, 69, 27, 4033, 28, 3361, 70, 25, 72, 26, 23494, 31, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x397d11F822578B37b10582db5BCEb43BF6E7C85b/sources/contracts/CTokenEx.sol
* @notice Sender redeems cTokens in exchange for a specified amount of underlying asset @dev Accrues interest whether or not the operation succeeds, unless reverted @param redeemToken The amount of underlying to receive from redeeming cTokens @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)/ accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed
function redeemUnderlyingInternal(uint redeemToken) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } }
8,329,155
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 15044, 283, 323, 7424, 276, 5157, 316, 7829, 364, 279, 1269, 3844, 434, 6808, 3310, 632, 5206, 15980, 86, 3610, 16513, 2856, 578, 486, 326, 1674, 21933, 16, 3308, 15226, 329, 632, 891, 283, 24903, 1345, 1021, 3844, 434, 6808, 358, 6798, 628, 283, 24903, 310, 276, 5157, 632, 2463, 2254, 374, 33, 4768, 16, 3541, 279, 5166, 261, 5946, 1068, 13289, 18, 18281, 364, 3189, 13176, 4078, 86, 344, 29281, 24169, 5963, 603, 1334, 16, 1496, 732, 4859, 2545, 358, 613, 326, 5410, 716, 392, 18121, 283, 24903, 2535, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 283, 24903, 14655, 6291, 3061, 12, 11890, 283, 24903, 1345, 13, 2713, 1661, 426, 8230, 970, 1135, 261, 11890, 13, 288, 203, 3639, 2254, 555, 273, 4078, 86, 344, 29281, 5621, 203, 3639, 309, 261, 1636, 480, 2254, 12, 668, 18, 3417, 67, 3589, 3719, 288, 203, 5411, 327, 2321, 12, 668, 12, 1636, 3631, 13436, 966, 18, 862, 1639, 3375, 67, 2226, 5093, 1821, 67, 9125, 11027, 67, 11965, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0x3B95c63382b0C6b0eC49395cCe59DE5d6fd1276F/sources/project_/contracts/_openzeppelin/contracts/access/Ownable.sol
* @dev Throws if called by any account other than the owner./
modifier onlyOwner() { _checkOwner(); _; }
7,080,257
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 22435, 309, 2566, 635, 1281, 2236, 1308, 2353, 326, 3410, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 9606, 1338, 5541, 1435, 288, 203, 389, 1893, 5541, 5621, 203, 389, 31, 203, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/3/0x01ad84f586F324380668ff3E2C6513D5A768c612/sources/browser/stake/stakev2.sol
/** * @notice A method for a stakeholder to remove a stake. * @param _stake The size of the stake to be removed. */
function removeStake(uint256 _stake) external nonReentrant returns (bool) { StakeHolders storage Buyer = Staker[_msgSender()]; require(Buyer._isStaker && Buyer.stakes >= _stake, "No stakes Found"); require( block.timestamp.sub(Buyer.lastTimestamp) > _possibleUnstakeTime, "You have not staked for a while yet, kindly wait a bit more" ); redeemRewards(); uint256 AStakes = _stake; if (unstakingFeeRate > 0) { uint256 fee = (AStakes * unstakingFeeRate).div(1e4); AStakes = AStakes.sub(fee); _token.safeTransfer(feesReceiver, fee); feesCollected += fee; } _burn(_msgSender(), _stake); _token.safeTransfer(_msgSender(), AStakes); if (Buyer.stakes == 0) { Buyer._isStaker = false; totalHolders -= 1; } }
14,129,413
[ 1, 4625, 348, 7953, 560, 30, 225, 1783, 225, 380, 632, 20392, 432, 707, 364, 279, 384, 911, 4505, 358, 1206, 279, 384, 911, 18, 225, 380, 632, 891, 389, 334, 911, 1021, 963, 434, 326, 384, 911, 358, 506, 3723, 18, 225, 1195, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1206, 510, 911, 12, 11890, 5034, 389, 334, 911, 13, 3903, 1661, 426, 8230, 970, 1135, 261, 6430, 13, 288, 203, 3639, 934, 911, 27003, 2502, 605, 16213, 273, 934, 6388, 63, 67, 3576, 12021, 1435, 15533, 203, 3639, 2583, 12, 38, 16213, 6315, 291, 510, 6388, 597, 605, 16213, 18, 334, 3223, 1545, 389, 334, 911, 16, 315, 2279, 384, 3223, 10750, 8863, 203, 3639, 2583, 12, 203, 5411, 1203, 18, 5508, 18, 1717, 12, 38, 16213, 18, 2722, 4921, 13, 405, 389, 12708, 984, 334, 911, 950, 16, 203, 5411, 315, 6225, 1240, 486, 384, 9477, 364, 279, 1323, 4671, 16, 3846, 715, 2529, 279, 2831, 1898, 6, 203, 3639, 11272, 203, 3639, 283, 24903, 17631, 14727, 5621, 203, 3639, 2254, 5034, 432, 510, 3223, 273, 389, 334, 911, 31, 203, 3639, 309, 261, 23412, 6159, 14667, 4727, 405, 374, 13, 288, 203, 5411, 2254, 5034, 14036, 273, 261, 37, 510, 3223, 380, 640, 334, 6159, 14667, 4727, 2934, 2892, 12, 21, 73, 24, 1769, 203, 5411, 432, 510, 3223, 273, 432, 510, 3223, 18, 1717, 12, 21386, 1769, 203, 5411, 389, 2316, 18, 4626, 5912, 12, 3030, 281, 12952, 16, 14036, 1769, 203, 5411, 1656, 281, 10808, 329, 1011, 14036, 31, 203, 3639, 289, 203, 3639, 389, 70, 321, 24899, 3576, 12021, 9334, 389, 334, 911, 1769, 203, 3639, 389, 2316, 18, 4626, 5912, 24899, 3576, 12021, 9334, 432, 510, 3223, 1769, 203, 203, 3639, 309, 261, 38, 16213, 18, 334, 3223, 422, 374, 13, 288, 203, 5411, 605, 16213, 6315, 291, 510, 6388, 273, 629, 31, 203, 5411, 2078, 27003, 3947, 404, 31, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
interface PermittedAddressesInterface { function permittedAddresses(address _address) external view returns(bool); function addressesTypes(address _address) external view returns(string memory); function isMatchTypes(address _address, uint256 addressType) external view returns(bool); } interface SmartFundERC20LightFactoryInterface { function createSmartFundLight( address _owner, string memory _name, uint256 _successFee, address _exchangePortalAddress, address _permittedAddresses, address _coinAddress, address _fundValueOracle, bool _isRequireTradeVerification, address _cotraderGlobalConfig ) external returns(address); } interface SmartFundETHLightFactoryInterface { function createSmartFundLight( address _owner, string memory _name, uint256 _successFee, address _exchangePortalAddress, address _permittedAddresses, address _fundValueOracle, bool _isRequireTradeVerification, address _cotraderGlobalConfig ) external returns(address); } interface SmartFundERC20FactoryInterface { function createSmartFund( address _owner, string memory _name, uint256 _successFee, address _exchangePortalAddress, address _poolPortalAddress, address _defiPortal, address _permittedAddresses, address _coinAddress, address _fundValueOracle, bool _isRequireTradeVerification, address _cotraderGlobalConfig ) external returns(address); } interface SmartFundETHFactoryInterface { function createSmartFund( address _owner, string memory _name, uint256 _successFee, address _exchangePortalAddress, address _poolPortalAddress, address _defiPortal, address _permittedAddresses, address _fundValueOracle, bool _isRequireTradeVerification, address _cotraderGlobalConfig ) external returns(address); } pragma solidity ^0.6.12; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /* * The SmartFundRegistry is used to manage the creation and permissions of SmartFund contracts */ contract SmartFundRegistry is Ownable { address[] public smartFunds; // The Smart Contract which stores the addresses of all the authorized address PermittedAddressesInterface public permittedAddresses; // Addresses of portals address public poolPortalAddress; address public exchangePortalAddress; address public defiPortalAddress; // Default maximum success fee is 3000/30% uint256 public maximumSuccessFee = 3000; // Address of stable coin can be set in constructor and changed via function address public stableCoinAddress; // Address of CoTrader coin be set in constructor address public COTCoinAddress; // Address of Oracle address public oracleAddress; // Address of Cotrader global config address public cotraderGlobalConfig; // Factories SmartFundETHFactoryInterface public smartFundETHFactory; SmartFundERC20FactoryInterface public smartFundERC20Factory; SmartFundETHLightFactoryInterface public smartFundETHLightFactory; SmartFundERC20LightFactoryInterface public smartFundERC20LightFactory; // Enum for detect fund type in create fund function // NOTE: You can add a new type at the end, but do not change this order enum FundType { ETH, USD, COT } event SmartFundAdded(address indexed smartFundAddress, address indexed owner); /** * @dev contructor * * @param _exchangePortalAddress Address of the initial ExchangePortal contract * @param _poolPortalAddress Address of the initial PoolPortal contract * @param _stableCoinAddress Address of the stable coin * @param _COTCoinAddress Address of Cotrader coin * @param _smartFundETHFactory Address of smartFund ETH factory * @param _smartFundERC20Factory Address of smartFund USD factory * @param _smartFundETHLightFactory Address of smartFund ETH factory * @param _smartFundERC20LightFactory Address of smartFund USD factory * @param _defiPortalAddress Address of defiPortal contract * @param _permittedAddresses Address of permittedAddresses contract * @param _oracleAddress Address of fund value oracle contract * @param _cotraderGlobalConfig Address of CoTraderGlobalConfig contract */ constructor( address _exchangePortalAddress, address _poolPortalAddress, address _stableCoinAddress, address _COTCoinAddress, address _smartFundETHFactory, address _smartFundERC20Factory, address _smartFundETHLightFactory, address _smartFundERC20LightFactory, address _defiPortalAddress, address _permittedAddresses, address _oracleAddress, address _cotraderGlobalConfig ) public { exchangePortalAddress = _exchangePortalAddress; poolPortalAddress = _poolPortalAddress; stableCoinAddress = _stableCoinAddress; COTCoinAddress = _COTCoinAddress; smartFundETHFactory = SmartFundETHFactoryInterface(_smartFundETHFactory); smartFundERC20Factory = SmartFundERC20FactoryInterface(_smartFundERC20Factory); smartFundETHLightFactory = SmartFundETHLightFactoryInterface(_smartFundETHLightFactory); smartFundERC20LightFactory = SmartFundERC20LightFactoryInterface(_smartFundERC20LightFactory); defiPortalAddress = _defiPortalAddress; permittedAddresses = PermittedAddressesInterface(_permittedAddresses); oracleAddress = _oracleAddress; cotraderGlobalConfig = _cotraderGlobalConfig; } /** * @dev Creates a new Full SmartFund * * @param _name The name of the new fund * @param _successFee The fund managers success fee * @param _fundType Fund type enum number * @param _isRequireTradeVerification If true fund can buy only tokens, * which include in Merkle Three white list */ function createSmartFund( string memory _name, uint256 _successFee, uint256 _fundType, bool _isRequireTradeVerification ) public { // Require that the funds success fee be less than the maximum allowed amount require(_successFee <= maximumSuccessFee); address smartFund; // ETH case if(_fundType == uint256(FundType.ETH)){ // Create ETH Fund smartFund = smartFundETHFactory.createSmartFund( msg.sender, _name, _successFee, // manager and platform fee exchangePortalAddress, poolPortalAddress, defiPortalAddress, address(permittedAddresses), oracleAddress, _isRequireTradeVerification, cotraderGlobalConfig ); } // ERC20 case else{ address coinAddress = getERC20AddressByFundType(_fundType); // Create ERC20 based fund smartFund = smartFundERC20Factory.createSmartFund( msg.sender, _name, _successFee, // manager and platform fee exchangePortalAddress, poolPortalAddress, defiPortalAddress, address(permittedAddresses), coinAddress, oracleAddress, _isRequireTradeVerification, cotraderGlobalConfig ); } smartFunds.push(smartFund); emit SmartFundAdded(smartFund, msg.sender); } /** * @dev Creates a new Light SmartFund * * @param _name The name of the new fund * @param _successFee The fund managers success fee * @param _fundType Fund type enum number * @param _isRequireTradeVerification If true fund can buy only tokens, * which include in Merkle Three white list */ function createSmartFundLight( string memory _name, uint256 _successFee, uint256 _fundType, bool _isRequireTradeVerification ) public { // Require that the funds success fee be less than the maximum allowed amount require(_successFee <= maximumSuccessFee); address smartFund; // ETH case if(_fundType == uint256(FundType.ETH)){ // Create ETH Fund smartFund = smartFundETHLightFactory.createSmartFundLight( msg.sender, _name, _successFee, // manager and platform fee exchangePortalAddress, address(permittedAddresses), oracleAddress, _isRequireTradeVerification, cotraderGlobalConfig ); } // ERC20 case else{ address coinAddress = getERC20AddressByFundType(_fundType); // Create ERC20 based fund smartFund = smartFundERC20LightFactory.createSmartFundLight( msg.sender, _name, _successFee, // manager and platform fee exchangePortalAddress, address(permittedAddresses), coinAddress, oracleAddress, _isRequireTradeVerification, cotraderGlobalConfig ); } smartFunds.push(smartFund); emit SmartFundAdded(smartFund, msg.sender); } function getERC20AddressByFundType(uint256 _fundType) private view returns(address coinAddress){ // Define coin address dependse of fund type coinAddress = _fundType == uint256(FundType.USD) ? stableCoinAddress : COTCoinAddress; } function totalSmartFunds() public view returns (uint256) { return smartFunds.length; } function getAllSmartFundAddresses() public view returns(address[] memory) { address[] memory addresses = new address[](smartFunds.length); for (uint i; i < smartFunds.length; i++) { addresses[i] = address(smartFunds[i]); } return addresses; } /** * @dev Owner can set a new default ExchangePortal address * * @param _newExchangePortalAddress Address of the new exchange portal to be set */ function setExchangePortalAddress(address _newExchangePortalAddress) external onlyOwner { // Require that the new exchange portal is permitted by permittedAddresses require(permittedAddresses.permittedAddresses(_newExchangePortalAddress)); exchangePortalAddress = _newExchangePortalAddress; } /** * @dev Owner can set a new default Portal Portal address * * @param _poolPortalAddress Address of the new pool portal to be set */ function setPoolPortalAddress(address _poolPortalAddress) external onlyOwner { // Require that the new pool portal is permitted by permittedAddresses require(permittedAddresses.permittedAddresses(_poolPortalAddress)); poolPortalAddress = _poolPortalAddress; } /** * @dev Allows the fund manager to connect to a new permitted defi portal * * @param _newDefiPortalAddress The address of the new permitted defi portal to use */ function setDefiPortal(address _newDefiPortalAddress) public onlyOwner { // Require that the new defi portal is permitted by permittedAddresses require(permittedAddresses.permittedAddresses(_newDefiPortalAddress)); defiPortalAddress = _newDefiPortalAddress; } /** * @dev Owner can set maximum success fee for all newly created SmartFunds * * @param _maximumSuccessFee New maximum success fee */ function setMaximumSuccessFee(uint256 _maximumSuccessFee) external onlyOwner { maximumSuccessFee = _maximumSuccessFee; } /** * @dev Owner can set new stableCoinAddress * * @param _stableCoinAddress New stable address */ function setStableCoinAddress(address _stableCoinAddress) external onlyOwner { require(permittedAddresses.permittedAddresses(_stableCoinAddress)); stableCoinAddress = _stableCoinAddress; } /** * @dev Owner can set new smartFundETHFactory * * @param _smartFundETHFactory address of ETH factory contract */ function setNewSmartFundETHFactory(address _smartFundETHFactory) external onlyOwner { smartFundETHFactory = SmartFundETHFactoryInterface(_smartFundETHFactory); } /** * @dev Owner can set new smartFundERC20Factory * * @param _smartFundERC20Factory address of ERC20 factory contract */ function setNewSmartFundERC20Factory(address _smartFundERC20Factory) external onlyOwner { smartFundERC20Factory = SmartFundERC20FactoryInterface(_smartFundERC20Factory); } /** * @dev Owner can set new smartFundETHLightFactory * * @param _smartFundETHLightFactory address of ETH factory contract */ function setNewSmartFundETHLightFactory(address _smartFundETHLightFactory) external onlyOwner { smartFundETHLightFactory = SmartFundETHLightFactoryInterface(_smartFundETHLightFactory); } /** * @dev Owner can set new smartFundERC20LightFactory * * @param _smartFundERC20LightFactory address of ERC20 factory contract */ function setNewSmartFundERC20LightFactory(address _smartFundERC20LightFactory) external onlyOwner { smartFundERC20LightFactory = SmartFundERC20LightFactoryInterface(_smartFundERC20LightFactory); } /** * @dev Owner can set new Oracle * * @param _oracleAddress address of Oracle contract */ function setNewOracle(address _oracleAddress) external onlyOwner { oracleAddress = _oracleAddress; } /** * @dev Allows withdarw tokens from this contract if someone will accidentally send tokens here * * @param _tokenAddress Address of the token to be withdrawn */ function withdrawTokens(address _tokenAddress) external onlyOwner { IERC20 token = IERC20(_tokenAddress); token.transfer(owner(), token.balanceOf(address(this))); } /** * @dev Allows withdarw ETH from this contract if someone will accidentally send tokens here */ function withdrawEther() external onlyOwner { payable(owner()).transfer(address(this).balance); } // Fallback payable function in order to receive ether when fund manager withdraws their cut fallback() external payable {} }
* @dev Owner can set new smartFundETHFactory @param _smartFundETHFactory address of ETH factory contract/
function setNewSmartFundETHFactory(address _smartFundETHFactory) external onlyOwner { smartFundETHFactory = SmartFundETHFactoryInterface(_smartFundETHFactory); }
6,555,017
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 16837, 848, 444, 394, 13706, 42, 1074, 1584, 44, 1733, 632, 891, 389, 26416, 42, 1074, 1584, 44, 1733, 565, 1758, 434, 512, 2455, 3272, 6835, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 19469, 23824, 42, 1074, 1584, 44, 1733, 12, 2867, 389, 26416, 42, 1074, 1584, 44, 1733, 13, 3903, 1338, 5541, 288, 203, 565, 13706, 42, 1074, 1584, 44, 1733, 273, 19656, 42, 1074, 1584, 44, 1733, 1358, 24899, 26416, 42, 1074, 1584, 44, 1733, 1769, 203, 225, 289, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; import {IMirrorOpenSaleV0, IMirrorOpenSaleV0Events} from "./interface/IMirrorOpenSaleV0.sol"; import {Reentrancy} from "../../lib/Reentrancy.sol"; import {IERC165} from "../../lib/ERC165/interface/IERC165.sol"; import {IERC2981} from "../../lib/ERC2981/interface/IERC2981.sol"; import {ITreasuryConfig} from "../../treasury/interface/ITreasuryConfig.sol"; import {IMirrorTreasury} from "../../treasury/interface/IMirrorTreasury.sol"; import {IMirrorFeeRegistry} from "../../fee-registry/MirrorFeeRegistry.sol"; import {IERC721Events} from "../../lib/ERC721/interface/IERC721.sol"; /** * @title MirrorOpenSaleV0 * * @notice The Mirror Open Sale allows anyone to list an ERC721 with a tokenId range. * * Each token will be sold with tokenId incrementing starting at the lower end of the range. * To minimize storage we hash all sale configuration to generate a unique ID and only store * the necessary data that maintains the sale state. * * The token holder must first approve this contract otherwise purchasing will revert. * * The contract forwards the ether payment to the specified recipient and pays an optional fee * to the Mirror Treasury (0x138c3d30a724de380739aad9ec94e59e613a9008). Additionally, sale * royalties are distributed using the NFT Roylaties Standard (EIP-2981). * * @author MirrorXYZ */ contract MirrorOpenSaleV0 is IMirrorOpenSaleV0, IMirrorOpenSaleV0Events, IERC721Events, Reentrancy { /// @notice Version uint8 public constant VERSION = 0; /// @notice Mirror treasury configuration address public immutable override treasuryConfig; /// @notice Mirror fee registry address public immutable override feeRegistry; /// @notice Mirror tributary registry address public immutable override tributaryRegistry; /// @notice Map of sale data hash to sale state mapping(bytes32 => Sale) internal sales_; /// @notice Store configuration and registry addresses as immutable /// @param treasuryConfig_ address for Mirror treasury configuration /// @param feeRegistry_ address for Mirror fee registry /// @param tributaryRegistry_ address for Mirror tributary registry constructor( address treasuryConfig_, address feeRegistry_, address tributaryRegistry_ ) { treasuryConfig = treasuryConfig_; feeRegistry = feeRegistry_; tributaryRegistry = tributaryRegistry_; } /// @notice Get stored state for a specific sale /// @param h keccak256 of sale configuration (see `_getHash`) function sale(bytes32 h) external view override returns (Sale memory) { return sales_[h]; } /// @notice Register a sale /// @dev only the token itself or the operator can list tokens /// @param saleConfig_ sale configuration function register(SaleConfig calldata saleConfig_) external override { require( msg.sender == saleConfig_.token || msg.sender == saleConfig_.operator, "cannot register" ); _register(saleConfig_); } /// @notice Close a sale /// @dev Reverts if called by an account that does not operate the sale /// @param saleConfig_ sale configuration function close(SaleConfig calldata saleConfig_) external override { require(msg.sender == saleConfig_.operator, "not operator"); _setSaleStatus(saleConfig_, false); } /// @notice Open a sale /// @dev Reverts if called by an account that does not operate the sale /// @param saleConfig_ sale configuration function open(SaleConfig calldata saleConfig_) external override { require(msg.sender == saleConfig_.operator, "not operator"); _setSaleStatus(saleConfig_, true); } /// @notice Purchase a token /// @dev Reverts if the sale configuration does not hash to an open sale, /// not enough ether is sent, he sale is sold out, or if token approval /// has not been granted. Sends funds to the recipient and treasury. /// @param saleConfig_ sale configuration /// @param recipient account that will receive the purchased token function purchase(SaleConfig calldata saleConfig_, address recipient) external payable override nonReentrant { // generate hash of sale data bytes32 h = _getHash(saleConfig_); // retrive stored sale data Sale storage s = sales_[h]; // the registered field serves to assert that the hash maps to // a listed sale and the open field asserts the listed sale is open require(s.registered && s.open, "closed sale"); // assert correct amount of eth is received require(msg.value == saleConfig_.price, "incorrect value"); // calculate next tokenId, and increment amount sold uint256 tokenId = saleConfig_.startTokenId + s.sold++; // check that the tokenId is valid require(tokenId <= saleConfig_.endTokenId, "sold out"); // transfer token to recipient IERC721(saleConfig_.token).transferFrom( saleConfig_.operator, recipient, tokenId ); emit Purchase( // h h, // token saleConfig_.token, // tokenId tokenId, // buyer msg.sender, // recipient recipient ); // send funds to recipient and pay fees if necessary _withdraw( saleConfig_.operator, saleConfig_.token, tokenId, h, saleConfig_.recipient, msg.value, saleConfig_.feePercentage ); } // ============ Internal Methods ============ function _feeAmount(uint256 amount, uint256 fee) internal pure returns (uint256) { return (amount * fee) / 10_000; } function _getHash(SaleConfig calldata saleConfig_) internal pure returns (bytes32) { return keccak256( abi.encode( saleConfig_.token, saleConfig_.startTokenId, saleConfig_.endTokenId, saleConfig_.operator, saleConfig_.recipient, saleConfig_.price, saleConfig_.open, saleConfig_.feePercentage ) ); } function _register(SaleConfig calldata saleConfig_) internal { // get maximum fee from fees registry uint256 maxFee = IMirrorFeeRegistry(feeRegistry).maxFee(); // allow to pay any fee below the max, including no fees require(saleConfig_.feePercentage <= maxFee, "fee too high"); // generate hash of sale data bytes32 h = _getHash(saleConfig_); // assert the sale has not been registered previously require(!sales_[h].registered, "sale already registered"); // store critical sale data sales_[h] = Sale({ registered: true, open: saleConfig_.open, sold: 0, operator: saleConfig_.operator }); // all fields used to generate the hash need to be emitted to store and // generate the hash off-chain for interacting with the sale emit RegisteredSale( // h h, // token saleConfig_.token, // startTokenId saleConfig_.startTokenId, // endTokenId saleConfig_.endTokenId, // operator saleConfig_.operator, // recipient saleConfig_.recipient, // price saleConfig_.price, // open saleConfig_.open, // feePercentage saleConfig_.feePercentage ); if (saleConfig_.open) { emit OpenSale(h); } else { emit CloseSale(h); } } function _setSaleStatus(SaleConfig calldata saleConfig_, bool status) internal { bytes32 h = _getHash(saleConfig_); // assert the sale is registered require(sales_[h].registered, "unregistered sale"); require(sales_[h].open != status, "status already set"); sales_[h].open = status; if (status) { emit OpenSale(h); } else { emit CloseSale(h); } } function _withdraw( address operator, address token, uint256 tokenId, bytes32 h, address recipient, uint256 totalAmount, uint256 feePercentage ) internal { uint256 feeAmount = 0; if (feePercentage > 0) { // calculate fee amount feeAmount = _feeAmount(totalAmount, feePercentage); // contribute to treasury IMirrorTreasury(ITreasuryConfig(treasuryConfig).treasury()) .contributeWithTributary{value: feeAmount}(operator); } uint256 saleAmount = totalAmount - feeAmount; (address royaltyRecipient, uint256 royaltyAmount) = _royaltyInfo( token, tokenId, saleAmount ); require(royaltyAmount < saleAmount, "invalid royalty amount"); if (msg.sender == royaltyRecipient || royaltyRecipient == address(0)) { // transfer funds to recipient _send(payable(recipient), saleAmount); // emit an event describing the withdrawal emit Withdraw(h, totalAmount, feeAmount, recipient); } else { // transfer funds to recipient _send(payable(recipient), saleAmount - royaltyAmount); // transfer royalties _send(payable(royaltyRecipient), royaltyAmount); // emit an event describing the withdrawal emit Withdraw(h, totalAmount, feeAmount, recipient); } } function _royaltyInfo( address token, uint256 tokenId, uint256 amount ) internal view returns (address royaltyRecipient, uint256 royaltyAmount) { // get royalty info if (IERC165(token).supportsInterface(type(IERC2981).interfaceId)) { (royaltyRecipient, royaltyAmount) = IERC2981(token).royaltyInfo( tokenId, amount ); } } function _send(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "recipient reverted"); } } interface IERC721 { function transferFrom( address from, address to, uint256 tokenId ) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface IMirrorOpenSaleV0Events { event RegisteredSale( bytes32 h, address indexed token, uint256 startTokenId, uint256 endTokenId, address indexed operator, address indexed recipient, uint256 price, bool open, uint256 feePercentage ); event Purchase( bytes32 h, address indexed token, uint256 tokenId, address indexed buyer, address indexed recipient ); event Withdraw( bytes32 h, uint256 amount, uint256 fee, address indexed recipient ); event OpenSale(bytes32 h); event CloseSale(bytes32 h); } interface IMirrorOpenSaleV0 { struct Sale { bool registered; bool open; uint256 sold; address operator; } struct SaleConfig { address token; uint256 startTokenId; uint256 endTokenId; address operator; address recipient; uint256 price; bool open; uint256 feePercentage; } function treasuryConfig() external returns (address); function feeRegistry() external returns (address); function tributaryRegistry() external returns (address); function sale(bytes32 h) external view returns (Sale memory); function register(SaleConfig calldata saleConfig_) external; function close(SaleConfig calldata saleConfig_) external; function open(SaleConfig calldata saleConfig_) external; function purchase(SaleConfig calldata saleConfig_, address recipient) external payable; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; contract Reentrancy { // ============ Constants ============ uint256 internal constant REENTRANCY_NOT_ENTERED = 1; uint256 internal constant REENTRANCY_ENTERED = 2; // ============ Mutable Storage ============ uint256 internal reentrancyStatus; // ============ Modifiers ============ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(reentrancyStatus != REENTRANCY_ENTERED, "Reentrant call"); // Any calls to nonReentrant after this point will fail reentrancyStatus = REENTRANCY_ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip2200) reentrancyStatus = REENTRANCY_NOT_ENTERED; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } abstract contract ERC165 is IERC165 { function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; /** * @title IERC2981 * @notice Interface for the NFT Royalty Standard */ interface IERC2981 { // / bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a /** * @notice Called with the sale price to determine how much royalty * is owed and to whom. * @param _tokenId - the NFT asset queried for royalty information * @param _salePrice - the sale price of the NFT asset specified by _tokenId * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for _salePrice */ function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface ITreasuryConfig { function treasury() external returns (address payable); function distributionModel() external returns (address); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface IMirrorTreasury { function transferFunds(address payable to, uint256 value) external; function transferERC20( address token, address to, uint256 value ) external; function contributeWithTributary(address tributary) external payable; function contribute(uint256 amount) external payable; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; import {Ownable} from "../lib/Ownable.sol"; interface IMirrorFeeRegistry { function maxFee() external returns (uint256); function updateMaxFee(uint256 newFee) external; } /** * @title MirrorFeeRegistry * @author MirrorXYZ */ contract MirrorFeeRegistry is IMirrorFeeRegistry, Ownable { uint256 public override maxFee = 500; constructor(address owner_) Ownable(owner_) {} function updateMaxFee(uint256 newFee) external override onlyOwner { maxFee = newFee; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface IERC721 { function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom( address from, address to, uint256 tokenId ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } interface IERC721Events { event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); } interface IERC721Metadata { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } interface IERC721Burnable is IERC721 { function burn(uint256 tokenId) external; } interface IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } interface IERC721Royalties { function getFeeRecipients(uint256 id) external view returns (address payable[] memory); function getFeeBps(uint256 id) external view returns (uint256[] memory); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.10; interface IOwnableEvents { event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); } contract Ownable is IOwnableEvents { address public owner; address private nextOwner; // modifiers modifier onlyOwner() { require(isOwner(), "caller is not the owner."); _; } modifier onlyNextOwner() { require(isNextOwner(), "current owner must set caller as next owner."); _; } /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor(address owner_) { owner = owner_; emit OwnershipTransferred(address(0), owner); } /** * @dev Initiate ownership transfer by setting nextOwner. */ function transferOwnership(address nextOwner_) external onlyOwner { require(nextOwner_ != address(0), "Next owner is the zero address."); nextOwner = nextOwner_; } /** * @dev Cancel ownership transfer by deleting nextOwner. */ function cancelOwnershipTransfer() external onlyOwner { delete nextOwner; } /** * @dev Accepts ownership transfer by setting owner. */ function acceptOwnership() external onlyNextOwner { delete nextOwner; owner = msg.sender; emit OwnershipTransferred(owner, msg.sender); } /** * @dev Renounce ownership by setting owner to zero address. */ function renounceOwnership() external onlyOwner { _renounceOwnership(); } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == owner; } /** * @dev Returns true if the caller is the next owner. */ function isNextOwner() public view returns (bool) { return msg.sender == nextOwner; } function _setOwner(address previousOwner, address newOwner) internal { owner = newOwner; emit OwnershipTransferred(previousOwner, owner); } function _renounceOwnership() internal { owner = address(0); emit OwnershipTransferred(owner, address(0)); } }
get maximum fee from fees registry allow to pay any fee below the max, including no fees generate hash of sale data assert the sale has not been registered previously store critical sale data
function _register(SaleConfig calldata saleConfig_) internal { uint256 maxFee = IMirrorFeeRegistry(feeRegistry).maxFee(); require(saleConfig_.feePercentage <= maxFee, "fee too high"); bytes32 h = _getHash(saleConfig_); require(!sales_[h].registered, "sale already registered"); sales_[h] = Sale({ registered: true, open: saleConfig_.open, sold: 0, operator: saleConfig_.operator }); ); if (saleConfig_.open) { emit OpenSale(h); emit CloseSale(h); } }
13,794,135
[ 1, 4625, 348, 7953, 560, 30, 225, 336, 4207, 14036, 628, 1656, 281, 4023, 1699, 358, 8843, 1281, 14036, 5712, 326, 943, 16, 6508, 1158, 1656, 281, 2103, 1651, 434, 272, 5349, 501, 1815, 326, 272, 5349, 711, 486, 2118, 4104, 7243, 1707, 11239, 272, 5349, 501, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 4861, 12, 30746, 809, 745, 892, 272, 5349, 809, 67, 13, 2713, 288, 203, 3639, 2254, 5034, 943, 14667, 273, 6246, 8299, 14667, 4243, 12, 21386, 4243, 2934, 1896, 14667, 5621, 203, 203, 3639, 2583, 12, 87, 5349, 809, 27799, 21386, 16397, 1648, 943, 14667, 16, 315, 21386, 4885, 3551, 8863, 203, 203, 3639, 1731, 1578, 366, 273, 389, 588, 2310, 12, 87, 5349, 809, 67, 1769, 203, 203, 3639, 2583, 12, 5, 87, 5408, 67, 63, 76, 8009, 14327, 16, 315, 87, 5349, 1818, 4104, 8863, 203, 203, 3639, 272, 5408, 67, 63, 76, 65, 273, 348, 5349, 12590, 203, 5411, 4104, 30, 638, 16, 203, 5411, 1696, 30, 272, 5349, 809, 27799, 3190, 16, 203, 5411, 272, 1673, 30, 374, 16, 203, 5411, 3726, 30, 272, 5349, 809, 27799, 9497, 203, 3639, 15549, 203, 203, 3639, 11272, 203, 203, 3639, 309, 261, 87, 5349, 809, 27799, 3190, 13, 288, 203, 5411, 3626, 3502, 30746, 12, 76, 1769, 203, 5411, 3626, 3527, 30746, 12, 76, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x6FAEB511989E280D3A51ca45ED756C90e736b012/sources/@violetprotocol/mauve-core/contracts/interfaces/pool/IMauvePoolEvents.sol
@title Events emitted by a pool @notice Contains all events emitted by the pool
interface IMauvePoolEvents { event Initialize(uint160 sqrtPriceX96, int24 tick); event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); pragma solidity >=0.5.0; }
15,680,884
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 2649, 9043, 17826, 635, 279, 2845, 632, 20392, 8398, 777, 2641, 17826, 635, 326, 2845, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5831, 6246, 8377, 537, 2864, 3783, 288, 203, 565, 871, 9190, 12, 11890, 16874, 5700, 5147, 60, 10525, 16, 509, 3247, 4024, 1769, 203, 203, 565, 871, 490, 474, 12, 203, 3639, 1758, 5793, 16, 203, 3639, 1758, 8808, 3410, 16, 203, 3639, 509, 3247, 8808, 4024, 4070, 16, 203, 3639, 509, 3247, 8808, 4024, 5988, 16, 203, 3639, 2254, 10392, 3844, 16, 203, 3639, 2254, 5034, 3844, 20, 16, 203, 3639, 2254, 5034, 3844, 21, 203, 565, 11272, 203, 203, 565, 871, 9302, 12, 203, 3639, 1758, 8808, 3410, 16, 203, 3639, 1758, 8027, 16, 203, 3639, 509, 3247, 8808, 4024, 4070, 16, 203, 3639, 509, 3247, 8808, 4024, 5988, 16, 203, 3639, 2254, 10392, 3844, 20, 16, 203, 3639, 2254, 10392, 3844, 21, 203, 565, 11272, 203, 203, 565, 871, 605, 321, 12, 203, 3639, 1758, 8808, 3410, 16, 203, 3639, 509, 3247, 8808, 4024, 4070, 16, 203, 3639, 509, 3247, 8808, 4024, 5988, 16, 203, 3639, 2254, 10392, 3844, 16, 203, 3639, 2254, 5034, 3844, 20, 16, 203, 3639, 2254, 5034, 3844, 21, 203, 565, 11272, 203, 203, 565, 871, 12738, 12, 203, 3639, 1758, 8808, 5793, 16, 203, 3639, 1758, 8808, 8027, 16, 203, 3639, 509, 5034, 3844, 20, 16, 203, 3639, 509, 5034, 3844, 21, 16, 203, 3639, 2254, 16874, 5700, 5147, 60, 10525, 16, 203, 3639, 2254, 10392, 4501, 372, 24237, 16, 203, 3639, 509, 3247, 4024, 203, 565, 11272, 203, 203, 565, 871, 657, 11908, 26199, 367, 20091, 2134, 12, 203, 3639, 2254, 2313, 13853, 20091, 2134, 7617, 16, 203, 3639, 2254, 2313, 13853, 20091, 2134, 1908, 203, 565, 11272, 203, 203, 565, 871, 1000, 14667, 5752, 12, 11890, 28, 14036, 5752, 20, 7617, 16, 2254, 28, 14036, 5752, 21, 7617, 16, 2254, 28, 14036, 5752, 20, 1908, 16, 2254, 28, 14036, 5752, 21, 1908, 1769, 203, 203, 565, 871, 9302, 5752, 12, 2867, 8808, 5793, 16, 1758, 8808, 8027, 16, 2254, 10392, 3844, 20, 16, 2254, 10392, 3844, 21, 1769, 203, 683, 9454, 18035, 560, 1545, 20, 18, 25, 18, 20, 31, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts/token/ERC777/IERC777Sender.sol"; import "@openzeppelin/contracts/token/ERC777/ERC777.sol"; import "@openzeppelin/contracts/token/ERC777/ERC777.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./Administration.sol"; import "./ERC777ReceiveSend.sol"; import "./xStarterInterfaces.sol"; import "./xStarterDeployers.sol"; //import "./UniswapInterface.sol"; // https://ropsten.etherscan.io/tx/0xd0fd6a146eca2faff282a10e7604fa1c0c334d6a8a6361e4694a743154b2798f // must first approve amount // https://ropsten.etherscan.io/tx/0x2f39644b43bb8f1407e4bb8bf9c1f6ceb116633be8be7c8fa2980235fa088c51 // transaction showing how to add liquidity for ETH to token pair // xStarterPoolPairB: project tokens are swapped after total funding is raised. As Long as a Minimum funding amount is reached. interface IERC20Custom { function totalSupply() external view returns (uint256); // function owner() external view returns (address); function allowance(address owner_, address spender) external view returns (uint256); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function balanceOf(address) external view returns (uint256); function decimals() external view returns (uint8); } interface IERC20Uni { function approve(address spender, uint256 amount) external returns (bool); function transfer(address to, uint value) external returns (bool); } interface IUniswapRouter { function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); // add liquidity, this will automatically create a pair for WETH function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); // get the WETH address function WETH() external pure returns (address); } interface IUniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address pair); } struct Info { uint8 _percentOfTokensForILO; uint8 _percentTokensForTeam; uint24 _dexDeadlineLength; uint48 _contribTimeLock; // length of lock for Liquidity tokens Minimum 365.25 days or 31557600 seconds uint48 _liqPairLockLen; uint _minPerSwap; uint _minPerAddr; uint _maxPerAddr; uint _softcap; uint _hardcap; address _fundingToken; address _addressOfDex; address _addressOfDexFactory; } contract ProjectBaseToken is Context, ERC777, ERC777NoReceiveRecipient, ERC777NoSendSender { using SafeMath for uint256; using Address for address; constructor( string memory name_, string memory symbol_, uint totalSupply_, address creatorAddr, address[] memory defaultOperators_ ) ERC777(name_, symbol_, defaultOperators_) { // this will mint total supply _mint(creatorAddr, totalSupply_, "", ""); // _mint(_msgSender(), totalSupply_, "", ""); } } contract ProjectBaseTokenERC20 is Context, ERC20{ using SafeMath for uint256; using Address for address; constructor( string memory name_, string memory symbol_, uint totalSupply_, address creatorAddr ) ERC20(name_, symbol_) { // _setupDecimals(decimals_); // this will mint total supply _mint(creatorAddr, totalSupply_); // _mint(_msgSender(), totalSupply_, "", ""); } } contract xStarterERCDeployer is BaseDeployer { function deployToken( string memory name_, string memory symbol_, uint totalTokenSupply_, address[] memory defaultOperators_ ) external onlyAllowedCaller returns(address ercToken){ //ProjectBaseToken newToken = new ProjectBaseToken(name_,symbol_, totalTokenSupply_, address(this), defaultOperators_); ercToken = address(new ProjectBaseTokenERC20(name_,symbol_, totalTokenSupply_, msg.sender)); } } interface IXStarterERCDeployer { function setAllowedCaller(address allowedCaller_) external returns(bool); function deployToken( string memory name_, string memory symbol_, uint totalTokenSupply_, address[] memory defaultOperators_ ) external returns(address ercToken); } contract xStarterPoolPairB is Administration, IERC777Recipient, IERC777Sender { using SafeMath for uint256; using Address for address; // this is for xDai chain it's 5 seconds, goerli is 15 seconds. if deploying to other chains check the length of block creation, some are faster uint MINE_LEN; struct FunderInfo { uint fundingTokenAmount; uint projectTokenAmount; } struct SwapInfo { uint24 fundTokenReceive; uint24 projectTokenGive; } modifier onlySetup() { require(_isSetup, "ILO has not been set up"); _; } modifier onlyOpen() { require(isEventOpen(), "ILO event not open"); _; } modifier notCurrentlyFunding() { require(!_currentlyFunding[_msgSender()], "Locked From Funding, A transaction you initiated has not been completed"); _; } modifier allowedToWithdraw() { require(!_currentlyWithdrawing[_msgSender()], "Locked From Withdrawing, A transaction you initiated has not been completed"); _; } event TokenCreatedByXStarterPoolPair(address indexed TokenAddr_, address indexed PoolPairAddr_, address indexed Admin_, uint timestamp_); event TokenSwapped(address indexed funder_, uint indexed tokensDesired, uint indexed tokensReceived_, uint tokensForLiq_); Info private i; // address private _addressOfDex; // address private _addressOfDexFactory; uint _decimals = 18; // stores address of the project's token address private _projectToken; uint8 private _projectTokenDecimals; // uint keeping track of total project's token supply. //for record. this is used to make sure total token is the same as voted for by the community uint private _totalTokensSupply; // added to when token is transferred from admin address to contract. // subtracted from when token is transfered to dex // subtracted from when token can be withdrawn by participants and admin uint private _tokensHeld; // this is set up by the launchpad, it enforces what the project told the community // if the project said 70% of tokens will be offered in the ILO. This will be set in the constructor. // address _fundingToken; // if 0 then use nativeTokenSwap // uint8 _fundingTokenDecimals; // address of dex liquidity token pair, this is the pair that issues liquidity tokens from uniswap or deriivatives address _liquidityPairAddress; address _proposalAddr; address _xStarterERCDeployer; address _xStarterToken; // Minimum xstarter token required to participate during private sale uint _minXSTN; address _xStarterLP; // Minimum xstarter LP tokens required uint _minXSTNLP; uint _totalLPTokens; // amount of liquidity uint _availLPTokens; // amount of liquidity // timestamp when contributors can start withdrawing their their Liquidity pool tokens uint _liqPairTimeLock; uint _liqPairBlockLock; uint8 private _percentOfTotalTokensForILO; uint8 private _percentOfILOTokensForLiquidity = 50; // timestamp of when contributors tokens will be free to withdraw uint private _contribTimeStampLock; // time stamp until project owner tokens are free usually double the length of contributor time uint private _projTimeLock; // block lock, use both timesamp and block number to add time lock uint private _projBlockLock; // the length in seconds of between block timestamp till timestamp when contributors can receive their tokens //Minimum is 14 days equivalent or 1,209,600 seconds // also project owners tokens are timelocked for either double the timelock of contributors or an additional 2 months uint private _contribBlockLock; // uint private _softcap; // uint private _hardcap; // uint private _minPerAddr = 1000000000000 wei; // uint private _maxPerAddr; // Minimum is 1 gwei, this is a really small amount and should only be overriden by a larger amount SwapInfo private _swapRatio; // uint amount of tokens aside for ILO. uint private _totalTokensILO; // tokens remaining for ILO uint private _availTokensILO; // tokens for liquidity uint private _tokensForLiquidity; // stores value of tokens for liquidity and is used to calculate contributors share uint private _amountForProjTokenCalc; // total funding tokens uint _fundingTokenTotal; // total funding tokens available. For non capital raising will be the same as i._fundingTokenTotal until liquidity pool is created uint _fundingTokenAvail; uint _fundingTokenForTeam; // utc timestamp uint48 private _startTime; // uint timestamp uint48 private _endTime; // utc timestamp uint48 private _pubStartTime; // bool if xStarterPoolPair is set up bool _isSetup; // bool _ILOValidated; bool _ILOSuccess; bool _approvedForLP; bool _liquidityPairCreated; uint private _adminBalance; mapping(address => FunderInfo) private _funders; mapping(address => bool) private _liqTokensWithdrawn; mapping(address => bool) private _projTokensWithdrawn; mapping(address => bool) private _currentlyFunding; mapping(address => bool) private _currentlyWithdrawing; // step 1 // todo: remove some of the unused parameters on the constructor constructor( address adminAddress, address proposalAddr_, address addressOfDex_, address addressOfDexFactory_, address xStarterToken_, address xstarterLP_, address xStarterERCDeployer_, uint minXSTN_, uint minXSTNLP_, uint blockTime_ ) Administration(adminAddress) { // require(percentOfTokensForILO_ > 0 && percentOfTokensForILO_ <= 100, "percent of tokens must be between 1 and 100"); // require(projectTokenGive_ > 0 && fundTokenReceive_ > 0, "swap ratio is zero "); // require(softcap_ > 0, "No softcap set"); (ILOProposal memory i_, ILOAdditionalInfo memory a_) = iXstarterProposal(proposalAddr_).getILOInfo(); MINE_LEN = blockTime_; _proposalAddr = proposalAddr_; _xStarterToken = xStarterToken_; _xStarterLP = xstarterLP_; _xStarterERCDeployer = xStarterERCDeployer_; _minXSTN = minXSTN_; _minXSTNLP = minXSTNLP_; i._minPerSwap = a_.minPerSwap; i._minPerAddr = a_.minPerAddr; _percentOfTotalTokensForILO = i_.percentOfTokensForILO; i._fundingToken = i_.fundingToken; i._dexDeadlineLength = 1800; // todo; in final production contract should be not less than 1209600 seconds or 14 days i._contribTimeLock = a_.contribTimeLock; i._liqPairLockLen = a_.liqPairLockLen; // i._addressOfDex = addressOfDex_; i._addressOfDex = addressOfDex_; i._addressOfDexFactory = addressOfDexFactory_; // if provided is less than default take default // todo require a minimum fund per address possible 1000 gwei or 1000000000000 wei i._minPerAddr = a_.minPerAddr; // 0 means not max set i._maxPerAddr = a_.maxPerAddr; i._softcap = a_.softcap; i._hardcap = a_.hardcap; i._percentTokensForTeam = a_.percentTokensForTeam > 20 ? 20 : a_.percentTokensForTeam; _totalTokensSupply = i_.totalSupply; } function getFullInfo() external view returns(Info memory) { return i; } function fundingTokenForTeam() public view returns(uint) { return _fundingTokenForTeam; } function addressOfDex() public view returns(address) { return i._addressOfDex; } function addressOfDexFactory() public view returns(address) { return i._addressOfDexFactory; } function amountRaised() public view returns(uint) { return _fundingTokenTotal; } function fundingTokenAvail() public view returns(uint) { return _fundingTokenAvail; } function availLPTokens() public view returns(uint) { return _availLPTokens; } function softcap() public view returns(uint) { return i._softcap; } function hardcap() public view returns(uint) { return i._hardcap; } function minSpend() public view returns(uint) { return i._minPerAddr; } function maxSpend() public view returns(uint) { return i._maxPerAddr; } function liquidityPairAddress() public view returns(address) { return _liquidityPairAddress; } function tokensForLiquidity() public view returns(uint) { return _tokensForLiquidity; } function amountForProjTokenCalc() public view returns(uint) { return _amountForProjTokenCalc; } function fundingTokenBalanceOfFunder(address funder_) public view returns(uint) { return _funders[funder_].fundingTokenAmount; } function projectTokenBalanceOfFunder(address funder_) public view returns(uint) { require(_ILOValidated, "project balance not available till ILO validated"); return _getProjTknBal(funder_); } function projectLPTokenBalanceOfFunder(address funder_) public view returns(uint) { require(_availLPTokens > 0, "LP tokens not yet set"); return _getLiqTknBal(funder_); } //todo: swapRatio should be called after ILO, which would allow individuals to see how much tokens they're receiving per funding token function swapRatio() public view returns(uint24, uint24) { return (_swapRatio.fundTokenReceive, _swapRatio.projectTokenGive); } function adminBalance() public view returns(uint balance_) { return _adminBalance; } function isWithdrawing(address addr_) public view returns(bool) { return _currentlyWithdrawing[addr_ ]; } function isSetup() public view returns (bool) { return _isSetup; } function isTimeLockSet() public view returns (bool) { return _projTimeLock != 0 && _contribTimeStampLock != 0 && _liqPairTimeLock != 0; } // return true if ILO is complete, Validated and ILO did not reach threshold ie _ILOSuccess == false function ILOFailed() public view returns (bool) { return isEventDone() && _ILOValidated && !_ILOSuccess; } function isContribTokenLocked() public view returns (bool) { require(isTimeLockSet(), "Time locked not set"); return block.timestamp < _contribTimeStampLock || block.number < _contribBlockLock; } function isProjTokenLocked() public view returns (bool) { require(isTimeLockSet(), "Time locked not set"); return block.timestamp < _projTimeLock || block.number < _projBlockLock; } function isLiqTokenLocked() public view returns (bool) { require(isTimeLockSet(), "Time locked not set"); return block.timestamp < _liqPairTimeLock || block.number < _liqPairBlockLock; } function getTimeLocks() public view returns (uint, uint, uint, uint, uint, uint) { return ( _contribTimeStampLock, _contribBlockLock, _projTimeLock, _projBlockLock, _liqPairTimeLock, _liqPairBlockLock); } function endTime() public view returns (uint48) { return _endTime; } function startTime() public view returns (uint48) { return _startTime; } function pubStartTime() public view returns(uint48) { return _pubStartTime; } function availTokensILO() public view returns (uint) { return _availTokensILO; } function totalTokensILO() public view returns (uint) { return _totalTokensILO; } function percentOfTotalTokensForILO() public view returns (uint) { return _percentOfTotalTokensForILO; } function tokensHeld() public view returns (uint) { return _tokensHeld; } function totalTokensSupply() public view returns (uint) { return _totalTokensSupply; } function projectToken() public view returns (address) { return _projectToken; } function fundingToken() public view returns (address) { return i._fundingToken; } // different function isEventOpen() public view returns (bool isOpen_) { uint48 currentTime = uint48(block.timestamp); if(currentTime >= startTime() && currentTime < endTime() && amountRaised() < i._hardcap && _isSetup) { isOpen_ = true; } } //different function isEventDone() public view returns (bool isOpen_) { uint48 currentTime = uint48(block.timestamp); if(_isSetup && ( currentTime >= endTime() )|| ( i._hardcap > 0 && amountRaised() == i._hardcap )) { isOpen_ = true; } } // Step 2 function setUpPoolPair( address addressOfProjectToken, string memory tokenName_, string memory tokenSymbol_, uint totalTokenSupply_, uint48 startTime_, uint48 endTime_ ) public onlyAdmin returns(bool) { require(admin() == msg.sender, "Administration: caller is not the admin"); require(!_isSetup,"initial setup already done"); require(startTime_ > block.timestamp && endTime_ > startTime_, "ILO dates not correct"); totalTokenSupply_ = totalTokenSupply_ * 10 ** _decimals; require(_totalTokensSupply == totalTokenSupply_, "Total token supply not equal to provided information"); // if address of project token is 0 address deploy token for it if(address(0) == addressOfProjectToken) { address[] memory defaultOperators_; _deployToken(_xStarterERCDeployer,tokenName_, tokenSymbol_, totalTokenSupply_, defaultOperators_); } else { IERC20Custom existingToken = IERC20Custom(addressOfProjectToken); // address existingTokenOwner = existingToken.owner(); uint existingTokenSupply = existingToken.totalSupply(); uint8 expDecimals = existingToken.decimals(); // require(existingTokenOwner == admin(),"Admin of pool pair must be owner of token contract"); require(existingTokenSupply == totalTokenSupply_, "All tokens from contract must be transferred"); require(expDecimals == _decimals, "decimals do not match"); _projectToken = addressOfProjectToken; // _totalTokensSupply = _totalTokensSupply.add(totalTokenSupply_); // _tokensHeld = _tokensHeld.add(totalTokenSupply_); } _startTime = startTime_; _endTime = endTime_; uint48 privLen = (endTime_ - startTime_) / 2; _pubStartTime = _xStarterToken == address(0) ? startTime_ : startTime_ + privLen; // this also sets ILO status to 1 _isSetup = iXstarterProposal(_proposalAddr).setILOTimes(_startTime, _endTime, _projectToken); // if address of project token was zero address, then poolpair launches ERC20 for the project and keeps control of supply _isSetup = address(0) == addressOfProjectToken ? iXstarterProposal(_proposalAddr).setStatus(2) : iXstarterProposal(_proposalAddr).setStatus(1); require(_isSetup, 'not able register on proposal'); return _isSetup; } // function should be called within a function that checks proper access function _deployToken( address ercDeployer_, string memory name_, string memory symbol_, uint totalTokenSupply_, address[] memory defaultOperators_ ) internal returns(bool){ //ProjectBaseToken newToken = new ProjectBaseToken(name_,symbol_, totalTokenSupply_, address(this), defaultOperators_); _projectToken = IXStarterERCDeployer(ercDeployer_).deployToken(name_,symbol_, totalTokenSupply_, defaultOperators_); // _projectToken = address(newToken); // _totalTokensSupply = totalTokenSupply_; _tokensHeld = _tokensHeld.add(totalTokenSupply_); //_totalTokensILO = _tokensHeld.mul(_percentOfTotalTokensForILO.div(100)); _setTokensForILO(); emit TokenCreatedByXStarterPoolPair(_projectToken, address(this), _msgSender(), block.timestamp); return true; } // step 3 if PoolPair has not been funded, if token was created by poolpair contract it is automatically funded, also sets ILO tokens function depositAllTokenSupply() public onlyAdmin onlySetup returns(bool success) { require(_tokensHeld != _totalTokensSupply, "already deposited"); // if(_tokensHeld == _totalTokensSupply) { // return true; // } IERC20Custom existingToken = IERC20Custom(_projectToken); uint allowance = existingToken.allowance(admin(), address(this)); require(allowance == _totalTokensSupply, "You must deposit all available tokens by calling the approve function on the token contract"); // transfer approved tokens from admin to current ILO contract success = existingToken.transferFrom(_msgSender(), address(this), _totalTokensSupply); require(success,'could not transfer project tokens to pool pair contract'); _tokensHeld = _tokensHeld.add(_totalTokensSupply); _setTokensForILO(); iXstarterProposal(_proposalAddr).setStatus(2); } // function should be called within a function that checks proper access ie onlyAdmin or onlyOwner function _setTokensForILO() internal { // using the percent of tokens set in constructor by launchpad set total tokens for ILO // formular: (_percentOfTotalTokensForILO/100 ) * _tokensHeld //uint amount = _tokensHeld.mul(_percentOfTotalTokensForILO/100); uint amount = _tokensHeld * _percentOfTotalTokensForILO/100; _totalTokensILO = amount; _availTokensILO = amount; _adminBalance = _tokensHeld.sub(amount); } // functions for taking part in ILO function contributeNativeToken() payable notCurrentlyFunding onlyOpen external returns(bool){ require(i._fundingToken == address(0), "please use contributeFundingToken"); require(msg.value > i._minPerSwap, "No value Sent"); _disallowFunding(); _contribute(msg.value, _msgSender()); _allowFunding(); return true; } // should be called after approving amount of token function contributeFundingToken() notCurrentlyFunding onlyOpen external returns(bool) { require(i._fundingToken != address(0), "please use nativeTokenSwap."); _disallowFunding(); uint amount_ = _retrieveApprovedToken(); _contribute(amount_, _msgSender()); _allowFunding(); return true; } function _contribute(uint fundingTokenAmount_, address funder_) internal { // check to see if currently in private sale time, for initial xStarter ILO this will == _startTime //for subsequent it will be half of the ILO time, for example, if the ILO time was 1000 seconds, private sale would be the first 500 seconds, // and the public sale would be the last 500 seconds if(_pubStartTime > 0 && block.timestamp < _pubStartTime) { require(IERC20Custom(_xStarterToken).balanceOf(funder_) >= _minXSTN || IERC20Custom(_xStarterLP).balanceOf(funder_) >= _minXSTNLP, "must hold xStarter tokens"); } _fundingTokenTotal = _fundingTokenTotal.add(fundingTokenAmount_); _fundingTokenAvail = _fundingTokenAvail.add(fundingTokenAmount_); require(_fundingTokenTotal <= i._hardcap, "exceeds hard carp"); // add to msg.sender token funder balance FunderInfo storage funder = _funders[funder_]; funder.fundingTokenAmount = funder.fundingTokenAmount.add(fundingTokenAmount_); // funding can be less than Minimum if max - total < minimum uint amountLeft = i._hardcap - _fundingTokenTotal; // funding amount should be greater or equal to Minimum OR if not then available amount should be less than Minimum and fundingTokenAmount equals to amount left require((funder.fundingTokenAmount >= i._minPerAddr) || (amountLeft < i._minPerAddr && fundingTokenAmount_ == amountLeft ) , "Minimum amount not met"); // if max is set then make sure not contributing max require(funder.fundingTokenAmount <= i._maxPerAddr || i._maxPerAddr == 0, "maximum exceeded"); // sets amount raised on proposal iXstarterProposal(_proposalAddr).setAmountRaised(_fundingTokenTotal); } function _retrieveApprovedToken() internal returns(uint allowedAmount_) { address ownAddress = address(this); IERC20Custom existingToken = IERC20Custom(i._fundingToken); allowedAmount_ = existingToken.allowance(_msgSender(), ownAddress); require(allowedAmount_ > i._minPerSwap, "Amount must be greater than 0"); bool success = existingToken.transferFrom(_msgSender(), ownAddress, allowedAmount_); require(success, "not able to retrieve approved tokens of funding token"); return allowedAmount_; } function _allowFunding() internal { _currentlyFunding[_msgSender()] = false; } function _disallowFunding() internal { _currentlyFunding[_msgSender()] = true; } function _allowWithdraw() internal { _currentlyWithdrawing[_msgSender()] = false; } function _disallowWithdraw() internal { _currentlyWithdrawing[_msgSender()] = true; } event ILOValidated(address indexed caller_, uint indexed amountRaised_, bool success_, uint indexed swappedTokens_); // step 4 validate after ILO // validate checks to make sure mini amount of project tokens raised // different function validateILO() external returns(bool) { require(isEventDone() && !_ILOValidated, "ILO not yet done OR already validated"); // uint minNeeded = uint(_totalTokensILO * _percentRequiredTokenPurchase / 100); _ILOSuccess = amountRaised() >= i._softcap; _ILOValidated = true; emit ILOValidated(_msgSender(), amountRaised(), _ILOSuccess, _totalTokensILO); if(_ILOSuccess) { _tokensForLiquidity = uint(_totalTokensILO * _percentOfILOTokensForLiquidity / 100); if(i._percentTokensForTeam > 0) { _fundingTokenForTeam = uint((_fundingTokenAvail * i._percentTokensForTeam) / 100); _fundingTokenAvail = _fundingTokenAvail.sub(_fundingTokenForTeam); } } iXstarterProposal(_proposalAddr).setStatus(3); return true; } // step 5 function approveTokensForLiquidityPair() external returns(bool) { require(_ILOValidated && !ILOFailed(), "You must first validate ILO"); require(address(0) != i._addressOfDex, "dex zero addr"); require(!_approvedForLP, "approved tokens for liquidity already called"); uint amountProjectToken = _tokensForLiquidity; if(address(0) == i._fundingToken) { _approvedForLP = _callApproveOnProjectToken(i._addressOfDex, amountProjectToken); } else { uint amountERC20 = _fundingTokenAvail; _approvedForLP = _callApproveOnProjectToken(i._addressOfDex, amountProjectToken) && _callApproveOnFundingToken(i._addressOfDex, amountERC20); } // approve project token to be sent to dex. Spender is dex IUniswapRouter address (honeyswap, uniswap etc) require(_approvedForLP, "xStarterPair: TokenApprovalFail"); iXstarterProposal(_proposalAddr).setStatus(4); return _approvedForLP; } event liquidityPairCreated(address indexed lpAddress_, address dexAddress_, uint lpTokenAmount_); // step 6 function createLiquidityPool() external returns(bool success) { // liquidity will be i._fundingTokenAvail to _tokensForLiquidity ratio require(_ILOValidated && !ILOFailed(), "You must first validate ILO"); require(_approvedForLP, "xStarterPair: TokenApprovalFail"); require(!_liquidityPairCreated, "Liquidity pair already created"); _liquidityPairCreated = true; uint liquidityAmount; // save current amount to be used later to calculate each individual contributors share of project tokens _amountForProjTokenCalc = _tokensForLiquidity; if(address(0) == i._fundingToken) { liquidityAmount = _createLiquidityPairETH(); } else { liquidityAmount = _createLiquidityPairERC20(); } _totalLPTokens = liquidityAmount; _availLPTokens = liquidityAmount; _liquidityPairAddress = _getLiquidityPairAddress(); emit liquidityPairCreated(_liquidityPairAddress, addressOfDex(), liquidityAmount); iXstarterProposal(_proposalAddr).setTokenAndLPAddr(_projectToken, _liquidityPairAddress); iXstarterProposal(_proposalAddr).setStatus(5); return true; } event ILOFinalized(address caller_); // step 7 function finalizeILO() external returns(bool success) { require(_liquidityPairCreated, "liquidity pair must be created first"); // set liquidity pair address success = _setTimeLocks(); emit ILOFinalized(_msgSender()); iXstarterProposal(_proposalAddr).setStatus(6); } event WithdrawnProjectToken(address indexed funder_, uint indexed amount_); function withdraw() external allowedToWithdraw returns(bool success) { _disallowWithdraw(); require(!isContribTokenLocked(), "withdrawal locked"); require(!_projTokensWithdrawn[_msgSender()], "project tokens already withdrawn"); uint amount_ = projectTokenBalanceOfFunder(_msgSender()); _projTokensWithdrawn[_msgSender()] = true; // FunderInfo storage funder = _funders[_msgSender()]; // require(funder.fundingTokenAmount > 0, "Did Not Contribute"); require(amount_ > 0, 'amount must be greater than 0'); //funder.projectTokenAmount = funder.projectTokenAmount.sub(amount_); // success = IERC20Custom(_projectToken).approve(_msgSender(), amount_); success = IERC20Custom(_projectToken).transfer(_msgSender(), amount_); _tokensHeld = _tokensHeld.sub(amount_); _allowWithdraw(); emit WithdrawnProjectToken(_msgSender(), amount_); } // todo: verify the balance is right function _getProjTknBal(address funder_) internal view returns(uint balance) { if(_projTokensWithdrawn[funder_] == true) { return 0; } uint tokensForContributors = _totalTokensILO - _amountForProjTokenCalc; balance = _getProportionAmt(tokensForContributors, _fundingTokenTotal, _funders[funder_].fundingTokenAmount); // avoid solidity rounding fractions to 0 // if(tokensForContributors > i._fundingTokenTotal) { // amtPer = tokensForContributors / i._fundingTokenTotal; // balance = _funders[funder_].fundingTokenAmount * amtPer; // }else { // amtPer = i._fundingTokenTotal / tokensForContributors; // balance = _funders[funder_].fundingTokenAmount / amtPer; // } // uint amtPer = i._fundingTokenTotal.div(10 ** 18); // lpPer * fundingTokenAmount to get lp tokens to send } function _getLiqTknBal(address funder_) internal view returns(uint balance) { if(_liqTokensWithdrawn[funder_] == true) { return 0; } balance = _getProportionAmt(_totalLPTokens, _fundingTokenTotal, _funders[funder_].fundingTokenAmount); // uint amtPer; // // avoid solidity rounding fractions to 0 // if(_totalLPTokens > i._fundingTokenTotal) { // amtPer = _totalLPTokens / i._fundingTokenTotal; // balance = _funders[funder_].fundingTokenAmount * amtPer; // }else { // amtPer = i._fundingTokenTotal / _totalLPTokens; // balance = _funders[funder_].fundingTokenAmount / amtPer; // } } function _getProportionAmt(uint totalRewardTokens, uint totalFundingTokens, uint funderFundingAmount) internal pure returns (uint proportionalRewardTokens) { // assumes each both tokens a decimals = 18, while precision is lost, reducing this blunts the loss of precision uint reducedTotalFundingTokens = totalFundingTokens / (10 ** 12); uint reducedFunderFundingAmount = funderFundingAmount / (10 ** 12); uint amtPer = totalRewardTokens / reducedTotalFundingTokens; proportionalRewardTokens = amtPer * reducedFunderFundingAmount; } event FundingTokenForTeamWithdrawn(address indexed admin_, uint indexed amount_, uint indexed percentTokensForTeam_, uint totalFundingTokens_ ); function withdrawFundingToken() external onlyAdmin returns(bool success) { require(_fundingTokenForTeam > 0, 'no balance'); uint amount_ = _fundingTokenForTeam; _fundingTokenForTeam = 0; if(i._fundingToken == address(0)) { // send native token to funder (success, ) = _msgSender().call{value: amount_}(''); }else { // or if funding token wasn't native, send ERC20 token success = IERC20Custom(i._fundingToken).transfer(_msgSender(), amount_); } emit FundingTokenForTeamWithdrawn(_msgSender(), amount_, i._percentTokensForTeam, _fundingTokenTotal); } event WithdrawnOnFailure(address indexed funder_, address indexed TokenAddr_, uint indexed amount_, bool isAdmin); function withdrawOnFailure() external allowedToWithdraw returns(bool success) { require(ILOFailed(), "ILO not failed"); _disallowWithdraw(); if(_msgSender() == _admin) { // if admin withdraw all project tokens require(_adminBalance != 0, "already withdrawn"); _adminBalance = 0; uint amount_ = _tokensHeld; _tokensHeld = 0; success = IERC20Custom(_projectToken).transfer(_msgSender(), amount_); emit WithdrawnOnFailure(_msgSender(), _projectToken, amount_, true); }else{ // if not admin send back funding token (nativ token like eth or ERC20 token) FunderInfo storage funder = _funders[_msgSender()]; uint amount_ = funder.fundingTokenAmount; require(amount_ > 0, "no balance"); // uint amount2_ = funder.projectTokenAmount; funder.fundingTokenAmount = 0; funder.projectTokenAmount = 0; _fundingTokenAvail = _fundingTokenAvail.sub(amount_); if(i._fundingToken == address(0)) { // send native token to funder (success, ) = _msgSender().call{value: amount_}(''); emit WithdrawnOnFailure(_msgSender(), address(0), amount_, false); }else { // or if funding token wasn't native, send ERC20 token success = IERC20Custom(i._fundingToken).transfer(_msgSender(), amount_); emit WithdrawnOnFailure(_msgSender(), i._fundingToken, amount_, false); } } _allowWithdraw(); } event WithdrawnLiquidityToken(address funder_, uint amount_); // withraws all the liquidity token of the user function withdrawLiquidityTokens() external allowedToWithdraw returns(bool success) { require(!isLiqTokenLocked(), "withdrawal locked "); _disallowWithdraw(); require(!_liqTokensWithdrawn[_msgSender()], "No tokens"); uint LPAmount_ = _getLiqTknBal(_msgSender()); _liqTokensWithdrawn[_msgSender()] = true; require(LPAmount_ > 0 && LPAmount_ <= _availLPTokens, "not enough lp tokens"); _availLPTokens = _availLPTokens.sub(LPAmount_); success = IERC20Uni(_liquidityPairAddress).transfer(_msgSender(), LPAmount_); _allowWithdraw(); emit WithdrawnLiquidityToken(_msgSender(), LPAmount_); } function withdrawAdmin() external onlyAdmin returns (bool success) { require(!isProjTokenLocked(), "withdrawal locked"); _disallowWithdraw(); // admin uint amount_ = _adminBalance; _adminBalance = 0; _tokensHeld = _tokensHeld.sub(amount_); success = IERC20Custom(_projectToken).transfer(_admin, amount_); _allowWithdraw(); } function _getLiquidityPairAddress() internal view returns(address liquidPair_) { if(address(0) == i._fundingToken) { address WETH_ = IUniswapRouter(i._addressOfDex).WETH(); liquidPair_ = IUniswapFactory(i._addressOfDexFactory).getPair(WETH_, _projectToken); require(address(0) != liquidPair_, "Liquidity Pair Should Be Created But Hasn't"); } else { liquidPair_ = IUniswapFactory(i._addressOfDexFactory).getPair(i._fundingToken, _projectToken); require(address(0) != liquidPair_, "Liquidity Pair Should Be Created But Not Created"); } } event TimeLockSet(uint indexed projTokenLock_, uint indexed contribTokenLock_, uint indexed liquidityTokenLock_); function _setTimeLocks() internal returns(bool) { require(!isTimeLockSet(), "Time lock already set"); uint timeLockLengthX2 = i._contribTimeLock * 2; // if timelock greater than 60 days in seconds, set to length of contributor timelock + 30 days uint timeLen = timeLockLengthX2 > 5184000 ? i._contribTimeLock + 2592000 : timeLockLengthX2; _projTimeLock = block.timestamp + timeLen; _projBlockLock = block.number + uint(timeLen / MINE_LEN); _contribTimeStampLock = block.timestamp + i._contribTimeLock; _contribBlockLock = block.number + uint(i._contribTimeLock / MINE_LEN); _liqPairTimeLock = block.timestamp + i._liqPairLockLen; _liqPairBlockLock = block.number + uint(i._liqPairLockLen / MINE_LEN); emit TimeLockSet(_projBlockLock, _contribBlockLock, _liqPairBlockLock); return true; } // this can be called by anyone. but should be called AFTER the ILO // on xDai chain ETH would be xDai, on BSC it would be BNB // step 6a function _createLiquidityPairETH() internal returns(uint liquidityTokens_) { //require(address(0) == i._fundingToken, "xStarterPair: FundingTokenError"); uint amountETH = _fundingTokenAvail; uint amountProjectToken = _tokensForLiquidity; // approve project token to be sent to dex. Spender is dex IUniswapRouter address (honeyswap, uniswap etc) //bool approved_ = _callApproveOnProjectToken(i._addressOfDex, amountProjectToken); (uint amountTokenInPool, uint amountETHInPool, uint amountliquidityToken) = IUniswapRouter(i._addressOfDex).addLiquidityETH{value: amountETH}( _projectToken, amountProjectToken, amountProjectToken, amountETH, address(this), block.timestamp + i._dexDeadlineLength ); liquidityTokens_ = amountliquidityToken; _fundingTokenAvail = 0; // subtract amount sent to liquidity pool from this _tokensHeld = _tokensHeld.sub(amountProjectToken); _tokensForLiquidity = 0; } // step 6b function _createLiquidityPairERC20() internal returns(uint liquidityTokens_) { require(address(0) != i._fundingToken, "xStarterPair: FundingTokenError"); //require(_approvedForLP, "xStarterPair: TokenApprovalFail, call syncBalances before calling again"); uint amountERC20 = _fundingTokenAvail; uint amountProjectToken = _tokensForLiquidity; // approve project token to be sent to dex. Spender is dex IUniswapRouter address (honeyswap, uniswap etc) // bool approvedA_ = _callApproveOnProjectToken(i._addressOfDex, amountProjectToken); // bool approvedB_ = _callApproveOnFundingToken(i._addressOfDex, amountERC20); //require(approvedA_ && approvedB_, "xStarterPair: TokenApprovalFail, call syncBalances before calling again"); (uint amountTokenInPool, uint amountETHInPool, uint amountliquidityToken) = IUniswapRouter(i._addressOfDex).addLiquidity( _projectToken, i._fundingToken, amountProjectToken, amountERC20, amountProjectToken, amountERC20, address(this), block.timestamp + i._dexDeadlineLength ); _fundingTokenAvail = 0; // subtract amount sent to liquidity pool from this _tokensHeld = _tokensHeld.sub(amountProjectToken); _tokensForLiquidity = 0; liquidityTokens_ = amountliquidityToken; } function _callApproveOnProjectToken(address spender_, uint amount_) internal returns(bool success) { success = IERC20(_projectToken).approve(spender_, amount_); } function _callApproveOnFundingToken(address spender_, uint amount_) internal returns(bool success) { success = IERC20(i._fundingToken).approve(spender_, amount_); } // IERC777Recipient implementation function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external view override{ // this contract should receive token using approve on ERC20/ and then fundingTokenSwap function on this contract require(from == address(this), "approve then call fundingTokenSwap"); } // IERC777Sender implementation called before tokenis function tokensToSend( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external view override { require(from == address(this), "approve then call fundingTokenSwap"); } }
ProjectBaseToken newToken = new ProjectBaseToken(name_,symbol_, totalTokenSupply_, address(this), defaultOperators_);
) external onlyAllowedCaller returns(address ercToken){ ercToken = address(new ProjectBaseTokenERC20(name_,symbol_, totalTokenSupply_, msg.sender)); }
15,816,716
[ 1, 4625, 348, 7953, 560, 30, 5420, 2171, 1345, 394, 1345, 273, 394, 5420, 2171, 1345, 12, 529, 67, 16, 7175, 67, 16, 2078, 1345, 3088, 1283, 67, 16, 1758, 12, 2211, 3631, 805, 24473, 67, 1769, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 262, 3903, 1338, 5042, 11095, 1135, 12, 2867, 6445, 71, 1345, 15329, 203, 4202, 6445, 71, 1345, 273, 1758, 12, 2704, 5420, 2171, 1345, 654, 39, 3462, 12, 529, 67, 16, 7175, 67, 16, 2078, 1345, 3088, 1283, 67, 16, 1234, 18, 15330, 10019, 203, 565, 289, 203, 377, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0xBCF85224fc0756B9Fa45aA7892530B47e10b6433/sources/src/v0.8/dev/CrossDomainOwnable.sol
* @notice validate, transfer ownership, and emit relevant events/
function _transferL1Ownership(address to) internal { require(to != msg.sender, "Cannot transfer to self"); s_l1PendingOwner = to; emit L1OwnershipTransferRequested(s_l1Owner, to); }
4,175,973
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 1954, 16, 7412, 23178, 16, 471, 3626, 9368, 2641, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 389, 13866, 48, 21, 5460, 12565, 12, 2867, 358, 13, 2713, 288, 203, 565, 2583, 12, 869, 480, 1234, 18, 15330, 16, 315, 4515, 7412, 358, 365, 8863, 203, 203, 565, 272, 67, 80, 21, 8579, 5541, 273, 358, 31, 203, 203, 565, 3626, 511, 21, 5460, 12565, 5912, 11244, 12, 87, 67, 80, 21, 5541, 16, 358, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/4/0x6D0d4c58450e6489e5B911dEDA8A235C3d9B6aAC/sources/HelloWorld2.sol
Accepts a string argument `initMessage` and sets the value into the contract's `message` storage variable).
constructor(string memory _initMessage) public { message = _initMessage; }
8,694,024
[ 1, 4625, 348, 7953, 560, 30, 225, 27158, 279, 533, 1237, 1375, 2738, 1079, 68, 471, 1678, 326, 460, 1368, 326, 6835, 1807, 1375, 2150, 68, 2502, 2190, 2934, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 3885, 12, 1080, 3778, 389, 2738, 1079, 13, 1071, 288, 203, 3639, 883, 273, 389, 2738, 1079, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.0; // Contract used to answer https://ethereum.stackexchange.com/questions/42207/solidity-deleting-a-struct-from-a-storage-array contract Lockers { struct Locker { uint creationTime; uint holdTime; uint balance; } mapping (address => Locker[]) lockersByAddress; event Withdrawal(address sender, uint balance); function store(uint holdTime) external payable { Locker memory locker = Locker(now, holdTime, msg.value); lockersByAddress[msg.sender].push(locker); } // Original function function withdrawAll() public { Locker[] storage lockers = lockersByAddress[msg.sender]; for (uint i = 0; i < lockers.length; i++) { if (lockers[i].creationTime + lockers[i].holdTime < now) { msg.sender.transfer(lockers[i].balance); Withdrawal(msg.sender, lockers[i].balance); delete lockers[i]; } } } // Modified function that demonstrates how to clear an array // Note: withdrawAll is a misnomer and no effort was made to deal with demonstrating how to deal with the edge case of a "locker" not being able to be deleted. function withdrawAll2() public { Locker[] memory memLockers = lockersByAddress[msg.sender]; // Avoid any re-entrancy issues delete lockersByAddress[msg.sender]; for (uint i = 0; i < memLockers.length; i++) { if (memLockers[i].creationTime + memLockers[i].holdTime < now) { msg.sender.transfer(memLockers[i].balance); Withdrawal(msg.sender, memLockers[i].balance); } } } function getNumLockers(address owner) external view returns(uint) { return lockersByAddress[owner].length; } function getLockerDetails(address owner, uint index) external view returns(uint creationTime, uint holdTime, uint balance) { Locker memory locker = lockersByAddress[owner][index]; creationTime = locker.creationTime; holdTime = locker.holdTime; balance = locker.balance; } }
Contract used to answer https:ethereum.stackexchange.com/questions/42207/solidity-deleting-a-struct-from-a-storage-array
contract Lockers { struct Locker { uint creationTime; uint holdTime; uint balance; } mapping (address => Locker[]) lockersByAddress; event Withdrawal(address sender, uint balance); function store(uint holdTime) external payable { Locker memory locker = Locker(now, holdTime, msg.value); lockersByAddress[msg.sender].push(locker); } function withdrawAll() public { Locker[] storage lockers = lockersByAddress[msg.sender]; for (uint i = 0; i < lockers.length; i++) { if (lockers[i].creationTime + lockers[i].holdTime < now) { msg.sender.transfer(lockers[i].balance); Withdrawal(msg.sender, lockers[i].balance); delete lockers[i]; } } } function withdrawAll() public { Locker[] storage lockers = lockersByAddress[msg.sender]; for (uint i = 0; i < lockers.length; i++) { if (lockers[i].creationTime + lockers[i].holdTime < now) { msg.sender.transfer(lockers[i].balance); Withdrawal(msg.sender, lockers[i].balance); delete lockers[i]; } } } function withdrawAll() public { Locker[] storage lockers = lockersByAddress[msg.sender]; for (uint i = 0; i < lockers.length; i++) { if (lockers[i].creationTime + lockers[i].holdTime < now) { msg.sender.transfer(lockers[i].balance); Withdrawal(msg.sender, lockers[i].balance); delete lockers[i]; } } } function withdrawAll2() public { Locker[] memory memLockers = lockersByAddress[msg.sender]; delete lockersByAddress[msg.sender]; for (uint i = 0; i < memLockers.length; i++) { if (memLockers[i].creationTime + memLockers[i].holdTime < now) { msg.sender.transfer(memLockers[i].balance); Withdrawal(msg.sender, memLockers[i].balance); } } } function withdrawAll2() public { Locker[] memory memLockers = lockersByAddress[msg.sender]; delete lockersByAddress[msg.sender]; for (uint i = 0; i < memLockers.length; i++) { if (memLockers[i].creationTime + memLockers[i].holdTime < now) { msg.sender.transfer(memLockers[i].balance); Withdrawal(msg.sender, memLockers[i].balance); } } } function withdrawAll2() public { Locker[] memory memLockers = lockersByAddress[msg.sender]; delete lockersByAddress[msg.sender]; for (uint i = 0; i < memLockers.length; i++) { if (memLockers[i].creationTime + memLockers[i].holdTime < now) { msg.sender.transfer(memLockers[i].balance); Withdrawal(msg.sender, memLockers[i].balance); } } } function getNumLockers(address owner) external view returns(uint) { return lockersByAddress[owner].length; } function getLockerDetails(address owner, uint index) external view returns(uint creationTime, uint holdTime, uint balance) { Locker memory locker = lockersByAddress[owner][index]; creationTime = locker.creationTime; holdTime = locker.holdTime; balance = locker.balance; } }
12,687,130
[ 1, 4625, 348, 7953, 560, 30, 225, 13456, 1399, 358, 5803, 2333, 30, 546, 822, 379, 18, 3772, 16641, 18, 832, 19, 9758, 19, 9452, 3462, 27, 19, 30205, 560, 17, 19003, 310, 17, 69, 17, 1697, 17, 2080, 17, 69, 17, 5697, 17, 1126, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 3488, 414, 288, 203, 565, 1958, 3488, 264, 288, 203, 3639, 2254, 6710, 950, 31, 203, 3639, 2254, 6887, 950, 31, 203, 3639, 2254, 11013, 31, 203, 565, 289, 203, 203, 565, 2874, 261, 2867, 516, 3488, 264, 63, 5717, 2176, 414, 858, 1887, 31, 203, 203, 565, 871, 3423, 9446, 287, 12, 2867, 5793, 16, 2254, 11013, 1769, 203, 203, 565, 445, 1707, 12, 11890, 6887, 950, 13, 3903, 8843, 429, 288, 203, 3639, 3488, 264, 3778, 28152, 273, 3488, 264, 12, 3338, 16, 6887, 950, 16, 1234, 18, 1132, 1769, 203, 3639, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 8009, 6206, 12, 739, 264, 1769, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 2502, 2176, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 2176, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 739, 414, 63, 77, 8009, 17169, 950, 397, 2176, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 739, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 2176, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 1430, 2176, 414, 63, 77, 15533, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 2502, 2176, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 2176, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 739, 414, 63, 77, 8009, 17169, 950, 397, 2176, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 739, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 2176, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 1430, 2176, 414, 63, 77, 15533, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 2502, 2176, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 2176, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 739, 414, 63, 77, 8009, 17169, 950, 397, 2176, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 739, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 2176, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 1430, 2176, 414, 63, 77, 15533, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 22, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 3778, 1663, 2531, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 1430, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 1663, 2531, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 3917, 2531, 414, 63, 77, 8009, 17169, 950, 397, 1663, 2531, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 3917, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 1663, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 22, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 3778, 1663, 2531, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 1430, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 1663, 2531, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 3917, 2531, 414, 63, 77, 8009, 17169, 950, 397, 1663, 2531, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 3917, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 1663, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1595, 22, 1435, 1071, 288, 203, 3639, 3488, 264, 8526, 3778, 1663, 2531, 414, 273, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 1430, 2176, 414, 858, 1887, 63, 3576, 18, 15330, 15533, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 1663, 2531, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 3917, 2531, 414, 63, 77, 8009, 17169, 950, 397, 1663, 2531, 414, 63, 77, 8009, 21056, 950, 411, 2037, 13, 288, 203, 7734, 1234, 18, 15330, 18, 13866, 12, 3917, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 7734, 3423, 9446, 287, 12, 3576, 18, 15330, 16, 1663, 2531, 414, 63, 77, 8009, 12296, 1769, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 11187, 2531, 414, 12, 2867, 3410, 13, 3903, 1476, 1135, 12, 11890, 13, 288, 203, 3639, 327, 2176, 414, 858, 1887, 63, 8443, 8009, 2469, 31, 203, 565, 289, 203, 203, 565, 445, 22206, 264, 3790, 12, 2867, 3410, 16, 2254, 770, 13, 3903, 1476, 1135, 12, 11890, 6710, 950, 16, 2254, 6887, 950, 16, 2254, 11013, 13, 288, 203, 3639, 3488, 264, 3778, 28152, 273, 2176, 414, 858, 1887, 63, 8443, 6362, 1615, 15533, 203, 3639, 6710, 950, 273, 28152, 18, 17169, 950, 31, 203, 3639, 6887, 950, 273, 28152, 18, 21056, 950, 31, 203, 3639, 11013, 273, 28152, 18, 12296, 31, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x51C22c78d753939C8AEbAe437c2f18EEE43CA296/sources/PrivateSale.sol
Variables Modifiers
contract Ownable { address public owner; address public newOwner; modifier onlyOwner() { require(msg.sender == owner); _; } function Ownable() public { owner = msg.sender; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } }
4,013,454
[ 1, 4625, 348, 7953, 560, 30, 23536, 565, 3431, 3383, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 14223, 6914, 288, 203, 203, 565, 1758, 1071, 3410, 31, 203, 203, 565, 1758, 1071, 394, 5541, 31, 203, 203, 565, 9606, 1338, 5541, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 3410, 1769, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 445, 14223, 6914, 1435, 1071, 288, 203, 3639, 3410, 273, 1234, 18, 15330, 31, 203, 565, 289, 203, 203, 203, 565, 445, 7412, 5460, 12565, 12, 2867, 389, 2704, 5541, 13, 1071, 1338, 5541, 288, 203, 3639, 2583, 24899, 2704, 5541, 480, 1758, 12, 20, 10019, 203, 3639, 394, 5541, 273, 389, 2704, 5541, 31, 203, 565, 289, 203, 203, 565, 445, 2791, 5460, 12565, 1435, 1071, 288, 203, 3639, 309, 261, 3576, 18, 15330, 422, 394, 5541, 13, 288, 203, 5411, 3410, 273, 394, 5541, 31, 203, 3639, 289, 203, 565, 289, 203, 565, 445, 2791, 5460, 12565, 1435, 1071, 288, 203, 3639, 309, 261, 3576, 18, 15330, 422, 394, 5541, 13, 288, 203, 5411, 3410, 273, 394, 5541, 31, 203, 3639, 289, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/3/0xcD1049D51adB3187FB9cc9f786cab99F57eCa4D1/sources/HoprToken.sol
* @dev `_valueAt` retrieves the number of tokens at a given block number @param snapshots The history of values being queried @param _block The block number to retrieve the value at @return The number of tokens being queried/ Shortcut for the actual value
function _valueAt( Snapshot[] storage snapshots, uint128 _block ) view internal returns (uint256) { if (snapshots.length == 0) return 0; if (_block >= snapshots[snapshots.length - 1].fromBlock) { return snapshots[snapshots.length - 1].value; } if (_block < snapshots[0].fromBlock) { return 0; } uint256 max = snapshots.length - 1; while (max > min) { uint256 mid = (max + min + 1) / 2; if (snapshots[mid].fromBlock <= _block) { min = mid; max = mid - 1; } } return snapshots[min].value; }
5,208,693
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 1375, 67, 1132, 861, 68, 9023, 326, 1300, 434, 2430, 622, 279, 864, 1203, 1300, 632, 891, 12808, 1021, 4927, 434, 924, 3832, 23264, 632, 891, 389, 2629, 1021, 1203, 1300, 358, 4614, 326, 460, 622, 632, 2463, 1021, 1300, 434, 2430, 3832, 23264, 19, 7925, 5150, 364, 326, 3214, 460, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 1132, 861, 12, 203, 3639, 10030, 8526, 2502, 12808, 16, 203, 3639, 2254, 10392, 389, 2629, 203, 565, 262, 1476, 2713, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 309, 261, 26918, 18, 2469, 422, 374, 13, 327, 374, 31, 203, 203, 3639, 309, 261, 67, 2629, 1545, 12808, 63, 26918, 18, 2469, 300, 404, 8009, 2080, 1768, 13, 288, 203, 5411, 327, 12808, 63, 26918, 18, 2469, 300, 404, 8009, 1132, 31, 203, 3639, 289, 203, 3639, 309, 261, 67, 2629, 411, 12808, 63, 20, 8009, 2080, 1768, 13, 288, 203, 5411, 327, 374, 31, 203, 3639, 289, 203, 203, 3639, 2254, 5034, 943, 273, 12808, 18, 2469, 300, 404, 31, 203, 3639, 1323, 261, 1896, 405, 1131, 13, 288, 203, 5411, 2254, 5034, 7501, 273, 261, 1896, 397, 1131, 397, 404, 13, 342, 576, 31, 203, 5411, 309, 261, 26918, 63, 13138, 8009, 2080, 1768, 1648, 389, 2629, 13, 288, 203, 7734, 1131, 273, 7501, 31, 203, 7734, 943, 273, 7501, 300, 404, 31, 203, 5411, 289, 203, 3639, 289, 203, 3639, 327, 12808, 63, 1154, 8009, 1132, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x4b441133e357512E4D970a6fAfcEc77C3f38c590/sources/InstallmentsModel.sol
Now its always greater than config.lentTime
_advanceClock(id, uint64(now) - config.lentTime);
4,187,439
[ 1, 4625, 348, 7953, 560, 30, 225, 4494, 2097, 3712, 6802, 2353, 642, 18, 80, 319, 950, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 389, 361, 5882, 14027, 12, 350, 16, 2254, 1105, 12, 3338, 13, 300, 642, 18, 80, 319, 950, 1769, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/420/0x502FCd72ABEeA838153CD0f51A16ba0238D94645/sources/contracts/CryptoCare.sol
FUNCTION SET n UNSET ADMIN (SUPER ADMIN)
function setToAdmin(address _user) internal onlySuperAdmin{ admin[_user] = true; }
13,226,576
[ 1, 4625, 348, 7953, 560, 30, 225, 13690, 7855, 290, 5019, 4043, 25969, 261, 13272, 654, 25969, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// File: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: solidity/contracts/converter/ConverterVersion.sol pragma solidity 0.6.12; contract ConverterVersion { uint16 public constant version = 46; } // File: solidity/contracts/utility/interfaces/IOwned.sol pragma solidity 0.6.12; /* Owned contract interface */ interface IOwned { // this function isn't since the compiler emits automatically generated getter functions as external function owner() external view returns (address); function transferOwnership(address _newOwner) external; function acceptOwnership() external; } // File: solidity/contracts/converter/interfaces/IConverterAnchor.sol pragma solidity 0.6.12; /* Converter Anchor interface */ interface IConverterAnchor is IOwned { } // File: solidity/contracts/converter/interfaces/IConverter.sol pragma solidity 0.6.12; /* Converter interface */ interface IConverter is IOwned { function converterType() external pure returns (uint16); function anchor() external view returns (IConverterAnchor); function isActive() external view returns (bool); function targetAmountAndFee( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount ) external view returns (uint256, uint256); function convert( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount, address _trader, address payable _beneficiary ) external payable returns (uint256); function conversionFee() external view returns (uint32); function maxConversionFee() external view returns (uint32); function reserveBalance(IERC20 _reserveToken) external view returns (uint256); receive() external payable; function transferAnchorOwnership(address _newOwner) external; function acceptAnchorOwnership() external; function setConversionFee(uint32 _conversionFee) external; function addReserve(IERC20 _token, uint32 _weight) external; function transferReservesOnUpgrade(address _newConverter) external; function onUpgradeComplete() external; // deprecated, backward compatibility function token() external view returns (IConverterAnchor); function transferTokenOwnership(address _newOwner) external; function acceptTokenOwnership() external; function connectors(IERC20 _address) external view returns ( uint256, uint32, bool, bool, bool ); function getConnectorBalance(IERC20 _connectorToken) external view returns (uint256); function connectorTokens(uint256 _index) external view returns (IERC20); function connectorTokenCount() external view returns (uint16); /** * @dev triggered when the converter is activated * * @param _type converter type * @param _anchor converter anchor * @param _activated true if the converter was activated, false if it was deactivated */ event Activation(uint16 indexed _type, IConverterAnchor indexed _anchor, bool indexed _activated); /** * @dev triggered when a conversion between two tokens occurs * * @param _fromToken source ERC20 token * @param _toToken target ERC20 token * @param _trader wallet that initiated the trade * @param _amount input amount in units of the source token * @param _return output amount minus conversion fee in units of the target token * @param _conversionFee conversion fee in units of the target token */ event Conversion( IERC20 indexed _fromToken, IERC20 indexed _toToken, address indexed _trader, uint256 _amount, uint256 _return, int256 _conversionFee ); /** * @dev triggered when the rate between two tokens in the converter changes * note that the event might be dispatched for rate updates between any two tokens in the converter * * @param _token1 address of the first token * @param _token2 address of the second token * @param _rateN rate of 1 unit of `_token1` in `_token2` (numerator) * @param _rateD rate of 1 unit of `_token1` in `_token2` (denominator) */ event TokenRateUpdate(IERC20 indexed _token1, IERC20 indexed _token2, uint256 _rateN, uint256 _rateD); /** * @dev triggered when the conversion fee is updated * * @param _prevFee previous fee percentage, represented in ppm * @param _newFee new fee percentage, represented in ppm */ event ConversionFeeUpdate(uint32 _prevFee, uint32 _newFee); } // File: solidity/contracts/converter/interfaces/IConverterUpgrader.sol pragma solidity 0.6.12; /* Converter Upgrader interface */ interface IConverterUpgrader { function upgrade(bytes32 _version) external; function upgrade(uint16 _version) external; } // File: solidity/contracts/utility/interfaces/ITokenHolder.sol pragma solidity 0.6.12; /* Token Holder interface */ interface ITokenHolder is IOwned { receive() external payable; function withdrawTokens( IERC20 token, address payable to, uint256 amount ) external; function withdrawTokensMultiple( IERC20[] calldata tokens, address payable to, uint256[] calldata amounts ) external; } // File: solidity/contracts/INetworkSettings.sol pragma solidity 0.6.12; interface INetworkSettings { function networkFeeParams() external view returns (ITokenHolder, uint32); function networkFeeWallet() external view returns (ITokenHolder); function networkFee() external view returns (uint32); } // File: solidity/contracts/token/interfaces/IDSToken.sol pragma solidity 0.6.12; /* DSToken interface */ interface IDSToken is IConverterAnchor, IERC20 { function issue(address _to, uint256 _amount) external; function destroy(address _from, uint256 _amount) external; } // File: solidity/contracts/utility/MathEx.sol pragma solidity 0.6.12; /** * @dev This library provides a set of complex math operations. */ library MathEx { uint256 private constant MAX_EXP_BIT_LEN = 4; uint256 private constant MAX_EXP = 2**MAX_EXP_BIT_LEN - 1; uint256 private constant MAX_UINT128 = 2**128 - 1; /** * @dev returns the largest integer smaller than or equal to the square root of a positive integer * * @param _num a positive integer * * @return the largest integer smaller than or equal to the square root of the positive integer */ function floorSqrt(uint256 _num) internal pure returns (uint256) { uint256 x = _num / 2 + 1; uint256 y = (x + _num / x) / 2; while (x > y) { x = y; y = (x + _num / x) / 2; } return x; } /** * @dev returns the smallest integer larger than or equal to the square root of a positive integer * * @param _num a positive integer * * @return the smallest integer larger than or equal to the square root of the positive integer */ function ceilSqrt(uint256 _num) internal pure returns (uint256) { uint256 x = floorSqrt(_num); return x * x == _num ? x : x + 1; } /** * @dev computes a powered ratio * * @param _n ratio numerator * @param _d ratio denominator * @param _exp ratio exponent * * @return powered ratio's numerator and denominator */ function poweredRatio( uint256 _n, uint256 _d, uint256 _exp ) internal pure returns (uint256, uint256) { require(_exp <= MAX_EXP, "ERR_EXP_TOO_LARGE"); uint256[MAX_EXP_BIT_LEN] memory ns; uint256[MAX_EXP_BIT_LEN] memory ds; (ns[0], ds[0]) = reducedRatio(_n, _d, MAX_UINT128); for (uint256 i = 0; (_exp >> i) > 1; i++) { (ns[i + 1], ds[i + 1]) = reducedRatio(ns[i] ** 2, ds[i] ** 2, MAX_UINT128); } uint256 n = 1; uint256 d = 1; for (uint256 i = 0; (_exp >> i) > 0; i++) { if (((_exp >> i) & 1) > 0) { (n, d) = reducedRatio(n * ns[i], d * ds[i], MAX_UINT128); } } return (n, d); } /** * @dev computes a reduced-scalar ratio * * @param _n ratio numerator * @param _d ratio denominator * @param _max maximum desired scalar * * @return ratio's numerator and denominator */ function reducedRatio( uint256 _n, uint256 _d, uint256 _max ) internal pure returns (uint256, uint256) { (uint256 n, uint256 d) = (_n, _d); if (n > _max || d > _max) { (n, d) = normalizedRatio(n, d, _max); } if (n != d) { return (n, d); } return (1, 1); } /** * @dev computes "scale * a / (a + b)" and "scale * b / (a + b)". */ function normalizedRatio( uint256 _a, uint256 _b, uint256 _scale ) internal pure returns (uint256, uint256) { if (_a <= _b) { return accurateRatio(_a, _b, _scale); } (uint256 y, uint256 x) = accurateRatio(_b, _a, _scale); return (x, y); } /** * @dev computes "scale * a / (a + b)" and "scale * b / (a + b)", assuming that "a <= b". */ function accurateRatio( uint256 _a, uint256 _b, uint256 _scale ) internal pure returns (uint256, uint256) { uint256 maxVal = uint256(-1) / _scale; if (_a > maxVal) { uint256 c = _a / (maxVal + 1) + 1; _a /= c; // we can now safely compute `_a * _scale` _b /= c; } if (_a != _b) { uint256 n = _a * _scale; uint256 d = _a + _b; // can overflow if (d >= _a) { // no overflow in `_a + _b` uint256 x = roundDiv(n, d); // we can now safely compute `_scale - x` uint256 y = _scale - x; return (x, y); } if (n < _b - (_b - _a) / 2) { return (0, _scale); // `_a * _scale < (_a + _b) / 2 < MAX_UINT256 < _a + _b` } return (1, _scale - 1); // `(_a + _b) / 2 < _a * _scale < MAX_UINT256 < _a + _b` } return (_scale / 2, _scale / 2); // allow reduction to `(1, 1)` in the calling function } /** * @dev computes the nearest integer to a given quotient without overflowing or underflowing. */ function roundDiv(uint256 _n, uint256 _d) internal pure returns (uint256) { return _n / _d + (_n % _d) / (_d - _d / 2); } /** * @dev returns the average number of decimal digits in a given list of positive integers * * @param _values list of positive integers * * @return the average number of decimal digits in the given list of positive integers */ function geometricMean(uint256[] memory _values) internal pure returns (uint256) { uint256 numOfDigits = 0; uint256 length = _values.length; for (uint256 i = 0; i < length; i++) { numOfDigits += decimalLength(_values[i]); } return uint256(10)**(roundDivUnsafe(numOfDigits, length) - 1); } /** * @dev returns the number of decimal digits in a given positive integer * * @param _x positive integer * * @return the number of decimal digits in the given positive integer */ function decimalLength(uint256 _x) internal pure returns (uint256) { uint256 y = 0; for (uint256 x = _x; x > 0; x /= 10) { y++; } return y; } /** * @dev returns the nearest integer to a given quotient * the computation is overflow-safe assuming that the input is sufficiently small * * @param _n quotient numerator * @param _d quotient denominator * * @return the nearest integer to the given quotient */ function roundDivUnsafe(uint256 _n, uint256 _d) internal pure returns (uint256) { return (_n + _d / 2) / _d; } /** * @dev returns the larger of two values * * @param _val1 the first value * @param _val2 the second value */ function max(uint256 _val1, uint256 _val2) internal pure returns (uint256) { return _val1 > _val2 ? _val1 : _val2; } } // File: solidity/contracts/utility/Owned.sol pragma solidity 0.6.12; /** * @dev This contract provides support and utilities for contract ownership. */ contract Owned is IOwned { address public override owner; address public newOwner; /** * @dev triggered when the owner is updated * * @param _prevOwner previous owner * @param _newOwner new owner */ event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner); /** * @dev initializes a new Owned instance */ constructor() public { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { _ownerOnly(); _; } // error message binary size optimization function _ownerOnly() internal view { require(msg.sender == owner, "ERR_ACCESS_DENIED"); } /** * @dev allows transferring the contract ownership * the new owner still needs to accept the transfer * can only be called by the contract owner * * @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public override ownerOnly { require(_newOwner != owner, "ERR_SAME_OWNER"); newOwner = _newOwner; } /** * @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public override { require(msg.sender == newOwner, "ERR_ACCESS_DENIED"); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); } } // File: solidity/contracts/utility/Utils.sol pragma solidity 0.6.12; /** * @dev Utilities & Common Modifiers */ contract Utils { uint32 internal constant PPM_RESOLUTION = 1000000; IERC20 internal constant NATIVE_TOKEN_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); // verifies that a value is greater than zero modifier greaterThanZero(uint256 _value) { _greaterThanZero(_value); _; } // error message binary size optimization function _greaterThanZero(uint256 _value) internal pure { require(_value > 0, "ERR_ZERO_VALUE"); } // validates an address - currently only checks that it isn't null modifier validAddress(address _address) { _validAddress(_address); _; } // error message binary size optimization function _validAddress(address _address) internal pure { require(_address != address(0), "ERR_INVALID_ADDRESS"); } // ensures that the portion is valid modifier validPortion(uint32 _portion) { _validPortion(_portion); _; } // error message binary size optimization function _validPortion(uint32 _portion) internal pure { require(_portion > 0 && _portion <= PPM_RESOLUTION, "ERR_INVALID_PORTION"); } // validates an external address - currently only checks that it isn't null or this modifier validExternalAddress(address _address) { _validExternalAddress(_address); _; } // error message binary size optimization function _validExternalAddress(address _address) internal view { require(_address != address(0) && _address != address(this), "ERR_INVALID_EXTERNAL_ADDRESS"); } // ensures that the fee is valid modifier validFee(uint32 fee) { _validFee(fee); _; } // error message binary size optimization function _validFee(uint32 fee) internal pure { require(fee <= PPM_RESOLUTION, "ERR_INVALID_FEE"); } } // File: solidity/contracts/utility/interfaces/IContractRegistry.sol pragma solidity 0.6.12; /* Contract Registry interface */ interface IContractRegistry { function addressOf(bytes32 _contractName) external view returns (address); } // File: solidity/contracts/utility/ContractRegistryClient.sol pragma solidity 0.6.12; /** * @dev This is the base contract for ContractRegistry clients. */ contract ContractRegistryClient is Owned, Utils { bytes32 internal constant CONTRACT_REGISTRY = "ContractRegistry"; bytes32 internal constant BANCOR_NETWORK = "BancorNetwork"; bytes32 internal constant BANCOR_FORMULA = "BancorFormula"; bytes32 internal constant CONVERTER_FACTORY = "ConverterFactory"; bytes32 internal constant CONVERSION_PATH_FINDER = "ConversionPathFinder"; bytes32 internal constant CONVERTER_UPGRADER = "BancorConverterUpgrader"; bytes32 internal constant CONVERTER_REGISTRY = "BancorConverterRegistry"; bytes32 internal constant CONVERTER_REGISTRY_DATA = "BancorConverterRegistryData"; bytes32 internal constant BNT_TOKEN = "BNTToken"; bytes32 internal constant BANCOR_X = "BancorX"; bytes32 internal constant BANCOR_X_UPGRADER = "BancorXUpgrader"; bytes32 internal constant LIQUIDITY_PROTECTION = "LiquidityProtection"; bytes32 internal constant NETWORK_SETTINGS = "NetworkSettings"; IContractRegistry public registry; // address of the current contract-registry IContractRegistry public prevRegistry; // address of the previous contract-registry bool public onlyOwnerCanUpdateRegistry; // only an owner can update the contract-registry /** * @dev verifies that the caller is mapped to the given contract name * * @param _contractName contract name */ modifier only(bytes32 _contractName) { _only(_contractName); _; } // error message binary size optimization function _only(bytes32 _contractName) internal view { require(msg.sender == addressOf(_contractName), "ERR_ACCESS_DENIED"); } /** * @dev initializes a new ContractRegistryClient instance * * @param _registry address of a contract-registry contract */ constructor(IContractRegistry _registry) internal validAddress(address(_registry)) { registry = IContractRegistry(_registry); prevRegistry = IContractRegistry(_registry); } /** * @dev updates to the new contract-registry */ function updateRegistry() public { // verify that this function is permitted require(msg.sender == owner || !onlyOwnerCanUpdateRegistry, "ERR_ACCESS_DENIED"); // get the new contract-registry IContractRegistry newRegistry = IContractRegistry(addressOf(CONTRACT_REGISTRY)); // verify that the new contract-registry is different and not zero require(newRegistry != registry && address(newRegistry) != address(0), "ERR_INVALID_REGISTRY"); // verify that the new contract-registry is pointing to a non-zero contract-registry require(newRegistry.addressOf(CONTRACT_REGISTRY) != address(0), "ERR_INVALID_REGISTRY"); // save a backup of the current contract-registry before replacing it prevRegistry = registry; // replace the current contract-registry with the new contract-registry registry = newRegistry; } /** * @dev restores the previous contract-registry */ function restoreRegistry() public ownerOnly { // restore the previous contract-registry registry = prevRegistry; } /** * @dev restricts the permission to update the contract-registry * * @param _onlyOwnerCanUpdateRegistry indicates whether or not permission is restricted to owner only */ function restrictRegistryUpdate(bool _onlyOwnerCanUpdateRegistry) public ownerOnly { // change the permission to update the contract-registry onlyOwnerCanUpdateRegistry = _onlyOwnerCanUpdateRegistry; } /** * @dev returns the address associated with the given contract name * * @param _contractName contract name * * @return contract address */ function addressOf(bytes32 _contractName) internal view returns (address) { return registry.addressOf(_contractName); } } // File: solidity/contracts/utility/ReentrancyGuard.sol pragma solidity 0.6.12; /** * @dev This contract provides protection against calling a function * (directly or indirectly) from within itself. */ contract ReentrancyGuard { uint256 private constant UNLOCKED = 1; uint256 private constant LOCKED = 2; // LOCKED while protected code is being executed, UNLOCKED otherwise uint256 private state = UNLOCKED; /** * @dev ensures instantiation only by sub-contracts */ constructor() internal {} // protects a function against reentrancy attacks modifier protected() { _protected(); state = LOCKED; _; state = UNLOCKED; } // error message binary size optimization function _protected() internal view { require(state == UNLOCKED, "ERR_REENTRANCY"); } } // File: solidity/contracts/utility/Time.sol pragma solidity 0.6.12; /* Time implementing contract */ contract Time { /** * @dev returns the current time */ function time() internal view virtual returns (uint256) { return block.timestamp; } } // File: solidity/contracts/converter/types/standard-pool/StandardPoolConverter.sol pragma solidity 0.6.12; /** * @dev This contract is a specialized version of the converter, which is * optimized for a liquidity pool that has 2 reserves with 50%/50% weights. */ contract StandardPoolConverter is ConverterVersion, IConverter, ContractRegistryClient, ReentrancyGuard, Time { using SafeMath for uint256; using SafeERC20 for IERC20; using MathEx for *; uint256 private constant MAX_UINT128 = 2**128 - 1; uint256 private constant MAX_UINT112 = 2**112 - 1; uint256 private constant MAX_UINT32 = 2**32 - 1; uint256 private constant AVERAGE_RATE_PERIOD = 10 minutes; uint256 private __reserveBalances; uint256 private _reserveBalancesProduct; IERC20[] private __reserveTokens; mapping(IERC20 => uint256) private __reserveIds; IConverterAnchor public override anchor; // converter anchor contract uint32 public override maxConversionFee; // maximum conversion fee, represented in ppm, 0...1000000 uint32 public override conversionFee; // current conversion fee, represented in ppm, 0...maxConversionFee // average rate details: // bits 0...111 represent the numerator of the rate between reserve token 0 and reserve token 1 // bits 111...223 represent the denominator of the rate between reserve token 0 and reserve token 1 // bits 224...255 represent the update-time of the rate between reserve token 0 and reserve token 1 // where `numerator / denominator` gives the worth of one reserve token 0 in units of reserve token 1 uint256 public averageRateInfo; /** * @dev triggered after liquidity is added * * @param _provider liquidity provider * @param _reserveToken reserve token address * @param _amount reserve token amount * @param _newBalance reserve token new balance * @param _newSupply pool token new supply */ event LiquidityAdded( address indexed _provider, IERC20 indexed _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply ); /** * @dev triggered after liquidity is removed * * @param _provider liquidity provider * @param _reserveToken reserve token address * @param _amount reserve token amount * @param _newBalance reserve token new balance * @param _newSupply pool token new supply */ event LiquidityRemoved( address indexed _provider, IERC20 indexed _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply ); /** * @dev initializes a new StandardPoolConverter instance * * @param _anchor anchor governed by the converter * @param _registry address of a contract registry contract * @param _maxConversionFee maximum conversion fee, represented in ppm */ constructor( IConverterAnchor _anchor, IContractRegistry _registry, uint32 _maxConversionFee ) public ContractRegistryClient(_registry) validAddress(address(_anchor)) validConversionFee(_maxConversionFee) { anchor = _anchor; maxConversionFee = _maxConversionFee; } // ensures that the converter is active modifier active() { _active(); _; } // error message binary size optimization function _active() internal view { require(isActive(), "ERR_INACTIVE"); } // ensures that the converter is not active modifier inactive() { _inactive(); _; } // error message binary size optimization function _inactive() internal view { require(!isActive(), "ERR_ACTIVE"); } // validates a reserve token address - verifies that the address belongs to one of the reserve tokens modifier validReserve(IERC20 _address) { _validReserve(_address); _; } // error message binary size optimization function _validReserve(IERC20 _address) internal view { require(__reserveIds[_address] != 0, "ERR_INVALID_RESERVE"); } // validates conversion fee modifier validConversionFee(uint32 _conversionFee) { _validConversionFee(_conversionFee); _; } // error message binary size optimization function _validConversionFee(uint32 _conversionFee) internal pure { require(_conversionFee <= PPM_RESOLUTION, "ERR_INVALID_CONVERSION_FEE"); } // validates reserve weight modifier validReserveWeight(uint32 _weight) { _validReserveWeight(_weight); _; } // error message binary size optimization function _validReserveWeight(uint32 _weight) internal pure { require(_weight == PPM_RESOLUTION / 2, "ERR_INVALID_RESERVE_WEIGHT"); } /** * @dev returns the converter type * * @return see the converter types in the the main contract doc */ function converterType() public pure virtual override returns (uint16) { return 3; } /** * @dev deposits ether * can only be called if the converter has an ETH reserve */ receive() external payable override(IConverter) validReserve(NATIVE_TOKEN_ADDRESS) {} /** * @dev checks whether or not the converter version is 28 or higher * * @return true, since the converter version is 28 or higher */ function isV28OrHigher() public pure returns (bool) { return true; } /** * @dev returns true if the converter is active, false otherwise * * @return true if the converter is active, false otherwise */ function isActive() public view virtual override returns (bool) { return anchor.owner() == address(this); } /** * @dev transfers the anchor ownership * the new owner needs to accept the transfer * can only be called by the converter upgrader while the upgrader is the owner * note that prior to version 28, you should use 'transferAnchorOwnership' instead * * @param _newOwner new token owner */ function transferAnchorOwnership(address _newOwner) public override ownerOnly only(CONVERTER_UPGRADER) { anchor.transferOwnership(_newOwner); } /** * @dev accepts ownership of the anchor after an ownership transfer * most converters are also activated as soon as they accept the anchor ownership * can only be called by the contract owner * note that prior to version 28, you should use 'acceptTokenOwnership' instead */ function acceptAnchorOwnership() public virtual override ownerOnly { // verify the the converter has exactly two reserves require(reserveTokenCount() == 2, "ERR_INVALID_RESERVE_COUNT"); anchor.acceptOwnership(); syncReserveBalances(0); emit Activation(converterType(), anchor, true); } /** * @dev updates the current conversion fee * can only be called by the contract owner * * @param _conversionFee new conversion fee, represented in ppm */ function setConversionFee(uint32 _conversionFee) public override ownerOnly { require(_conversionFee <= maxConversionFee, "ERR_INVALID_CONVERSION_FEE"); emit ConversionFeeUpdate(conversionFee, _conversionFee); conversionFee = _conversionFee; } /** * @dev transfers reserve balances to a new converter during an upgrade * can only be called by the converter upgraded which should be set at its owner * * @param _newConverter address of the converter to receive the new amount */ function transferReservesOnUpgrade(address _newConverter) external override protected ownerOnly only(CONVERTER_UPGRADER) { uint256 reserveCount = __reserveTokens.length; for (uint256 i = 0; i < reserveCount; ++i) { IERC20 reserveToken = __reserveTokens[i]; uint256 amount; if (reserveToken == NATIVE_TOKEN_ADDRESS) { amount = address(this).balance; } else { amount = reserveToken.balanceOf(address(this)); } safeTransfer(reserveToken, _newConverter, amount); syncReserveBalance(reserveToken); } } /** * @dev upgrades the converter to the latest version * can only be called by the owner * note that the owner needs to call acceptOwnership on the new converter after the upgrade */ function upgrade() public ownerOnly { IConverterUpgrader converterUpgrader = IConverterUpgrader(addressOf(CONVERTER_UPGRADER)); // trigger de-activation event emit Activation(converterType(), anchor, false); transferOwnership(address(converterUpgrader)); converterUpgrader.upgrade(version); acceptOwnership(); } /** * @dev executed by the upgrader at the end of the upgrade process to handle custom pool logic */ function onUpgradeComplete() external override protected ownerOnly only(CONVERTER_UPGRADER) { (uint256 reserveBalance0, uint256 reserveBalance1) = reserveBalances(1, 2); _reserveBalancesProduct = reserveBalance0 * reserveBalance1; } /** * @dev returns the number of reserve tokens * note that prior to version 17, you should use 'connectorTokenCount' instead * * @return number of reserve tokens */ function reserveTokenCount() public view returns (uint16) { return uint16(__reserveTokens.length); } /** * @dev returns the array of reserve tokens * * @return array of reserve tokens */ function reserveTokens() public view returns (IERC20[] memory) { return __reserveTokens; } /** * @dev defines a new reserve token for the converter * can only be called by the owner while the converter is inactive * * @param _token address of the reserve token * @param _weight reserve weight, represented in ppm, 1-1000000 */ function addReserve(IERC20 _token, uint32 _weight) public virtual override ownerOnly inactive validExternalAddress(address(_token)) validReserveWeight(_weight) { // validate input require(address(_token) != address(anchor) && __reserveIds[_token] == 0, "ERR_INVALID_RESERVE"); require(reserveTokenCount() < 2, "ERR_INVALID_RESERVE_COUNT"); __reserveTokens.push(_token); __reserveIds[_token] = __reserveTokens.length; } /** * @dev returns the reserve's weight * added in version 28 * * @param _reserveToken reserve token contract address * * @return reserve weight */ function reserveWeight(IERC20 _reserveToken) public view validReserve(_reserveToken) returns (uint32) { return PPM_RESOLUTION / 2; } /** * @dev returns the balance of a given reserve token * * @param _reserveToken reserve token contract address * * @return the balance of the given reserve token */ function reserveBalance(IERC20 _reserveToken) public view override returns (uint256) { uint256 reserveId = __reserveIds[_reserveToken]; require(reserveId != 0, "ERR_INVALID_RESERVE"); return reserveBalance(reserveId); } /** * @dev returns the balances of both reserve tokens * * @return the balances of both reserve tokens */ function reserveBalances() public view returns (uint256, uint256) { return reserveBalances(1, 2); } /** * @dev syncs all stored reserve balances */ function syncReserveBalances() external { syncReserveBalances(0); } /** * @dev calculates the accumulated network fee and transfers it to the network fee wallet */ function processNetworkFees() external protected { (uint256 reserveBalance0, uint256 reserveBalance1) = processNetworkFees(0); _reserveBalancesProduct = reserveBalance0 * reserveBalance1; } /** * @dev calculates the accumulated network fee and transfers it to the network fee wallet * * @param _value amount of ether to exclude from the ether reserve balance (if relevant) * * @return new reserve balances */ function processNetworkFees(uint256 _value) internal returns (uint256, uint256) { syncReserveBalances(_value); (uint256 reserveBalance0, uint256 reserveBalance1) = reserveBalances(1, 2); (ITokenHolder wallet, uint256 fee0, uint256 fee1) = networkWalletAndFees(reserveBalance0, reserveBalance1); reserveBalance0 -= fee0; reserveBalance1 -= fee1; setReserveBalances(1, 2, reserveBalance0, reserveBalance1); safeTransfer(__reserveTokens[0], address(wallet), fee0); safeTransfer(__reserveTokens[1], address(wallet), fee1); return (reserveBalance0, reserveBalance1); } /** * @dev returns the reserve balances of the given reserve tokens minus their corresponding fees * * @param _reserveTokens reserve tokens * * @return reserve balances minus their corresponding fees */ function baseReserveBalances(IERC20[] memory _reserveTokens) internal view returns (uint256[2] memory) { uint256 reserveId0 = __reserveIds[_reserveTokens[0]]; uint256 reserveId1 = __reserveIds[_reserveTokens[1]]; (uint256 reserveBalance0, uint256 reserveBalance1) = reserveBalances(reserveId0, reserveId1); (, uint256 fee0, uint256 fee1) = networkWalletAndFees(reserveBalance0, reserveBalance1); return [reserveBalance0 - fee0, reserveBalance1 - fee1]; } /** * @dev converts a specific amount of source tokens to target tokens * can only be called by the bancor network contract * * @param _sourceToken source ERC20 token * @param _targetToken target ERC20 token * @param _amount amount of tokens to convert (in units of the source token) * @param _trader address of the caller who executed the conversion * @param _beneficiary wallet to receive the conversion result * * @return amount of tokens received (in units of the target token) */ function convert( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount, address _trader, address payable _beneficiary ) public payable override protected only(BANCOR_NETWORK) returns (uint256) { // validate input require(_sourceToken != _targetToken, "ERR_SAME_SOURCE_TARGET"); return doConvert(_sourceToken, _targetToken, _amount, _trader, _beneficiary); } /** * @dev returns the conversion fee for a given target amount * * @param _targetAmount target amount * * @return conversion fee */ function calculateFee(uint256 _targetAmount) internal view returns (uint256) { return _targetAmount.mul(conversionFee) / PPM_RESOLUTION; } /** * @dev returns the conversion fee taken from a given target amount * * @param _targetAmount target amount * * @return conversion fee */ function calculateFeeInv(uint256 _targetAmount) internal view returns (uint256) { return _targetAmount.mul(conversionFee).div(PPM_RESOLUTION - conversionFee); } /** * @dev loads the stored reserve balance for a given reserve id * * @param _reserveId reserve id */ function reserveBalance(uint256 _reserveId) internal view returns (uint256) { return decodeReserveBalance(__reserveBalances, _reserveId); } /** * @dev loads the stored reserve balances * * @param _sourceId source reserve id * @param _targetId target reserve id */ function reserveBalances(uint256 _sourceId, uint256 _targetId) internal view returns (uint256, uint256) { require((_sourceId == 1 && _targetId == 2) || (_sourceId == 2 && _targetId == 1), "ERR_INVALID_RESERVES"); return decodeReserveBalances(__reserveBalances, _sourceId, _targetId); } /** * @dev stores the stored reserve balance for a given reserve id * * @param _reserveId reserve id * @param _reserveBalance reserve balance */ function setReserveBalance(uint256 _reserveId, uint256 _reserveBalance) internal { require(_reserveBalance <= MAX_UINT128, "ERR_RESERVE_BALANCE_OVERFLOW"); uint256 otherBalance = decodeReserveBalance(__reserveBalances, 3 - _reserveId); __reserveBalances = encodeReserveBalances(_reserveBalance, _reserveId, otherBalance, 3 - _reserveId); } /** * @dev stores the stored reserve balances * * @param _sourceId source reserve id * @param _targetId target reserve id * @param _sourceBalance source reserve balance * @param _targetBalance target reserve balance */ function setReserveBalances( uint256 _sourceId, uint256 _targetId, uint256 _sourceBalance, uint256 _targetBalance ) internal { require(_sourceBalance <= MAX_UINT128 && _targetBalance <= MAX_UINT128, "ERR_RESERVE_BALANCE_OVERFLOW"); __reserveBalances = encodeReserveBalances(_sourceBalance, _sourceId, _targetBalance, _targetId); } /** * @dev syncs the stored reserve balance for a given reserve with the real reserve balance * * @param _reserveToken address of the reserve token */ function syncReserveBalance(IERC20 _reserveToken) internal { uint256 reserveId = __reserveIds[_reserveToken]; uint256 balance = _reserveToken == NATIVE_TOKEN_ADDRESS ? address(this).balance : _reserveToken.balanceOf(address(this)); setReserveBalance(reserveId, balance); } /** * @dev syncs all stored reserve balances, excluding a given amount of ether from the ether reserve balance (if relevant) * * @param _value amount of ether to exclude from the ether reserve balance (if relevant) */ function syncReserveBalances(uint256 _value) internal { IERC20 _reserveToken0 = __reserveTokens[0]; IERC20 _reserveToken1 = __reserveTokens[1]; uint256 balance0 = _reserveToken0 == NATIVE_TOKEN_ADDRESS ? address(this).balance - _value : _reserveToken0.balanceOf(address(this)); uint256 balance1 = _reserveToken1 == NATIVE_TOKEN_ADDRESS ? address(this).balance - _value : _reserveToken1.balanceOf(address(this)); setReserveBalances(1, 2, balance0, balance1); } /** * @dev helper, dispatches the Conversion event * * @param _sourceToken source ERC20 token * @param _targetToken target ERC20 token * @param _trader address of the caller who executed the conversion * @param _amount amount purchased/sold (in the source token) * @param _returnAmount amount returned (in the target token) */ function dispatchConversionEvent( IERC20 _sourceToken, IERC20 _targetToken, address _trader, uint256 _amount, uint256 _returnAmount, uint256 _feeAmount ) internal { emit Conversion(_sourceToken, _targetToken, _trader, _amount, _returnAmount, int256(_feeAmount)); } /** * @dev returns the expected amount and expected fee for converting one reserve to another * * @param _sourceToken address of the source reserve token contract * @param _targetToken address of the target reserve token contract * @param _amount amount of source reserve tokens converted * * @return expected amount in units of the target reserve token * @return expected fee in units of the target reserve token */ function targetAmountAndFee( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount ) public view virtual override active returns (uint256, uint256) { uint256 sourceId = __reserveIds[_sourceToken]; uint256 targetId = __reserveIds[_targetToken]; (uint256 sourceBalance, uint256 targetBalance) = reserveBalances(sourceId, targetId); return targetAmountAndFee(_sourceToken, _targetToken, sourceBalance, targetBalance, _amount); } /** * @dev returns the expected amount and expected fee for converting one reserve to another * * @param _sourceBalance balance in the source reserve token contract * @param _targetBalance balance in the target reserve token contract * @param _amount amount of source reserve tokens converted * * @return expected amount in units of the target reserve token * @return expected fee in units of the target reserve token */ function targetAmountAndFee( IERC20, /* _sourceToken */ IERC20, /* _targetToken */ uint256 _sourceBalance, uint256 _targetBalance, uint256 _amount ) internal view virtual returns (uint256, uint256) { uint256 amount = crossReserveTargetAmount(_sourceBalance, _targetBalance, _amount); uint256 fee = calculateFee(amount); return (amount - fee, fee); } /** * @dev returns the required amount and expected fee for converting one reserve to another * * @param _sourceToken address of the source reserve token contract * @param _targetToken address of the target reserve token contract * @param _amount amount of target reserve tokens desired * * @return required amount in units of the source reserve token * @return expected fee in units of the target reserve token */ function sourceAmountAndFee( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount ) public view virtual active returns (uint256, uint256) { uint256 sourceId = __reserveIds[_sourceToken]; uint256 targetId = __reserveIds[_targetToken]; (uint256 sourceBalance, uint256 targetBalance) = reserveBalances(sourceId, targetId); uint256 fee = calculateFeeInv(_amount); uint256 amount = crossReserveSourceAmount(sourceBalance, targetBalance, _amount.add(fee)); return (amount, fee); } /** * @dev converts a specific amount of source tokens to target tokens * * @param _sourceToken source ERC20 token * @param _targetToken target ERC20 token * @param _amount amount of tokens to convert (in units of the source token) * @param _trader address of the caller who executed the conversion * @param _beneficiary wallet to receive the conversion result * * @return amount of tokens received (in units of the target token) */ function doConvert( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount, address _trader, address payable _beneficiary ) internal returns (uint256) { // update the recent average rate updateRecentAverageRate(); uint256 sourceId = __reserveIds[_sourceToken]; uint256 targetId = __reserveIds[_targetToken]; (uint256 sourceBalance, uint256 targetBalance) = reserveBalances(sourceId, targetId); // get the target amount minus the conversion fee and the conversion fee (uint256 amount, uint256 fee) = targetAmountAndFee(_sourceToken, _targetToken, sourceBalance, targetBalance, _amount); // ensure that the trade gives something in return require(amount != 0, "ERR_ZERO_TARGET_AMOUNT"); // ensure that the trade won't deplete the reserve balance assert(amount < targetBalance); // ensure that the input amount was already deposited uint256 actualSourceBalance; if (_sourceToken == NATIVE_TOKEN_ADDRESS) { actualSourceBalance = address(this).balance; require(msg.value == _amount, "ERR_ETH_AMOUNT_MISMATCH"); } else { actualSourceBalance = _sourceToken.balanceOf(address(this)); require(msg.value == 0 && actualSourceBalance.sub(sourceBalance) >= _amount, "ERR_INVALID_AMOUNT"); } // sync the reserve balances setReserveBalances(sourceId, targetId, actualSourceBalance, targetBalance - amount); // transfer funds to the beneficiary in the to reserve token safeTransfer(_targetToken, _beneficiary, amount); // dispatch the conversion event dispatchConversionEvent(_sourceToken, _targetToken, _trader, _amount, amount, fee); // dispatch rate updates dispatchTokenRateUpdateEvents(_sourceToken, _targetToken, actualSourceBalance, targetBalance - amount); return amount; } /** * @dev returns the recent average rate of 1 `_token` in the other reserve token units * * @param _token token to get the rate for * * @return recent average rate between the reserves (numerator) * @return recent average rate between the reserves (denominator) */ function recentAverageRate(IERC20 _token) external view validReserve(_token) returns (uint256, uint256) { // get the recent average rate of reserve 0 uint256 rate = calcRecentAverageRate(averageRateInfo); uint256 rateN = decodeAverageRateN(rate); uint256 rateD = decodeAverageRateD(rate); if (_token == __reserveTokens[0]) { return (rateN, rateD); } return (rateD, rateN); } /** * @dev updates the recent average rate if needed */ function updateRecentAverageRate() internal { uint256 averageRateInfo1 = averageRateInfo; uint256 averageRateInfo2 = calcRecentAverageRate(averageRateInfo1); if (averageRateInfo1 != averageRateInfo2) { averageRateInfo = averageRateInfo2; } } /** * @dev returns the recent average rate of 1 reserve token 0 in reserve token 1 units * * @param _averageRateInfo a local copy of the `averageRateInfo` state-variable * * @return recent average rate between the reserves */ function calcRecentAverageRate(uint256 _averageRateInfo) internal view returns (uint256) { // get the previous average rate and its update-time uint256 prevAverageRateT = decodeAverageRateT(_averageRateInfo); uint256 prevAverageRateN = decodeAverageRateN(_averageRateInfo); uint256 prevAverageRateD = decodeAverageRateD(_averageRateInfo); // get the elapsed time since the previous average rate was calculated uint256 currentTime = time(); uint256 timeElapsed = currentTime - prevAverageRateT; // if the previous average rate was calculated in the current block, the average rate remains unchanged if (timeElapsed == 0) { return _averageRateInfo; } // get the current rate between the reserves (uint256 currentRateD, uint256 currentRateN) = reserveBalances(); // if the previous average rate was calculated a while ago or never, the average rate is equal to the current rate if (timeElapsed >= AVERAGE_RATE_PERIOD || prevAverageRateT == 0) { (currentRateN, currentRateD) = MathEx.reducedRatio(currentRateN, currentRateD, MAX_UINT112); return encodeAverageRateInfo(currentTime, currentRateN, currentRateD); } uint256 x = prevAverageRateD.mul(currentRateN); uint256 y = prevAverageRateN.mul(currentRateD); // since we know that timeElapsed < AVERAGE_RATE_PERIOD, we can avoid using SafeMath: uint256 newRateN = y.mul(AVERAGE_RATE_PERIOD - timeElapsed).add(x.mul(timeElapsed)); uint256 newRateD = prevAverageRateD.mul(currentRateD).mul(AVERAGE_RATE_PERIOD); (newRateN, newRateD) = MathEx.reducedRatio(newRateN, newRateD, MAX_UINT112); return encodeAverageRateInfo(currentTime, newRateN, newRateD); } /** * @dev increases the pool's liquidity and mints new shares in the pool to the caller * * @param _reserveTokens address of each reserve token * @param _reserveAmounts amount of each reserve token * @param _minReturn token minimum return-amount * * @return amount of pool tokens issued */ function addLiquidity( IERC20[] memory _reserveTokens, uint256[] memory _reserveAmounts, uint256 _minReturn ) public payable protected active returns (uint256) { // verify the user input verifyLiquidityInput(_reserveTokens, _reserveAmounts, _minReturn); // if one of the reserves is ETH, then verify that the input amount of ETH is equal to the input value of ETH for (uint256 i = 0; i < 2; i++) { if (_reserveTokens[i] == NATIVE_TOKEN_ADDRESS) { require(_reserveAmounts[i] == msg.value, "ERR_ETH_AMOUNT_MISMATCH"); } } // if the input value of ETH is larger than zero, then verify that one of the reserves is ETH if (msg.value > 0) { require(__reserveIds[NATIVE_TOKEN_ADDRESS] != 0, "ERR_NO_ETH_RESERVE"); } // save a local copy of the pool token IDSToken poolToken = IDSToken(address(anchor)); // get the total supply uint256 totalSupply = poolToken.totalSupply(); uint256[2] memory prevReserveBalances; uint256[2] memory newReserveBalances; // process the network fees and get the reserve balances (prevReserveBalances[0], prevReserveBalances[1]) = processNetworkFees(msg.value); uint256 amount; uint256[2] memory reserveAmounts; // calculate the amount of pool tokens to mint for the caller // and the amount of reserve tokens to transfer from the caller if (totalSupply == 0) { amount = MathEx.geometricMean(_reserveAmounts); reserveAmounts[0] = _reserveAmounts[0]; reserveAmounts[1] = _reserveAmounts[1]; } else { (amount, reserveAmounts) = addLiquidityAmounts( _reserveTokens, _reserveAmounts, prevReserveBalances, totalSupply ); } uint256 newPoolTokenSupply = totalSupply.add(amount); for (uint256 i = 0; i < 2; i++) { IERC20 reserveToken = _reserveTokens[i]; uint256 reserveAmount = reserveAmounts[i]; require(reserveAmount > 0, "ERR_ZERO_TARGET_AMOUNT"); assert(reserveAmount <= _reserveAmounts[i]); // transfer each one of the reserve amounts from the user to the pool if (reserveToken != NATIVE_TOKEN_ADDRESS) { // ETH has already been transferred as part of the transaction reserveToken.safeTransferFrom(msg.sender, address(this), reserveAmount); } else if (_reserveAmounts[i] > reserveAmount) { // transfer the extra amount of ETH back to the user msg.sender.transfer(_reserveAmounts[i] - reserveAmount); } // save the new reserve balance newReserveBalances[i] = prevReserveBalances[i].add(reserveAmount); emit LiquidityAdded(msg.sender, reserveToken, reserveAmount, newReserveBalances[i], newPoolTokenSupply); // dispatch the `TokenRateUpdate` event for the pool token emit TokenRateUpdate(poolToken, reserveToken, newReserveBalances[i], newPoolTokenSupply); } // set the reserve balances setReserveBalances(1, 2, newReserveBalances[0], newReserveBalances[1]); // set the reserve balances product _reserveBalancesProduct = newReserveBalances[0] * newReserveBalances[1]; // verify that the equivalent amount of tokens is equal to or larger than the user's expectation require(amount >= _minReturn, "ERR_RETURN_TOO_LOW"); // issue the tokens to the user poolToken.issue(msg.sender, amount); // return the amount of pool tokens issued return amount; } /** * @dev get the amount of pool tokens to mint for the caller * and the amount of reserve tokens to transfer from the caller * * @param _reserveAmounts amount of each reserve token * @param _reserveBalances balance of each reserve token * @param _totalSupply total supply of pool tokens * * @return amount of pool tokens to mint for the caller * @return amount of reserve tokens to transfer from the caller */ function addLiquidityAmounts( IERC20[] memory, /* _reserveTokens */ uint256[] memory _reserveAmounts, uint256[2] memory _reserveBalances, uint256 _totalSupply ) internal view virtual returns (uint256, uint256[2] memory) { this; uint256 index = _reserveAmounts[0].mul(_reserveBalances[1]) < _reserveAmounts[1].mul(_reserveBalances[0]) ? 0 : 1; uint256 amount = fundSupplyAmount(_totalSupply, _reserveBalances[index], _reserveAmounts[index]); uint256[2] memory reserveAmounts = [fundCost(_totalSupply, _reserveBalances[0], amount), fundCost(_totalSupply, _reserveBalances[1], amount)]; return (amount, reserveAmounts); } /** * @dev decreases the pool's liquidity and burns the caller's shares in the pool * * @param _amount token amount * @param _reserveTokens address of each reserve token * @param _reserveMinReturnAmounts minimum return-amount of each reserve token * * @return the amount of each reserve token granted for the given amount of pool tokens */ function removeLiquidity( uint256 _amount, IERC20[] memory _reserveTokens, uint256[] memory _reserveMinReturnAmounts ) public protected active returns (uint256[] memory) { // verify the user input bool inputRearranged = verifyLiquidityInput(_reserveTokens, _reserveMinReturnAmounts, _amount); // save a local copy of the pool token IDSToken poolToken = IDSToken(address(anchor)); // get the total supply BEFORE destroying the user tokens uint256 totalSupply = poolToken.totalSupply(); // destroy the user tokens poolToken.destroy(msg.sender, _amount); uint256 newPoolTokenSupply = totalSupply.sub(_amount); uint256[2] memory prevReserveBalances; uint256[2] memory newReserveBalances; // process the network fees and get the reserve balances (prevReserveBalances[0], prevReserveBalances[1]) = processNetworkFees(0); uint256[] memory reserveAmounts = removeLiquidityReserveAmounts(_amount, totalSupply, prevReserveBalances); for (uint256 i = 0; i < 2; i++) { IERC20 reserveToken = _reserveTokens[i]; uint256 reserveAmount = reserveAmounts[i]; require(reserveAmount >= _reserveMinReturnAmounts[i], "ERR_ZERO_TARGET_AMOUNT"); // save the new reserve balance newReserveBalances[i] = prevReserveBalances[i].sub(reserveAmount); // transfer each one of the reserve amounts from the pool to the user safeTransfer(reserveToken, msg.sender, reserveAmount); emit LiquidityRemoved(msg.sender, reserveToken, reserveAmount, newReserveBalances[i], newPoolTokenSupply); // dispatch the `TokenRateUpdate` event for the pool token emit TokenRateUpdate(poolToken, reserveToken, newReserveBalances[i], newPoolTokenSupply); } // set the reserve balances setReserveBalances(1, 2, newReserveBalances[0], newReserveBalances[1]); // set the reserve balances product _reserveBalancesProduct = newReserveBalances[0] * newReserveBalances[1]; if (inputRearranged) { uint256 tempReserveAmount = reserveAmounts[0]; reserveAmounts[0] = reserveAmounts[1]; reserveAmounts[1] = tempReserveAmount; } // return the amount of each reserve token granted for the given amount of pool tokens return reserveAmounts; } /** * @dev given the amount of one of the reserve tokens to add liquidity of, * returns the required amount of each one of the other reserve tokens * since an empty pool can be funded with any list of non-zero input amounts, * this function assumes that the pool is not empty (has already been funded) * * @param _reserveTokens address of each reserve token * @param _reserveTokenIndex index of the relevant reserve token * @param _reserveAmount amount of the relevant reserve token * * @return the required amount of each one of the reserve tokens */ function addLiquidityCost( IERC20[] memory _reserveTokens, uint256 _reserveTokenIndex, uint256 _reserveAmount ) public view returns (uint256[] memory) { uint256 totalSupply = IDSToken(address(anchor)).totalSupply(); uint256[2] memory baseBalances = baseReserveBalances(_reserveTokens); uint256 amount = fundSupplyAmount(totalSupply, baseBalances[_reserveTokenIndex], _reserveAmount); uint256[] memory reserveAmounts = new uint256[](2); reserveAmounts[0] = fundCost(totalSupply, baseBalances[0], amount); reserveAmounts[1] = fundCost(totalSupply, baseBalances[1], amount); return reserveAmounts; } /** * @dev returns the amount of pool tokens entitled for given amounts of reserve tokens * since an empty pool can be funded with any list of non-zero input amounts, * this function assumes that the pool is not empty (has already been funded) * * @param _reserveTokens address of each reserve token * @param _reserveAmounts amount of each reserve token * * @return the amount of pool tokens entitled for the given amounts of reserve tokens */ function addLiquidityReturn(IERC20[] memory _reserveTokens, uint256[] memory _reserveAmounts) public view returns (uint256) { uint256 totalSupply = IDSToken(address(anchor)).totalSupply(); uint256[2] memory baseBalances = baseReserveBalances(_reserveTokens); (uint256 amount, ) = addLiquidityAmounts(_reserveTokens, _reserveAmounts, baseBalances, totalSupply); return amount; } /** * @dev returns the amount of each reserve token entitled for a given amount of pool tokens * * @param _amount amount of pool tokens * @param _reserveTokens address of each reserve token * * @return the amount of each reserve token entitled for the given amount of pool tokens */ function removeLiquidityReturn(uint256 _amount, IERC20[] memory _reserveTokens) public view returns (uint256[] memory) { uint256 totalSupply = IDSToken(address(anchor)).totalSupply(); uint256[2] memory baseBalances = baseReserveBalances(_reserveTokens); return removeLiquidityReserveAmounts(_amount, totalSupply, baseBalances); } /** * @dev verifies that a given array of tokens is identical to the converter's array of reserve tokens * we take this input in order to allow specifying the corresponding reserve amounts in any order * this function rearranges the input arrays according to the converter's array of reserve tokens * * @param _reserveTokens array of reserve tokens * @param _reserveAmounts array of reserve amounts * @param _amount token amount * * @return true if the function has rearranged the input arrays; false otherwise */ function verifyLiquidityInput( IERC20[] memory _reserveTokens, uint256[] memory _reserveAmounts, uint256 _amount ) private view returns (bool) { require(validReserveAmounts(_reserveAmounts) && _amount > 0, "ERR_ZERO_AMOUNT"); uint256 reserve0Id = __reserveIds[_reserveTokens[0]]; uint256 reserve1Id = __reserveIds[_reserveTokens[1]]; if (reserve0Id == 2 && reserve1Id == 1) { IERC20 tempReserveToken = _reserveTokens[0]; _reserveTokens[0] = _reserveTokens[1]; _reserveTokens[1] = tempReserveToken; uint256 tempReserveAmount = _reserveAmounts[0]; _reserveAmounts[0] = _reserveAmounts[1]; _reserveAmounts[1] = tempReserveAmount; return true; } require(reserve0Id == 1 && reserve1Id == 2, "ERR_INVALID_RESERVE"); return false; } /** * @dev checks whether or not both reserve amounts are larger than zero * * @param _reserveAmounts array of reserve amounts * * @return true if both reserve amounts are larger than zero; false otherwise */ function validReserveAmounts(uint256[] memory _reserveAmounts) internal pure virtual returns (bool) { return _reserveAmounts[0] > 0 && _reserveAmounts[1] > 0; } /** * @dev returns the amount of each reserve token entitled for a given amount of pool tokens * * @param _amount amount of pool tokens * @param _totalSupply total supply of pool tokens * @param _reserveBalances balance of each reserve token * * @return the amount of each reserve token entitled for the given amount of pool tokens */ function removeLiquidityReserveAmounts( uint256 _amount, uint256 _totalSupply, uint256[2] memory _reserveBalances ) private pure returns (uint256[] memory) { uint256[] memory reserveAmounts = new uint256[](2); reserveAmounts[0] = liquidateReserveAmount(_totalSupply, _reserveBalances[0], _amount); reserveAmounts[1] = liquidateReserveAmount(_totalSupply, _reserveBalances[1], _amount); return reserveAmounts; } /** * @dev dispatches token rate update events for the reserve tokens and the pool token * * @param _sourceToken address of the source reserve token * @param _targetToken address of the target reserve token * @param _sourceBalance balance of the source reserve token * @param _targetBalance balance of the target reserve token */ function dispatchTokenRateUpdateEvents( IERC20 _sourceToken, IERC20 _targetToken, uint256 _sourceBalance, uint256 _targetBalance ) private { // save a local copy of the pool token IDSToken poolToken = IDSToken(address(anchor)); // get the total supply of pool tokens uint256 poolTokenSupply = poolToken.totalSupply(); // dispatch token rate update event for the reserve tokens emit TokenRateUpdate(_sourceToken, _targetToken, _targetBalance, _sourceBalance); // dispatch token rate update events for the pool token emit TokenRateUpdate(poolToken, _sourceToken, _sourceBalance, poolTokenSupply); emit TokenRateUpdate(poolToken, _targetToken, _targetBalance, poolTokenSupply); } function encodeReserveBalance(uint256 _balance, uint256 _id) private pure returns (uint256) { assert(_balance <= MAX_UINT128 && (_id == 1 || _id == 2)); return _balance << ((_id - 1) * 128); } function decodeReserveBalance(uint256 _balances, uint256 _id) private pure returns (uint256) { assert(_id == 1 || _id == 2); return (_balances >> ((_id - 1) * 128)) & MAX_UINT128; } function encodeReserveBalances( uint256 _balance0, uint256 _id0, uint256 _balance1, uint256 _id1 ) private pure returns (uint256) { return encodeReserveBalance(_balance0, _id0) | encodeReserveBalance(_balance1, _id1); } function decodeReserveBalances( uint256 _balances, uint256 _id0, uint256 _id1 ) private pure returns (uint256, uint256) { return (decodeReserveBalance(_balances, _id0), decodeReserveBalance(_balances, _id1)); } function encodeAverageRateInfo( uint256 _averageRateT, uint256 _averageRateN, uint256 _averageRateD ) private pure returns (uint256) { assert(_averageRateT <= MAX_UINT32 && _averageRateN <= MAX_UINT112 && _averageRateD <= MAX_UINT112); return (_averageRateT << 224) | (_averageRateN << 112) | _averageRateD; } function decodeAverageRateT(uint256 _averageRateInfo) private pure returns (uint256) { return _averageRateInfo >> 224; } function decodeAverageRateN(uint256 _averageRateInfo) private pure returns (uint256) { return (_averageRateInfo >> 112) & MAX_UINT112; } function decodeAverageRateD(uint256 _averageRateInfo) private pure returns (uint256) { return _averageRateInfo & MAX_UINT112; } /** * @dev returns the largest integer smaller than or equal to the square root of a given value * * @param x the given value * * @return the largest integer smaller than or equal to the square root of the given value */ function floorSqrt(uint256 x) private pure returns (uint256) { return x > 0 ? MathEx.floorSqrt(x) : 0; } function crossReserveTargetAmount( uint256 _sourceReserveBalance, uint256 _targetReserveBalance, uint256 _amount ) private pure returns (uint256) { // validate input require(_sourceReserveBalance > 0 && _targetReserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); return _targetReserveBalance.mul(_amount) / _sourceReserveBalance.add(_amount); } function crossReserveSourceAmount( uint256 _sourceReserveBalance, uint256 _targetReserveBalance, uint256 _amount ) private pure returns (uint256) { // validate input require(_sourceReserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); require(_amount < _targetReserveBalance, "ERR_INVALID_AMOUNT"); if (_amount == 0) { return 0; } return (_sourceReserveBalance.mul(_amount) - 1) / (_targetReserveBalance - _amount) + 1; } function fundCost( uint256 _supply, uint256 _reserveBalance, uint256 _amount ) private pure returns (uint256) { // validate input require(_supply > 0, "ERR_INVALID_SUPPLY"); require(_reserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); // special case for 0 amount if (_amount == 0) { return 0; } return (_amount.mul(_reserveBalance) - 1) / _supply + 1; } function fundSupplyAmount( uint256 _supply, uint256 _reserveBalance, uint256 _amount ) private pure returns (uint256) { // validate input require(_supply > 0, "ERR_INVALID_SUPPLY"); require(_reserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); // special case for 0 amount if (_amount == 0) { return 0; } return _amount.mul(_supply) / _reserveBalance; } function liquidateReserveAmount( uint256 _supply, uint256 _reserveBalance, uint256 _amount ) private pure returns (uint256) { // validate input require(_supply > 0, "ERR_INVALID_SUPPLY"); require(_reserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); require(_amount <= _supply, "ERR_INVALID_AMOUNT"); // special case for 0 amount if (_amount == 0) { return 0; } // special case for liquidating the entire supply if (_amount == _supply) { return _reserveBalance; } return _amount.mul(_reserveBalance) / _supply; } /** * @dev returns the network wallet and fees * * @param reserveBalance0 1st reserve balance * @param reserveBalance1 2nd reserve balance * * @return the network wallet * @return the network fee on the 1st reserve * @return the network fee on the 2nd reserve */ function networkWalletAndFees(uint256 reserveBalance0, uint256 reserveBalance1) private view returns ( ITokenHolder, uint256, uint256 ) { uint256 prevPoint = floorSqrt(_reserveBalancesProduct); uint256 currPoint = floorSqrt(reserveBalance0 * reserveBalance1); if (prevPoint >= currPoint) { return (ITokenHolder(address(0)), 0, 0); } (ITokenHolder networkFeeWallet, uint32 networkFee) = INetworkSettings(addressOf(NETWORK_SETTINGS)).networkFeeParams(); uint256 n = (currPoint - prevPoint) * networkFee; uint256 d = currPoint * PPM_RESOLUTION; return (networkFeeWallet, reserveBalance0.mul(n).div(d), reserveBalance1.mul(n).div(d)); } /** * @dev transfers funds held by the contract and sends them to an account * * @param token ERC20 token contract address * @param to account to receive the new amount * @param amount amount to withdraw */ function safeTransfer( IERC20 token, address to, uint256 amount ) private { if (amount == 0) { return; } if (token == NATIVE_TOKEN_ADDRESS) { payable(to).transfer(amount); } else { token.safeTransfer(to, amount); } } /** * @dev deprecated since version 28, backward compatibility - use only for earlier versions */ function token() public view override returns (IConverterAnchor) { return anchor; } /** * @dev deprecated, backward compatibility */ function transferTokenOwnership(address _newOwner) public override ownerOnly { transferAnchorOwnership(_newOwner); } /** * @dev deprecated, backward compatibility */ function acceptTokenOwnership() public override ownerOnly { acceptAnchorOwnership(); } /** * @dev deprecated, backward compatibility */ function connectors(IERC20 _address) public view override returns ( uint256, uint32, bool, bool, bool ) { uint256 reserveId = __reserveIds[_address]; if (reserveId != 0) { return (reserveBalance(reserveId), PPM_RESOLUTION / 2, false, false, true); } return (0, 0, false, false, false); } /** * @dev deprecated, backward compatibility */ function connectorTokens(uint256 _index) public view override returns (IERC20) { return __reserveTokens[_index]; } /** * @dev deprecated, backward compatibility */ function connectorTokenCount() public view override returns (uint16) { return reserveTokenCount(); } /** * @dev deprecated, backward compatibility */ function getConnectorBalance(IERC20 _connectorToken) public view override returns (uint256) { return reserveBalance(_connectorToken); } /** * @dev deprecated, backward compatibility */ function getReturn( IERC20 _sourceToken, IERC20 _targetToken, uint256 _amount ) public view returns (uint256, uint256) { return targetAmountAndFee(_sourceToken, _targetToken, _amount); } } // File: solidity/contracts/converter/interfaces/ITypedConverterFactory.sol pragma solidity 0.6.12; /* Typed Converter Factory interface */ interface ITypedConverterFactory { function converterType() external pure returns (uint16); function createConverter( IConverterAnchor _anchor, IContractRegistry _registry, uint32 _maxConversionFee ) external returns (IConverter); } // File: solidity/contracts/converter/types/standard-pool/StandardPoolConverterFactory.sol pragma solidity 0.6.12; /* StandardPoolConverter Factory */ contract StandardPoolConverterFactory is ITypedConverterFactory { /** * @dev returns the converter type the factory is associated with * * @return converter type */ function converterType() external pure override returns (uint16) { return 3; } /** * @dev creates a new converter with the given arguments and transfers * the ownership to the caller * * @param _anchor anchor governed by the converter * @param _registry address of a contract registry contract * @param _maxConversionFee maximum conversion fee, represented in ppm * * @return a new converter */ function createConverter( IConverterAnchor _anchor, IContractRegistry _registry, uint32 _maxConversionFee ) external virtual override returns (IConverter) { IConverter converter = new StandardPoolConverter(IDSToken(address(_anchor)), _registry, _maxConversionFee); converter.transferOwnership(msg.sender); return converter; } }
validate input special case for 0 amount special case for liquidating the entire supply
function liquidateReserveAmount( uint256 _supply, uint256 _reserveBalance, uint256 _amount ) private pure returns (uint256) { require(_supply > 0, "ERR_INVALID_SUPPLY"); require(_reserveBalance > 0, "ERR_INVALID_RESERVE_BALANCE"); require(_amount <= _supply, "ERR_INVALID_AMOUNT"); if (_amount == 0) { return 0; } if (_amount == _supply) { return _reserveBalance; } return _amount.mul(_reserveBalance) / _supply; }
1,736,067
[ 1, 4625, 348, 7953, 560, 30, 225, 1954, 810, 4582, 648, 364, 374, 3844, 4582, 648, 364, 4501, 26595, 1776, 326, 7278, 14467, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 4501, 26595, 340, 607, 6527, 6275, 12, 203, 3639, 2254, 5034, 389, 2859, 1283, 16, 203, 3639, 2254, 5034, 389, 455, 6527, 13937, 16, 203, 3639, 2254, 5034, 389, 8949, 203, 565, 262, 3238, 16618, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 2583, 24899, 2859, 1283, 405, 374, 16, 315, 9712, 67, 9347, 67, 13272, 23893, 8863, 203, 3639, 2583, 24899, 455, 6527, 13937, 405, 374, 16, 315, 9712, 67, 9347, 67, 862, 2123, 3412, 67, 38, 1013, 4722, 8863, 203, 3639, 2583, 24899, 8949, 1648, 389, 2859, 1283, 16, 315, 9712, 67, 9347, 67, 2192, 51, 5321, 8863, 203, 203, 3639, 309, 261, 67, 8949, 422, 374, 13, 288, 203, 5411, 327, 374, 31, 203, 3639, 289, 203, 203, 3639, 309, 261, 67, 8949, 422, 389, 2859, 1283, 13, 288, 203, 5411, 327, 389, 455, 6527, 13937, 31, 203, 3639, 289, 203, 203, 3639, 327, 389, 8949, 18, 16411, 24899, 455, 6527, 13937, 13, 342, 389, 2859, 1283, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.16; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0 && _value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0 && _value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } /** * @title Pausable token * * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } } contract Crowdsale is PausableToken { uint256 public crowdsaleSupply = 0; uint256 public crowdsalePrice = 20000; uint256 public crowdsaleTotal = 2100000000; uint8 public decimals = 18; uint256 public limit = 2 * (10 ** uint256(decimals)); function crowdsale() public payable returns (bool) { require(msg.value >= limit); uint256 vv = msg.value.div(10 ** uint256(decimals)); uint256 coin = crowdsalePrice.mul(vv); require(coin.add(totalSupply) <= 21000000000); require(crowdsaleSupply.add(coin) <= crowdsaleTotal); balances[msg.sender] = coin.add(balances[msg.sender]); totalSupply = totalSupply.add(coin); crowdsaleSupply = crowdsaleSupply.add(coin); balances[msg.sender] = coin; return true; } } /** * @title GGPC Token * * @dev Implementation of GGPC Token based on the basic standard token. */ contract GGPCToken is Crowdsale { /** * Public variables of the token * The following variables are OPTIONAL vanities. One does not have to include them. * They allow one to customise the token contract & in no way influences the core functionality. * Some wallets/interfaces might not even bother to look at this information. */ string public name = "Global game payment currency"; string public symbol = "GGPC"; string public version = '1.0.0'; /** * @dev Function to check the amount of tokens that an owner allowed to a spender. */ function GGPCToken() public { totalSupply = 18900000000; balances[msg.sender] = 18900000000; // Give the creator all initial tokens } function () public { //if ether is sent to this address, send it back. revert(); } }
* Public variables of the token The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information./* @dev Function to check the amount of tokens that an owner allowed to a spender./
function GGPCToken() public { totalSupply = 18900000000; }
560,734
[ 1, 4625, 348, 7953, 560, 30, 380, 7224, 3152, 434, 326, 1147, 1021, 3751, 3152, 854, 14930, 331, 304, 1961, 18, 6942, 1552, 486, 1240, 358, 2341, 2182, 18, 16448, 1699, 1245, 358, 1679, 784, 326, 1147, 6835, 473, 316, 1158, 4031, 13947, 89, 2369, 326, 2922, 14176, 18, 10548, 17662, 2413, 19, 15898, 4825, 486, 5456, 23440, 358, 2324, 622, 333, 1779, 18, 20308, 632, 5206, 4284, 358, 866, 326, 3844, 434, 2430, 716, 392, 3410, 2935, 358, 279, 17571, 264, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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445, 611, 9681, 1268, 969, 1435, 1071, 288, 203, 3639, 2078, 3088, 1283, 273, 6549, 29, 12648, 31, 203, 565, 289, 203, 377, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/3/0x86ECD3151c87a443a132051B8B5800a2F9Ec1256/sources/contracts/TheDudesV5.sol
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}./
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < TheDudesERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; }
8,152,320
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2164, 288, 45, 654, 39, 27, 5340, 3572, 25121, 17, 2316, 951, 5541, 21268, 5496, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1147, 951, 5541, 21268, 12, 2867, 3410, 16, 2254, 5034, 770, 13, 1071, 1476, 5024, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 2583, 12, 1615, 411, 1021, 40, 6500, 654, 39, 27, 5340, 18, 12296, 951, 12, 8443, 3631, 315, 654, 39, 27, 5340, 3572, 25121, 30, 3410, 770, 596, 434, 4972, 8863, 203, 3639, 327, 389, 995, 329, 5157, 63, 8443, 6362, 1615, 15533, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity >=0.4.23 <0.6.0; import "./tokens/TRC20/TRC20Detailed.sol"; import "./tokens/TRC20/TRC20.sol"; import "./roles/MinterRole.sol"; contract HoraToken is TRC20, TRC20Detailed, MinterRole { uint8 private constant _decimals = 6; uint256 private constant _maxMint = 100000000 * (10 ** uint256(_decimals)); // 100 millions uint256 private constant _cap = _maxMint * 120; // 12 billions cap, 10 years minting in estimate uint private constant _mintInterval = 60 * 60 * 24 * 25; // 25 days minimum interval between mintings - sec * min * h * day uint private _lastMint = 0; constructor () TRC20Detailed("Hora Token", "HORA", _decimals) TRC20() public {} function cap() public pure returns (uint256) { return _cap; } function lastMintTime() public view returns (uint) { return _lastMint; } function mintCooldownMinutes() public view returns (uint) { require(now - _mintInterval < _lastMint, "MINT: READY"); return ((_mintInterval - (now - _lastMint)) / 60 + 1); } function mint(address to, uint256 value) public onlyMinter returns (bool) { uint256 _value = value * (10 ** uint256(_decimals)); require(_value <= _maxMint, "MINT: AMOUNT NOT ALLOWED"); require(now - _mintInterval > _lastMint, "MINT: TIME RANGE LOW"); require(totalSupply().add(_value) <= _cap, "MINT: TOTAL SUPPLY LIMIT HIT"); _mint(to, _value); _lastMint = now; return true; } }
25 days minimum interval between mintings - sec * min * h * day
uint private constant _mintInterval = 60 * 60 * 24 * 25;
13,133,589
[ 1, 4625, 348, 7953, 560, 30, 225, 6969, 4681, 5224, 3673, 3086, 312, 474, 899, 300, 1428, 380, 1131, 380, 366, 380, 2548, 203, 2, 0, 0, 0,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-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "@keep-network/keep-core/contracts/KeepToken.sol"; import "@keep-network/keep-core/contracts/TokenStaking.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/cryptography/MerkleProof.sol"; /// @title ECDSA Rewards distributor /// @notice This contract can be used by stakers to claim their rewards for /// participation in the keep network for operating ECDSA nodes. /// @dev This contract is based on the Uniswap's Merkle Distributor /// https://github.com/Uniswap/merkle-distributor with some modifications: /// - added a map of merkle root keys. Whenever a new merkle root is put in the /// map, we assign 'true' value to this key /// - added 'allocate()' function that will be called each time to allocate /// new KEEP rewards for a given merkle root. Merkle root is going to be generated /// regulary (ex. every week) and it is also means that an interval for that /// merkle root has passed /// - changed code accordingly to process claimed rewards using a map of merkle /// roots contract ECDSARewardsDistributor is Ownable { using SafeERC20 for KeepToken; KeepToken public token; TokenStaking public tokenStaking; // This event is triggered whenever a call to #claim succeeds. event RewardsClaimed( bytes32 indexed merkleRoot, uint256 indexed index, address indexed operator, address beneficiary, uint256 amount ); // This event is triggered whenever rewards are allocated. event RewardsAllocated(bytes32 merkleRoot, uint256 amount); // Map of merkle roots indicating whether a given interval was allocated with // KEEP token rewards. For each interval there is always created a new merkle // tree including a root, rewarded operators along with their amounts and proofs. mapping(bytes32 => bool) private merkleRoots; // Bytes32 key is a merkle root and the value is a packed array of booleans. mapping(bytes32 => mapping(uint256 => uint256)) private claimedBitMap; constructor(address _token, address _tokenStaking) public { token = KeepToken(_token); tokenStaking = TokenStaking(_tokenStaking); } /// Claim KEEP rewards for a given merkle root (interval) and the given operator /// address. Rewards will be sent to a beneficiary assigned to the operator. /// @param merkleRoot Merkle root for a given interval. /// @param index Index of the operator in the merkle tree. /// @param operator Operator address that reward will be claimed. /// @param amount The amount of KEEP reward to be claimed. /// @param merkleProof Array of merkle proofs. function claim( bytes32 merkleRoot, uint256 index, address operator, uint256 amount, bytes32[] calldata merkleProof ) external { require( merkleRoots[merkleRoot], "Rewards must be allocated for a given merkle root" ); require(!isClaimed(merkleRoot, index), "Reward already claimed"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, operator, amount)); require( MerkleProof.verify(merkleProof, merkleRoot, node), "Invalid proof" ); // Mark it claimed and send the token. _setClaimed(merkleRoot, index); address beneficiary = tokenStaking.beneficiaryOf(operator); require(IERC20(token).transfer(beneficiary, amount), "Transfer failed"); emit RewardsClaimed(merkleRoot, index, operator, beneficiary, amount); } /// Allocates amount of KEEP for a given merkle root. /// @param merkleRoot Merkle root for a given interval. /// @param amount The amount of KEEP tokens allocated for the merkle root. function allocate(bytes32 merkleRoot, uint256 amount) public onlyOwner { token.safeTransferFrom(msg.sender, address(this), amount); merkleRoots[merkleRoot] = true; emit RewardsAllocated(merkleRoot, amount); } function isClaimed(bytes32 merkleRoot, uint256 index) public view returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedBitMap[merkleRoot][claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(bytes32 merkleRoot, uint256 index) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedBitMap[merkleRoot][claimedWordIndex] = claimedBitMap[merkleRoot][claimedWordIndex] | (1 << claimedBitIndex); } }
Allocates amount of KEEP for a given merkle root. @param merkleRoot Merkle root for a given interval. @param amount The amount of KEEP tokens allocated for the merkle root.
function allocate(bytes32 merkleRoot, uint256 amount) public onlyOwner { token.safeTransferFrom(msg.sender, address(this), amount); merkleRoots[merkleRoot] = true; emit RewardsAllocated(merkleRoot, amount); }
12,733,818
[ 1, 4625, 348, 7953, 560, 30, 225, 12830, 815, 3844, 434, 1475, 9383, 52, 364, 279, 864, 30235, 1365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 16, 2254, 5034, 3844, 13, 1071, 1338, 5541, 288, 203, 3639, 1147, 18, 4626, 5912, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 3844, 1769, 203, 203, 3639, 30235, 17540, 63, 6592, 15609, 2375, 65, 273, 638, 31, 203, 203, 3639, 3626, 534, 359, 14727, 29392, 12, 6592, 15609, 2375, 16, 3844, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.18; contract DelegateERC20 { function delegateTotalSupply() public view returns (uint256); function delegateBalanceOf(address who) public view returns (uint256); function delegateTransfer(address to, uint256 value, address origSender) public returns (bool); function delegateAllowance(address owner, address spender) public view returns (uint256); function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool); function delegateApprove(address spender, uint256 value, address origSender) public returns (bool); function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool); function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool); } contract Ownable { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function transferOwnership(address newOwner) public; } contract Pausable is Ownable { event Pause(); event Unpause(); function pause() public; function unpause() public; } contract CanReclaimToken is Ownable { function reclaimToken(ERC20Basic token) external; } contract Claimable is Ownable { function transferOwnership(address newOwner) public; function claimOwnership() public; } contract AddressList is Claimable { event ChangeWhiteList(address indexed to, bool onList); function changeList(address _to, bool _onList) public; } contract HasNoContracts is Ownable { function reclaimContract(address contractAddr) external; } contract HasNoEther is Ownable { function() external; function reclaimEther() external; } contract HasNoTokens is CanReclaimToken { function tokenFallback(address from_, uint256 value_, bytes data_) external; } contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts { } contract AllowanceSheet is Claimable { function addAllowance(address tokenHolder, address spender, uint256 value) public; function subAllowance(address tokenHolder, address spender, uint256 value) public; function setAllowance(address tokenHolder, address spender, uint256 value) public; } contract BalanceSheet is Claimable { function addBalance(address addr, uint256 value) public; function subBalance(address addr, uint256 value) public; function setBalance(address addr, uint256 value) public; } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic, Claimable { function setBalanceSheet(address sheet) external; function totalSupply() public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function transferAllArgsNoAllowance(address _from, address _to, uint256 _value) internal; function balanceOf(address _owner) public view returns (uint256 balance); } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public; } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeERC20 { } contract StandardToken is ERC20, BasicToken { function setAllowanceSheet(address sheet) external; function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function transferAllArgsYesAllowance(address _from, address _to, uint256 _value, address spender) internal; function approve(address _spender, uint256 _value) public returns (bool); function approveAllArgs(address _spender, uint256 _value, address _tokenHolder) internal; function allowance(address _owner, address _spender) public view returns (uint256); function increaseApproval(address _spender, uint _addedValue) public returns (bool); function increaseApprovalAllArgs(address _spender, uint _addedValue, address tokenHolder) internal; function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool); function decreaseApprovalAllArgs(address _spender, uint _subtractedValue, address tokenHolder) internal; } contract CanDelegate is StandardToken { event DelegatedTo(address indexed newContract); function delegateToNewContract(DelegateERC20 newContract) public; function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function balanceOf(address who) public view returns (uint256); function approve(address spender, uint256 value) public returns (bool); function allowance(address _owner, address spender) public view returns (uint256); function totalSupply() public view returns (uint256); function increaseApproval(address spender, uint addedValue) public returns (bool); function decreaseApproval(address spender, uint subtractedValue) public returns (bool); } contract StandardDelegate is StandardToken, DelegateERC20 { function setDelegatedFrom(address addr) public; function delegateTotalSupply() public view returns (uint256); function delegateBalanceOf(address who) public view returns (uint256); function delegateTransfer(address to, uint256 value, address origSender) public returns (bool); function delegateAllowance(address owner, address spender) public view returns (uint256); function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool); function delegateApprove(address spender, uint256 value, address origSender) public returns (bool); function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool); function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool); } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function increaseApproval(address _spender, uint _addedValue) public returns (bool success); function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success); } contract TrueUSD is StandardDelegate, PausableToken, BurnableToken, NoOwner, CanDelegate { event ChangeBurnBoundsEvent(uint256 newMin, uint256 newMax); event Mint(address indexed to, uint256 amount); event WipedAccount(address indexed account, uint256 balance); function setLists(AddressList _canReceiveMintWhiteList, AddressList _canBurnWhiteList, AddressList _blackList, AddressList _noFeesList) public; function changeName(string _name, string _symbol) public; function burn(uint256 _value) public; function mint(address _to, uint256 _amount) public; function changeBurnBounds(uint newMin, uint newMax) public; function transferAllArgsNoAllowance(address _from, address _to, uint256 _value) internal; function wipeBlacklistedAccount(address account) public; function payStakingFee(address payer, uint256 value, uint80 numerator, uint80 denominator, uint256 flatRate, address otherParticipant) private returns (uint256); function changeStakingFees(uint80 _transferFeeNumerator, uint80 _transferFeeDenominator, uint80 _mintFeeNumerator, uint80 _mintFeeDenominator, uint256 _mintFeeFlat, uint80 _burnFeeNumerator, uint80 _burnFeeDenominator, uint256 _burnFeeFlat) public; function changeStaker(address newStaker) public; } /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ library NewSafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring &#39;a&#39; not being zero, but the // benefit is lost if &#39;b&#39; is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = _a / _b; // assert(_a == _b * c + _a % _b); // There is no case in which this doesn&#39;t hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } /** * @title Cash311 * @dev The main contract of the project. */ /** * @title Cash311 * @dev https://311.cash/; */ contract Cash311 { // Connecting SafeMath for safe calculations. // Подключает библиотеку безопасных вычислений к контракту. using NewSafeMath for uint; // A variable for address of the owner; // Переменная для хранения адреса владельца контракта; address owner; // A variable for address of the ERC20 token; // Переменная для хранения адреса токена ERC20; TrueUSD public token = TrueUSD(0x8dd5fbce2f6a956c3022ba3663759011dd51e73e); // A variable for decimals of the token; // Переменная для количества знаков после запятой у токена; uint private decimals = 10**18; // A variable for storing deposits of investors. // Переменная для хранения записей о сумме инвестиций инвесторов. mapping (address => uint) deposit; uint deposits; // A variable for storing amount of withdrawn money of investors. // Переменная для хранения записей о сумме снятых средств. mapping (address => uint) withdrawn; // A variable for storing reference point to count available money to withdraw. // Переменная для хранения времени отчета для инвесторов. mapping (address => uint) lastTimeWithdraw; // RefSystem mapping (address => uint) referals1; mapping (address => uint) referals2; mapping (address => uint) referals3; mapping (address => uint) referals1m; mapping (address => uint) referals2m; mapping (address => uint) referals3m; mapping (address => address) referers; mapping (address => bool) refIsSet; mapping (address => uint) refBonus; // A constructor function for the contract. It used single time as contract is deployed. // Единоразовая функция вызываемая при деплое контракта. function Cash311() public { // Sets an owner for the contract; // Устанавливает владельца контракта; owner = msg.sender; } // A function for transferring ownership of the contract (available only for the owner). // Функция для переноса права владения контракта (доступна только для владельца). function transferOwnership(address _newOwner) external { require(msg.sender == owner); require(_newOwner != address(0)); owner = _newOwner; } // RefSystem function bytesToAddress1(bytes source) internal pure returns(address parsedReferer) { assembly { parsedReferer := mload(add(source,0x14)) } return parsedReferer; } // A function for getting key info for investors. // Функция для вызова ключевой информации для инвестора. function getInfo(address _address) public view returns(uint Deposit, uint Withdrawn, uint AmountToWithdraw, uint Bonuses) { // 1) Amount of invested tokens; // 1) Сумма вложенных токенов; Deposit = deposit[_address].div(decimals); // 2) Amount of withdrawn tokens; // 3) Сумма снятых средств; Withdrawn = withdrawn[_address].div(decimals); // Amount of tokens which is available to withdraw. // Formula without SafeMath: ((Current Time - Reference Point) / 1 period)) * (Deposit * 0.0311) // Расчет количества токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) / 1 period)) * (Сумма депозита * 0.0311) uint _a = (block.timestamp.sub(lastTimeWithdraw[_address])).div(1 days).mul(deposit[_address].mul(311).div(10000)); AmountToWithdraw = _a.div(decimals); // RefSystem Bonuses = refBonus[_address].div(decimals); } // RefSystem function getRefInfo(address _address) public view returns(uint Referals1, uint Referals1m, uint Referals2, uint Referals2m, uint Referals3, uint Referals3m) { Referals1 = referals1[_address]; Referals1m = referals1m[_address].div(decimals); Referals2 = referals2[_address]; Referals2m = referals2m[_address].div(decimals); Referals3 = referals3[_address]; Referals3m = referals3m[_address].div(decimals); } function getNumber() public view returns(uint) { return deposits; } function getTime(address _address) public view returns(uint Hours, uint Minutes) { Hours = (lastTimeWithdraw[_address] % 1 days) / 1 hours; Minutes = (lastTimeWithdraw[_address] % 1 days) % 1 hours / 1 minutes; } // A "fallback" function. It is automatically being called when anybody sends ETH to the contract. Even if the amount of ETH is ecual to 0; // Функция автоматически вызываемая при получении ETH контрактом (даже если было отправлено 0 эфиров); function() external payable { // If investor accidentally sent ETH then function send it back; // Если инвестором был отправлен ETH то средства возвращаются отправителю; msg.sender.transfer(msg.value); // If the value of sent ETH is equal to 0 then function executes special algorithm: // 1) Gets amount of intended deposit (approved tokens). // 2) If there are no approved tokens then function "withdraw" is called for investors; // Если было отправлено 0 эфиров то исполняется следующий алгоритм: // 1) Заправшивается количество токенов для инвестирования (кол-во одобренных к выводу токенов). // 2) Если одобрены токенов нет, для действующих инвесторов вызывается функция инвестирования (после этого действие функции прекращается); uint _approvedTokens = token.allowance(msg.sender, address(this)); if (_approvedTokens == 0 && deposit[msg.sender] > 0) { withdraw(); return; // If there are some approved tokens to invest then function "invest" is called; // Если были одобрены токены то вызывается функция инвестирования (после этого действие функции прекращается); } else { if (msg.data.length == 20) { address referer = bytesToAddress1(bytes(msg.data)); if (referer != msg.sender) { invest(referer); return; } } invest(0x0); return; } } // RefSystem function refSystem(uint _value, address _referer) internal { refBonus[_referer] = refBonus[_referer].add(_value.div(40)); referals1m[_referer] = referals1m[_referer].add(_value); if (refIsSet[_referer]) { address ref2 = referers[_referer]; refBonus[ref2] = refBonus[ref2].add(_value.div(50)); referals2m[ref2] = referals2m[ref2].add(_value); if (refIsSet[referers[_referer]]) { address ref3 = referers[referers[_referer]]; refBonus[ref3] = refBonus[ref3].add(_value.mul(3).div(200)); referals3m[ref3] = referals3m[ref3].add(_value); } } } // RefSystem function setRef(uint _value, address referer) internal { if (deposit[referer] > 0) { referers[msg.sender] = referer; refIsSet[msg.sender] = true; referals1[referer] = referals1[referer].add(1); if (refIsSet[referer]) { referals2[referers[referer]] = referals2[referers[referer]].add(1); if (refIsSet[referers[referer]]) { referals3[referers[referers[referer]]] = referals3[referers[referers[referer]]].add(1); } } refBonus[msg.sender] = refBonus[msg.sender].add(_value.div(50)); refSystem(_value, referer); } } // A function which accepts tokens of investors. // Функция для перевода токенов на контракт. function invest(address _referer) public { // Gets amount of deposit (approved tokens); // Заправшивает количество токенов для инвестирования (кол-во одобренных к выводу токенов); uint _value = token.allowance(msg.sender, address(this)); // Transfers approved ERC20 tokens from investors address; // Переводит одобренные к выводу токены ERC20 на данный контракт; token.transferFrom(msg.sender, address(this), _value); // Transfers a fee to the owner of the contract. The fee is 10% of the deposit (or Deposit / 10) // Начисляет комиссию владельцу (10%); refBonus[owner] = refBonus[owner].add(_value.div(10)); // The special algorithm for investors who increases their deposits: // Специальный алгоритм для инвесторов увеличивающих их вклад; if (deposit[msg.sender] > 0) { // Amount of tokens which is available to withdraw. // Formula without SafeMath: ((Current Time - Reference Point) / 1 period)) * (Deposit * 0.0311) // Расчет количества токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) / 1 period)) * (Сумма депозита * 0.0311) uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender])).div(1 days).mul(deposit[msg.sender].mul(311).div(10000)); // The additional algorithm for investors who need to withdraw available dividends: // Дополнительный алгоритм для инвесторов которые имеют средства к снятию; if (amountToWithdraw != 0) { // Increasing the withdrawn tokens by the investor. // Увеличение количества выведенных средств инвестором; withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw); // Transferring available dividends to the investor. // Перевод доступных к выводу средств на кошелек инвестора; token.transfer(msg.sender, amountToWithdraw); // RefSystem uint _bonus = refBonus[msg.sender]; if (_bonus != 0) { refBonus[msg.sender] = 0; token.transfer(msg.sender, _bonus); withdrawn[msg.sender] = withdrawn[msg.sender].add(_bonus); } } // Setting the reference point to the current time. // Установка нового отчетного времени для инвестора; lastTimeWithdraw[msg.sender] = block.timestamp; // Increasing of the deposit of the investor. // Увеличение Суммы депозита инвестора; deposit[msg.sender] = deposit[msg.sender].add(_value); // End of the function for investors who increases their deposits. // Конец функции для инвесторов увеличивающих свои депозиты; // RefSystem if (refIsSet[msg.sender]) { refSystem(_value, referers[msg.sender]); } else if (_referer != 0x0 && _referer != msg.sender) { setRef(_value, _referer); } return; } // The algorithm for new investors: // Setting the reference point to the current time. // Алгоритм для новых инвесторов: // Установка нового отчетного времени для инвестора; lastTimeWithdraw[msg.sender] = block.timestamp; // Storing the amount of the deposit for new investors. // Установка суммы внесенного депозита; deposit[msg.sender] = (_value); deposits += 1; // RefSystem if (refIsSet[msg.sender]) { refSystem(_value, referers[msg.sender]); } else if (_referer != 0x0 && _referer != msg.sender) { setRef(_value, _referer); } } // A function for getting available dividends of the investor. // Функция для вывода средств доступных к снятию; function withdraw() public { // Amount of tokens which is available to withdraw. // Formula without SafeMath: ((Current Time - Reference Point) / 1 period)) * (Deposit * 0.0311) // Расчет количества токенов доступных к выводу; // Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) / 1 period)) * (Сумма депозита * 0.0311) uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender])).div(1 days).mul(deposit[msg.sender].mul(311).div(10000)); // Reverting the whole function for investors who got nothing to withdraw yet. // В случае если к выводу нет средств то функция отменяется; if (amountToWithdraw == 0) { revert(); } // Increasing the withdrawn tokens by the investor. // Увеличение количества выведенных средств инвестором; withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw); // Updating the reference point. // Formula without SafeMath: Current Time - ((Current Time - Previous Reference Point) % 1 period) // Обновление отчетного времени инвестора; // Формула без библиотеки безопасных вычислений: Текущее время - ((Текущее время - Предыдущее отчетное время) % 1 period) lastTimeWithdraw[msg.sender] = block.timestamp.sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days)); // Transferring the available dividends to the investor. // Перевод выведенных средств; token.transfer(msg.sender, amountToWithdraw); // RefSystem uint _bonus = refBonus[msg.sender]; if (_bonus != 0) { refBonus[msg.sender] = 0; token.transfer(msg.sender, _bonus); withdrawn[msg.sender] = withdrawn[msg.sender].add(_bonus); } } }
A function for getting key info for investors. Функция для вызова ключевой информации для инвестора. 1) Amount of invested tokens; 1) Сумма вложенных токенов; 2) Amount of withdrawn tokens; 3) Сумма снятых средств; Amount of tokens which is available to withdraw. Formula without SafeMath: ((Current Time - Reference Point) / 1 period)) * (Deposit * 0.0311) Расчет количества токенов доступных к выводу; Формула без библиотеки безопасных вычислений: ((Текущее время - Отчетное время) / 1 period)) * (Сумма депозита * 0.0311) RefSystem
function getInfo(address _address) public view returns(uint Deposit, uint Withdrawn, uint AmountToWithdraw, uint Bonuses) { Deposit = deposit[_address].div(decimals); Withdrawn = withdrawn[_address].div(decimals); uint _a = (block.timestamp.sub(lastTimeWithdraw[_address])).div(1 days).mul(deposit[_address].mul(311).div(10000)); AmountToWithdraw = _a.div(decimals); Bonuses = refBonus[_address].div(decimals); }
6,680,243
[ 1, 4625, 348, 7953, 560, 30, 225, 432, 445, 364, 8742, 498, 1123, 364, 2198, 395, 1383, 18, 225, 145, 102, 146, 230, 145, 126, 145, 123, 146, 233, 145, 121, 146, 242, 225, 145, 117, 145, 124, 146, 242, 225, 145, 115, 146, 238, 145, 120, 145, 127, 145, 115, 145, 113, 225, 145, 123, 145, 124, 146, 241, 146, 234, 145, 118, 145, 115, 145, 127, 145, 122, 225, 145, 121, 145, 126, 146, 231, 145, 127, 146, 227, 145, 125, 145, 113, 146, 233, 145, 121, 145, 121, 225, 145, 117, 145, 124, 146, 242, 225, 145, 121, 145, 126, 145, 115, 145, 118, 146, 228, 146, 229, 145, 127, 146, 227, 145, 113, 18, 404, 13, 16811, 434, 2198, 3149, 2430, 31, 404, 13, 225, 145, 99, 146, 230, 145, 125, 145, 125, 145, 113, 225, 145, 115, 145, 124, 145, 127, 145, 119, 145, 118, 145, 126, 145, 126, 146, 238, 146, 232, 225, 146, 229, 145, 127, 145, 123, 145, 118, 145, 126, 145, 127, 145, 115, 31, 576, 13, 16811, 434, 598, 9446, 82, 2430, 31, 890, 13, 225, 145, 99, 146, 230, 145, 125, 145, 125, 145, 113, 225, 146, 228, 145, 126, 146, 242, 146, 229, 146, 238, 146, 232, 225, 146, 228, 146, 227, 145, 118, 145, 117, 146, 228, 146, 229, 145, 115, 31, 16811, 434, 2430, 1492, 353, 2319, 358, 598, 9446, 18, 26758, 2887, 14060, 10477, 30, 14015, 3935, 2647, 300, 6268, 4686, 13, 342, 404, 3879, 3719, 380, 261, 758, 1724, 380, 374, 18, 4630, 2499, 13, 225, 145, 259, 145, 113, 146, 228, 146, 234, 145, 118, 146, 229, 225, 145, 123, 145, 127, 145, 124, 145, 121, 146, 234, 145, 118, 146, 228, 146, 229, 145, 115, 145, 113, 225, 146, 229, 145, 127, 145, 123, 145, 118, 145, 126, 145, 127, 145, 115, 225, 145, 117, 145, 127, 146, 228, 146, 229, 146, 230, 145, 128, 145, 126, 146, 238, 146, 232, 225, 145, 123, 225, 145, 115, 146, 238, 145, 115, 145, 127, 145, 117, 146, 230, 31, 225, 145, 102, 145, 127, 146, 227, 145, 125, 146, 230, 145, 124, 145, 113, 225, 145, 114, 145, 118, 145, 120, 225, 145, 114, 145, 121, 145, 114, 145, 124, 145, 121, 145, 127, 146, 229, 145, 118, 145, 123, 145, 121, 225, 145, 114, 145, 118, 145, 120, 145, 127, 145, 128, 145, 113, 146, 228, 145, 126, 146, 238, 146, 232, 225, 145, 115, 146, 238, 146, 234, 145, 121, 146, 228, 145, 124, 145, 118, 145, 126, 145, 121, 145, 122, 30, 14015, 145, 100, 145, 118, 145, 123, 146, 230, 146, 236, 145, 118, 145, 118, 225, 145, 115, 146, 227, 145, 118, 145, 125, 146, 242, 300, 225, 145, 257, 146, 229, 146, 234, 145, 118, 146, 229, 145, 126, 145, 127, 145, 118, 225, 145, 115, 146, 227, 145, 118, 145, 125, 146, 242, 13, 342, 404, 3879, 3719, 380, 261, 145, 99, 146, 230, 145, 125, 145, 125, 145, 113, 225, 145, 117, 145, 118, 145, 128, 2 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
[ 1, 3639, 445, 17142, 12, 2867, 389, 2867, 13, 1071, 1476, 1135, 12, 11890, 4019, 538, 305, 16, 2254, 3423, 9446, 82, 16, 2254, 16811, 774, 1190, 9446, 16, 2254, 605, 265, 6117, 13, 288, 203, 203, 5411, 4019, 538, 305, 273, 443, 1724, 63, 67, 2867, 8009, 2892, 12, 31734, 1769, 203, 5411, 3423, 9446, 82, 273, 598, 9446, 82, 63, 67, 2867, 8009, 2892, 12, 31734, 1769, 203, 5411, 2254, 389, 69, 273, 261, 2629, 18, 5508, 18, 1717, 12, 2722, 950, 1190, 9446, 63, 67, 2867, 5717, 2934, 2892, 12, 21, 4681, 2934, 16411, 12, 323, 1724, 63, 67, 2867, 8009, 16411, 12, 23, 2499, 2934, 2892, 12, 23899, 10019, 203, 5411, 16811, 774, 1190, 9446, 273, 389, 69, 18, 2892, 12, 31734, 1769, 203, 5411, 605, 265, 6117, 273, 1278, 38, 22889, 63, 67, 2867, 8009, 2892, 12, 31734, 1769, 203, 3639, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// File: openzeppelin-solidity/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: openzeppelin-solidity/contracts/GSN/Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: openzeppelin-solidity/contracts/ownership/Ownable.sol pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/IStaking.sol pragma solidity 0.5.0; /** * @title Staking interface, as defined by EIP-900. * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-900.md */ contract IStaking { event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); function stake(uint256 amount, bytes calldata data) external; function stakeFor(address user, uint256 amount, bytes calldata data) external; function unstake(uint256 amount, bytes calldata data) external; function totalStakedFor(address addr) public view returns (uint256); function totalStaked() public view returns (uint256); function token() external view returns (address); /** * @return False. This application does not support staking history. */ function supportsHistory() external pure returns (bool) { return false; } } // File: contracts/TokenPool.sol pragma solidity 0.5.0; /** * @title A simple holder of tokens. * This is a simple contract to hold tokens. It's useful in the case where a separate contract * needs to hold multiple distinct pools of the same token. */ contract TokenPool is Ownable { IERC20 public token; constructor(IERC20 _token) public { token = _token; } function balance() public view returns (uint256) { return token.balanceOf(address(this)); } function transfer(address to, uint256 value) external onlyOwner returns (bool) { return token.transfer(to, value); } } // File: contracts/MinePool.sol pragma solidity 0.5.0; contract MinePool is Ownable { IERC20 public shareToken; IERC20 public dollarToken; constructor(IERC20 _shareToken, IERC20 _dollarToken) public { shareToken = _shareToken; dollarToken = _dollarToken; } function shareBalance() public view returns (uint256) { return shareToken.balanceOf(address(this)); } function shareTransfer(address to, uint256 value) external onlyOwner returns (bool) { return shareToken.transfer(to, value); } function dollarBalance() public view returns (uint256) { return dollarToken.balanceOf(address(this)); } function dollarTransfer(address to, uint256 value) external onlyOwner returns (bool) { return dollarToken.transfer(to, value); } } // File: contracts/SeigniorageMining.sol pragma solidity 0.5.0; /** * @title Dollar Rewards * Forked from Ampleforth's GitHub and modified * * Distribution tokens are added to a locked pool in the contract and become unlocked over time * according to a once-configurable unlock schedule. Once unlocked, they are available to be * claimed by users. * * Distribution tokens (SHARE) accrues USD as well. * * A user may deposit tokens to accrue ownership share over the unlocked pool. This owner share * is a function of the number of tokens deposited as well as the length of time deposited. * Specifically, a user's share of the currently-unlocked pool equals their "deposit-seconds" * divided by the global "deposit-seconds". This aligns the new token distribution with long * term supporters of the project, addressing one of the major drawbacks of simple airdrops. */ contract SeigniorageMining is IStaking, Ownable { using SafeMath for uint256; event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event TokensClaimed(address indexed user, uint256 amount); event DollarsClaimed(address indexed user, uint256 amount); event TokensLocked(uint256 amount, uint256 durationSec, uint256 total); // amount: Unlocked tokens, total: Total locked tokens event TokensUnlocked(uint256 amount, uint256 total); event DollarsUnlocked(uint256 amount, uint256 total); TokenPool private _stakingPool; MinePool private _unlockedPool; MinePool private _lockedPool; // // Global accounting state // uint256 public totalLockedShares = 0; uint256 public totalStakingShares = 0; uint256 private _totalStakingShareSeconds = 0; uint256 private _lastAccountingTimestampSec = now; uint256 private _maxUnlockSchedules = 0; uint256 private _initialSharesPerToken = 0; // // User accounting state // // Represents a single stake for a user. A user may have multiple. struct Stake { uint256 stakingShares; uint256 timestampSec; } // Caches aggregated values from the User->Stake[] map to save computation. // If lastAccountingTimestampSec is 0, there's no entry for that user. struct UserTotals { uint256 stakingShares; uint256 stakingShareSeconds; uint256 lastAccountingTimestampSec; } // Aggregated staking values per user mapping(address => UserTotals) private _userTotals; // The collection of stakes for each user. Ordered by timestamp, earliest to latest. mapping(address => Stake[]) private _userStakes; // // Locked/Unlocked Accounting state // struct UnlockSchedule { uint256 initialLockedShares; uint256 unlockedShares; uint256 lastUnlockTimestampSec; uint256 startAtSec; uint256 endAtSec; uint256 durationSec; } UnlockSchedule[] public unlockSchedules; /** * @param stakingToken The token users deposit as stake. * @param shareToken Token 1 users receive as they unstake. * @param dollarToken Token 2 users receive as they unstake. * @param maxUnlockSchedules Max number of unlock stages, to guard against hitting gas limit. * @param initialSharesPerToken Number of shares to mint per staking token on first stake. */ constructor(IERC20 stakingToken, IERC20 shareToken, IERC20 dollarToken, uint256 maxUnlockSchedules, uint256 initialSharesPerToken) public { require(initialSharesPerToken > 0, 'SeigniorageMining: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new MinePool(shareToken, dollarToken); _lockedPool = new MinePool(shareToken, dollarToken); _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken; } /** * @return The token users deposit as stake. */ function getStakingToken() public view returns (IERC20) { return _stakingPool.token(); } /** * @return The token users receive as they unstake. */ function getDistributionToken() public view returns (IERC20) { assert(_unlockedPool.shareToken() == _lockedPool.shareToken()); return _unlockedPool.shareToken(); } /** * @dev Transfers amount of deposit tokens from the user. * @param amount Number of deposit tokens to stake. * @param data Not used. */ function stake(uint256 amount, bytes calldata data) external { _stakeFor(msg.sender, msg.sender, amount); } /** * @dev Transfers amount of deposit tokens from the caller on behalf of user. * @param user User address who gains credit for this stake operation. * @param amount Number of deposit tokens to stake. * @param data Not used. */ function stakeFor(address user, uint256 amount, bytes calldata data) external { _stakeFor(msg.sender, user, amount); } /** * @dev Private implementation of staking methods. * @param staker User address who deposits tokens to stake. * @param beneficiary User address who gains credit for this stake operation. * @param amount Number of deposit tokens to stake. */ function _stakeFor(address staker, address beneficiary, uint256 amount) private { require(amount > 0, 'SeigniorageMining: stake amount is zero'); require(beneficiary != address(0), 'SeigniorageMining: beneficiary is zero address'); require(totalStakingShares == 0 || totalStaked() > 0, 'SeigniorageMining: Invalid state. Staking shares exist, but no staking tokens do'); uint256 mintedStakingShares = (totalStakingShares > 0) ? totalStakingShares.mul(amount).div(totalStaked()) : amount.mul(_initialSharesPerToken); require(mintedStakingShares > 0, 'SeigniorageMining: Stake amount is too small'); updateAccounting(); // 1. User Accounting UserTotals storage totals = _userTotals[beneficiary]; totals.stakingShares = totals.stakingShares.add(mintedStakingShares); totals.lastAccountingTimestampSec = now; Stake memory newStake = Stake(mintedStakingShares, now); _userStakes[beneficiary].push(newStake); // 2. Global Accounting totalStakingShares = totalStakingShares.add(mintedStakingShares); // Already set in updateAccounting() // _lastAccountingTimestampSec = now; // interactions require(_stakingPool.token().transferFrom(staker, address(_stakingPool), amount), 'SeigniorageMining: transfer into staking pool failed'); emit Staked(beneficiary, amount, totalStakedFor(beneficiary), ""); } /** * @dev Unstakes a certain amount of previously deposited tokens. User also receives their * alotted number of distribution tokens. * @param amount Number of deposit tokens to unstake / withdraw. * @param data Not used. */ function unstake(uint256 amount, bytes calldata data) external { _unstake(amount); } /** * @param amount Number of deposit tokens to unstake / withdraw. * @return The total number of distribution tokens that would be rewarded. */ function unstakeQuery(uint256 amount) public returns (uint256, uint256) { return _unstake(amount); } /** * @dev Unstakes a certain amount of previously deposited tokens. User also receives their * alotted number of distribution tokens. * @param amount Number of deposit tokens to unstake / withdraw. * @return The total number of distribution tokens rewarded. */ function _unstake(uint256 amount) private returns (uint256, uint256) { updateAccounting(); // checks require(amount > 0, 'SeigniorageMining: unstake amount is zero'); require(totalStakedFor(msg.sender) >= amount, 'SeigniorageMining: unstake amount is greater than total user stakes'); uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div(totalStaked()); require(stakingSharesToBurn > 0, 'SeigniorageMining: Unable to unstake amount this small'); // 1. User Accounting UserTotals storage totals = _userTotals[msg.sender]; Stake[] storage accountStakes = _userStakes[msg.sender]; // Redeem from most recent stake and go backwards in time. uint256 stakingShareSecondsToBurn = 0; uint256 sharesLeftToBurn = stakingSharesToBurn; uint256 rewardAmount = 0; uint256 rewardDollarAmount = 0; while (sharesLeftToBurn > 0) { Stake storage lastStake = accountStakes[accountStakes.length - 1]; uint256 stakeTimeSec = now.sub(lastStake.timestampSec); uint256 newStakingShareSecondsToBurn = 0; if (lastStake.stakingShares <= sharesLeftToBurn) { // fully redeem a past stake newStakingShareSecondsToBurn = lastStake.stakingShares.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares); accountStakes.length--; } else { // partially redeem a past stake newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn); sharesLeftToBurn = 0; } } totals.stakingShareSeconds = totals.stakingShareSeconds.sub(stakingShareSecondsToBurn); totals.stakingShares = totals.stakingShares.sub(stakingSharesToBurn); // Already set in updateAccounting // totals.lastAccountingTimestampSec = now; // 2. Global Accounting _totalStakingShareSeconds = _totalStakingShareSeconds.sub(stakingShareSecondsToBurn); totalStakingShares = totalStakingShares.sub(stakingSharesToBurn); // Already set in updateAccounting // _lastAccountingTimestampSec = now; // interactions require(_stakingPool.transfer(msg.sender, amount), 'SeigniorageMining: transfer out of staking pool failed'); require(_unlockedPool.shareTransfer(msg.sender, rewardAmount), 'SeigniorageMining: shareTransfer out of unlocked pool failed'); require(_unlockedPool.dollarTransfer(msg.sender, rewardDollarAmount), 'SeigniorageMining: dollarTransfer out of unlocked pool failed'); emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), ""); emit TokensClaimed(msg.sender, rewardAmount); emit DollarsClaimed(msg.sender, rewardDollarAmount); require(totalStakingShares == 0 || totalStaked() > 0, "SeigniorageMining: Error unstaking. Staking shares exist, but no staking tokens do"); return (rewardAmount, rewardDollarAmount); } /** * @param currentRewardTokens The current number of distribution tokens already alotted for this * unstake op. * @param stakingShareSeconds The stakingShare-seconds that are being burned for new * distribution tokens. * @return Updated amount of distribution tokens to award. */ function computeNewReward(uint256 currentRewardTokens, uint256 stakingShareSeconds) private view returns (uint256) { uint256 newRewardTokens = totalUnlocked() .mul(stakingShareSeconds) .div(_totalStakingShareSeconds); return currentRewardTokens.add(newRewardTokens); } function computeNewDollarReward(uint256 currentRewardTokens, uint256 stakingShareSeconds) private view returns (uint256) { uint256 newRewardTokens = totalUnlockedDollars() .mul(stakingShareSeconds) .div(_totalStakingShareSeconds); return currentRewardTokens.add(newRewardTokens); } /** * @param addr The user to look up staking information for. * @return The number of staking tokens deposited for addr. */ function totalStakedFor(address addr) public view returns (uint256) { return totalStakingShares > 0 ? totalStaked().mul(_userTotals[addr].stakingShares).div(totalStakingShares) : 0; } /** * @return The total number of deposit tokens staked globally, by all users. */ function totalStaked() public view returns (uint256) { return _stakingPool.balance(); } /** * @dev Note that this application has a staking token as well as a distribution token, which * may be different. This function is required by EIP-900. * @return The deposit token used for staking. */ function token() external view returns (address) { return address(getStakingToken()); } function totalUserShareRewards(address user) external view returns (uint256) { UserTotals storage totals = _userTotals[user]; return (_totalStakingShareSeconds > 0) ? totalUnlocked().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; } function totalUserDollarRewards(address user) external view returns (uint256) { UserTotals storage totals = _userTotals[user]; return (_totalStakingShareSeconds > 0) ? totalLockedDollars().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; } /** * @dev A globally callable function to update the accounting state of the system. * Global state and state for the caller are updated. * @return [0] balance of the locked pool * @return [1] balance of the unlocked pool * @return [2] caller's staking share seconds * @return [3] global staking share seconds * @return [4] Rewards caller has accumulated * @return [5] Dollar Rewards caller has accumulated * @return [6] block timestamp */ function updateAccounting() public returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256) { unlockTokens(); // Global accounting uint256 newStakingShareSeconds = now .sub(_lastAccountingTimestampSec) .mul(totalStakingShares); _totalStakingShareSeconds = _totalStakingShareSeconds.add(newStakingShareSeconds); _lastAccountingTimestampSec = now; // User Accounting UserTotals storage totals = _userTotals[msg.sender]; uint256 newUserStakingShareSeconds = now .sub(totals.lastAccountingTimestampSec) .mul(totals.stakingShares); totals.stakingShareSeconds = totals.stakingShareSeconds .add(newUserStakingShareSeconds); totals.lastAccountingTimestampSec = now; uint256 totalUserShareRewards = (_totalStakingShareSeconds > 0) ? totalUnlocked().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; uint256 totalUserDollarRewards = (_totalStakingShareSeconds > 0) ? totalLockedDollars().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; return ( totalLocked(), totalUnlocked(), totals.stakingShareSeconds, _totalStakingShareSeconds, totalUserShareRewards, totalUserDollarRewards, now ); } /** * @return Total number of locked distribution tokens. */ function totalLocked() public view returns (uint256) { return _lockedPool.shareBalance(); } /** * @return Total number of unlocked distribution tokens. */ function totalUnlocked() public view returns (uint256) { return _unlockedPool.shareBalance(); } /** * @return Total number of locked distribution tokens. */ function totalLockedDollars() public view returns (uint256) { return _lockedPool.dollarBalance(); } /** * @return Total number of unlocked distribution tokens. */ function totalUnlockedDollars() public view returns (uint256) { return _unlockedPool.dollarBalance(); } /** * @return Number of unlock schedules. */ function unlockScheduleCount() public view returns (uint256) { return unlockSchedules.length; } function changeStakingToken(IERC20 stakingToken) external onlyOwner { _stakingPool = new TokenPool(stakingToken); } /** * @dev This funcion allows the contract owner to add more locked distribution tokens, along * with the associated "unlock schedule". These locked tokens immediately begin unlocking * linearly over the duraction of durationSec timeframe. * @param amount Number of distribution tokens to lock. These are transferred from the caller. * @param durationSec Length of time to linear unlock the tokens. */ function lockTokens(uint256 amount, uint256 startTimeSec, uint256 durationSec) external onlyOwner { require(unlockSchedules.length < _maxUnlockSchedules, 'SeigniorageMining: reached maximum unlock schedules'); // Update lockedTokens amount before using it in computations after. updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now; schedule.startAtSec = startTimeSec; schedule.endAtSec = startTimeSec.add(durationSec); schedule.durationSec = durationSec; unlockSchedules.push(schedule); totalLockedShares = totalLockedShares.add(mintedLockedShares); require(_lockedPool.shareToken().transferFrom(msg.sender, address(_lockedPool), amount), 'SeigniorageMining: transfer into locked pool failed'); emit TokensLocked(amount, durationSec, totalLocked()); } /** * @dev Moves distribution tokens from the locked pool to the unlocked pool, according to the * previously defined unlock schedules. Publicly callable. * @return Number of newly unlocked distribution tokens. */ function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lockedShareTokens; unlockedDollars = lockedDollars; } else { uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedShareTokens = unlockedShares.mul(lockedShareTokens).div(totalLockedShares); unlockedDollars = unlockedShares.mul(lockedDollars).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedShareTokens > 0) { require(_lockedPool.shareTransfer(address(_unlockedPool), unlockedShareTokens), 'SeigniorageMining: shareTransfer out of locked pool failed'); require(_lockedPool.dollarTransfer(address(_unlockedPool), unlockedDollars), 'SeigniorageMining: dollarTransfer out of locked pool failed'); emit TokensUnlocked(unlockedShareTokens, totalLocked()); emit DollarsUnlocked(unlockedDollars, totalLocked()); } return unlockedShareTokens; } /** * @dev Returns the number of unlockable shares from a given schedule. The returned value * depends on the time since the last unlock. This function updates schedule accounting, * but does not actually transfer any tokens. * @param s Index of the unlock schedule. * @return The number of unlocked shares. */ function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if(schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; if (now < schedule.startAtSec) { // do nothing } else if (now >= schedule.endAtSec) { // Special case to handle any leftover dust from integer division sharesToUnlock = (schedule.initialLockedShares.sub(schedule.unlockedShares)); schedule.lastUnlockTimestampSec = schedule.endAtSec; } else { sharesToUnlock = now.sub(schedule.lastUnlockTimestampSec) .mul(schedule.initialLockedShares) .div(schedule.durationSec); schedule.lastUnlockTimestampSec = now; } schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock); return sharesToUnlock; } }
* @title Dollar Rewards Forked from Ampleforth's GitHub and modified Distribution tokens are added to a locked pool in the contract and become unlocked over time according to a once-configurable unlock schedule. Once unlocked, they are available to be claimed by users. Distribution tokens (SHARE) accrues USD as well. A user may deposit tokens to accrue ownership share over the unlocked pool. This owner share is a function of the number of tokens deposited as well as the length of time deposited. Specifically, a user's share of the currently-unlocked pool equals their "deposit-seconds" divided by the global "deposit-seconds". This aligns the new token distribution with long term supporters of the project, addressing one of the major drawbacks of simple airdrops./ amount: Unlocked tokens, total: Total locked tokens Global accounting state User accounting state Represents a single stake for a user. A user may have multiple.
contract SeigniorageMining is IStaking, Ownable { using SafeMath for uint256; event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event TokensClaimed(address indexed user, uint256 amount); event DollarsClaimed(address indexed user, uint256 amount); event TokensLocked(uint256 amount, uint256 durationSec, uint256 total); event TokensUnlocked(uint256 amount, uint256 total); event DollarsUnlocked(uint256 amount, uint256 total); TokenPool private _stakingPool; MinePool private _unlockedPool; MinePool private _lockedPool; uint256 public totalLockedShares = 0; uint256 public totalStakingShares = 0; uint256 private _totalStakingShareSeconds = 0; uint256 private _lastAccountingTimestampSec = now; uint256 private _maxUnlockSchedules = 0; uint256 private _initialSharesPerToken = 0; struct Stake { uint256 stakingShares; uint256 timestampSec; } struct UserTotals { uint256 stakingShares; uint256 stakingShareSeconds; uint256 lastAccountingTimestampSec; } mapping(address => UserTotals) private _userTotals; mapping(address => Stake[]) private _userStakes; struct UnlockSchedule { uint256 initialLockedShares; uint256 unlockedShares; uint256 lastUnlockTimestampSec; uint256 startAtSec; uint256 endAtSec; uint256 durationSec; } UnlockSchedule[] public unlockSchedules; constructor(IERC20 stakingToken, IERC20 shareToken, IERC20 dollarToken, uint256 maxUnlockSchedules, uint256 initialSharesPerToken) public { require(initialSharesPerToken > 0, 'SeigniorageMining: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new MinePool(shareToken, dollarToken); _lockedPool = new MinePool(shareToken, dollarToken); _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken; } function getStakingToken() public view returns (IERC20) { return _stakingPool.token(); } function getDistributionToken() public view returns (IERC20) { assert(_unlockedPool.shareToken() == _lockedPool.shareToken()); return _unlockedPool.shareToken(); } function stake(uint256 amount, bytes calldata data) external { _stakeFor(msg.sender, msg.sender, amount); } function stakeFor(address user, uint256 amount, bytes calldata data) external { _stakeFor(msg.sender, user, amount); } function _stakeFor(address staker, address beneficiary, uint256 amount) private { require(amount > 0, 'SeigniorageMining: stake amount is zero'); require(beneficiary != address(0), 'SeigniorageMining: beneficiary is zero address'); require(totalStakingShares == 0 || totalStaked() > 0, 'SeigniorageMining: Invalid state. Staking shares exist, but no staking tokens do'); uint256 mintedStakingShares = (totalStakingShares > 0) ? totalStakingShares.mul(amount).div(totalStaked()) : amount.mul(_initialSharesPerToken); require(mintedStakingShares > 0, 'SeigniorageMining: Stake amount is too small'); updateAccounting(); UserTotals storage totals = _userTotals[beneficiary]; totals.stakingShares = totals.stakingShares.add(mintedStakingShares); totals.lastAccountingTimestampSec = now; Stake memory newStake = Stake(mintedStakingShares, now); _userStakes[beneficiary].push(newStake); totalStakingShares = totalStakingShares.add(mintedStakingShares); require(_stakingPool.token().transferFrom(staker, address(_stakingPool), amount), 'SeigniorageMining: transfer into staking pool failed'); emit Staked(beneficiary, amount, totalStakedFor(beneficiary), ""); } function unstake(uint256 amount, bytes calldata data) external { _unstake(amount); } function unstakeQuery(uint256 amount) public returns (uint256, uint256) { return _unstake(amount); } function _unstake(uint256 amount) private returns (uint256, uint256) { updateAccounting(); require(amount > 0, 'SeigniorageMining: unstake amount is zero'); require(totalStakedFor(msg.sender) >= amount, 'SeigniorageMining: unstake amount is greater than total user stakes'); uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div(totalStaked()); require(stakingSharesToBurn > 0, 'SeigniorageMining: Unable to unstake amount this small'); UserTotals storage totals = _userTotals[msg.sender]; Stake[] storage accountStakes = _userStakes[msg.sender]; uint256 stakingShareSecondsToBurn = 0; uint256 sharesLeftToBurn = stakingSharesToBurn; uint256 rewardAmount = 0; uint256 rewardDollarAmount = 0; while (sharesLeftToBurn > 0) { Stake storage lastStake = accountStakes[accountStakes.length - 1]; uint256 stakeTimeSec = now.sub(lastStake.timestampSec); uint256 newStakingShareSecondsToBurn = 0; if (lastStake.stakingShares <= sharesLeftToBurn) { newStakingShareSecondsToBurn = lastStake.stakingShares.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares); accountStakes.length--; newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn); sharesLeftToBurn = 0; } } totals.stakingShareSeconds = totals.stakingShareSeconds.sub(stakingShareSecondsToBurn); totals.stakingShares = totals.stakingShares.sub(stakingSharesToBurn); totalStakingShares = totalStakingShares.sub(stakingSharesToBurn); 'SeigniorageMining: transfer out of staking pool failed'); require(_unlockedPool.shareTransfer(msg.sender, rewardAmount), 'SeigniorageMining: shareTransfer out of unlocked pool failed'); require(_unlockedPool.dollarTransfer(msg.sender, rewardDollarAmount), 'SeigniorageMining: dollarTransfer out of unlocked pool failed'); emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), ""); emit TokensClaimed(msg.sender, rewardAmount); emit DollarsClaimed(msg.sender, rewardDollarAmount); require(totalStakingShares == 0 || totalStaked() > 0, "SeigniorageMining: Error unstaking. Staking shares exist, but no staking tokens do"); return (rewardAmount, rewardDollarAmount); } function _unstake(uint256 amount) private returns (uint256, uint256) { updateAccounting(); require(amount > 0, 'SeigniorageMining: unstake amount is zero'); require(totalStakedFor(msg.sender) >= amount, 'SeigniorageMining: unstake amount is greater than total user stakes'); uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div(totalStaked()); require(stakingSharesToBurn > 0, 'SeigniorageMining: Unable to unstake amount this small'); UserTotals storage totals = _userTotals[msg.sender]; Stake[] storage accountStakes = _userStakes[msg.sender]; uint256 stakingShareSecondsToBurn = 0; uint256 sharesLeftToBurn = stakingSharesToBurn; uint256 rewardAmount = 0; uint256 rewardDollarAmount = 0; while (sharesLeftToBurn > 0) { Stake storage lastStake = accountStakes[accountStakes.length - 1]; uint256 stakeTimeSec = now.sub(lastStake.timestampSec); uint256 newStakingShareSecondsToBurn = 0; if (lastStake.stakingShares <= sharesLeftToBurn) { newStakingShareSecondsToBurn = lastStake.stakingShares.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares); accountStakes.length--; newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn); sharesLeftToBurn = 0; } } totals.stakingShareSeconds = totals.stakingShareSeconds.sub(stakingShareSecondsToBurn); totals.stakingShares = totals.stakingShares.sub(stakingSharesToBurn); totalStakingShares = totalStakingShares.sub(stakingSharesToBurn); 'SeigniorageMining: transfer out of staking pool failed'); require(_unlockedPool.shareTransfer(msg.sender, rewardAmount), 'SeigniorageMining: shareTransfer out of unlocked pool failed'); require(_unlockedPool.dollarTransfer(msg.sender, rewardDollarAmount), 'SeigniorageMining: dollarTransfer out of unlocked pool failed'); emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), ""); emit TokensClaimed(msg.sender, rewardAmount); emit DollarsClaimed(msg.sender, rewardDollarAmount); require(totalStakingShares == 0 || totalStaked() > 0, "SeigniorageMining: Error unstaking. Staking shares exist, but no staking tokens do"); return (rewardAmount, rewardDollarAmount); } function _unstake(uint256 amount) private returns (uint256, uint256) { updateAccounting(); require(amount > 0, 'SeigniorageMining: unstake amount is zero'); require(totalStakedFor(msg.sender) >= amount, 'SeigniorageMining: unstake amount is greater than total user stakes'); uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div(totalStaked()); require(stakingSharesToBurn > 0, 'SeigniorageMining: Unable to unstake amount this small'); UserTotals storage totals = _userTotals[msg.sender]; Stake[] storage accountStakes = _userStakes[msg.sender]; uint256 stakingShareSecondsToBurn = 0; uint256 sharesLeftToBurn = stakingSharesToBurn; uint256 rewardAmount = 0; uint256 rewardDollarAmount = 0; while (sharesLeftToBurn > 0) { Stake storage lastStake = accountStakes[accountStakes.length - 1]; uint256 stakeTimeSec = now.sub(lastStake.timestampSec); uint256 newStakingShareSecondsToBurn = 0; if (lastStake.stakingShares <= sharesLeftToBurn) { newStakingShareSecondsToBurn = lastStake.stakingShares.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares); accountStakes.length--; newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec); rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn); rewardDollarAmount = computeNewDollarReward(rewardDollarAmount, newStakingShareSecondsToBurn); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn); lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn); sharesLeftToBurn = 0; } } totals.stakingShareSeconds = totals.stakingShareSeconds.sub(stakingShareSecondsToBurn); totals.stakingShares = totals.stakingShares.sub(stakingSharesToBurn); totalStakingShares = totalStakingShares.sub(stakingSharesToBurn); 'SeigniorageMining: transfer out of staking pool failed'); require(_unlockedPool.shareTransfer(msg.sender, rewardAmount), 'SeigniorageMining: shareTransfer out of unlocked pool failed'); require(_unlockedPool.dollarTransfer(msg.sender, rewardDollarAmount), 'SeigniorageMining: dollarTransfer out of unlocked pool failed'); emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), ""); emit TokensClaimed(msg.sender, rewardAmount); emit DollarsClaimed(msg.sender, rewardDollarAmount); require(totalStakingShares == 0 || totalStaked() > 0, "SeigniorageMining: Error unstaking. Staking shares exist, but no staking tokens do"); return (rewardAmount, rewardDollarAmount); } } else { _totalStakingShareSeconds = _totalStakingShareSeconds.sub(stakingShareSecondsToBurn); require(_stakingPool.transfer(msg.sender, amount), function computeNewReward(uint256 currentRewardTokens, uint256 stakingShareSeconds) private view returns (uint256) { uint256 newRewardTokens = totalUnlocked() .mul(stakingShareSeconds) .div(_totalStakingShareSeconds); return currentRewardTokens.add(newRewardTokens); } function computeNewDollarReward(uint256 currentRewardTokens, uint256 stakingShareSeconds) private view returns (uint256) { uint256 newRewardTokens = totalUnlockedDollars() .mul(stakingShareSeconds) .div(_totalStakingShareSeconds); return currentRewardTokens.add(newRewardTokens); } function totalStakedFor(address addr) public view returns (uint256) { return totalStakingShares > 0 ? totalStaked().mul(_userTotals[addr].stakingShares).div(totalStakingShares) : 0; } function totalStaked() public view returns (uint256) { return _stakingPool.balance(); } function token() external view returns (address) { return address(getStakingToken()); } function totalUserShareRewards(address user) external view returns (uint256) { UserTotals storage totals = _userTotals[user]; return (_totalStakingShareSeconds > 0) ? totalUnlocked().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; } function totalUserDollarRewards(address user) external view returns (uint256) { UserTotals storage totals = _userTotals[user]; return (_totalStakingShareSeconds > 0) ? totalLockedDollars().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; } function updateAccounting() public returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256) { unlockTokens(); uint256 newStakingShareSeconds = now .sub(_lastAccountingTimestampSec) .mul(totalStakingShares); _totalStakingShareSeconds = _totalStakingShareSeconds.add(newStakingShareSeconds); _lastAccountingTimestampSec = now; UserTotals storage totals = _userTotals[msg.sender]; uint256 newUserStakingShareSeconds = now .sub(totals.lastAccountingTimestampSec) .mul(totals.stakingShares); totals.stakingShareSeconds = totals.stakingShareSeconds .add(newUserStakingShareSeconds); totals.lastAccountingTimestampSec = now; uint256 totalUserShareRewards = (_totalStakingShareSeconds > 0) ? totalUnlocked().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; uint256 totalUserDollarRewards = (_totalStakingShareSeconds > 0) ? totalLockedDollars().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds) : 0; return ( totalLocked(), totalUnlocked(), totals.stakingShareSeconds, _totalStakingShareSeconds, totalUserShareRewards, totalUserDollarRewards, now ); } function totalLocked() public view returns (uint256) { return _lockedPool.shareBalance(); } function totalUnlocked() public view returns (uint256) { return _unlockedPool.shareBalance(); } function totalLockedDollars() public view returns (uint256) { return _lockedPool.dollarBalance(); } function totalUnlockedDollars() public view returns (uint256) { return _unlockedPool.dollarBalance(); } function unlockScheduleCount() public view returns (uint256) { return unlockSchedules.length; } function changeStakingToken(IERC20 stakingToken) external onlyOwner { _stakingPool = new TokenPool(stakingToken); } function lockTokens(uint256 amount, uint256 startTimeSec, uint256 durationSec) external onlyOwner { require(unlockSchedules.length < _maxUnlockSchedules, 'SeigniorageMining: reached maximum unlock schedules'); updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now; schedule.startAtSec = startTimeSec; schedule.endAtSec = startTimeSec.add(durationSec); schedule.durationSec = durationSec; unlockSchedules.push(schedule); totalLockedShares = totalLockedShares.add(mintedLockedShares); require(_lockedPool.shareToken().transferFrom(msg.sender, address(_lockedPool), amount), 'SeigniorageMining: transfer into locked pool failed'); emit TokensLocked(amount, durationSec, totalLocked()); } function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lockedShareTokens; unlockedDollars = lockedDollars; uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedShareTokens = unlockedShares.mul(lockedShareTokens).div(totalLockedShares); unlockedDollars = unlockedShares.mul(lockedDollars).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedShareTokens > 0) { require(_lockedPool.shareTransfer(address(_unlockedPool), unlockedShareTokens), 'SeigniorageMining: shareTransfer out of locked pool failed'); require(_lockedPool.dollarTransfer(address(_unlockedPool), unlockedDollars), 'SeigniorageMining: dollarTransfer out of locked pool failed'); emit TokensUnlocked(unlockedShareTokens, totalLocked()); emit DollarsUnlocked(unlockedDollars, totalLocked()); } return unlockedShareTokens; } function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lockedShareTokens; unlockedDollars = lockedDollars; uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedShareTokens = unlockedShares.mul(lockedShareTokens).div(totalLockedShares); unlockedDollars = unlockedShares.mul(lockedDollars).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedShareTokens > 0) { require(_lockedPool.shareTransfer(address(_unlockedPool), unlockedShareTokens), 'SeigniorageMining: shareTransfer out of locked pool failed'); require(_lockedPool.dollarTransfer(address(_unlockedPool), unlockedDollars), 'SeigniorageMining: dollarTransfer out of locked pool failed'); emit TokensUnlocked(unlockedShareTokens, totalLocked()); emit DollarsUnlocked(unlockedDollars, totalLocked()); } return unlockedShareTokens; } } else { function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lockedShareTokens; unlockedDollars = lockedDollars; uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedShareTokens = unlockedShares.mul(lockedShareTokens).div(totalLockedShares); unlockedDollars = unlockedShares.mul(lockedDollars).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedShareTokens > 0) { require(_lockedPool.shareTransfer(address(_unlockedPool), unlockedShareTokens), 'SeigniorageMining: shareTransfer out of locked pool failed'); require(_lockedPool.dollarTransfer(address(_unlockedPool), unlockedDollars), 'SeigniorageMining: dollarTransfer out of locked pool failed'); emit TokensUnlocked(unlockedShareTokens, totalLocked()); emit DollarsUnlocked(unlockedDollars, totalLocked()); } return unlockedShareTokens; } function unlockTokens() public returns (uint256) { uint256 unlockedShareTokens = 0; uint256 lockedShareTokens = totalLocked(); uint256 unlockedDollars = 0; uint256 lockedDollars = totalLockedDollars(); if (totalLockedShares == 0) { unlockedShareTokens = lockedShareTokens; unlockedDollars = lockedDollars; uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedShareTokens = unlockedShares.mul(lockedShareTokens).div(totalLockedShares); unlockedDollars = unlockedShares.mul(lockedDollars).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedShareTokens > 0) { require(_lockedPool.shareTransfer(address(_unlockedPool), unlockedShareTokens), 'SeigniorageMining: shareTransfer out of locked pool failed'); require(_lockedPool.dollarTransfer(address(_unlockedPool), unlockedDollars), 'SeigniorageMining: dollarTransfer out of locked pool failed'); emit TokensUnlocked(unlockedShareTokens, totalLocked()); emit DollarsUnlocked(unlockedDollars, totalLocked()); } return unlockedShareTokens; } function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if(schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; if (now < schedule.startAtSec) { sharesToUnlock = (schedule.initialLockedShares.sub(schedule.unlockedShares)); schedule.lastUnlockTimestampSec = schedule.endAtSec; sharesToUnlock = now.sub(schedule.lastUnlockTimestampSec) .mul(schedule.initialLockedShares) .div(schedule.durationSec); schedule.lastUnlockTimestampSec = now; } schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock); return sharesToUnlock; } function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if(schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; if (now < schedule.startAtSec) { sharesToUnlock = (schedule.initialLockedShares.sub(schedule.unlockedShares)); schedule.lastUnlockTimestampSec = schedule.endAtSec; sharesToUnlock = now.sub(schedule.lastUnlockTimestampSec) .mul(schedule.initialLockedShares) .div(schedule.durationSec); schedule.lastUnlockTimestampSec = now; } schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock); return sharesToUnlock; } function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if(schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; if (now < schedule.startAtSec) { sharesToUnlock = (schedule.initialLockedShares.sub(schedule.unlockedShares)); schedule.lastUnlockTimestampSec = schedule.endAtSec; sharesToUnlock = now.sub(schedule.lastUnlockTimestampSec) .mul(schedule.initialLockedShares) .div(schedule.durationSec); schedule.lastUnlockTimestampSec = now; } schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock); return sharesToUnlock; } } else { }
9,902,247
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 463, 25442, 534, 359, 14727, 1377, 27599, 329, 628, 432, 1291, 298, 1884, 451, 1807, 15668, 471, 4358, 1377, 17547, 2430, 854, 3096, 358, 279, 8586, 2845, 316, 326, 6835, 471, 12561, 25966, 1879, 813, 1377, 4888, 358, 279, 3647, 17, 1425, 7463, 7186, 4788, 18, 12419, 25966, 16, 2898, 854, 2319, 358, 506, 1377, 7516, 329, 635, 3677, 18, 1377, 17547, 2430, 261, 8325, 862, 13, 4078, 86, 3610, 587, 9903, 487, 5492, 18, 1377, 432, 729, 2026, 443, 1724, 2430, 358, 4078, 86, 344, 23178, 7433, 1879, 326, 25966, 2845, 18, 1220, 3410, 7433, 1377, 353, 279, 445, 434, 326, 1300, 434, 2430, 443, 1724, 329, 487, 5492, 487, 326, 769, 434, 813, 443, 1724, 329, 18, 1377, 23043, 1230, 16, 279, 729, 1807, 7433, 434, 326, 4551, 17, 318, 15091, 2845, 1606, 3675, 315, 323, 1724, 17, 7572, 6, 1377, 26057, 635, 326, 2552, 315, 323, 1724, 17, 7572, 9654, 1220, 5689, 87, 326, 394, 1147, 7006, 598, 1525, 1377, 2481, 1169, 3831, 5432, 434, 326, 1984, 16, 1758, 310, 1245, 434, 326, 7888, 3724, 823, 87, 434, 4143, 279, 6909, 16703, 18, 19, 3844, 30, 3967, 329, 2430, 16, 2078, 30, 10710, 8586, 2430, 8510, 2236, 310, 919, 2177, 2236, 310, 919, 868, 6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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 3265, 724, 77, 1531, 2930, 310, 353, 467, 510, 6159, 16, 14223, 6914, 288, 203, 565, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 203, 565, 871, 934, 9477, 12, 2867, 8808, 729, 16, 2254, 5034, 3844, 16, 2254, 5034, 2078, 16, 1731, 501, 1769, 203, 565, 871, 1351, 334, 9477, 12, 2867, 8808, 729, 16, 2254, 5034, 3844, 16, 2254, 5034, 2078, 16, 1731, 501, 1769, 203, 377, 203, 565, 871, 13899, 9762, 329, 12, 2867, 8808, 729, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 463, 22382, 5913, 9762, 329, 12, 2867, 8808, 729, 16, 2254, 5034, 3844, 1769, 203, 203, 565, 871, 13899, 8966, 12, 11890, 5034, 3844, 16, 2254, 5034, 3734, 2194, 16, 2254, 5034, 2078, 1769, 203, 565, 871, 13899, 7087, 329, 12, 11890, 5034, 3844, 16, 2254, 5034, 2078, 1769, 203, 565, 871, 463, 22382, 5913, 7087, 329, 12, 11890, 5034, 3844, 16, 2254, 5034, 2078, 1769, 203, 203, 565, 3155, 2864, 3238, 389, 334, 6159, 2864, 31, 203, 565, 490, 558, 2864, 3238, 389, 318, 15091, 2864, 31, 203, 565, 490, 558, 2864, 3238, 389, 15091, 2864, 31, 203, 203, 565, 2254, 5034, 1071, 2078, 8966, 24051, 273, 374, 31, 203, 565, 2254, 5034, 1071, 2078, 510, 6159, 24051, 273, 374, 31, 203, 565, 2254, 5034, 3238, 389, 4963, 510, 6159, 9535, 6762, 273, 374, 31, 203, 565, 2254, 5034, 3238, 389, 2722, 3032, 310, 4921, 2194, 273, 2037, 31, 203, 565, 2254, 5034, 3238, 389, 1896, 7087, 27073, 273, 374, 31, 203, 565, 2254, 5034, 3238, 389, 6769, 24051, 2173, 1345, 273, 374, 31, 203, 203, 203, 565, 1958, 934, 911, 288, 203, 3639, 2254, 5034, 384, 6159, 24051, 31, 203, 3639, 2254, 5034, 2858, 2194, 31, 203, 565, 289, 203, 203, 565, 1958, 2177, 31025, 288, 203, 3639, 2254, 5034, 384, 6159, 24051, 31, 203, 3639, 2254, 5034, 384, 6159, 9535, 6762, 31, 203, 3639, 2254, 5034, 1142, 3032, 310, 4921, 2194, 31, 203, 565, 289, 203, 203, 203, 203, 565, 2874, 12, 2867, 516, 2177, 31025, 13, 3238, 389, 1355, 31025, 31, 203, 565, 2874, 12, 2867, 516, 934, 911, 63, 5717, 3238, 389, 1355, 510, 3223, 31, 203, 565, 1958, 3967, 6061, 288, 203, 3639, 2254, 5034, 2172, 8966, 24051, 31, 203, 3639, 2254, 5034, 25966, 24051, 31, 203, 3639, 2254, 5034, 1142, 7087, 4921, 2194, 31, 203, 3639, 2254, 5034, 787, 861, 2194, 31, 203, 3639, 2254, 5034, 679, 861, 2194, 31, 203, 3639, 2254, 5034, 3734, 2194, 31, 203, 565, 289, 203, 203, 565, 3967, 6061, 8526, 1071, 7186, 27073, 31, 203, 203, 565, 3885, 12, 45, 654, 39, 3462, 384, 6159, 1345, 16, 467, 654, 39, 3462, 7433, 1345, 16, 467, 654, 39, 3462, 302, 25442, 1345, 16, 2254, 5034, 943, 7087, 27073, 16, 203, 5411, 2254, 5034, 2172, 24051, 2173, 1345, 13, 1071, 288, 203, 3639, 2583, 12, 6769, 24051, 2173, 1345, 405, 374, 16, 296, 1761, 724, 77, 1531, 2930, 310, 30, 2172, 24051, 2173, 1345, 353, 3634, 8284, 203, 203, 3639, 389, 334, 6159, 2864, 273, 394, 3155, 2864, 12, 334, 6159, 1345, 1769, 203, 3639, 389, 318, 15091, 2864, 273, 394, 490, 558, 2864, 12, 14419, 1345, 16, 302, 25442, 1345, 1769, 203, 3639, 389, 15091, 2864, 273, 394, 490, 558, 2864, 12, 14419, 1345, 16, 302, 25442, 1345, 1769, 203, 3639, 389, 1896, 7087, 27073, 273, 943, 7087, 27073, 31, 203, 3639, 389, 6769, 24051, 2173, 1345, 273, 2172, 24051, 2173, 1345, 31, 203, 565, 289, 203, 203, 565, 445, 21491, 6159, 1345, 1435, 1071, 1476, 1135, 261, 45, 654, 39, 3462, 13, 288, 203, 3639, 327, 389, 334, 6159, 2864, 18, 2316, 5621, 203, 565, 289, 203, 203, 565, 445, 336, 9003, 1345, 1435, 1071, 1476, 1135, 261, 45, 654, 39, 3462, 13, 288, 203, 3639, 1815, 24899, 318, 15091, 2864, 18, 14419, 1345, 1435, 422, 389, 15091, 2864, 18, 14419, 1345, 10663, 203, 3639, 327, 389, 318, 15091, 2864, 18, 14419, 1345, 5621, 203, 565, 289, 203, 203, 565, 445, 384, 911, 12, 11890, 5034, 3844, 16, 1731, 745, 892, 501, 13, 3903, 288, 203, 3639, 389, 334, 911, 1290, 12, 3576, 18, 15330, 16, 1234, 18, 15330, 16, 3844, 1769, 203, 565, 289, 203, 203, 565, 445, 384, 911, 1290, 12, 2867, 729, 16, 2254, 5034, 3844, 16, 1731, 745, 892, 501, 13, 3903, 288, 203, 3639, 389, 334, 911, 1290, 12, 3576, 18, 15330, 16, 729, 16, 3844, 1769, 203, 565, 289, 203, 203, 565, 445, 389, 334, 911, 1290, 12, 2867, 384, 6388, 16, 1758, 27641, 74, 14463, 814, 16, 2254, 5034, 3844, 13, 3238, 288, 203, 3639, 2583, 12, 8949, 405, 374, 16, 296, 1761, 724, 77, 1531, 2930, 310, 30, 384, 911, 3844, 353, 3634, 8284, 203, 3639, 2583, 12, 70, 4009, 74, 14463, 814, 480, 1758, 12, 20, 3631, 296, 1761, 724, 77, 1531, 2930, 310, 30, 27641, 74, 14463, 814, 353, 3634, 1758, 8284, 203, 3639, 2583, 12, 4963, 510, 6159, 24051, 422, 374, 747, 2078, 510, 9477, 1435, 405, 374, 16, 203, 7734, 296, 1761, 724, 77, 1531, 2930, 310, 30, 1962, 919, 18, 934, 6159, 24123, 1005, 16, 1496, 1158, 384, 6159, 2430, 741, 8284, 203, 203, 3639, 2254, 5034, 312, 474, 329, 510, 6159, 24051, 273, 261, 4963, 510, 6159, 24051, 405, 374, 13, 203, 5411, 692, 2078, 510, 6159, 24051, 18, 16411, 12, 8949, 2934, 2892, 12, 4963, 510, 9477, 10756, 203, 5411, 294, 3844, 18, 16411, 24899, 6769, 24051, 2173, 1345, 1769, 203, 3639, 2583, 12, 81, 474, 329, 510, 6159, 24051, 405, 374, 16, 296, 1761, 724, 77, 1531, 2930, 310, 30, 934, 911, 3844, 353, 4885, 5264, 8284, 203, 203, 3639, 1089, 3032, 310, 5621, 203, 203, 3639, 2177, 31025, 2502, 19489, 273, 389, 1355, 31025, 63, 70, 4009, 74, 14463, 814, 15533, 203, 3639, 19489, 18, 334, 6159, 24051, 273, 19489, 18, 334, 6159, 24051, 18, 1289, 12, 81, 474, 329, 510, 6159, 24051, 1769, 203, 3639, 19489, 18, 2722, 3032, 310, 4921, 2194, 273, 2037, 31, 203, 203, 3639, 934, 911, 3778, 394, 510, 911, 273, 934, 911, 12, 81, 474, 329, 510, 6159, 24051, 16, 2037, 1769, 203, 3639, 389, 1355, 510, 3223, 2 ]
./full_match/1/0x6f9140097Ab6278B41Cf9597a597030207b8D75d/sources/lib/seaport-core/src/lib/Executor.sol
* @dev Internal pure function to retrieve the current conduit key set for the accumulator. @param accumulator An open-ended array that collects transfers to execute against a given conduit in a single call. @return accumulatorConduitKey The conduit key currently set for the accumulator./ Retrieve the current conduit key from the accumulator.
function _getAccumulatorConduitKey(bytes memory accumulator) internal pure returns (bytes32 accumulatorConduitKey) { assembly { accumulatorConduitKey := mload(add(accumulator, Accumulator_conduitKey_ptr)) } }
9,675,976
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 3186, 16618, 445, 358, 4614, 326, 783, 356, 2544, 305, 498, 444, 364, 1377, 326, 13514, 18, 632, 891, 13514, 1922, 1696, 17, 3934, 526, 716, 30976, 29375, 358, 1836, 10792, 5314, 279, 864, 356, 2544, 305, 316, 279, 2202, 745, 18, 632, 2463, 13514, 442, 2544, 305, 653, 1021, 356, 2544, 305, 498, 4551, 444, 364, 326, 1171, 9079, 13514, 18, 19, 10708, 326, 783, 356, 2544, 305, 498, 628, 326, 13514, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 588, 27361, 442, 2544, 305, 653, 12, 3890, 3778, 13514, 13, 203, 3639, 2713, 203, 3639, 16618, 203, 3639, 1135, 261, 3890, 1578, 13514, 442, 2544, 305, 653, 13, 203, 565, 288, 203, 3639, 19931, 288, 203, 5411, 13514, 442, 2544, 305, 653, 519, 312, 945, 12, 1289, 12, 8981, 18514, 16, 15980, 18514, 67, 591, 2544, 305, 653, 67, 6723, 3719, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
//No Colored Allowed by DappVinci //The 'tokenURI' function returns SVG // SPDX-License-Identifier: MIT pragma solidity 0.7.0; contract Ownable { string public constant not_cur_owner108 = "018001"; //inject NONSTANDARD NAMING string public constant no_xfer_2_0983 = "018002"; //inject NONSTANDARD NAMING address public owner; event OWNERSHIPTRANSFERRED733(address indexed previousOwner, address indexed newOwner); //inject NONSTANDARD NAMING modifier ONLYOWNER618(){ //inject NONSTANDARD NAMING require(msg.sender == owner, not_cur_owner108); _; } function TRANSFEROWNERSHIP914(address _newOwner) public ONLYOWNER618 { //inject NONSTANDARD NAMING require(_newOwner != address(0), no_xfer_2_0983); emit OWNERSHIPTRANSFERRED733(owner, _newOwner); owner = _newOwner; }} library AddressUtils { function ISCONTRACT915(address _addr) internal view returns (bool addressCheck) { //inject NONSTANDARD NAMING bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(_addr) } // solhint-disable-line addressCheck = (codehash != 0x0 && codehash != accountHash); }} interface ERC165{ function SUPPORTSINTERFACE217(bytes4 _interfaceID) external view returns (bool); //inject NONSTANDARD NAMING } contract SupportsInterface is ERC165 { mapping(bytes4 => bool) internal supportedInterfaces; function SUPPORTSINTERFACE217( //inject NONSTANDARD NAMING bytes4 _interfaceID) external override view returns (bool) { return supportedInterfaces[_interfaceID]; }} library SafeMath { string constant overflow201 = "008001"; //inject NONSTANDARD NAMING string constant subtrahend_greater_then_minuend467 = "008002"; //inject NONSTANDARD NAMING function ADD46(uint256 _addend1, uint256 _addend2) internal pure returns (uint256 sum) { //inject NONSTANDARD NAMING sum = _addend1 + _addend2; require(sum >= _addend1, overflow201); }} interface ERC721TokenReceiver { function ONERC721RECEIVED244(address _operator, address _from, uint256 _tokenId, bytes calldata _data) external returns(bytes4); //inject NONSTANDARD NAMING } interface ERC721{ event TRANSFER898(address indexed _from, address indexed _to, uint256 indexed _tokenId); //inject NONSTANDARD NAMING event APPROVAL562(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); //inject NONSTANDARD NAMING event APPROVALFORALL444(address indexed _owner, address indexed _operator, bool _approved); //inject NONSTANDARD NAMING function SAFETRANSFERFROM138(address _from, address _to, uint256 _tokenId, bytes calldata _data) external; //inject NONSTANDARD NAMING function SAFETRANSFERFROM138(address _from, address _to, uint256 _tokenId) external; //inject NONSTANDARD NAMING function TRANSFERFROM921(address _from, address _to, uint256 _tokenId) external; //inject NONSTANDARD NAMING function APPROVE958(address _approved, uint256 _tokenId) external; //inject NONSTANDARD NAMING function SETAPPROVALFORALL105(address _operator, bool _approved) external; //inject NONSTANDARD NAMING function BALANCEOF270(address _owner) external view returns (uint256); //inject NONSTANDARD NAMING function OWNEROF456(uint256 _tokenId) external view returns (address); //inject NONSTANDARD NAMING function GETAPPROVED790(uint256 _tokenId) external view returns (address); //inject NONSTANDARD NAMING function ISAPPROVEDFORALL873(address _owner, address _operator) external view returns (bool); //inject NONSTANDARD NAMING } contract NFToken is ERC721, SupportsInterface { using SafeMath for uint256; using AddressUtils for address; string constant zero_address727 = "003001"; //inject NONSTANDARD NAMING string constant not_valid_nft741 = "003002"; //inject NONSTANDARD NAMING string constant not_owner_or_operator13 = "003003"; //inject NONSTANDARD NAMING string constant not_owner_approwed_or_operator515 = "003004"; //inject NONSTANDARD NAMING string constant not_able_to_receive_nft141 = "003005"; //inject NONSTANDARD NAMING string constant nft_already_exists595 = "003006"; //inject NONSTANDARD NAMING string constant not_owner152 = "003007"; //inject NONSTANDARD NAMING string constant is_owner158 = "003008"; //inject NONSTANDARD NAMING bytes4 internal constant magic_on_erc721_received864 = 0x150b7a02; //inject NONSTANDARD NAMING mapping (uint256 => address) internal idToOwner; mapping (uint256 => address) internal idToApproval; mapping (address => uint256) private ownerToNFTokenCount; mapping (address => mapping (address => bool)) internal ownerToOperators; modifier CANOPERATE488(uint256 _tokenId) { //inject NONSTANDARD NAMING address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == msg.sender || ownerToOperators[tokenOwner][msg.sender], not_owner_or_operator13); _; } modifier CANTRANSFER713(uint256 _tokenId) { //inject NONSTANDARD NAMING address tokenOwner = idToOwner[_tokenId]; require( tokenOwner == msg.sender || idToApproval[_tokenId] == msg.sender || ownerToOperators[tokenOwner][msg.sender], not_owner_approwed_or_operator515); _; } modifier VALIDNFTOKEN826(uint256 _tokenId) { //inject NONSTANDARD NAMING require(idToOwner[_tokenId] != address(0), not_valid_nft741); _; } function SAFETRANSFERFROM138(address _from, address _to, uint256 _tokenId, bytes calldata _data) external override{ //inject NONSTANDARD NAMING _SAFETRANSFERFROM261(_from, _to, _tokenId, _data); } function SAFETRANSFERFROM138(address _from, address _to, uint256 _tokenId) external override { //inject NONSTANDARD NAMING _SAFETRANSFERFROM261(_from, _to, _tokenId, ""); } function TRANSFERFROM921(address _from, address _to, uint256 _tokenId) external override CANTRANSFER713(_tokenId) VALIDNFTOKEN826(_tokenId) { //inject NONSTANDARD NAMING address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == _from, not_owner152); require(_to != address(0), zero_address727); _TRANSFER192(_to, _tokenId); } function APPROVE958( address _approved, uint256 _tokenId) external override CANOPERATE488(_tokenId) VALIDNFTOKEN826(_tokenId) { //inject NONSTANDARD NAMING address tokenOwner = idToOwner[_tokenId]; require(_approved != tokenOwner, is_owner158); idToApproval[_tokenId] = _approved; emit APPROVAL562(tokenOwner, _approved, _tokenId); } function SETAPPROVALFORALL105(address _operator, bool _approved) external override { //inject NONSTANDARD NAMING ownerToOperators[msg.sender][_operator] = _approved; emit APPROVALFORALL444(msg.sender, _operator, _approved); } function BALANCEOF270(address _owner) external override view returns (uint256) { //inject NONSTANDARD NAMING require(_owner != address(0), zero_address727); return _GETOWNERNFTCOUNT378(_owner); } function OWNEROF456(uint256 _tokenId) external override view returns (address _owner){ //inject NONSTANDARD NAMING _owner = idToOwner[_tokenId]; require(_owner != address(0), not_valid_nft741); } function GETAPPROVED790(uint256 _tokenId) //inject NONSTANDARD NAMING external override view VALIDNFTOKEN826(_tokenId) returns (address) { return idToApproval[_tokenId]; } function ISAPPROVEDFORALL873(address _owner, address _operator) external override view returns (bool) { //inject NONSTANDARD NAMING return ownerToOperators[_owner][_operator]; } function _TRANSFER192(address _to, uint256 _tokenId) internal { //inject NONSTANDARD NAMING address from = idToOwner[_tokenId]; _CLEARAPPROVAL604(_tokenId); _REMOVENFTOKEN830(from, _tokenId); _ADDNFTOKEN970(_to, _tokenId); emit TRANSFER898(from, _to, _tokenId); } function _MINT19(address _to, uint256 _tokenId) internal virtual { //inject NONSTANDARD NAMING require(_to != address(0), zero_address727); require(idToOwner[_tokenId] == address(0), nft_already_exists595); _ADDNFTOKEN970(_to, _tokenId); emit TRANSFER898(address(0), _to, _tokenId); } function _REMOVENFTOKEN830(address _from, uint256 _tokenId) internal virtual { //inject NONSTANDARD NAMING require(idToOwner[_tokenId] == _from, not_owner152); ownerToNFTokenCount[_from] = ownerToNFTokenCount[_from] - 1; delete idToOwner[_tokenId]; } function _ADDNFTOKEN970(address _to, uint256 _tokenId) internal virtual { //inject NONSTANDARD NAMING require(idToOwner[_tokenId] == address(0), nft_already_exists595); idToOwner[_tokenId] = _to; ownerToNFTokenCount[_to] = ownerToNFTokenCount[_to].ADD46(1); } function _GETOWNERNFTCOUNT378(address _owner) internal virtual view returns (uint256){ //inject NONSTANDARD NAMING return ownerToNFTokenCount[_owner]; } function _SAFETRANSFERFROM261(address _from, address _to, uint256 _tokenId, bytes memory _data) //inject NONSTANDARD NAMING private CANTRANSFER713(_tokenId) VALIDNFTOKEN826(_tokenId){ address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == _from, not_owner152); require(_to != address(0), zero_address727); _TRANSFER192(_to, _tokenId); if (_to.ISCONTRACT915()) { bytes4 retval = ERC721TokenReceiver(_to).ONERC721RECEIVED244(msg.sender, _from, _tokenId, _data); require(retval == magic_on_erc721_received864, not_able_to_receive_nft141); }} function _CLEARAPPROVAL604(uint256 _tokenId) private { //inject NONSTANDARD NAMING if (idToApproval[_tokenId] != address(0)) { delete idToApproval[_tokenId]; }}} contract NFTokenMetadata is NFToken { string internal nftName; string internal nftSymbol; mapping (uint256 => string) internal idToUri; function NAME497() external view returns (string memory _name){ //inject NONSTANDARD NAMING _name = nftName; } function SYMBOL48() external view returns (string memory _symbol) { //inject NONSTANDARD NAMING _symbol = nftSymbol; }} contract NoColoredAllowed is NFTokenMetadata, Ownable{ constructor() { nftName = "No Colored Allowed"; nftSymbol = "XCA"; owner = msg.sender; supportedInterfaces[0x01ffc9a7] = true; // ERC165 supportedInterfaces[0x80ac58cd] = true; // ERC721 supportedInterfaces[0x5b5e139f] = true; // ERC721Metadata } uint256 public artTotal; uint256 public artCap = 144; string public constant arthead473 = '<svg version="1.1" id="NoColoredAllowed" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1000 1000"><symbol id="a" viewBox="-7.9 -13 15.8 26"><path d="M2.6-12.7c0 6 .4-.3-5-.3-3 0-5.5 2-5.5 6.8 0 6.2 2.1 9.5 10.5 8.4 0 2.3.2 3.7-.5 4.8-.9 1.4-4.3 1.3-4.9-1.7h-5c.4 6.2 5.9 8.9 10.9 7.1 6.3-2.3 4.6-9 4.6-25.1H2.6zm0 10.9c-9.2 1.6-4.8-10.7-.7-5.9.9 1.2.7 2.8.7 5.9z"/></symbol><symbol id="b" viewBox="-7.7 -17.9 15.4 35.9"><path d="M-7.7-17.7v35.6h5.1c0-20.1-1.5-10 4.8-10C7.4 7.9 7.6 4 7.6-.5 7.6-10.3 9.1-18 2.3-18c-1.9 0-2.9.4-4.8 2.6-.1-3 .9-2.3-5.2-2.3zM2.5-.1c0 4.3-5 3.7-5 .2 0-10.6-.2-11 .7-12.1 1-1.2 3-1.1 3.8.1.7 1.3.5 2.5.5 11.8z"/></symbol><symbol id="c" viewBox="-7.6 -13 15.3 26"><path d="M-2.5-5.4c0-3.1 4.6-3.7 5 .1h5.1c0-8.6-11-10-14.2-4C-8.2-6.5-7.5 5.8-7.4 7c1.3 8.3 15 8.4 15-2.2H2.5c0 3.5-3.2 3.5-4.3 2.3-.9-.9-.7-1.2-.7-12.5z"/></symbol><symbol id="e" viewBox="-7.6 -13.1 15.3 26.1"><path d="M7.6-1.9C-4.5-1.9-2.5-.8-2.5-5.4c0-3.1 4.6-3.7 5 .1h5.1C7.6-15-7.6-16.7-7.6-4.2-7.6 5.2-8.4 9.4-4 12c4.4 2.6 11.7.5 11.7-6.9v-7zm-10.1 4c6.3 0 5-.9 5 2.9 0 2-1 2.9-2.5 2.9-2.9 0-2.5-2.9-2.5-5.8z"/></symbol><symbol id="f" viewBox="-5.8 -17.8 11.6 35.6"><path d="M-3.2-17.8c0 24.6 1 21.4-2.5 21.4 0 5-.8 4 2.5 4 0 8.5.9 10.2 8.9 10.2 0-6 .7-4.8-2.3-4.8-1.9 0-1.5-1.8-1.5-5.4 4.8 0 3.8 1 3.8-4-5.1 0-3.8 4.3-3.8-21.4h-5.1z"/></symbol><symbol id="h" viewBox="-7.7 -17.8 15.4 35.6"><path id="h_1_" d="M-7.7-17.8v35.6h5.1c0-20.5-1.6-10 4.9-10 6.6 0 5.2-5.9 5.2-25.6h-5C2.5 1 2.7.9 1.8 1.9.9 3.1-1.4 3-2 1.8-2.8.6-2.6 0-2.6-17.8h-5.1z"/></symbol><symbol id="i" viewBox="-2.7 -17.9 5.3 35.7"><path d="M-2.6 12.6c0 6.4-1.3 5.1 5.1 5.1.1-6.4 1.4-5.1-5.1-5.1zm0-30.5V7.5h5.1v-25.4h-5.1z"/></symbol><symbol id="m" viewBox="-12.7 -12.8 25.4 25.7"><path d="M-12.7-12.8v25.4h5.1c0-5.7-.5.3 4.9.3 1.5 0 3-.5 4.6-2.5 4.1 4.5 10.8 2.9 10.8-3.6v-19.5H7.6C7.6 6 7.8 5.8 7 6.9c-1 1.2-3.2 1-3.8-.1-.8-1.2-.7-1.3-.7-19.6h-5.1C-2.5 5.6-1.8 7.7-5 7.7c-3.4 0-2.5-2.1-2.5-20.5h-5.2z"/></symbol><symbol id="n" viewBox="-7.7 -12.8 15.4 25.6"><path d="M-7.7-12.8v25.4h5.1c0-5.7-.5.3 4.9.3 6.6 0 5.2-5.9 5.2-25.6h-5c0 18.7.2 18.5-.7 19.6-1 1.2-3.2 1-3.8-.1-.8-1.2-.6-1.8-.6-19.6h-5.1z"/></symbol><symbol id="o" viewBox="-7.8 -13.1 15.7 26.3"><path d="M7.7 4.1c0-8.8.9-13.5-3.5-16.1-4.1-2.5-10.6-.8-11.5 4.9-4.1 26.8 15 23 15 11.2zM-2.4-5.1c0-3.9 5-3.9 5 0 0 10.7.3 11.2-.6 12.2-.9 1-2.7 1-3.7 0-.9-1-.7-1.6-.7-12.2z"/></symbol><symbol id="p" viewBox="-7.7 -18 15.3 35.9"><path d="M-7.7-18v35.6h5.1c0-3.5-.5-2.3 2-.5 1.6 1.2 5.8 1.3 7.3-1.6 1.5-2.8.8-18.9.7-19.1C6.8-8.8.3-9.5-2.5-5.4c-.1 0-.1 1.1-.1-12.5h-5.1zM2.5 9.4c0 4.8-5 4.4-5 .3-.1-10.7-.3-10.8.7-11.8 1.1-1.2 3.1-1 3.8.1.7 1.2.5 1.3.5 11.4z"/></symbol><symbol id="r" viewBox="-6 -12.8 12 25.6"><path d="M-6-12.8v25.4h5.1c0-6-.2.3 6.8.3 0-8.3 1.1-4.1-3.3-5.4C-1.9 6.1-.9 2-.9-12.8H-6z"/></symbol><symbol id="s" viewBox="-7.7 -13 15.4 26"><path d="M2.4 5.6c-.1 3.5-5.1 3.4-5.1 0C-2.7 1.9 4 3 6.4-1.2 13-12.9-7.4-18.6-7.7-5.3c6.7 0 3.9.5 5.5-2s6.8.3 4.3 3.7c-.7 1-2.2 1.4-4.5 2.2C-8.7 1-8.7 7.7-5.3 11c4.2 4.2 12.5 1.9 12.5-5.4H2.4z"/></symbol><symbol id="t" viewBox="-5.5 -16.6 10.9 33.2"><path d="M-2.8 8.7c0 9.7-1.5 7.7 5.1 7.7 0-9.4-1-7.7 3.1-7.7 0-5 .8-4-3.1-4 0-15.5-.6-16.3 1.7-16.5 1.9-.2 1.4.9 1.4-4.9-10.5 0-8.2 4.6-8.2 21.4-3.3 0-2.5-1-2.5 4h2.5z"/></symbol><symbol id="u" viewBox="-7.7 -12.8 15.4 25.6"><path d="M7.7 12.8v-25.4H2.6c0 5.7.5-.3-4.9-.3-6.6 0-5.2 5.9-5.2 25.6h5.1C-2.5-6-2.7-5.8-1.8-6.9c.9-1.2 3.2-1 3.9.1.7 1.2.5 1.8.5 19.6h5.1z"/></symbol><symbol id="y" viewBox="-8.9 -17.8 17.7 35.7"><path d="M-8.9 17.8h5.4c4.7-21.1 2.5-21 7.1 0h5.2c-7.3-30-6.9-35.6-14.3-35.6-1.9 0-1.4-1-1.4 4.8 2.6 0 3.3-.1 4.2 3.1 1.2 4.3 1.6.6-6.2 27.7z"/></symbol><path id="bg" class="bg" d="M0 0h1000v1000H0z"/><g id="DV"><path id="V" d="M976.7 927.8c-16.6 66.5-9.9 66.8-26.6 0h26.6z"/><path id="D" d="M926.7 927.9c31.1-2 31.2 51.9 0 49.9v-49.9z"/></g><path id="hilite" d="M428.5 471h361.9v58H428.5z"/><path id="T" d="M199.7 442v-31.1c-7.3 0-5.8 1.3-5.8-4.9h16.6c0 6.1 1.5 4.9-5.8 4.9V442h-5z"/><use xlink:href="#h" width="15.4" height="35.6" x="-7.7" y="-17.8" transform="matrix(1 0 0 -1 221.781 423.8)"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 242.106 428.925)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 262.83 428.775)"/><path id="k" d="M275.9 441.5v-35.6h5.1c0 22.9-.1 21.3.1 21.3 7.4-13.3 4.8-11.1 11.2-11.1l-6 10.3 7.3 15c-7 0-4.6 2.2-10.1-11-3.1 4.8-2.5 2.4-2.5 11h-5.1z"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 303.423 428.925)"/><use xlink:href="#f" width="11.6" height="35.6" x="-5.8" y="-17.8" transform="matrix(1 0 0 -1 330.453 423.8)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 346.17 428.925)"/><use xlink:href="#r" width="12" height="25.6" x="-6" y="-12.8" transform="matrix(1 0 0 -1 365.228 428.775)"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 392.42 428.925)"/><use xlink:href="#u" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 412.376 429.075)"/><use xlink:href="#b" width="15.4" height="35.9" x="-7.7" y="-17.9" transform="matrix(1 0 0 -1 433.376 423.95)"/><use xlink:href="#m" width="25.4" height="25.7" x="-12.7" y="-12.8" transform="matrix(1 0 0 -1 459.15 428.775)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 479.836 423.8)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 491 425.075)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 503.9 425.075)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 516.1 423.8)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 532.024 428.775)"/><path id="g" d="M550.6 444.5c.2 3 5 3.8 5-.2 0-9.6.9-2.4-4.8-2.4-6.8 0-5.3-7.5-5.3-17.5 0-3.5-.2-6.2 2.5-7.8 1.1-.8 3.4-.8 4.5-.5 3.4 1 3.2 4.6 3.2.1h5.1v28.5c0 9.3-14 10.7-15.2-.1h5zm0-10.7c0 4.3 5 3.7 5 .2 0-10.7.2-11-.7-12.1-1-1.2-3-1.1-3.8.1-.8 1.3-.5 2.5-.5 11.8z"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 580.097 425.075)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 595.752 428.925)"/><path id="S" d="M636.8 416.1c-6.1 0-5.1.4-5.1-1.1 0-5.6-7-6.1-7 .3 0 8 10.7 3.2 12 12.6 2.4 18.5-17.3 18.2-17.3 3.6 6.1 0 5.1-.5 5.1 1.6 0 4.6 5.5 4.4 6.8 2.2.8-1.4.7-6.3 0-7.6-1.5-2.3-8.4-2.6-10.5-6.7-8-15.6 16-23 16-4.9z"/><use xlink:href="#u" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 649.37 429.075)"/><use xlink:href="#p" width="15.3" height="35.9" x="-7.7" y="-18" transform="matrix(1 0 0 -1 670.37 433.9)"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 690.895 429.075)"/><use xlink:href="#r" width="12" height="25.6" x="-6" y="-12.8" transform="matrix(1 0 0 -1 709.72 428.925)"/><path id="R" d="M719.9 441.5v-35.6h8.2c10.3 0 9.9 11.7 8 15.8-3.2 7.2-6.1-4.4 2.1 19.8-7.2 0-4.5 3-10.2-15.2-4.1 0-3-3-3 15.2h-5.1zm5.1-30.8c0 13.3-1 11.1 2.9 11.1 6.2 0 3.8-8.9 3.3-9.7-1.1-1.7-3.8-1.4-6.2-1.4z"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 749.444 428.925)"/><use xlink:href="#r" width="12" height="25.6" x="-6" y="-12.8" transform="matrix(1 0 0 -1 768.87 428.775)"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 785.144 429.065)"/><path id="dot" d="M797.8 441.5c0-6-1.2-4.8 4.8-4.8 0 6 1.2 4.8-4.8 4.8z"/><path id="U" d="M212.2 478c0 27.9 1.6 32.4-5.1 35.2-4.3 1.9-9-.4-10.8-4.4-.9-1.9-.6-.6-.6-30.8h5.1c0 28.7-1.1 30.8 3.2 30.8 4.2 0 3.1-2 3.1-30.8h5.1z"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 225.63 500.776)"/><use xlink:href="#f" width="11.6" height="35.6" x="-5.8" y="-17.8" transform="matrix(1 0 0 -1 242.555 495.95)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 258.204 500.925)"/><use xlink:href="#r" width="12" height="25.6" x="-6" y="-12.8" transform="matrix(1 0 0 -1 276.73 500.776)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 290.454 497.076)"/><use xlink:href="#u" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 307.788 501.075)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 328.228 500.776)"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 348.253 501.075)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 363.903 497.18)"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 379.653 500.925)"/><path id="l" d="M392 478h5.1c0 32.5-.9 30.7 2.5 31.1 0 5.2.8 5.3-3.2 4.5-5.8-1.2-4.4-4.6-4.4-35.6z"/><use xlink:href="#y" width="17.7" height="35.7" x="-8.9" y="-17.8" transform="matrix(1 0 0 -1 409.513 506.05)"/><g id="lit" fill="#fff"><path id="w" d="M456.9 488.3l-6 25.4h-4.5c-3-16.2-2.7-15-2.9-15-3.4 18.1-1.3 15-7.3 15l-6-25.4h5.4c3.4 17.1 3 15.8 3.2 15.8 3.4-18.9 1.5-15.8 6.8-15.8 3.7 21.4 1.9 20.6 5.8 0h5.5z"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 467.101 500.925)"/><use xlink:href="#c" width="15.3" height="26" x="-7.6" y="-13" transform="matrix(1 0 0 -1 498.15 500.925)"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 516.95 500.925)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 537.6 500.776)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 558.074 500.776)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 578.299 501.012)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 593.748 497.076)"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 619.847 501.012)"/><use xlink:href="#c" width="15.3" height="26" x="-7.6" y="-13" transform="matrix(1 0 0 -1 640.547 501.108)"/><use xlink:href="#c" width="15.3" height="26" x="-7.6" y="-13" transform="matrix(1 0 0 -1 660.297 500.925)"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 679.195 501.108)"/><use xlink:href="#p" width="15.3" height="35.9" x="-7.7" y="-18" transform="matrix(1 0 0 -1 699.522 505.9)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 715.446 497.076)"/><use xlink:href="#y" width="17.7" height="35.7" x="-8.9" y="-17.8" transform="matrix(1 0 0 -1 741.295 506.05)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 760.148 500.925)"/><use xlink:href="#u" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 780.458 501.075)"/></g><use xlink:href="#r" width="12" height="25.6" x="-6" y="-12.8" transform="matrix(1 0 0 -1 799.52 500.776)"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 314.03 572.925)"/><use xlink:href="#u" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 333.905 573.075)"/><use xlink:href="#b" width="15.4" height="35.9" x="-7.7" y="-17.9" transform="matrix(1 0 0 -1 354.704 567.95)"/><use xlink:href="#m" width="25.4" height="25.7" x="-12.7" y="-12.8" transform="matrix(1 0 0 -1 380.676 572.925)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 401.37 567.95)"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 416.297 572.925)"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 435.128 573.068)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 449.927 567.95)"/><use xlink:href="#o" width="15.7" height="26.3" x="-7.8" y="-13.1" transform="matrix(1 0 0 -1 464.887 573.068)"/><use xlink:href="#n" width="15.4" height="25.6" x="-7.7" y="-12.8" transform="matrix(1 0 0 -1 485.501 573.068)"/><use xlink:href="#a" width="15.8" height="26" x="-7.9" y="-13" transform="matrix(1 0 0 -1 516.275 572.925)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 532.025 568.991)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 554.224 569.075)"/><use xlink:href="#h" width="15.4" height="35.6" x="-7.7" y="-17.8" transform="matrix(1 0 0 -1 570.548 567.8)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 586.268 567.8)"/><use xlink:href="#s" width="15.4" height="26" x="-7.7" y="-13" transform="matrix(1 0 0 -1 601.073 572.925)"/><use xlink:href="#t" width="10.9" height="33.2" x="-5.5" y="-16.6" transform="matrix(1 0 0 -1 626.822 569.075)"/><use xlink:href="#i" width="5.3" height="35.7" x="-2.7" y="-17.9" transform="matrix(1 0 0 -1 638.072 567.8)"/><use xlink:href="#m" width="25.4" height="25.7" x="-12.7" y="-12.8" transform="matrix(1 0 0 -1 658.871 572.776)"/><use xlink:href="#e" width="15.3" height="26.1" x="-7.6" y="-13.1" transform="matrix(1 0 0 -1 684.273 572.863)"/><style>.bg{fill:#'; //inject NONSTANDARD NAMING string public constant arttail672 = ';}</style></svg>'; //inject NONSTANDARD NAMING mapping (uint256 => string) internal artDNAStore; mapping (uint256 => uint256) internal artSetStore; event BIRTH139(uint256 tokenID, string artDNA, uint256 artSet); //inject NONSTANDARD NAMING function GETDNA928(uint256 tokenID) public view returns (string memory artDNA) { //inject NONSTANDARD NAMING artDNA = artDNAStore[tokenID]; } function GETSET947(uint256 tokenID) public view returns (uint256 artSet) { //inject NONSTANDARD NAMING artSet = artSetStore[tokenID]; } function GENERATE93(uint256 tokenID) public view returns (string memory SVG) { //inject NONSTANDARD NAMING SVG = string(abi.encodePacked(arthead473, artDNAStore[tokenID], arttail672)); } function TOKENURI670(uint256 _tokenId) external view VALIDNFTOKEN826(_tokenId) returns (string memory) { //inject NONSTANDARD NAMING return GENERATE93(_tokenId); } function TOKENIZE443 (string memory artDNA, uint256 artSet) public ONLYOWNER618 {{ //inject NONSTANDARD NAMING artTotal = artTotal + 1; artDNAStore[artTotal] = artDNA; artSetStore[artTotal] = artSet; _MINTPRINT97(); emit BIRTH139(artTotal, artDNA, artSet); }} function _MINTPRINT97() private { //inject NONSTANDARD NAMING uint256 tokenId = artTotal; require(artTotal <= artCap, "144 tokens max"); _MINT19(msg.sender, tokenId); }}
inject NONSTANDARD NAMING
string constant overflow201 = "008001";
15,841,661
[ 1, 4625, 348, 7953, 560, 30, 4590, 18708, 882, 18264, 423, 2192, 1360, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 1080, 5381, 9391, 6734, 273, 315, 713, 28, 11664, 14432, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/3/0xeD11516d35B36dC3FDf557a94565c8fF2f2C035d/sources/contracts/kudos.sol
memory because we dont know the length of variable, while for address it is fixed
function giveKudos(address toWhom, string memory what, string memory comments) public {
8,178,061
[ 1, 4625, 348, 7953, 560, 30, 3778, 2724, 732, 14046, 5055, 326, 769, 434, 2190, 16, 1323, 364, 1758, 518, 353, 5499, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 8492, 47, 1100, 538, 12, 2867, 358, 2888, 362, 16, 533, 3778, 4121, 16, 533, 3778, 5678, 13, 1071, 288, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT /* MIT License Copyright (c) 2021 Paladin10 */ pragma solidity ^0.8.0; interface IFeature { function featureByIndex (address nft, uint256 id, uint256 fi) external view returns (uint256 what, bytes32 fHash); } interface IERC721 { function ownerOf(uint256 tokenId) external view returns (address owner); function getApproved(uint256 tokenId) external view returns (address operator); function totalSupply() external returns (uint256); function mint(address to) external; } interface IStatsBytes { function setStat (string calldata statId, address _721, uint256 nftId, bytes memory val) external; } interface IStats { function add (string calldata statId, address _721, uint256 nftId, uint256 val) external; function sub (string calldata statId, address _721, uint256 nftId, uint256 val) external; function setStat (string calldata statId, address _721, uint256 nftId, uint256 val) external; function getStat (string calldata statId, address _721, uint256 nftId) external view returns(uint256); } interface IAllyBasic { function baseStatsFromAlly (bytes32 featureHash, bytes32 allyId) external view returns (uint256[6] memory stats); function baseCulture (bytes32 ally) external pure returns (bytes32); function SizeAndNApp (uint256 base, uint256 seed) external view returns (uint256 size, uint256 napp); function lifeformHash (uint256 base, uint256 seed) external view returns (bytes32); function lifeform (bytes32 hash) external pure returns (uint256 base, uint256 seed); } contract FeatureClaimAlly { //contracts IFeature public FEATURES = IFeature(0x47eC56991f0E456593b7F26897C44b72617C77C4); IStats public STATS = IStats(0xeEd019D0726e415526804fb3105a98323911E494); IStatsBytes public STATSBYTES = IStatsBytes(0x0382b163D4B46999660d5AD85Fdc0f3fB5Eb9541); IAllyBasic public ALLY = IAllyBasic(0xD8DCB29D2138f4dAf50A0d184428cE9cf1F17700); IERC721 public NFTALLY = IERC721(0xAe1Ad876f3759eaBcc04733ce32918cBEC5218B5); //feature id uint256 internal constant FID = 0; //pay to claim string internal PAYID = "SRD.COSMIC"; uint256 internal COST = 1 ether; uint256[3] internal COSTM = [10,5,3]; //claim once per day uint256 internal PERIOD = 1 days; mapping (bytes32 => uint256) public lastClaim; function _claimId (address nft, uint256 id, uint256 fi) internal pure returns(bytes32) { return keccak256(abi.encode(nft, id, fi)); } function _isApprovedOrOwner(address nft, uint256 id) internal view returns (bool) { return IERC721(nft).getApproved(id) == msg.sender || IERC721(nft).ownerOf(id) == msg.sender; } function _nftHash (address nft, uint256 id) internal view returns (bytes32) { uint256 _stat = STATS.getStat("HASH", nft, id); return _stat != 0 ? bytes32(_stat) : keccak256(abi.encode("But God...",nft,id)); } function _mayClaim (address nft, uint256 id, uint256 fi) internal { require(_isApprovedOrOwner(nft, id), "FeatureClaim: not approved or owner"); //claim period bytes32 _claim = _claimId(nft,id,fi); uint256 _now = block.timestamp; require((_now - lastClaim[_claim]) >= PERIOD, "FeatureClaim: wait one day to claim"); //update claim lastClaim[_claim] = _now; } function claim (address shardNFT, uint256 _shard, uint256 fi) public { /* * Check allow claim * collect payment */ _mayClaim(shardNFT, _shard, fi); //get feature (uint256 fid, bytes32 fHash) = FEATURES.featureByIndex(shardNFT, _shard, fi); require(fHash != bytes32(0), "FeatureClaim: beyond available features"); require(fid == FID, "FeatureClaim: incorrect feature type for cliam"); //get basic data (uint256 base, uint256 seed) = ALLY.lifeform(fHash); (, uint256 napp) = ALLY.SizeAndNApp(base, seed); uint256 cost = COSTM[napp] * COST; //pull payment, subtract - will throw a error if not enough STATS.sub(PAYID, shardNFT, _shard, cost); /* * Mint Token */ //gets id - which will be incremented by mint uint256 _ally = NFTALLY.totalSupply(); NFTALLY.mint(msg.sender); bytes32 allyId = _nftHash(address(NFTALLY), _ally); /* * Set Stats */ //home, current shard location bytes memory shardBytes = abi.encode(shardNFT,_shard); STATSBYTES.setStat("home", address(NFTALLY), _ally, shardBytes); STATSBYTES.setStat("shard", address(NFTALLY), _ally, shardBytes); //lifeform, culture STATSBYTES.setStat("people", address(NFTALLY), _ally, abi.encode(fHash,ALLY.baseCulture(fHash))); //base stats STATSBYTES.setStat("baseStats", address(NFTALLY), _ally, abi.encode(ALLY.baseStatsFromAlly(fHash, allyId))); } }
claim periodupdate claim
function _mayClaim (address nft, uint256 id, uint256 fi) internal { require(_isApprovedOrOwner(nft, id), "FeatureClaim: not approved or owner"); bytes32 _claim = _claimId(nft,id,fi); uint256 _now = block.timestamp; require((_now - lastClaim[_claim]) >= PERIOD, "FeatureClaim: wait one day to claim"); lastClaim[_claim] = _now; }
14,114,488
[ 1, 4625, 348, 7953, 560, 30, 7516, 3879, 2725, 7516, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 24877, 9762, 261, 2867, 290, 1222, 16, 2254, 5034, 612, 16, 2254, 5034, 7314, 13, 7010, 3639, 2713, 203, 565, 288, 203, 3639, 2583, 24899, 291, 31639, 1162, 5541, 12, 82, 1222, 16, 612, 3631, 315, 4595, 9762, 30, 486, 20412, 578, 3410, 8863, 203, 540, 203, 3639, 1731, 1578, 389, 14784, 273, 389, 14784, 548, 12, 82, 1222, 16, 350, 16, 22056, 1769, 203, 3639, 2254, 5034, 389, 3338, 273, 1203, 18, 5508, 31, 7010, 3639, 2583, 12443, 67, 3338, 300, 1142, 9762, 63, 67, 14784, 5717, 1545, 10950, 21054, 16, 315, 4595, 9762, 30, 2529, 1245, 2548, 358, 7516, 8863, 203, 3639, 1142, 9762, 63, 67, 14784, 65, 273, 389, 3338, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
//Address: 0x7c43dea72a94972a341489b60ce9a07eb45253f9 //Contract name: AGRECrowdsale //Balance: 0 Ether //Verification Date: 12/3/2017 //Transacion Count: 1 // CODE STARTS HERE pragma solidity ^0.4.18; //====== Open Zeppelin Library ===== /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Contracts that should not own Contracts * @author Remco Bloemen <remco@2π.com> * @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner * of this contract to reclaim ownership of the contracts. */ contract HasNoContracts is Ownable { /** * @dev Reclaim ownership of Ownable contracts * @param contractAddr The address of the Ownable to be reclaimed. */ function reclaimContract(address contractAddr) external onlyOwner { Ownable contractInst = Ownable(contractAddr); contractInst.transferOwnership(owner); } } /** * @title Contracts that should be able to recover tokens * @author SylTi * @dev This allow a contract to recover any ERC20 token received in a contract by transferring the balance to the contract owner. * This will prevent any accidental loss of tokens. */ contract CanReclaimToken is Ownable { using SafeERC20 for ERC20Basic; /** * @dev Reclaim all ERC20Basic compatible tokens * @param token ERC20Basic The address of the token contract */ function reclaimToken(ERC20Basic token) external onlyOwner { uint256 balance = token.balanceOf(this); token.safeTransfer(owner, balance); } } /** * @title Contracts that should not own Tokens * @author Remco Bloemen <remco@2π.com> * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens. * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the * owner to reclaim the tokens. */ contract HasNoTokens is CanReclaimToken { /** * @dev Reject all ERC23 compatible tokens * @param from_ address The address that is transferring the tokens * @param value_ uint256 the amount of the specified token * @param data_ Bytes The data passed from the caller. */ function tokenFallback(address from_, uint256 value_, bytes data_) external { from_; value_; data_; revert(); } } /** * @title Destructible * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. */ contract Destructible is Ownable { function Destructible() public payable { } /** * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public { selfdestruct(_recipient); } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } //====== AGRE Contracts ===== /** * @title TradeableToken can be bought and sold from/to it's own contract during it's life time * Sold tokens and Ether received to buy tokens are collected during specified period and then time comes * contract owner should specify price for the last period and send tokens/ether to their new owners. */ contract TradeableToken is StandardToken, Ownable { using SafeMath for uint256; event Sale(address indexed buyer, uint256 amount); event Redemption(address indexed seller, uint256 amount); event DistributionError(address seller, uint256 amount); /** * State of the contract: * Collecting - collecting ether and tokens * Distribution - distribution of bought tokens and ether is in process */ enum State{Collecting, Distribution} State public currentState; //Current state of the contract uint256 public previousPeriodRate; //Previous rate: how many tokens one could receive for 1 ether in the last period uint256 public currentPeriodEndTimestamp; //Timestamp after which no more trades are accepted and contract is waiting to start distribution uint256 public currentPeriodStartBlock; //Number of block when current perions was started uint256 public currentPeriodRate; //Current rate: how much tokens one should receive for 1 ether in current distribution period uint256 public currentPeriodEtherCollected; //How much ether was collected (to buy tokens) during current period and waiting for distribution uint256 public currentPeriodTokenCollected; //How much tokens was collected (to sell tokens) during current period and waiting for distribution mapping(address => uint256) receivedEther; //maps address of buyer to amount of ether he sent mapping(address => uint256) soldTokens; //maps address of seller to amount of tokens he sent uint32 constant MILLI_PERCENT_DIVIDER = 100*1000; uint32 public buyFeeMilliPercent; //The buyer's fee in a thousandth of percent. So, if buyer's fee = 5%, then buyFeeMilliPercent = 5000 and if without buyer shoud receive 200 tokens with fee it will receive 200 - (200 * 5000 / MILLI_PERCENT_DIVIDER) uint32 public sellFeeMilliPercent; //The seller's fee in a thousandth of percent. (see above) uint256 public minBuyAmount; //Minimal amount of ether to buy uint256 public minSellAmount; //Minimal amount of tokens to sell modifier canBuyAndSell() { require(currentState == State.Collecting); require(now < currentPeriodEndTimestamp); _; } function TradeableToken() public { currentState = State.Distribution; //currentPeriodStartBlock = 0; currentPeriodEndTimestamp = now; //ensure that nothing can be collected until new period is started by owner } /** * @notice Send Ether to buy tokens */ function() payable public { require(msg.value > 0); buy(msg.sender, msg.value); } /** * @notice Transfer or sell tokens * Sells tokens transferred to this contract itself or to zero address * @param _to The address to transfer to or token contract address to burn. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if( (_to == address(this)) || (_to == 0) ){ return sell(msg.sender, _value); }else{ return super.transfer(_to, _value); } } /** * @notice Transfer tokens from one address to another or sell them if _to is this contract or zero address * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if( (_to == address(this)) || (_to == 0) ){ var _allowance = allowed[_from][msg.sender]; require (_value <= _allowance); allowed[_from][msg.sender] = _allowance.sub(_value); return sell(_from, _value); }else{ return super.transferFrom(_from, _to, _value); } } /** * @dev Fuction called when somebody is buying tokens * @param who The address of buyer (who will own bought tokens) * @param amount The amount to be transferred. */ function buy(address who, uint256 amount) canBuyAndSell internal returns(bool){ require(amount >= minBuyAmount); currentPeriodEtherCollected = currentPeriodEtherCollected.add(amount); receivedEther[who] = receivedEther[who].add(amount); //if this is first operation from this address, initial value of receivedEther[to] == 0 Sale(who, amount); return true; } /** * @dev Fuction called when somebody is selling his tokens * @param who The address of seller (whose tokens are sold) * @param amount The amount to be transferred. */ function sell(address who, uint256 amount) canBuyAndSell internal returns(bool){ require(amount >= minSellAmount); currentPeriodTokenCollected = currentPeriodTokenCollected.add(amount); soldTokens[who] = soldTokens[who].add(amount); //if this is first operation from this address, initial value of soldTokens[to] == 0 totalSupply = totalSupply.sub(amount); Redemption(who, amount); Transfer(who, address(0), amount); return true; } /** * @notice Set fee applied when buying tokens * @param _buyFeeMilliPercent fee in thousandth of percent (5% = 5000) */ function setBuyFee(uint32 _buyFeeMilliPercent) onlyOwner public { require(_buyFeeMilliPercent < MILLI_PERCENT_DIVIDER); buyFeeMilliPercent = _buyFeeMilliPercent; } /** * @notice Set fee applied when selling tokens * @param _sellFeeMilliPercent fee in thousandth of percent (5% = 5000) */ function setSellFee(uint32 _sellFeeMilliPercent) onlyOwner public { require(_sellFeeMilliPercent < MILLI_PERCENT_DIVIDER); sellFeeMilliPercent = _sellFeeMilliPercent; } /** * @notice set minimal amount of ether which can be used to buy tokens * @param _minBuyAmount minimal amount of ether */ function setMinBuyAmount(uint256 _minBuyAmount) onlyOwner public { minBuyAmount = _minBuyAmount; } /** * @notice set minimal amount of ether which can be used to buy tokens * @param _minSellAmount minimal amount of tokens */ function setMinSellAmount(uint256 _minSellAmount) onlyOwner public { minSellAmount = _minSellAmount; } /** * @notice Collect ether received for token purshases * This is possible both during Collection and Distribution phases */ function collectEther(uint256 amount) onlyOwner public { owner.transfer(amount); } /** * @notice Start distribution phase * @param _currentPeriodRate exchange rate for current distribution */ function startDistribution(uint256 _currentPeriodRate) onlyOwner public { require(currentState != State.Distribution); //owner should not be able to change rate after distribution is started, ensures that everyone have the same rate require(_currentPeriodRate != 0); //something has to be distributed! //require(now >= currentPeriodEndTimestamp) //DO NOT require period end timestamp passed, because there can be some situations when it is neede to end it sooner. But this should be done with extremal care, because of possible race condition between new sales/purshases and currentPeriodRate definition currentState = State.Distribution; currentPeriodRate = _currentPeriodRate; } /** * @notice Distribute tokens to buyers * @param buyers an array of addresses to pay tokens for their ether. Should be composed from outside by reading Sale events */ function distributeTokens(address[] buyers) onlyOwner public { require(currentState == State.Distribution); require(currentPeriodRate > 0); for(uint256 i=0; i < buyers.length; i++){ address buyer = buyers[i]; require(buyer != address(0)); uint256 etherAmount = receivedEther[buyer]; if(etherAmount == 0) continue; //buyer not found or already paid uint256 tokenAmount = etherAmount.mul(currentPeriodRate); uint256 fee = tokenAmount.mul(buyFeeMilliPercent).div(MILLI_PERCENT_DIVIDER); tokenAmount = tokenAmount.sub(fee); receivedEther[buyer] = 0; currentPeriodEtherCollected = currentPeriodEtherCollected.sub(etherAmount); //mint tokens totalSupply = totalSupply.add(tokenAmount); balances[buyer] = balances[buyer].add(tokenAmount); Transfer(address(0), buyer, tokenAmount); } } /** * @notice Distribute ether to sellers * If not enough ether is available on contract ballance * @param sellers an array of addresses to pay ether for their tokens. Should be composed from outside by reading Redemption events */ function distributeEther(address[] sellers) onlyOwner payable public { require(currentState == State.Distribution); require(currentPeriodRate > 0); for(uint256 i=0; i < sellers.length; i++){ address seller = sellers[i]; require(seller != address(0)); uint256 tokenAmount = soldTokens[seller]; if(tokenAmount == 0) continue; //seller not found or already paid uint256 etherAmount = tokenAmount.div(currentPeriodRate); uint256 fee = etherAmount.mul(sellFeeMilliPercent).div(MILLI_PERCENT_DIVIDER); etherAmount = etherAmount.sub(fee); soldTokens[seller] = 0; currentPeriodTokenCollected = currentPeriodTokenCollected.sub(tokenAmount); if(!seller.send(etherAmount)){ //in this case we can only log error and let owner to handle it manually DistributionError(seller, etherAmount); owner.transfer(etherAmount); //assume this should not fail..., overwise - change owner } } } function startCollecting(uint256 _collectingEndTimestamp) onlyOwner public { require(_collectingEndTimestamp > now); //Need some time for collection require(currentState == State.Distribution); //Do not allow to change collection terms after it is started require(currentPeriodEtherCollected == 0); //All sold tokens are distributed require(currentPeriodTokenCollected == 0); //All redeemed tokens are paid previousPeriodRate = currentPeriodRate; currentPeriodRate = 0; currentPeriodStartBlock = block.number; currentPeriodEndTimestamp = _collectingEndTimestamp; currentState = State.Collecting; } } contract AGREToken is TradeableToken, MintableToken, HasNoContracts, HasNoTokens { //MintableToken is StandardToken, Ownable string public symbol = "AGRE"; string public name = "Aggregate Coin"; uint8 public constant decimals = 18; address public founder; //founder address to allow him transfer tokens while minting function init(address _founder, uint32 _buyFeeMilliPercent, uint32 _sellFeeMilliPercent, uint256 _minBuyAmount, uint256 _minSellAmount) onlyOwner public { founder = _founder; setBuyFee(_buyFeeMilliPercent); setSellFee(_sellFeeMilliPercent); setMinBuyAmount(_minBuyAmount); setMinSellAmount(_minSellAmount); } /** * Allow transfer only after crowdsale finished */ modifier canTransfer() { require(mintingFinished || msg.sender == founder); _; } function transfer(address _to, uint256 _value) canTransfer public returns(bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) canTransfer public returns(bool) { return super.transferFrom(_from, _to, _value); } } contract AGRECrowdsale is Ownable, Destructible { using SafeMath for uint256; uint256 public maxGasPrice = 50000000000 wei; //Maximum gas price for contribution transactions uint256 public startTimestamp; //when crowdsal starts uint256 public endTimestamp; //when crowdsal ends uint256 public rate; //how many tokens will be minted for 1 ETH (like 300 CPM for 1 ETH) uint256 public hardCap; //maximum amount of ether to collect AGREToken public token; uint256 public collectedEther; /** * verifies that the gas price is lower than maxGasPrice */ modifier validGasPrice() { require(tx.gasprice <= maxGasPrice); _; } /** * @notice Create a crowdsale contract, a token and initialize them * @param _ownerTokens Amount of tokens that will be mint to owner during the sale */ function AGRECrowdsale(uint256 _startTimestamp, uint256 _endTimestamp, uint256 _rate, uint256 _hardCap, uint256 _ownerTokens, uint32 _buyFeeMilliPercent, uint32 _sellFeeMilliPercent, uint256 _minBuyAmount, uint256 _minSellAmount) public { require(_startTimestamp < _endTimestamp); require(_rate > 0); startTimestamp = _startTimestamp; endTimestamp = _endTimestamp; rate = _rate; hardCap = _hardCap; token = new AGREToken(); token.init(msg.sender, _buyFeeMilliPercent, _sellFeeMilliPercent, _minBuyAmount, _minSellAmount); token.mint(msg.sender, _ownerTokens); } function () payable validGasPrice public { require(crowdsaleOpen()); require(msg.value > 0); require(collectedEther.add(msg.value) <= hardCap); collectedEther = collectedEther.add(msg.value); uint256 buyerTokens = rate.mul(msg.value); token.mint(msg.sender, buyerTokens); } function crowdsaleOpen() public constant returns(bool){ return (rate > 0) && (collectedEther < hardCap) && (startTimestamp <= now) && (now <= endTimestamp); } /** * @notice Updates max gas price for crowdsale transactions */ function setMaxGasPrice(uint256 _maxGasPrice) public onlyOwner { maxGasPrice = _maxGasPrice; } /** * @notice Closes crowdsale, finishes minting (allowing token transfers), transfers token ownership to the owner */ function finalizeCrowdsale() public onlyOwner { rate = 0; //this makes crowdsaleOpen() return false; token.finishMinting(); token.transferOwnership(owner); if(this.balance > 0) owner.transfer(this.balance); } /** * @notice Claim collected ether without closing crowdsale */ function claimEther() public onlyOwner { if(this.balance > 0) owner.transfer(this.balance); } }
if this is first operation from this address, initial value of soldTokens[to] == 0
soldTokens[who] = soldTokens[who].add(amount);
12,995,593
[ 1, 4625, 348, 7953, 560, 30, 309, 333, 353, 1122, 1674, 628, 333, 1758, 16, 2172, 460, 434, 272, 1673, 5157, 63, 869, 65, 422, 374, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 272, 1673, 5157, 63, 3350, 83, 65, 273, 272, 1673, 5157, 63, 3350, 83, 8009, 1289, 12, 8949, 1769, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/43114/0xe759d11678Ecc37Eaa3Bdbb804D4aFBd3b97797d/sources/dolphinmasterchef.sol
View function to see pending Dolphins on frontend.
function pendingDolphin(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accDolphinPerShare = pool.accDolphinPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 DolphinReward = multiplier.mul(DolphinPerBlock).mul(pool.allocPoint).div( totalAllocPoint ); accDolphinPerShare = accDolphinPerShare.add( DolphinReward.mul(1e12).div(lpSupply) ); } return user.amount.mul(accDolphinPerShare).div(1e12).sub(user.rewardDebt); }
4,587,696
[ 1, 4625, 348, 7953, 560, 30, 225, 4441, 445, 358, 2621, 4634, 463, 355, 844, 2679, 603, 15442, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0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639, 1476, 203, 3639, 1135, 261, 11890, 5034, 13, 203, 565, 288, 203, 3639, 8828, 966, 2502, 2845, 273, 2845, 966, 63, 67, 6610, 15533, 203, 3639, 25003, 2502, 729, 273, 16753, 63, 67, 6610, 6362, 67, 1355, 15533, 203, 3639, 2254, 5034, 4078, 40, 355, 844, 267, 2173, 9535, 273, 2845, 18, 8981, 40, 355, 844, 267, 2173, 9535, 31, 203, 3639, 2254, 5034, 12423, 3088, 1283, 273, 2845, 18, 9953, 1345, 18, 12296, 951, 12, 2867, 12, 2211, 10019, 203, 3639, 309, 261, 2629, 18, 2696, 405, 2845, 18, 2722, 17631, 1060, 1768, 597, 12423, 3088, 1283, 480, 374, 13, 288, 203, 5411, 2254, 5034, 15027, 273, 203, 7734, 31863, 5742, 12, 6011, 18, 2722, 17631, 1060, 1768, 16, 1203, 18, 2696, 1769, 203, 5411, 2254, 5034, 463, 355, 844, 267, 17631, 1060, 273, 203, 7734, 15027, 18, 16411, 12, 40, 355, 844, 267, 2173, 1768, 2934, 16411, 12, 6011, 18, 9853, 2148, 2934, 2892, 12, 203, 10792, 2078, 8763, 2148, 203, 7734, 11272, 203, 5411, 4078, 40, 355, 844, 267, 2173, 9535, 273, 4078, 40, 355, 844, 267, 2173, 9535, 18, 1289, 12, 203, 7734, 463, 355, 844, 267, 17631, 1060, 18, 16411, 12, 21, 73, 2138, 2934, 2892, 12, 9953, 3088, 1283, 13, 203, 5411, 11272, 203, 3639, 289, 203, 3639, 327, 729, 18, 8949, 18, 16411, 12, 8981, 40, 355, 844, 267, 2173, 9535, 2934, 2892, 12, 21, 73, 2138, 2934, 1717, 12, 1355, 18, 266, 2913, 758, 23602, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/56/0xC2b651F2Efbc6616b8e468755496cC5E32f9F812/sources/MasterFrog.sol
TOAD tokens created per block.
uint256 public toadPerBlock;
11,150,449
[ 1, 4625, 348, 7953, 560, 30, 225, 8493, 1880, 2430, 2522, 1534, 1203, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 358, 361, 2173, 1768, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../interfaces/IControllable.sol"; abstract contract Controllable is IControllable { mapping(address => bool) _controllers; /** * @dev Throws if called by any account not in authorized list */ modifier onlyController() { require( _controllers[msg.sender] == true || address(this) == msg.sender, "Controllable: caller is not a controller" ); _; } /** * @dev Add an address allowed to control this contract */ function _addController(address _controller) internal { _controllers[_controller] = true; } /** * @dev Add an address allowed to control this contract */ function addController(address _controller) external override onlyController { _controllers[_controller] = true; } /** * @dev Check if this address is a controller */ function isController(address _address) external view override returns (bool allowed) { allowed = _controllers[_address]; } /** * @dev Check if this address is a controller */ function relinquishControl() external view override onlyController { _controllers[msg.sender]; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; interface IControllable { event ControllerAdded(address indexed contractAddress, address indexed controllerAddress); event ControllerRemoved(address indexed contractAddress, address indexed controllerAddress); function addController(address controller) external; function isController(address controller) external view returns (bool); function relinquishControl() external; } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "./IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "./IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../interfaces/IERC165.sol"; /** * _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface INFTGemMultiToken { // called by controller to mint a claim or a gem function mint( address account, uint256 tokenHash, uint256 amount ) external; // called by controller to burn a claim function burn( address account, uint256 tokenHash, uint256 amount ) external; function allHeldTokens(address holder, uint256 _idx) external view returns (uint256); function allHeldTokensLength(address holder) external view returns (uint256); function allTokenHolders(uint256 _token, uint256 _idx) external view returns (address); function allTokenHoldersLength(uint256 _token) external view returns (uint256); function totalBalances(uint256 _id) external view returns (uint256); function allProxyRegistries(uint256 _idx) external view returns (address); function allProxyRegistriesLength() external view returns (uint256); function addProxyRegistry(address registry) external; function removeProxyRegistryAt(uint256 index) external; function getRegistryManager() external view returns (address); function setRegistryManager(address newManager) external; function lock(uint256 token, uint256 timeframe) external; function unlockTime(address account, uint256 token) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../interfaces/IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor() { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; library Strings { function strConcat( string memory _a, string memory _b, string memory _c, string memory _d, string memory _e ) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint256 k = 0; for (uint256 i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint256 i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint256 i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint256 i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint256 i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat( string memory _a, string memory _b, string memory _c, string memory _d ) internal pure returns (string memory) { return strConcat(_a, _b, _c, _d, ""); } function strConcat( string memory _a, string memory _b, string memory _c ) internal pure returns (string memory) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b) internal pure returns (string memory) { return strConcat(_a, _b, "", "", ""); } function uint2str(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint256 j = _i; uint256 len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint256 k = len - 1; while (_i != 0) { bstr[k--] = bytes1(uint8(48 + (_i % 10))); _i /= 10; } return string(bstr); } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../interfaces/IERC1155.sol"; import "../interfaces/IERC1155MetadataURI.sol"; import "../interfaces//IERC1155Receiver.sol"; import "../utils/Context.sol"; import "../introspection/ERC165.sol"; import "../libs/SafeMath.sol"; import "../utils/Address.sol"; /** * * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using SafeMath for uint256; using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) internal _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) internal _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /* * bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58e * bytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4 * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432a * bytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 * * => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ * 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 */ bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26; /* * bytes4(keccak256('uri(uint256)')) == 0x0e89341c */ bytes4 private constant _INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); // register the supported interfaces to conform to ERC1155 via ERC165 _registerInterface(_INTERFACE_ID_ERC1155); // register the supported interfaces to conform to ERC1155MetadataURI via ERC165 _registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) external view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); _balances[id][to] = _balances[id][to].add(amount); emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); _balances[id][to] = _balances[id][to].add(amount); } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] = _balances[id][account].add(amount); emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] = amounts[i].add(_balances[ids[i]][to]); } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); _balances[id][account] = _balances[id][account].sub(amount, "ERC1155: burn amount exceeds balance"); emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][account] = _balances[ids[i]][account].sub( amounts[i], "ERC1155: burn amount exceeds balance" ); } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) internal { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver(to).onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver(to).onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) internal pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "./ERC1155Receiver.sol"; /** * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "./ERC1155.sol"; import "../utils/Pausable.sol"; /** * @dev ERC1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * _Available since v3.1._ */ abstract contract ERC1155Pausable is ERC1155, Pausable { /** * @dev See {ERC1155-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); require(!paused(), "ERC1155Pausable: token transfer while paused"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../interfaces/IERC1155Receiver.sol"; import "../introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { constructor() { _registerInterface( ERC1155Receiver(address(0)).onERC1155Received.selector ^ ERC1155Receiver(address(0)).onERC1155BatchReceived.selector ); } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "../libs/Strings.sol"; import "../libs/SafeMath.sol"; import "./ERC1155Pausable.sol"; import "./ERC1155Holder.sol"; import "../access/Controllable.sol"; import "../interfaces/INFTGemMultiToken.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract NFTGemMultiToken is ERC1155Pausable, ERC1155Holder, INFTGemMultiToken, Controllable { using SafeMath for uint256; using Strings for string; // allows opensea to address private constant OPENSEA_REGISTRY_ADDRESS = 0xa5409ec958C83C3f309868babACA7c86DCB077c1; address[] private proxyRegistries; address private registryManager; mapping(uint256 => uint256) private _totalBalances; mapping(address => mapping(uint256 => uint256)) private _tokenLocks; mapping(address => uint256[]) private _heldTokens; mapping(uint256 => address[]) private _tokenHolders; /** * @dev Contract initializer. */ constructor() ERC1155("https://metadata.bitgem.co/") { _addController(msg.sender); registryManager = msg.sender; proxyRegistries.push(OPENSEA_REGISTRY_ADDRESS); } function lock(uint256 token, uint256 timestamp) external override { require(_tokenLocks[_msgSender()][token] < timestamp, "ALREADY_LOCKED"); _tokenLocks[_msgSender()][timestamp] = timestamp; } function unlockTime(address account, uint256 token) external view override returns (uint256 theTime) { theTime = _tokenLocks[account][token]; } /** * @dev Returns the metadata URI for this token type */ function uri(uint256 _id) public view override(ERC1155) returns (string memory) { require(_totalBalances[_id] != 0, "NFTGemMultiToken#uri: NONEXISTENT_TOKEN"); return Strings.strConcat(ERC1155Pausable(this).uri(_id), Strings.uint2str(_id)); } /** * @dev Returns the total balance minted of this type */ function allHeldTokens(address holder, uint256 _idx) external view override returns (uint256) { return _heldTokens[holder][_idx]; } /** * @dev Returns the total balance minted of this type */ function allHeldTokensLength(address holder) external view override returns (uint256) { return _heldTokens[holder].length; } /** * @dev Returns the total balance minted of this type */ function allTokenHolders(uint256 _token, uint256 _idx) external view override returns (address) { return _tokenHolders[_token][_idx]; } /** * @dev Returns the total balance minted of this type */ function allTokenHoldersLength(uint256 _token) external view override returns (uint256) { return _tokenHolders[_token].length; } /** * @dev Returns the total balance minted of this type */ function totalBalances(uint256 _id) external view override returns (uint256) { return _totalBalances[_id]; } /** * @dev Returns the total balance minted of this type */ function allProxyRegistries(uint256 _idx) external view override returns (address) { return proxyRegistries[_idx]; } /** * @dev Returns the total balance minted of this type */ function getRegistryManager() external view override returns (address) { return registryManager; } /** * @dev Returns the total balance minted of this type */ function setRegistryManager(address newManager) external override { require(msg.sender == registryManager, "UNAUTHORIZED"); require(newManager != address(0), "UNAUTHORIZED"); registryManager = newManager; } /** * @dev Returns the total balance minted of this type */ function allProxyRegistriesLength() external view override returns (uint256) { return proxyRegistries.length; } /** * @dev Returns the total balance minted of this type */ function addProxyRegistry(address registry) external override { require(msg.sender == registryManager, "UNAUTHORIZED"); proxyRegistries.push(registry); } /** * @dev Returns the total balance minted of this type */ function removeProxyRegistryAt(uint256 index) external override { require(msg.sender == registryManager, "UNAUTHORIZED"); require(index < proxyRegistries.length, "INVALID_INDEX"); proxyRegistries[index] = proxyRegistries[proxyRegistries.length - 1]; delete proxyRegistries[proxyRegistries.length - 1]; } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings. */ function isApprovedForAll(address _owner, address _operator) public view override returns (bool isOperator) { // Whitelist OpenSea proxy contract for easy trading. for(uint256 i = 0; i < proxyRegistries.length; i++) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistries[i]); if (address(proxyRegistry.proxies(_owner)) == _operator) { return true; } } return ERC1155.isApprovedForAll(_owner, _operator); } /** * @dev mint some amount of tokens. Only callable by token owner */ function mint( address account, uint256 tokenHash, uint256 amount ) external override onlyController { _mint(account, uint256(tokenHash), amount, "0x0"); } /** * @dev internal mint overridden to manage token holders and held tokens lists */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual override { super._mint(account, id, amount, data); } /** * @dev internal minttbatch should account for managing lists */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._mintBatch(to, ids, amounts, data); } /** * @dev mint some amount of tokens. Only callable by token owner */ function burn( address account, uint256 tokenHash, uint256 amount ) external override onlyController { _burn(account, uint256(tokenHash), amount); } /** * @dev internal burn overridden to track lists */ function _burn( address account, uint256 id, uint256 amount ) internal virtual override { super._burn(account, id, amount); } /** * @dev internal burnBatch should account for managing lists */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual override { super._burnBatch(account, ids, amounts); } /** * @dev intercepting token transfers to manage a list of zero-token holders */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { // prevent send if tokens are locked if (from != address(0)) { require(_tokenLocks[from][ids[i]] <= block.timestamp, "TOKEN_LOCKED"); } // if this is not a mint then remove the held token id from lists if // this is the last token if this type the sender owns if (from != address(0) && balanceOf(from, ids[i]) - amounts[i] == 0) { // remove from heldTokens for (uint256 j = 0; j < _heldTokens[from].length; j++) { if (_heldTokens[from][j] == ids[i]) { _heldTokens[from][j] = _heldTokens[from][_heldTokens[from].length - 1]; delete _heldTokens[from][_heldTokens[from].length - 1]; } } // remove from tokenHolders for (uint256 j = 0; j < _tokenHolders[ids[i]].length; j++) { if (_tokenHolders[ids[i]][j] == from) { _tokenHolders[ids[i]][j] = _tokenHolders[ids[i]][_tokenHolders[ids[i]].length - 1]; delete _tokenHolders[ids[i]][_tokenHolders[ids[i]].length - 1]; } } } // if this is not a burn and receiver does not yet own token then // add that account to the token for that id if (to != address(0) && balanceOf(to, ids[i]) == 0) { _heldTokens[to].push(ids[i]); _tokenHolders[ids[i]].push(to); } // inc and dec balances for each token type if (from == address(0)) { _totalBalances[uint256(ids[i])] = _totalBalances[uint256(ids[i])].add(amounts[i]); } if (to == address(0)) { _totalBalances[uint256(ids[i])] = _totalBalances[uint256(ids[i])].sub(amounts[i]); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.0; import "./Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
* @dev Returns the total balance minted of this type/
function allTokenHolders(uint256 _token, uint256 _idx) external view override returns (address) { return _tokenHolders[_token][_idx]; }
1,317,914
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 326, 2078, 11013, 312, 474, 329, 434, 333, 618, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 777, 1345, 27003, 12, 11890, 5034, 389, 2316, 16, 2254, 5034, 389, 3465, 13, 3903, 1476, 3849, 1135, 261, 2867, 13, 288, 203, 3639, 327, 389, 2316, 27003, 63, 67, 2316, 6362, 67, 3465, 15533, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./RebalancingStrategy1.sol"; /** * This contract is part of Orbs Liquidity Nexus protocol. It is a thin wrapper over * Sushi LP token and represents liquidity added to the Sushi ETH/USDC pair. * * The purpose of Liquidity Nexus is to allow single-sided ETH-only farming on SushiSwap. * In regular Sushi LP, users add liquidity of both USDC and ETH in equal values. Nexus * LP allows users to add liquidity in ETH only, without needing any USDC. * * So where does the USDC come from? USDC is sourced separately from Orbs Liquidity * Nexus and originates from CeFi. This large pool of USDC is deployed in advance and is * waiting in the contract until ETH is added. Once ETH is added by users, it is paired * with part of the available USDC to generate regular Sushi LP. When liquidity is * removed by a user, the Sushi LP is burned, the USDC is returned to the pool and the * ETH is returned to the user. */ contract NexusLPSushi is ERC20("Nexus LP SushiSwap ETH/USDC", "NSLP"), RebalancingStrategy1 { using SafeERC20 for IERC20; event Mint(address indexed sender, address indexed beneficiary, uint256 shares); event Burn(address indexed sender, address indexed beneficiary, uint256 shares); event Pair( address indexed sender, address indexed minter, uint256 pairedUSDC, uint256 pairedETH, uint256 liquidity ); event Unpair(address indexed sender, address indexed minter, uint256 exitUSDC, uint256 exitETH, uint256 liquidity); event ClaimRewards(address indexed sender, uint256 amount); event CompoundProfits(address indexed sender, uint256 liquidity); /** * Stores the original minter for every Nexus LP token, only this original minter * can burn the tokens and remove liquidity. This means the address that calls addLiquidity * must also call removeLiquidity. */ struct Minter { uint256 pairedETH; uint256 pairedUSDC; uint256 pairedShares; // Nexus LP tokens that represent ETH paired with USDC to create Sushi LP uint256 unpairedETH; uint256 unpairedShares; // Nexus LP tokens that represent standalone ETH (waiting in this contract's balance) } uint256 public totalLiquidity; uint256 public totalPairedUSDC; uint256 public totalPairedETH; uint256 public totalPairedShares; mapping(address => Minter) public minters; /** * The contract holds available USDC to be paired with newly deposited ETH to create * Sushi LP. If there's not enough available USDC, the ETH deposit tx will revert. * This view function shows what's the maximum amount of ETH that can be deposited. * Should be called by clients to make sure users' txs are not reverted. */ function availableSpaceToDepositETH() external view returns (uint256 amountETH) { return quoteInverse(IERC20(USDC).balanceOf(address(this))); } /** * The number of Sushi LP per Nexus LP share is growing due to rewards compounding. * This view function shows this number that should be above 1 at all times. */ function pricePerFullShare() external view returns (uint256) { if (totalPairedShares == 0) return 0; return (1 ether * totalLiquidity) / totalPairedShares; } /** * Depositors only deposit ETH. This convenience function allows to deposit ETH directly. */ function addLiquidityETH(address beneficiary, uint256 deadline) external payable nonReentrant whenNotPaused verifyPrice(quote(1 ether)) { uint256 amountETH = msg.value; IWETH(WETH).deposit{value: amountETH}(); _deposit(beneficiary, amountETH, deadline); } /** * Depositors only deposit ETH. This convenience function allows to deposit WETH (ERC20). */ function addLiquidity( address beneficiary, uint256 amountETH, uint256 deadline ) external nonReentrant whenNotPaused verifyPrice(quote(1 ether)) { IERC20(WETH).safeTransferFrom(msg.sender, address(this), amountETH); _deposit(beneficiary, amountETH, deadline); } /** * When a depositor removes liquidity, they get ETH back. This works with ETH directly. * Argument shares is the number of Nexus LP tokens to burn. * Note: only the original address that called addLiquidity can call removeLiquidity. */ function removeLiquidityETH( address payable beneficiary, uint256 shares, uint256 deadline ) external nonReentrant verifyPrice(quote(1 ether)) returns (uint256 exitETH) { exitETH = _withdraw(msg.sender, beneficiary, shares, deadline); IWETH(WETH).withdraw(exitETH); Address.sendValue(beneficiary, exitETH); } /** * When a depositor removes liquidity, they get ETH back. This works with WETH (ERC20). * Argument shares is the number of Nexus LP tokens to burn. * Note: only the original address that called addLiquidity can call removeLiquidity. */ function removeLiquidity( address beneficiary, uint256 shares, uint256 deadline ) external nonReentrant verifyPrice(quote(1 ether)) returns (uint256 exitETH) { exitETH = _withdraw(msg.sender, beneficiary, shares, deadline); IERC20(WETH).safeTransfer(beneficiary, exitETH); } /** * Remove the entire Nexus LP balance. */ function removeAllLiquidityETH(address payable beneficiary, uint256 deadline) external nonReentrant verifyPrice(quote(1 ether)) returns (uint256 exitETH) { exitETH = _withdraw(msg.sender, beneficiary, balanceOf(msg.sender), deadline); require(exitETH <= IERC20(WETH).balanceOf(address(this)), "not enough ETH"); IWETH(WETH).withdraw(exitETH); Address.sendValue(beneficiary, exitETH); } /** * Remove the entire Nexus LP balance. */ function removeAllLiquidity(address beneficiary, uint256 deadline) external nonReentrant verifyPrice(quote(1 ether)) returns (uint256 exitETH) { exitETH = _withdraw(msg.sender, beneficiary, balanceOf(msg.sender), deadline); IERC20(WETH).safeTransfer(beneficiary, exitETH); } /** * Since all Sushi LP held by this contract are auto deposited in Sushi MasterChef, SUSHI rewards accrue. * This allows the governance (the vault working with this contract) to claim the rewards so they can * be sold by governance and compounded back inside via compoundProfits. */ function claimRewards() external nonReentrant onlyGovernance { _claimRewards(); uint256 amount = IERC20(REWARD).balanceOf(address(this)); IERC20(REWARD).safeTransfer(msg.sender, amount); emit ClaimRewards(msg.sender, amount); } /** * SUSHI rewards that were claimed by governance (the vault working with this contract) and sold by * governance can be compounded back inside via this function. Receives all sold rewards as ETH. * Argument capitalProviderRewardPercentmil is the split of the profits that should be given to the * provider of USDC. Use 50000 to have an even 50/50 split of the reward profits. Use 20000 to take 80% * to the ETH providers and leave 20% of reward profits to the USDC provider. */ function compoundProfits(uint256 amountETH, uint256 capitalProviderRewardPercentmil) external nonReentrant onlyGovernance returns ( uint256 pairedUSDC, uint256 pairedETH, uint256 liquidity ) { IERC20(WETH).safeTransferFrom(msg.sender, address(this), amountETH); if (capitalProviderRewardPercentmil > 0) { uint256 ownerETH = (amountETH * capitalProviderRewardPercentmil) / 100_000; _swapExactETHForUSDC(ownerETH); amountETH -= ownerETH; } amountETH /= 2; _swapExactETHForUSDC(amountETH); (pairedUSDC, pairedETH, liquidity) = _addLiquidityAndStake(amountETH, block.timestamp); // solhint-disable-line not-rely-on-time totalPairedUSDC += pairedUSDC; totalPairedETH += pairedETH; totalLiquidity += liquidity; // not adding to shares to distribute rewards to all shareholders emit CompoundProfits(msg.sender, liquidity); } function _deposit( address beneficiary, uint256 amountETH, uint256 deadline ) private { uint256 shares = _pair(beneficiary, amountETH, deadline); _mint(beneficiary, shares); emit Mint(msg.sender, beneficiary, shares); } /** * Pair deposited ETH with USDC available in the contract's balance to create Sushi LP. */ function _pair( address minterAddress, uint256 amountETH, uint256 deadline ) private returns (uint256 shares) { (uint256 pairedUSDC, uint256 pairedETH, uint256 liquidity) = _addLiquidityAndStake(amountETH, deadline); if (totalPairedShares == 0) { shares = liquidity; } else { shares = (liquidity * totalPairedShares) / totalLiquidity; } Minter storage minter = minters[minterAddress]; minter.pairedUSDC += pairedUSDC; minter.pairedETH += pairedETH; minter.pairedShares += shares; totalPairedUSDC += pairedUSDC; totalPairedETH += pairedETH; totalPairedShares += shares; totalLiquidity += liquidity; emit Pair(msg.sender, minterAddress, pairedUSDC, pairedETH, liquidity); } function _withdraw( address sender, address beneficiary, uint256 shares, uint256 deadline ) private returns (uint256 exitETH) { Minter storage minter = minters[sender]; shares = Math.min(shares, minter.pairedShares + minter.unpairedShares); require(shares > 0, "sender not in minters"); if (shares > minter.unpairedShares) { _unpair(sender, shares - minter.unpairedShares, deadline); } exitETH = (shares * minter.unpairedETH) / minter.unpairedShares; minter.unpairedETH -= exitETH; minter.unpairedShares -= shares; _burn(sender, shares); emit Burn(sender, beneficiary, shares); } /** * Unpair ETH from USDC by burning Sushi LP and rebalancing IL between the two. */ function _unpair( address minterAddress, uint256 shares, uint256 deadline ) private { uint256 liquidity = (shares * totalLiquidity) / totalPairedShares; (uint256 removedETH, uint256 removedUSDC) = _unstakeAndRemoveLiquidity(liquidity, deadline); Minter storage minter = minters[minterAddress]; uint256 pairedUSDC = (minter.pairedUSDC * shares) / minter.pairedShares; uint256 pairedETH = (minter.pairedETH * shares) / minter.pairedShares; (uint256 exitUSDC, uint256 exitETH) = applyRebalance(removedUSDC, removedETH, pairedUSDC, pairedETH); minter.pairedUSDC -= pairedUSDC; minter.pairedETH -= pairedETH; minter.pairedShares -= shares; minter.unpairedETH += exitETH; minter.unpairedShares += shares; totalPairedUSDC -= pairedUSDC; totalPairedETH -= pairedETH; totalPairedShares -= shares; totalLiquidity -= liquidity; emit Unpair(msg.sender, minterAddress, exitUSDC, exitETH, liquidity); } /** * Allows the owner (the capital provider of USDC) to emergency exit all of their USDC. * When called, all Sushi LP is burned to extract ETH+USDC, the USDC part is returned to owner. * The ETH will wait in the contract until the original ETH depositors will remove it. */ function emergencyExit(address[] memory minterAddresses) external onlyOwner { for (uint256 i = 0; i < minterAddresses.length; i++) { address minterAddress = minterAddresses[i]; Minter storage minter = minters[minterAddress]; uint256 shares = minter.pairedShares; if (shares > 0) { _unpair(minterAddress, shares, block.timestamp); //solhint-disable-line not-rely-on-time } } withdrawFreeCapital(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-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 virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./base/SushiswapIntegration.sol"; abstract contract RebalancingStrategy1 is SushiswapIntegration { /** * Rebalance usd and eth such that the eth provider takes all IL risk but receives all excess eth, * while usd provider's principal is protected */ function applyRebalance( uint256 removedUSDC, uint256 removedETH, uint256 entryUSDC, uint256 //entryETH ) internal returns (uint256 exitUSDC, uint256 exitETH) { if (removedUSDC > entryUSDC) { uint256 deltaUSDC = removedUSDC - entryUSDC; exitETH = removedETH + _swapExactUSDCForETH(deltaUSDC); exitUSDC = entryUSDC; } else { uint256 deltaUSDC = entryUSDC - removedUSDC; uint256 deltaETH = Math.min(removedETH, amountInETHForRequestedOutUSDC(deltaUSDC)); exitUSDC = removedUSDC + _swapExactETHForUSDC(deltaETH); exitETH = removedETH - deltaETH; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./LiquidityNexusBase.sol"; import "../interface/ISushiswapRouter.sol"; import "../interface/ISushiMasterChef.sol"; abstract contract SushiswapIntegration is Salvageable, LiquidityNexusBase { using SafeERC20 for IERC20; address public constant SLP = address(0x397FF1542f962076d0BFE58eA045FfA2d347ACa0); // Sushiswap USDC/ETH pair address public constant ROUTER = address(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); // Sushiswap Router2 address public constant MASTERCHEF = address(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd); address public constant REWARD = address(0x6B3595068778DD592e39A122f4f5a5cF09C90fE2); uint256 public constant POOL_ID = 1; address[] public pathToETH = new address[](2); address[] public pathToUSDC = new address[](2); constructor() { pathToUSDC[0] = WETH; pathToUSDC[1] = USDC; pathToETH[0] = USDC; pathToETH[1] = WETH; IERC20(USDC).safeApprove(ROUTER, type(uint256).max); IERC20(WETH).safeApprove(ROUTER, type(uint256).max); IERC20(SLP).safeApprove(ROUTER, type(uint256).max); IERC20(SLP).safeApprove(MASTERCHEF, type(uint256).max); } /** * returns price of ETH in USDC */ function quote(uint256 inETH) public view returns (uint256 outUSDC) { (uint112 rUSDC, uint112 rETH, ) = IUniswapV2Pair(SLP).getReserves(); outUSDC = IUniswapV2Router02(ROUTER).quote(inETH, rETH, rUSDC); } /** * returns price of USDC in ETH */ function quoteInverse(uint256 inUSDC) public view returns (uint256 outETH) { (uint112 rUSDC, uint112 rETH, ) = IUniswapV2Pair(SLP).getReserves(); outETH = IUniswapV2Router02(ROUTER).quote(inUSDC, rUSDC, rETH); } /** * returns ETH amount (in) needed when swapping for requested USDC amount (out) */ function amountInETHForRequestedOutUSDC(uint256 outUSDC) public view returns (uint256 inETH) { inETH = IUniswapV2Router02(ROUTER).getAmountsIn(outUSDC, pathToUSDC)[0]; } function _swapExactUSDCForETH(uint256 inUSDC) internal returns (uint256 outETH) { if (inUSDC == 0) return 0; uint256[] memory amounts = IUniswapV2Router02(ROUTER).swapExactTokensForTokens(inUSDC, 0, pathToETH, address(this), block.timestamp); // solhint-disable-line not-rely-on-time require(inUSDC == amounts[0], "leftover USDC"); outETH = amounts[1]; } function _swapExactETHForUSDC(uint256 inETH) internal returns (uint256 outUSDC) { if (inETH == 0) return 0; uint256[] memory amounts = IUniswapV2Router02(ROUTER).swapExactTokensForTokens( inETH, 0, pathToUSDC, address(this), block.timestamp // solhint-disable-line not-rely-on-time ); require(inETH == amounts[0], "leftover ETH"); outUSDC = amounts[1]; } function _addLiquidityAndStake(uint256 amountETH, uint256 deadline) internal returns ( uint256 addedUSDC, uint256 addedETH, uint256 liquidity ) { require(IERC20(WETH).balanceOf(address(this)) >= amountETH, "not enough WETH"); uint256 quotedUSDC = quote(amountETH); require(IERC20(USDC).balanceOf(address(this)) >= quotedUSDC, "not enough free capital"); (addedETH, addedUSDC, liquidity) = IUniswapV2Router02(ROUTER).addLiquidity( WETH, USDC, amountETH, quotedUSDC, amountETH, 0, address(this), deadline ); require(addedETH == amountETH, "leftover ETH"); IMasterChef(MASTERCHEF).deposit(POOL_ID, liquidity); } function _unstakeAndRemoveLiquidity(uint256 liquidity, uint256 deadline) internal returns (uint256 removedETH, uint256 removedUSDC) { if (liquidity == 0) return (0, 0); IMasterChef(MASTERCHEF).withdraw(POOL_ID, liquidity); (removedETH, removedUSDC) = IUniswapV2Router02(ROUTER).removeLiquidity( WETH, USDC, liquidity, 0, 0, address(this), deadline ); } function _claimRewards() internal { IMasterChef(MASTERCHEF).deposit(POOL_ID, 0); } function canSalvage(address token) public pure override returns (bool) { return token != WETH && token != USDC && token != SLP && token != REWARD; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./Governable.sol"; import "./Salvageable.sol"; import "./PriceGuard.sol"; abstract contract LiquidityNexusBase is Ownable, Pausable, Governable, Salvageable, ReentrancyGuard, PriceGuard { using SafeERC20 for IERC20; address public constant WETH = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address public constant USDC = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); /** * Only the owner is supposed to deposit USDC into this contract. */ function depositCapital(uint256 amount) public onlyOwner { IERC20(USDC).safeTransferFrom(msg.sender, address(this), amount); } function depositAllCapital() external onlyOwner { depositCapital(IERC20(USDC).balanceOf(msg.sender)); } /** * The owner can withdraw the unused USDC capital that they had deposited earlier. */ function withdrawFreeCapital() public onlyOwner { uint256 balance = IERC20(USDC).balanceOf(address(this)); if (balance > 0) { IERC20(USDC).safeTransfer(msg.sender, balance); } } /** * Pause will only prevent new ETH deposits (addLiquidity). Existing depositors will still * be able to removeLiquidity even when paused. */ function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } /** * Owner can disable the PriceGuard oracle in case of emergency */ function pausePriceGuard() external onlyOwner { _pausePriceGuard(true); } function unpausePriceGuard() external onlyOwner { _pausePriceGuard(false); } /** * Owner can only salvage unrelated tokens that were sent by mistake. */ function salvage(address[] memory tokens) external onlyOwner { _salvage(tokens); } receive() external payable {} // solhint-disable-line no-empty-blocks } // SPDX-License-Identifier: MIT // solhint-disable pragma solidity 0.8.4; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint256); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function migrator() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; function setMigrator(address) external; } interface IERC20Uniswap { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); } interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); function withdraw(uint256) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; interface IMasterChef { function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function emergencyWithdraw(uint256 _pid) external; function userInfo(uint256 _pid, address _user) external view returns (uint256 amount, uint256 rewardDebt); function poolInfo(uint256 _pid) external view returns ( address lpToken, uint256, uint256, uint256 ); function massUpdatePools() external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; abstract contract Governable { address public governance; constructor() { governance = msg.sender; } modifier onlyGovernance() { require(msg.sender == governance, "only governance"); _; } function setGovernance(address _governance) external onlyGovernance { require(_governance != address(0), "null governance"); governance = _governance; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; abstract contract Salvageable { using SafeERC20 for IERC20; function _salvage(address[] memory tokens) internal { for (uint256 i = 0; i < tokens.length; i++) { address token = tokens[i]; require(canSalvage(token), "token not salvageable"); uint256 balance = IERC20(token).balanceOf(address(this)); if (balance > 0) { IERC20(token).safeTransfer(msg.sender, balance); } } } function canSalvage(address token) public pure virtual returns (bool); } // SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/utils/math/Math.sol"; interface IChainlinkOracle { function latestAnswer() external view returns (uint256); } abstract contract PriceGuard { event PausePriceGuard(address indexed sender, bool paused); uint256 public constant SPREAD_TOLERANCE = 10; // max 10% spread address public constant CHAINLINK_ORACLE = address(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); bool public priceGuardPaused = false; modifier verifyPrice(uint256 priceETHUSD) { if (!priceGuardPaused) { uint256 oraclePrice = chainlinkPriceETHUSD(); uint256 min = Math.min(priceETHUSD, oraclePrice); uint256 max = Math.max(priceETHUSD, oraclePrice); uint256 upperLimit = (min * (SPREAD_TOLERANCE + 100)) / 100; require(max <= upperLimit, "PriceOracle ETHUSD"); } _; } /** * returns price of ETH in USD (6 decimals) */ function chainlinkPriceETHUSD() public view returns (uint256) { return IChainlinkOracle(CHAINLINK_ORACLE).latestAnswer() / 100; // chainlink answer is 8 decimals } function _pausePriceGuard(bool _paused) internal { priceGuardPaused = _paused; emit PausePriceGuard(msg.sender, priceGuardPaused); } }
* Depositors only deposit ETH. This convenience function allows to deposit WETH (ERC20)./
function addLiquidity( address beneficiary, uint256 amountETH, uint256 deadline ) external nonReentrant whenNotPaused verifyPrice(quote(1 ether)) { IERC20(WETH).safeTransferFrom(msg.sender, address(this), amountETH); _deposit(beneficiary, amountETH, deadline); }
11,666,856
[ 1, 4625, 348, 7953, 560, 30, 380, 4019, 538, 13704, 1338, 443, 1724, 512, 2455, 18, 1220, 13553, 445, 5360, 358, 443, 1724, 678, 1584, 44, 261, 654, 39, 3462, 2934, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 527, 48, 18988, 24237, 12, 203, 3639, 1758, 27641, 74, 14463, 814, 16, 203, 3639, 2254, 5034, 3844, 1584, 44, 16, 203, 3639, 2254, 5034, 14096, 203, 565, 262, 3903, 1661, 426, 8230, 970, 1347, 1248, 28590, 3929, 5147, 12, 6889, 12, 21, 225, 2437, 3719, 288, 203, 3639, 467, 654, 39, 3462, 12, 59, 1584, 44, 2934, 4626, 5912, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 3844, 1584, 44, 1769, 203, 3639, 389, 323, 1724, 12, 70, 4009, 74, 14463, 814, 16, 3844, 1584, 44, 16, 14096, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: Unlicense pragma solidity ^0.5.0; import "./scm.sol"; import "canonical-weth/contracts/WETH9.sol"; contract ICO { // Current state of the ICO. enum State { // ICO is is progress, new contributions are accepted. Ongoing, // ICO is closed, new contributions are not accepted. // SCM tokens are pending release. Closed, // ICO is finished, SCM tokens are released // and available for withdrawal. Finished } // How much ether do we want to collect. uint256 public constant target = 10 ether; // Rate for converting ETH to SCM. uint256 public constant rate = 10; // Time between ICO is closed and tokens are released. uint256 public constant holdDuration = 2 minutes; // SCM coin we're issuing. SCM public scm; // WETH coin we're collecting. WETH9 public weth; // Emitted when the ICO is closed. // // Args: // // - `closedTime`: timestamp of when this ICO was closed. // - `finishedTime`: timestamp of when issued SCM tokens // will be available for withdrawal. event IcoClosed(uint256 closedTime, uint256 finishedTime); // Emitted when someone funds this ICO. // // Args: // // - `buyer`: who bought the tokens. // - `ethersUsed`: number of ETH tokens added to the ICO. // - `scmPurchased`: number of SCM tokens added to the buyer's balance. event Fund(address indexed buyer, uint256 ethUsed, uint256 scmPurchased); uint256 private _left = target; uint256 private _closeTime = 0; mapping (address => uint256) private _contributions; // XXX: ideally we'd like some logic to cancel the ICO. Initially, // all collected ether is stored at the ICO's address. If within // certain time we don't collect enough funds, ICO is cancelled // and users can get their money back. Otherwise, ICO succeeds // and `ethReceiver` can claim their ethers, while contributors // can claim their SCMs. I'm not going to implement this because // I've already spent enough time on this task =) address _ethReceiver; constructor(WETH9 _weth, address ethReceiver) public { scm = new SCM(toScm(target)); weth = _weth; _ethReceiver = ethReceiver; } // Convert ETH to SCM. function toScm(uint256 eth) public pure returns (uint256) { return eth * rate; } // Get the current state of the ICO. function state() public view returns (State) { if (_left > 0) { return State.Ongoing; } else if (block.timestamp < _closeTime + holdDuration) { return State.Closed; } else { return State.Finished; } } // Time when this ICO was closed. It is an error to call this function // when the ICO is still ongoing. function closeTime() public view returns (uint256) { require(state() != State.Ongoing, "ICO is still ongoing"); return _closeTime; } // Time when this ICO was or will be finished. It is an error to call // this function when the ICO is still ongoing. function finishTime() public view returns (uint256) { require(state() != State.Ongoing, "ICO is still ongoing"); return _closeTime + holdDuration; } // Get number of WETH tokens that's left to gather to close this ICO. function leftEth() public view returns (uint256) { return _left; } // Get number of SCM tokens available for purchase. function leftScm() public view returns (uint256) { return toScm(_left); } // Get number of ETH tokens contributed by the given user. // The balance will become zero once the user claims their tokens. function balanceEth(address owner) public view returns (uint256) { return _contributions[owner]; } // Get number of SCM tokens available for the given user. // The balance will become zero once the user claims their tokens. function balanceScm(address owner) public view returns (uint256) { return toScm(_contributions[owner]); } // Fund this ICO with the given amount of WETH. If there's not enough // SCM left for the given amount of WETH, this function fails. // Returns number of purchased SCM tokens. function fund(uint256 funds) public returns (uint256) { require(state() == State.Ongoing, "ICO is closed"); require(funds <= _left, "not enough tokens left"); require(weth.balanceOf(msg.sender) >= funds, "not enough WETH"); require(weth.allowance(msg.sender, address(this)) >= funds, "not allowed to spend WETH"); require(weth.transferFrom(msg.sender, address(_ethReceiver), funds)); _contributions[msg.sender] += funds; _left -= funds; emit Fund(msg.sender, funds, toScm(funds)); if (_left == 0) { _closeTime = block.timestamp; emit IcoClosed(closeTime(), finishTime()); } return toScm(funds); } // Fund this ICO with the given amount of WETH. If there's not enough // SCM left for the given amount of WETH, purchase all available SCM. // Returns number of spent WETH and number of purchased SCM tokens. function fundAny(uint256 funds) public returns (uint256 spent, uint256 claimed) { if (funds > _left) { return (_left, fund(_left)); } else { return (funds, fund(funds)); } } // Claim purchased SCM. Returns number of transferred tokens. // It is an error to call this function twice, or to call it if user's // balance is zero. function claim() public returns (uint256) { require(state() == State.Finished, "ICO is not finished yet"); uint256 balance = toScm(_contributions[msg.sender]); require(balance > 0, "no SCM tokens to claim"); require(scm.transfer(msg.sender, balance)); _contributions[msg.sender] = 0; return balance; } }
Claim purchased SCM. Returns number of transferred tokens. It is an error to call this function twice, or to call it if user's balance is zero.
function claim() public returns (uint256) { require(state() == State.Finished, "ICO is not finished yet"); uint256 balance = toScm(_contributions[msg.sender]); require(balance > 0, "no SCM tokens to claim"); require(scm.transfer(msg.sender, balance)); _contributions[msg.sender] = 0; return balance; }
975,908
[ 1, 4625, 348, 7953, 560, 30, 225, 18381, 5405, 343, 8905, 8795, 49, 18, 2860, 1300, 434, 906, 4193, 2430, 18, 2597, 353, 392, 555, 358, 745, 333, 445, 13605, 16, 578, 358, 745, 518, 309, 729, 1807, 11013, 353, 3634, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 7516, 1435, 1071, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 2583, 12, 2019, 1435, 422, 3287, 18, 10577, 16, 315, 2871, 51, 353, 486, 6708, 4671, 8863, 203, 203, 3639, 2254, 5034, 11013, 273, 358, 1541, 81, 24899, 591, 15326, 63, 3576, 18, 15330, 19226, 203, 203, 3639, 2583, 12, 12296, 405, 374, 16, 315, 2135, 8795, 49, 2430, 358, 7516, 8863, 203, 3639, 2583, 12, 1017, 81, 18, 13866, 12, 3576, 18, 15330, 16, 11013, 10019, 203, 203, 3639, 389, 591, 15326, 63, 3576, 18, 15330, 65, 273, 374, 31, 203, 203, 3639, 327, 11013, 31, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0xb855D7106b8061a3F9Bd6E05Aea99539FFa60843/sources/ChainlinkAdapter.sol
* @dev Returns the addition of two unsigned integers, reverting on overflow./
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "Unaddition overflow"); return c; }
2,611,786
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 326, 2719, 434, 2795, 9088, 12321, 16, 15226, 310, 603, 9391, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 527, 12, 11890, 5034, 279, 16, 2254, 5034, 324, 13, 2713, 16618, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 2254, 5034, 276, 273, 279, 397, 324, 31, 203, 3639, 2583, 12, 71, 1545, 279, 16, 315, 984, 1289, 608, 9391, 8863, 203, 203, 3639, 327, 276, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // File contracts/Ptp.sol pragma solidity 0.8.9; /// @title the ptp token /// Note initially forked from Uniswap and then upgraded to 0.8.9 contract Ptp { /// @notice EIP-20 token name for this token string public constant name = 'Platypus'; /// @notice EIP-20 token symbol for this token string public constant symbol = 'PTP'; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint256 public totalSupply = 300_000_000e18; // 300M PTP /// @notice Address which may mint new tokens address public minter; /// @notice The timestamp after which minting may occur uint256 public mintingAllowedAfter; /// @notice Minimum time between mints uint32 public constant minimumTimeBetweenMints = 1 days * 365; /// @notice Cap on the percentage of totalSupply that can be minted at each mint uint8 public constant mintCap = 2; /// @notice Allowance amounts on behalf of others mapping(address => mapping(address => uint96)) internal allowances; /// @notice Official record of token balances for each account mapping(address => uint96) internal balances; /// @notice The EIP-712 typehash for the contract's domain bytes32 public immutable DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)'); /// @notice The EIP-712 typehash for the permit struct used by the contract bytes32 public immutable PERMIT_TYPEHASH = keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when the minter address is changed event MinterChanged(address minter, address newMinter); /// @notice The standard EIP-20 transfer event event Transfer(address indexed from, address indexed to, uint256 amount); /// @notice The standard EIP-20 approval event event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @notice Construct a new Ptp token * @param account The initial account to grant all the tokens * @param minter_ The account with minting ability * @param mintingAllowedAfter_ The timestamp after which minting may occur */ constructor( address account, address minter_, uint256 mintingAllowedAfter_ ) { require(mintingAllowedAfter_ >= block.timestamp, 'Ptp::constructor: minting can only begin after deployment'); balances[account] = uint96(totalSupply); emit Transfer(address(0), account, totalSupply); minter = minter_; emit MinterChanged(address(0), minter_); mintingAllowedAfter = mintingAllowedAfter_; } /** * @notice Change the minter address * @param minter_ The address of the new minter */ function setMinter(address minter_) external { require(msg.sender == minter, 'Ptp::setMinter: only the minter can change the minter address'); emit MinterChanged(minter, minter_); minter = minter_; } /** * @notice Mint new tokens * @param dst The address of the destination account * @param rawAmount The number of tokens to be minted */ function mint(address dst, uint256 rawAmount) external { require(msg.sender == minter, 'Ptp::mint: only the minter can mint'); require(block.timestamp >= mintingAllowedAfter, 'Ptp::mint: minting not allowed yet'); require(dst != address(0), 'Ptp::mint: cannot transfer to the zero address'); // record the mint mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); // mint the amount uint96 amount = safe96(rawAmount, 'Ptp::mint: amount exceeds 96 bits'); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), 'Ptp::mint: exceeded mint cap'); totalSupply = safe96(SafeMath.add(totalSupply, amount), 'Ptp::mint: totalSupply exceeds 96 bits'); // transfer the amount to the recipient balances[dst] = add96(balances[dst], amount, 'Ptp::mint: transfer amount overflows'); emit Transfer(address(0), dst, amount); } /** * @notice Get the number of tokens `spender` is approved to spend on behalf of `account` * @param account The address of the account holding the funds * @param spender The address of the account spending the funds * @return The number of tokens approved */ function allowance(address account, address spender) external view returns (uint256) { return allowances[account][spender]; } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 rawAmount) external returns (bool) { uint96 amount; if (rawAmount == type(uint256).max) { amount = type(uint96).max; } else { amount = safe96(rawAmount, 'Ptp::approve: amount exceeds 96 bits'); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @notice Triggers an approval from owner to spends * @param owner The address to approve from * @param spender The address to be approved * @param rawAmount The number of tokens that are approved (2^256-1 means infinite) * @param deadline The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function permit( address owner, address spender, uint256 rawAmount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { // PTP-01M fix require(v == 27 || v == 28, 'Ptp::permit: invalid range for v'); require( uint256(s) < 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1, 'Ptp::permit: invalid range for s' ); uint96 amount; if (rawAmount == type(uint256).max) { amount = type(uint96).max; } else { amount = safe96(rawAmount, 'Ptp::permit: amount exceeds 96 bits'); } bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)) ); bytes32 structHash = keccak256( abi.encode(PERMIT_TYPEHASH, owner, spender, rawAmount, nonces[owner]++, deadline) ); bytes32 digest = keccak256(abi.encodePacked('\x19\x01', domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), 'Ptp::permit: invalid signature'); require(signatory == owner, 'Ptp::permit: unauthorized'); require(block.timestamp <= deadline, 'Ptp::permit: signature expired'); allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @notice Get the number of tokens held by the `account` * @param account The address of the account to get the balance of * @return The number of tokens held */ function balanceOf(address account) external view returns (uint256) { return balances[account]; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @dev This function is expected to ALWAYS return true, or else it should throw * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 rawAmount) external returns (bool) { uint96 amount = safe96(rawAmount, 'Ptp::transfer: amount exceeds 96 bits'); _transferTokens(msg.sender, dst, amount); return true; } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param rawAmount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 rawAmount ) external returns (bool) { address spender = msg.sender; uint96 spenderAllowance = allowances[src][spender]; uint96 amount = safe96(rawAmount, 'Ptp::approve: amount exceeds 96 bits'); if (spender != src && spenderAllowance != type(uint96).max) { uint96 newAllowance = sub96( spenderAllowance, amount, 'Ptp::transferFrom: transfer amount exceeds spender allowance' ); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } function _transferTokens( address src, address dst, uint96 amount ) internal { require(src != address(0), 'Ptp::_transferTokens: cannot transfer from the zero address'); require(dst != address(0), 'Ptp::_transferTokens: cannot transfer to the zero address'); balances[src] = sub96(balances[src], amount, 'Ptp::_transferTokens: transfer amount exceeds balance'); balances[dst] = add96(balances[dst], amount, 'Ptp::_transferTokens: transfer amount overflows'); emit Transfer(src, dst, amount); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
* @notice Mint new tokens @param dst The address of the destination account @param rawAmount The number of tokens to be minted/ record the mint mint the amount transfer the amount to the recipient
function mint(address dst, uint256 rawAmount) external { require(msg.sender == minter, 'Ptp::mint: only the minter can mint'); require(block.timestamp >= mintingAllowedAfter, 'Ptp::mint: minting not allowed yet'); require(dst != address(0), 'Ptp::mint: cannot transfer to the zero address'); mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); uint96 amount = safe96(rawAmount, 'Ptp::mint: amount exceeds 96 bits'); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), 'Ptp::mint: exceeded mint cap'); totalSupply = safe96(SafeMath.add(totalSupply, amount), 'Ptp::mint: totalSupply exceeds 96 bits'); balances[dst] = add96(balances[dst], amount, 'Ptp::mint: transfer amount overflows'); emit Transfer(address(0), dst, amount); }
2,481,001
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 490, 474, 394, 2430, 632, 891, 3046, 1021, 1758, 434, 326, 2929, 2236, 632, 891, 1831, 6275, 1021, 1300, 434, 2430, 358, 506, 312, 474, 329, 19, 1409, 326, 312, 474, 312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81, 474, 30, 1338, 326, 1131, 387, 848, 312, 474, 8284, 203, 3639, 2583, 12, 2629, 18, 5508, 1545, 312, 474, 310, 5042, 4436, 16, 296, 52, 6834, 2866, 81, 474, 30, 312, 474, 310, 486, 2935, 4671, 8284, 203, 3639, 2583, 12, 11057, 480, 1758, 12, 20, 3631, 296, 52, 6834, 2866, 81, 474, 30, 2780, 7412, 358, 326, 3634, 1758, 8284, 203, 203, 3639, 312, 474, 310, 5042, 4436, 273, 14060, 10477, 18, 1289, 12, 2629, 18, 5508, 16, 5224, 950, 11831, 49, 28142, 1769, 203, 203, 3639, 2254, 10525, 3844, 273, 4183, 10525, 12, 1899, 6275, 16, 296, 52, 6834, 2866, 81, 474, 30, 3844, 14399, 19332, 4125, 8284, 203, 3639, 2583, 12, 8949, 1648, 14060, 10477, 18, 2892, 12, 9890, 10477, 18, 16411, 12, 4963, 3088, 1283, 16, 312, 474, 4664, 3631, 2130, 3631, 296, 52, 6834, 2866, 81, 474, 30, 12428, 312, 474, 3523, 8284, 203, 3639, 2078, 3088, 1283, 273, 4183, 10525, 12, 9890, 10477, 18, 1289, 12, 4963, 3088, 1283, 16, 3844, 3631, 296, 52, 6834, 2866, 81, 474, 30, 2078, 3088, 1283, 14399, 19332, 4125, 8284, 203, 203, 3639, 324, 26488, 63, 11057, 65, 273, 527, 10525, 12, 70, 26488, 63, 11057, 6487, 3844, 16, 296, 52, 6834, 2866, 81, 474, 30, 7412, 3844, 9391, 87, 8284, 203, 3639, 3626, 12279, 12, 2867, 12, 20, 3631, 3046, 16, 3844, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity 0.5.15; contract IAugur { function CREATECHILDUNIVERSE712(bytes32 _parentPayoutDistributionHash, uint256[] memory _parentPayoutNumerators) public returns (IUniverse); //inject NONSTANDARD NAMING function ISKNOWNUNIVERSE698(IUniverse _universe) public view returns (bool); //inject NONSTANDARD NAMING function TRUSTEDCASHTRANSFER967(address _from, address _to, uint256 _amount) public returns (bool); //inject NONSTANDARD NAMING function ISTRUSTEDSENDER635(address _address) public returns (bool); //inject NONSTANDARD NAMING function ONCATEGORICALMARKETCREATED679(uint256 _endTime, string memory _extraInfo, IMarket _market, address _marketCreator, address _designatedReporter, uint256 _feePerCashInAttoCash, bytes32[] memory _outcomes) public returns (bool); //inject NONSTANDARD NAMING function ONYESNOMARKETCREATED215(uint256 _endTime, string memory _extraInfo, IMarket _market, address _marketCreator, address _designatedReporter, uint256 _feePerCashInAttoCash) public returns (bool); //inject NONSTANDARD NAMING function ONSCALARMARKETCREATED844(uint256 _endTime, string memory _extraInfo, IMarket _market, address _marketCreator, address _designatedReporter, uint256 _feePerCashInAttoCash, int256[] memory _prices, uint256 _numTicks) public returns (bool); //inject NONSTANDARD NAMING function LOGINITIALREPORTSUBMITTED874(IUniverse _universe, address _reporter, address _market, address _initialReporter, uint256 _amountStaked, bool _isDesignatedReporter, uint256[] memory _payoutNumerators, string memory _description, uint256 _nextWindowStartTime, uint256 _nextWindowEndTime) public returns (bool); //inject NONSTANDARD NAMING function DISPUTECROWDSOURCERCREATED646(IUniverse _universe, address _market, address _disputeCrowdsourcer, uint256[] memory _payoutNumerators, uint256 _size, uint256 _disputeRound) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERCONTRIBUTION255(IUniverse _universe, address _reporter, address _market, address _disputeCrowdsourcer, uint256 _amountStaked, string memory description, uint256[] memory _payoutNumerators, uint256 _currentStake, uint256 _stakeRemaining, uint256 _disputeRound) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERCOMPLETED546(IUniverse _universe, address _market, address _disputeCrowdsourcer, uint256[] memory _payoutNumerators, uint256 _nextWindowStartTime, uint256 _nextWindowEndTime, bool _pacingOn, uint256 _totalRepStakedInPayout, uint256 _totalRepStakedInMarket, uint256 _disputeRound) public returns (bool); //inject NONSTANDARD NAMING function LOGINITIALREPORTERREDEEMED338(IUniverse _universe, address _reporter, address _market, uint256 _amountRedeemed, uint256 _repReceived, uint256[] memory _payoutNumerators) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERREDEEMED9(IUniverse _universe, address _reporter, address _market, uint256 _amountRedeemed, uint256 _repReceived, uint256[] memory _payoutNumerators) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETFINALIZED368(IUniverse _universe, uint256[] memory _winningPayoutNumerators) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETMIGRATED444(IMarket _market, IUniverse _originalUniverse) public returns (bool); //inject NONSTANDARD NAMING function LOGREPORTINGPARTICIPANTDISAVOWED43(IUniverse _universe, IMarket _market) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETPARTICIPANTSDISAVOWED537(IUniverse _universe) public returns (bool); //inject NONSTANDARD NAMING function LOGCOMPLETESETSPURCHASED486(IUniverse _universe, IMarket _market, address _account, uint256 _numCompleteSets) public returns (bool); //inject NONSTANDARD NAMING function LOGCOMPLETESETSSOLD144(IUniverse _universe, IMarket _market, address _account, uint256 _numCompleteSets, uint256 _fees) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETOICHANGED928(IUniverse _universe, IMarket _market) public returns (bool); //inject NONSTANDARD NAMING function LOGTRADINGPROCEEDSCLAIMED757(IUniverse _universe, address _sender, address _market, uint256 _outcome, uint256 _numShares, uint256 _numPayoutTokens, uint256 _fees) public returns (bool); //inject NONSTANDARD NAMING function LOGUNIVERSEFORKED116(IMarket _forkingMarket) public returns (bool); //inject NONSTANDARD NAMING function LOGREPUTATIONTOKENSTRANSFERRED904(IUniverse _universe, address _from, address _to, uint256 _value, uint256 _fromBalance, uint256 _toBalance) public returns (bool); //inject NONSTANDARD NAMING function LOGREPUTATIONTOKENSBURNED995(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGREPUTATIONTOKENSMINTED985(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGSHARETOKENSBALANCECHANGED123(address _account, IMarket _market, uint256 _outcome, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERTOKENSTRANSFERRED932(IUniverse _universe, address _from, address _to, uint256 _value, uint256 _fromBalance, uint256 _toBalance) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERTOKENSBURNED518(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTECROWDSOURCERTOKENSMINTED48(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGDISPUTEWINDOWCREATED79(IDisputeWindow _disputeWindow, uint256 _id, bool _initial) public returns (bool); //inject NONSTANDARD NAMING function LOGPARTICIPATIONTOKENSREDEEMED534(IUniverse universe, address _sender, uint256 _attoParticipationTokens, uint256 _feePayoutShare) public returns (bool); //inject NONSTANDARD NAMING function LOGTIMESTAMPSET762(uint256 _newTimestamp) public returns (bool); //inject NONSTANDARD NAMING function LOGINITIALREPORTERTRANSFERRED573(IUniverse _universe, IMarket _market, address _from, address _to) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETTRANSFERRED247(IUniverse _universe, address _from, address _to) public returns (bool); //inject NONSTANDARD NAMING function LOGPARTICIPATIONTOKENSTRANSFERRED386(IUniverse _universe, address _from, address _to, uint256 _value, uint256 _fromBalance, uint256 _toBalance) public returns (bool); //inject NONSTANDARD NAMING function LOGPARTICIPATIONTOKENSBURNED957(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGPARTICIPATIONTOKENSMINTED248(IUniverse _universe, address _target, uint256 _amount, uint256 _totalSupply, uint256 _balance) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETREPBONDTRANSFERRED31(address _universe, address _from, address _to) public returns (bool); //inject NONSTANDARD NAMING function LOGWARPSYNCDATAUPDATED845(address _universe, uint256 _warpSyncHash, uint256 _marketEndTime) public returns (bool); //inject NONSTANDARD NAMING function ISKNOWNFEESENDER211(address _feeSender) public view returns (bool); //inject NONSTANDARD NAMING function LOOKUP594(bytes32 _key) public view returns (address); //inject NONSTANDARD NAMING function GETTIMESTAMP626() public view returns (uint256); //inject NONSTANDARD NAMING function GETMAXIMUMMARKETENDDATE626() public returns (uint256); //inject NONSTANDARD NAMING function ISKNOWNMARKET166(IMarket _market) public view returns (bool); //inject NONSTANDARD NAMING function DERIVEPAYOUTDISTRIBUTIONHASH812(uint256[] memory _payoutNumerators, uint256 _numTicks, uint256 numOutcomes) public view returns (bytes32); //inject NONSTANDARD NAMING function LOGVALIDITYBONDCHANGED992(uint256 _validityBond) public returns (bool); //inject NONSTANDARD NAMING function LOGDESIGNATEDREPORTSTAKECHANGED748(uint256 _designatedReportStake) public returns (bool); //inject NONSTANDARD NAMING function LOGNOSHOWBONDCHANGED254(uint256 _noShowBond) public returns (bool); //inject NONSTANDARD NAMING function LOGREPORTINGFEECHANGED596(uint256 _reportingFee) public returns (bool); //inject NONSTANDARD NAMING function GETUNIVERSEFORKINDEX548(IUniverse _universe) public view returns (uint256); //inject NONSTANDARD NAMING } contract IOwnable { function GETOWNER826() public view returns (address); //inject NONSTANDARD NAMING function TRANSFEROWNERSHIP284(address _newOwner) public returns (bool); //inject NONSTANDARD NAMING } contract ITyped { function GETTYPENAME153() public view returns (bytes32); //inject NONSTANDARD NAMING } library SafeMathUint256 { function MUL760(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function DIV647(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function SUB692(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING require(b <= a); return a - b; } function ADD571(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING uint256 c = a + b; require(c >= a); return c; } function MIN885(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING if (a <= b) { return a; } else { return b; } } function MAX990(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING if (a >= b) { return a; } else { return b; } } function SQRT858(uint256 y) internal pure returns (uint256 z) { //inject NONSTANDARD NAMING if (y > 3) { uint256 x = (y + 1) / 2; z = y; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } function GETUINT256MIN331() internal pure returns (uint256) { //inject NONSTANDARD NAMING return 0; } function GETUINT256MAX467() internal pure returns (uint256) { //inject NONSTANDARD NAMING // 2 ** 256 - 1 return 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; } function ISMULTIPLEOF540(uint256 a, uint256 b) internal pure returns (bool) { //inject NONSTANDARD NAMING return a % b == 0; } // Float [fixed point] Operations function FXPMUL102(uint256 a, uint256 b, uint256 base) internal pure returns (uint256) { //inject NONSTANDARD NAMING return DIV647(MUL760(a, b), base); } function FXPDIV922(uint256 a, uint256 b, uint256 base) internal pure returns (uint256) { //inject NONSTANDARD NAMING return DIV647(MUL760(a, base), b); } } interface IERC1155 { event TRANSFERSINGLE49( //inject NONSTANDARD NAMING address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value ); event TRANSFERBATCH882( //inject NONSTANDARD NAMING address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); event APPROVALFORALL731( //inject NONSTANDARD NAMING address indexed owner, address indexed operator, bool approved ); event URI998( //inject NONSTANDARD NAMING string value, uint256 indexed id ); function SAFETRANSFERFROM689( //inject NONSTANDARD NAMING address from, address to, uint256 id, uint256 value, bytes calldata data ) external; function SAFEBATCHTRANSFERFROM779( //inject NONSTANDARD NAMING address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; function SETAPPROVALFORALL494(address operator, bool approved) external; //inject NONSTANDARD NAMING function ISAPPROVEDFORALL901(address owner, address operator) external view returns (bool); //inject NONSTANDARD NAMING function BALANCEOF492(address owner, uint256 id) external view returns (uint256); //inject NONSTANDARD NAMING function TOTALSUPPLY304(uint256 id) external view returns (uint256); //inject NONSTANDARD NAMING function BALANCEOFBATCH918( //inject NONSTANDARD NAMING address[] calldata owners, uint256[] calldata ids ) external view returns (uint256[] memory balances_); } contract IERC20 { function TOTALSUPPLY304() external view returns (uint256); //inject NONSTANDARD NAMING function BALANCEOF492(address owner) public view returns (uint256); //inject NONSTANDARD NAMING function TRANSFER644(address to, uint256 amount) public returns (bool); //inject NONSTANDARD NAMING function TRANSFERFROM669(address from, address to, uint256 amount) public returns (bool); //inject NONSTANDARD NAMING function APPROVE293(address spender, uint256 amount) public returns (bool); //inject NONSTANDARD NAMING function ALLOWANCE377(address owner, address spender) public view returns (uint256); //inject NONSTANDARD NAMING // solhint-disable-next-line no-simple-event-func-name event TRANSFER723(address indexed from, address indexed to, uint256 value); //inject NONSTANDARD NAMING event APPROVAL665(address indexed owner, address indexed spender, uint256 value); //inject NONSTANDARD NAMING } contract ICash is IERC20 { } contract ERC20 is IERC20 { using SafeMathUint256 for uint256; uint8 constant public decimals866 = 18; //inject NONSTANDARD NAMING uint256 public totalSupply; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowances; function BALANCEOF492(address _account) public view returns (uint256) { //inject NONSTANDARD NAMING return balances[_account]; } function TRANSFER644(address _recipient, uint256 _amount) public returns (bool) { //inject NONSTANDARD NAMING _TRANSFER433(msg.sender, _recipient, _amount); return true; } function ALLOWANCE377(address _owner, address _spender) public view returns (uint256) { //inject NONSTANDARD NAMING return allowances[_owner][_spender]; } function APPROVE293(address _spender, uint256 _amount) public returns (bool) { //inject NONSTANDARD NAMING _APPROVE571(msg.sender, _spender, _amount); return true; } function TRANSFERFROM669(address _sender, address _recipient, uint256 _amount) public returns (bool) { //inject NONSTANDARD NAMING _TRANSFER433(_sender, _recipient, _amount); _APPROVE571(_sender, msg.sender, allowances[_sender][msg.sender].SUB692(_amount)); return true; } function INCREASEALLOWANCE307(address _spender, uint256 _addedValue) public returns (bool) { //inject NONSTANDARD NAMING _APPROVE571(msg.sender, _spender, allowances[msg.sender][_spender].ADD571(_addedValue)); return true; } function DECREASEALLOWANCE757(address _spender, uint256 _subtractedValue) public returns (bool) { //inject NONSTANDARD NAMING _APPROVE571(msg.sender, _spender, allowances[msg.sender][_spender].SUB692(_subtractedValue)); return true; } function _TRANSFER433(address _sender, address _recipient, uint256 _amount) internal { //inject NONSTANDARD NAMING require(_sender != address(0), "ERC20: transfer from the zero address"); require(_recipient != address(0), "ERC20: transfer to the zero address"); balances[_sender] = balances[_sender].SUB692(_amount); balances[_recipient] = balances[_recipient].ADD571(_amount); emit TRANSFER723(_sender, _recipient, _amount); ONTOKENTRANSFER292(_sender, _recipient, _amount); } function _MINT880(address _account, uint256 _amount) internal { //inject NONSTANDARD NAMING require(_account != address(0), "ERC20: mint to the zero address"); totalSupply = totalSupply.ADD571(_amount); balances[_account] = balances[_account].ADD571(_amount); emit TRANSFER723(address(0), _account, _amount); } function _BURN356(address _account, uint256 _amount) internal { //inject NONSTANDARD NAMING require(_account != address(0), "ERC20: burn from the zero address"); balances[_account] = balances[_account].SUB692(_amount); totalSupply = totalSupply.SUB692(_amount); emit TRANSFER723(_account, address(0), _amount); } function _APPROVE571(address _owner, address _spender, uint256 _amount) internal { //inject NONSTANDARD NAMING require(_owner != address(0), "ERC20: approve from the zero address"); require(_spender != address(0), "ERC20: approve to the zero address"); allowances[_owner][_spender] = _amount; emit APPROVAL665(_owner, _spender, _amount); } function _BURNFROM317(address _account, uint256 _amount) internal { //inject NONSTANDARD NAMING _BURN356(_account, _amount); _APPROVE571(_account, msg.sender, allowances[_account][msg.sender].SUB692(_amount)); } // Subclasses of this token generally want to send additional logs through the centralized Augur log emitter contract function ONTOKENTRANSFER292(address _from, address _to, uint256 _value) internal; //inject NONSTANDARD NAMING } contract VariableSupplyToken is ERC20 { using SafeMathUint256 for uint256; function MINT146(address _target, uint256 _amount) internal returns (bool) { //inject NONSTANDARD NAMING _MINT880(_target, _amount); ONMINT315(_target, _amount); return true; } function BURN234(address _target, uint256 _amount) internal returns (bool) { //inject NONSTANDARD NAMING _BURN356(_target, _amount); ONBURN653(_target, _amount); return true; } // Subclasses of this token may want to send additional logs through the centralized Augur log emitter contract function ONMINT315(address, uint256) internal { //inject NONSTANDARD NAMING } // Subclasses of this token may want to send additional logs through the centralized Augur log emitter contract function ONBURN653(address, uint256) internal { //inject NONSTANDARD NAMING } } contract IAffiliateValidator { function VALIDATEREFERENCE609(address _account, address _referrer) external view returns (bool); //inject NONSTANDARD NAMING } contract IDisputeWindow is ITyped, IERC20 { function INVALIDMARKETSTOTAL511() external view returns (uint256); //inject NONSTANDARD NAMING function VALIDITYBONDTOTAL28() external view returns (uint256); //inject NONSTANDARD NAMING function INCORRECTDESIGNATEDREPORTTOTAL522() external view returns (uint256); //inject NONSTANDARD NAMING function INITIALREPORTBONDTOTAL695() external view returns (uint256); //inject NONSTANDARD NAMING function DESIGNATEDREPORTNOSHOWSTOTAL443() external view returns (uint256); //inject NONSTANDARD NAMING function DESIGNATEDREPORTERNOSHOWBONDTOTAL703() external view returns (uint256); //inject NONSTANDARD NAMING function INITIALIZE90(IAugur _augur, IUniverse _universe, uint256 _disputeWindowId, bool _participationTokensEnabled, uint256 _duration, uint256 _startTime) public; //inject NONSTANDARD NAMING function TRUSTEDBUY954(address _buyer, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function GETUNIVERSE719() public view returns (IUniverse); //inject NONSTANDARD NAMING function GETREPUTATIONTOKEN35() public view returns (IReputationToken); //inject NONSTANDARD NAMING function GETSTARTTIME383() public view returns (uint256); //inject NONSTANDARD NAMING function GETENDTIME626() public view returns (uint256); //inject NONSTANDARD NAMING function GETWINDOWID901() public view returns (uint256); //inject NONSTANDARD NAMING function ISACTIVE720() public view returns (bool); //inject NONSTANDARD NAMING function ISOVER108() public view returns (bool); //inject NONSTANDARD NAMING function ONMARKETFINALIZED596() public; //inject NONSTANDARD NAMING function REDEEM559(address _account) public returns (bool); //inject NONSTANDARD NAMING } contract IMarket is IOwnable { enum MarketType { YES_NO, CATEGORICAL, SCALAR } function INITIALIZE90(IAugur _augur, IUniverse _universe, uint256 _endTime, uint256 _feePerCashInAttoCash, IAffiliateValidator _affiliateValidator, uint256 _affiliateFeeDivisor, address _designatedReporterAddress, address _creator, uint256 _numOutcomes, uint256 _numTicks) public; //inject NONSTANDARD NAMING function DERIVEPAYOUTDISTRIBUTIONHASH812(uint256[] memory _payoutNumerators) public view returns (bytes32); //inject NONSTANDARD NAMING function DOINITIALREPORT448(uint256[] memory _payoutNumerators, string memory _description, uint256 _additionalStake) public returns (bool); //inject NONSTANDARD NAMING function GETUNIVERSE719() public view returns (IUniverse); //inject NONSTANDARD NAMING function GETDISPUTEWINDOW804() public view returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETNUMBEROFOUTCOMES636() public view returns (uint256); //inject NONSTANDARD NAMING function GETNUMTICKS752() public view returns (uint256); //inject NONSTANDARD NAMING function GETMARKETCREATORSETTLEMENTFEEDIVISOR51() public view returns (uint256); //inject NONSTANDARD NAMING function GETFORKINGMARKET637() public view returns (IMarket _market); //inject NONSTANDARD NAMING function GETENDTIME626() public view returns (uint256); //inject NONSTANDARD NAMING function GETWINNINGPAYOUTDISTRIBUTIONHASH916() public view returns (bytes32); //inject NONSTANDARD NAMING function GETWINNINGPAYOUTNUMERATOR375(uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function GETWINNINGREPORTINGPARTICIPANT424() public view returns (IReportingParticipant); //inject NONSTANDARD NAMING function GETREPUTATIONTOKEN35() public view returns (IV2ReputationToken); //inject NONSTANDARD NAMING function GETFINALIZATIONTIME347() public view returns (uint256); //inject NONSTANDARD NAMING function GETINITIALREPORTER212() public view returns (IInitialReporter); //inject NONSTANDARD NAMING function GETDESIGNATEDREPORTINGENDTIME834() public view returns (uint256); //inject NONSTANDARD NAMING function GETVALIDITYBONDATTOCASH123() public view returns (uint256); //inject NONSTANDARD NAMING function AFFILIATEFEEDIVISOR322() external view returns (uint256); //inject NONSTANDARD NAMING function GETNUMPARTICIPANTS137() public view returns (uint256); //inject NONSTANDARD NAMING function GETDISPUTEPACINGON415() public view returns (bool); //inject NONSTANDARD NAMING function DERIVEMARKETCREATORFEEAMOUNT558(uint256 _amount) public view returns (uint256); //inject NONSTANDARD NAMING function RECORDMARKETCREATORFEES738(uint256 _marketCreatorFees, address _sourceAccount, bytes32 _fingerprint) public returns (bool); //inject NONSTANDARD NAMING function ISCONTAINERFORREPORTINGPARTICIPANT696(IReportingParticipant _reportingParticipant) public view returns (bool); //inject NONSTANDARD NAMING function ISFINALIZEDASINVALID362() public view returns (bool); //inject NONSTANDARD NAMING function FINALIZE310() public returns (bool); //inject NONSTANDARD NAMING function ISFINALIZED623() public view returns (bool); //inject NONSTANDARD NAMING function GETOPENINTEREST251() public view returns (uint256); //inject NONSTANDARD NAMING } contract IReportingParticipant { function GETSTAKE932() public view returns (uint256); //inject NONSTANDARD NAMING function GETPAYOUTDISTRIBUTIONHASH1000() public view returns (bytes32); //inject NONSTANDARD NAMING function LIQUIDATELOSING232() public; //inject NONSTANDARD NAMING function REDEEM559(address _redeemer) public returns (bool); //inject NONSTANDARD NAMING function ISDISAVOWED173() public view returns (bool); //inject NONSTANDARD NAMING function GETPAYOUTNUMERATOR512(uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function GETPAYOUTNUMERATORS444() public view returns (uint256[] memory); //inject NONSTANDARD NAMING function GETMARKET927() public view returns (IMarket); //inject NONSTANDARD NAMING function GETSIZE85() public view returns (uint256); //inject NONSTANDARD NAMING } contract IDisputeCrowdsourcer is IReportingParticipant, IERC20 { function INITIALIZE90(IAugur _augur, IMarket market, uint256 _size, bytes32 _payoutDistributionHash, uint256[] memory _payoutNumerators, uint256 _crowdsourcerGeneration) public; //inject NONSTANDARD NAMING function CONTRIBUTE720(address _participant, uint256 _amount, bool _overload) public returns (uint256); //inject NONSTANDARD NAMING function SETSIZE177(uint256 _size) public; //inject NONSTANDARD NAMING function GETREMAININGTOFILL115() public view returns (uint256); //inject NONSTANDARD NAMING function CORRECTSIZE807() public returns (bool); //inject NONSTANDARD NAMING function GETCROWDSOURCERGENERATION652() public view returns (uint256); //inject NONSTANDARD NAMING } contract IInitialReporter is IReportingParticipant, IOwnable { function INITIALIZE90(IAugur _augur, IMarket _market, address _designatedReporter) public; //inject NONSTANDARD NAMING function REPORT291(address _reporter, bytes32 _payoutDistributionHash, uint256[] memory _payoutNumerators, uint256 _initialReportStake) public; //inject NONSTANDARD NAMING function DESIGNATEDREPORTERSHOWED809() public view returns (bool); //inject NONSTANDARD NAMING function INITIALREPORTERWASCORRECT338() public view returns (bool); //inject NONSTANDARD NAMING function GETDESIGNATEDREPORTER404() public view returns (address); //inject NONSTANDARD NAMING function GETREPORTTIMESTAMP304() public view returns (uint256); //inject NONSTANDARD NAMING function MIGRATETONEWUNIVERSE701(address _designatedReporter) public; //inject NONSTANDARD NAMING function RETURNREPFROMDISAVOW512() public; //inject NONSTANDARD NAMING } contract IReputationToken is IERC20 { function MIGRATEOUTBYPAYOUT436(uint256[] memory _payoutNumerators, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function MIGRATEIN692(address _reporter, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function TRUSTEDREPORTINGPARTICIPANTTRANSFER10(address _source, address _destination, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function TRUSTEDMARKETTRANSFER61(address _source, address _destination, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function TRUSTEDUNIVERSETRANSFER148(address _source, address _destination, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function TRUSTEDDISPUTEWINDOWTRANSFER53(address _source, address _destination, uint256 _attotokens) public returns (bool); //inject NONSTANDARD NAMING function GETUNIVERSE719() public view returns (IUniverse); //inject NONSTANDARD NAMING function GETTOTALMIGRATED220() public view returns (uint256); //inject NONSTANDARD NAMING function GETTOTALTHEORETICALSUPPLY552() public view returns (uint256); //inject NONSTANDARD NAMING function MINTFORREPORTINGPARTICIPANT798(uint256 _amountMigrated) public returns (bool); //inject NONSTANDARD NAMING } contract IShareToken is ITyped, IERC1155 { function INITIALIZE90(IAugur _augur) external; //inject NONSTANDARD NAMING function INITIALIZEMARKET720(IMarket _market, uint256 _numOutcomes, uint256 _numTicks) public; //inject NONSTANDARD NAMING function UNSAFETRANSFERFROM654(address _from, address _to, uint256 _id, uint256 _value) public; //inject NONSTANDARD NAMING function UNSAFEBATCHTRANSFERFROM211(address _from, address _to, uint256[] memory _ids, uint256[] memory _values) public; //inject NONSTANDARD NAMING function CLAIMTRADINGPROCEEDS854(IMarket _market, address _shareHolder, bytes32 _fingerprint) external returns (uint256[] memory _outcomeFees); //inject NONSTANDARD NAMING function GETMARKET927(uint256 _tokenId) external view returns (IMarket); //inject NONSTANDARD NAMING function GETOUTCOME167(uint256 _tokenId) external view returns (uint256); //inject NONSTANDARD NAMING function GETTOKENID371(IMarket _market, uint256 _outcome) public pure returns (uint256 _tokenId); //inject NONSTANDARD NAMING function GETTOKENIDS530(IMarket _market, uint256[] memory _outcomes) public pure returns (uint256[] memory _tokenIds); //inject NONSTANDARD NAMING function BUYCOMPLETESETS983(IMarket _market, address _account, uint256 _amount) external returns (bool); //inject NONSTANDARD NAMING function BUYCOMPLETESETSFORTRADE277(IMarket _market, uint256 _amount, uint256 _longOutcome, address _longRecipient, address _shortRecipient) external returns (bool); //inject NONSTANDARD NAMING function SELLCOMPLETESETS485(IMarket _market, address _holder, address _recipient, uint256 _amount, bytes32 _fingerprint) external returns (uint256 _creatorFee, uint256 _reportingFee); //inject NONSTANDARD NAMING function SELLCOMPLETESETSFORTRADE561(IMarket _market, uint256 _outcome, uint256 _amount, address _shortParticipant, address _longParticipant, address _shortRecipient, address _longRecipient, uint256 _price, address _sourceAccount, bytes32 _fingerprint) external returns (uint256 _creatorFee, uint256 _reportingFee); //inject NONSTANDARD NAMING function TOTALSUPPLYFORMARKETOUTCOME526(IMarket _market, uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function BALANCEOFMARKETOUTCOME21(IMarket _market, uint256 _outcome, address _account) public view returns (uint256); //inject NONSTANDARD NAMING function LOWESTBALANCEOFMARKETOUTCOMES298(IMarket _market, uint256[] memory _outcomes, address _account) public view returns (uint256); //inject NONSTANDARD NAMING } contract IUniverse { function CREATIONTIME597() external view returns (uint256); //inject NONSTANDARD NAMING function MARKETBALANCE692(address) external view returns (uint256); //inject NONSTANDARD NAMING function FORK341() public returns (bool); //inject NONSTANDARD NAMING function UPDATEFORKVALUES73() public returns (bool); //inject NONSTANDARD NAMING function GETPARENTUNIVERSE169() public view returns (IUniverse); //inject NONSTANDARD NAMING function CREATECHILDUNIVERSE712(uint256[] memory _parentPayoutNumerators) public returns (IUniverse); //inject NONSTANDARD NAMING function GETCHILDUNIVERSE576(bytes32 _parentPayoutDistributionHash) public view returns (IUniverse); //inject NONSTANDARD NAMING function GETREPUTATIONTOKEN35() public view returns (IV2ReputationToken); //inject NONSTANDARD NAMING function GETFORKINGMARKET637() public view returns (IMarket); //inject NONSTANDARD NAMING function GETFORKENDTIME510() public view returns (uint256); //inject NONSTANDARD NAMING function GETFORKREPUTATIONGOAL776() public view returns (uint256); //inject NONSTANDARD NAMING function GETPARENTPAYOUTDISTRIBUTIONHASH230() public view returns (bytes32); //inject NONSTANDARD NAMING function GETDISPUTEROUNDDURATIONINSECONDS412(bool _initial) public view returns (uint256); //inject NONSTANDARD NAMING function GETORCREATEDISPUTEWINDOWBYTIMESTAMP65(uint256 _timestamp, bool _initial) public returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETORCREATECURRENTDISPUTEWINDOW813(bool _initial) public returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETORCREATENEXTDISPUTEWINDOW682(bool _initial) public returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETORCREATEPREVIOUSDISPUTEWINDOW575(bool _initial) public returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETOPENINTERESTINATTOCASH866() public view returns (uint256); //inject NONSTANDARD NAMING function GETTARGETREPMARKETCAPINATTOCASH438() public view returns (uint256); //inject NONSTANDARD NAMING function GETORCACHEVALIDITYBOND873() public returns (uint256); //inject NONSTANDARD NAMING function GETORCACHEDESIGNATEDREPORTSTAKE630() public returns (uint256); //inject NONSTANDARD NAMING function GETORCACHEDESIGNATEDREPORTNOSHOWBOND936() public returns (uint256); //inject NONSTANDARD NAMING function GETORCACHEMARKETREPBOND533() public returns (uint256); //inject NONSTANDARD NAMING function GETORCACHEREPORTINGFEEDIVISOR44() public returns (uint256); //inject NONSTANDARD NAMING function GETDISPUTETHRESHOLDFORFORK42() public view returns (uint256); //inject NONSTANDARD NAMING function GETDISPUTETHRESHOLDFORDISPUTEPACING311() public view returns (uint256); //inject NONSTANDARD NAMING function GETINITIALREPORTMINVALUE947() public view returns (uint256); //inject NONSTANDARD NAMING function GETPAYOUTNUMERATORS444() public view returns (uint256[] memory); //inject NONSTANDARD NAMING function GETREPORTINGFEEDIVISOR13() public view returns (uint256); //inject NONSTANDARD NAMING function GETPAYOUTNUMERATOR512(uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function GETWINNINGCHILDPAYOUTNUMERATOR599(uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function ISOPENINTERESTCASH47(address) public view returns (bool); //inject NONSTANDARD NAMING function ISFORKINGMARKET534() public view returns (bool); //inject NONSTANDARD NAMING function GETCURRENTDISPUTEWINDOW862(bool _initial) public view returns (IDisputeWindow); //inject NONSTANDARD NAMING function GETDISPUTEWINDOWSTARTTIMEANDDURATION802(uint256 _timestamp, bool _initial) public view returns (uint256, uint256); //inject NONSTANDARD NAMING function ISPARENTOF319(IUniverse _shadyChild) public view returns (bool); //inject NONSTANDARD NAMING function UPDATETENTATIVEWINNINGCHILDUNIVERSE89(bytes32 _parentPayoutDistributionHash) public returns (bool); //inject NONSTANDARD NAMING function ISCONTAINERFORDISPUTEWINDOW320(IDisputeWindow _shadyTarget) public view returns (bool); //inject NONSTANDARD NAMING function ISCONTAINERFORMARKET856(IMarket _shadyTarget) public view returns (bool); //inject NONSTANDARD NAMING function ISCONTAINERFORREPORTINGPARTICIPANT696(IReportingParticipant _reportingParticipant) public view returns (bool); //inject NONSTANDARD NAMING function MIGRATEMARKETOUT672(IUniverse _destinationUniverse) public returns (bool); //inject NONSTANDARD NAMING function MIGRATEMARKETIN285(IMarket _market, uint256 _cashBalance, uint256 _marketOI) public returns (bool); //inject NONSTANDARD NAMING function DECREMENTOPENINTEREST834(uint256 _amount) public returns (bool); //inject NONSTANDARD NAMING function DECREMENTOPENINTERESTFROMMARKET346(IMarket _market) public returns (bool); //inject NONSTANDARD NAMING function INCREMENTOPENINTEREST645(uint256 _amount) public returns (bool); //inject NONSTANDARD NAMING function GETWINNINGCHILDUNIVERSE709() public view returns (IUniverse); //inject NONSTANDARD NAMING function ISFORKING853() public view returns (bool); //inject NONSTANDARD NAMING function DEPOSIT693(address _sender, uint256 _amount, address _market) public returns (bool); //inject NONSTANDARD NAMING function WITHDRAW474(address _recipient, uint256 _amount, address _market) public returns (bool); //inject NONSTANDARD NAMING function CREATESCALARMARKET875(uint256 _endTime, uint256 _feePerCashInAttoCash, IAffiliateValidator _affiliateValidator, uint256 _affiliateFeeDivisor, address _designatedReporterAddress, int256[] memory _prices, uint256 _numTicks, string memory _extraInfo) public returns (IMarket _newMarket); //inject NONSTANDARD NAMING } contract IV2ReputationToken is IReputationToken { function PARENTUNIVERSE976() external returns (IUniverse); //inject NONSTANDARD NAMING function BURNFORMARKET683(uint256 _amountToBurn) public returns (bool); //inject NONSTANDARD NAMING function MINTFORWARPSYNC909(uint256 _amountToMint, address _target) public returns (bool); //inject NONSTANDARD NAMING } library Reporting { uint256 private constant designated_reporting_duration_seconds939 = 1 days; //inject NONSTANDARD NAMING uint256 private constant dispute_round_duration_seconds351 = 7 days; //inject NONSTANDARD NAMING uint256 private constant initial_dispute_round_duration_seconds185 = 1 days; //inject NONSTANDARD NAMING uint256 private constant dispute_window_buffer_seconds655 = 1 hours; //inject NONSTANDARD NAMING uint256 private constant fork_duration_seconds463 = 60 days; //inject NONSTANDARD NAMING uint256 private constant base_market_duration_maximum20 = 30 days; // A market of 30 day length can always be created //inject NONSTANDARD NAMING uint256 private constant upgrade_cadence254 = 365 days; //inject NONSTANDARD NAMING uint256 private constant initial_upgrade_timestamp605 = 1627776000; // Aug 1st 2021 //inject NONSTANDARD NAMING uint256 private constant initial_rep_supply507 = 11 * 10 ** 6 * 10 ** 18; // 11 Million REP //inject NONSTANDARD NAMING uint256 private constant affiliate_source_cut_divisor194 = 5; // The trader gets 20% of the affiliate fee when an affiliate fee is taken //inject NONSTANDARD NAMING uint256 private constant default_validity_bond803 = 10 ether; // 10 Cash (Dai) //inject NONSTANDARD NAMING uint256 private constant validity_bond_floor708 = 10 ether; // 10 Cash (Dai) //inject NONSTANDARD NAMING uint256 private constant default_reporting_fee_divisor809 = 10000; // .01% fees //inject NONSTANDARD NAMING uint256 private constant maximum_reporting_fee_divisor548 = 10000; // Minimum .01% fees //inject NONSTANDARD NAMING uint256 private constant minimum_reporting_fee_divisor749 = 3; // Maximum 33.3~% fees. Note than anything less than a value of 2 here will likely result in bugs such as divide by 0 cases. //inject NONSTANDARD NAMING uint256 private constant target_invalid_markets_divisor747 = 100; // 1% of markets are expected to be invalid //inject NONSTANDARD NAMING uint256 private constant target_incorrect_designated_report_markets_divisor83 = 100; // 1% of markets are expected to have an incorrect designate report //inject NONSTANDARD NAMING uint256 private constant target_designated_report_no_shows_divisor678 = 20; // 5% of markets are expected to have a no show //inject NONSTANDARD NAMING uint256 private constant target_rep_market_cap_multiplier475 = 5; // We multiply and divide by constants since we may want to multiply by a fractional amount //inject NONSTANDARD NAMING uint256 private constant fork_threshold_divisor49 = 40; // 2.5% of the total REP supply being filled in a single dispute bond will trigger a fork //inject NONSTANDARD NAMING uint256 private constant maximum_dispute_rounds529 = 20; // We ensure that after 20 rounds of disputes a fork will occur //inject NONSTANDARD NAMING uint256 private constant minimum_slow_rounds438 = 8; // We ensure that at least 8 dispute rounds take DISPUTE_ROUND_DURATION_SECONDS+ seconds to complete until the next round begins //inject NONSTANDARD NAMING function GETDESIGNATEDREPORTINGDURATIONSECONDS10() internal pure returns (uint256) { return designated_reporting_duration_seconds939; } //inject NONSTANDARD NAMING function GETINITIALDISPUTEROUNDDURATIONSECONDS286() internal pure returns (uint256) { return initial_dispute_round_duration_seconds185; } //inject NONSTANDARD NAMING function GETDISPUTEWINDOWBUFFERSECONDS683() internal pure returns (uint256) { return dispute_window_buffer_seconds655; } //inject NONSTANDARD NAMING function GETDISPUTEROUNDDURATIONSECONDS187() internal pure returns (uint256) { return dispute_round_duration_seconds351; } //inject NONSTANDARD NAMING function GETFORKDURATIONSECONDS842() internal pure returns (uint256) { return fork_duration_seconds463; } //inject NONSTANDARD NAMING function GETBASEMARKETDURATIONMAXIMUM759() internal pure returns (uint256) { return base_market_duration_maximum20; } //inject NONSTANDARD NAMING function GETUPGRADECADENCE338() internal pure returns (uint256) { return upgrade_cadence254; } //inject NONSTANDARD NAMING function GETINITIALUPGRADETIMESTAMP486() internal pure returns (uint256) { return initial_upgrade_timestamp605; } //inject NONSTANDARD NAMING function GETDEFAULTVALIDITYBOND656() internal pure returns (uint256) { return default_validity_bond803; } //inject NONSTANDARD NAMING function GETVALIDITYBONDFLOOR634() internal pure returns (uint256) { return validity_bond_floor708; } //inject NONSTANDARD NAMING function GETTARGETINVALIDMARKETSDIVISOR906() internal pure returns (uint256) { return target_invalid_markets_divisor747; } //inject NONSTANDARD NAMING function GETTARGETINCORRECTDESIGNATEDREPORTMARKETSDIVISOR444() internal pure returns (uint256) { return target_incorrect_designated_report_markets_divisor83; } //inject NONSTANDARD NAMING function GETTARGETDESIGNATEDREPORTNOSHOWSDIVISOR524() internal pure returns (uint256) { return target_designated_report_no_shows_divisor678; } //inject NONSTANDARD NAMING function GETTARGETREPMARKETCAPMULTIPLIER935() internal pure returns (uint256) { return target_rep_market_cap_multiplier475; } //inject NONSTANDARD NAMING function GETMAXIMUMREPORTINGFEEDIVISOR201() internal pure returns (uint256) { return maximum_reporting_fee_divisor548; } //inject NONSTANDARD NAMING function GETMINIMUMREPORTINGFEEDIVISOR230() internal pure returns (uint256) { return minimum_reporting_fee_divisor749; } //inject NONSTANDARD NAMING function GETDEFAULTREPORTINGFEEDIVISOR804() internal pure returns (uint256) { return default_reporting_fee_divisor809; } //inject NONSTANDARD NAMING function GETINITIALREPSUPPLY859() internal pure returns (uint256) { return initial_rep_supply507; } //inject NONSTANDARD NAMING function GETAFFILIATESOURCECUTDIVISOR779() internal pure returns (uint256) { return affiliate_source_cut_divisor194; } //inject NONSTANDARD NAMING function GETFORKTHRESHOLDDIVISOR823() internal pure returns (uint256) { return fork_threshold_divisor49; } //inject NONSTANDARD NAMING function GETMAXIMUMDISPUTEROUNDS774() internal pure returns (uint256) { return maximum_dispute_rounds529; } //inject NONSTANDARD NAMING function GETMINIMUMSLOWROUNDS218() internal pure returns (uint256) { return minimum_slow_rounds438; } //inject NONSTANDARD NAMING } contract IAugurTrading { function LOOKUP594(bytes32 _key) public view returns (address); //inject NONSTANDARD NAMING function LOGPROFITLOSSCHANGED911(IMarket _market, address _account, uint256 _outcome, int256 _netPosition, uint256 _avgPrice, int256 _realizedProfit, int256 _frozenFunds, int256 _realizedCost) public returns (bool); //inject NONSTANDARD NAMING function LOGORDERCREATED154(IUniverse _universe, bytes32 _orderId, bytes32 _tradeGroupId) public returns (bool); //inject NONSTANDARD NAMING function LOGORDERCANCELED389(IUniverse _universe, IMarket _market, address _creator, uint256 _tokenRefund, uint256 _sharesRefund, bytes32 _orderId) public returns (bool); //inject NONSTANDARD NAMING function LOGORDERFILLED166(IUniverse _universe, address _creator, address _filler, uint256 _price, uint256 _fees, uint256 _amountFilled, bytes32 _orderId, bytes32 _tradeGroupId) public returns (bool); //inject NONSTANDARD NAMING function LOGMARKETVOLUMECHANGED635(IUniverse _universe, address _market, uint256 _volume, uint256[] memory _outcomeVolumes, uint256 _totalTrades) public returns (bool); //inject NONSTANDARD NAMING function LOGZEROXORDERFILLED898(IUniverse _universe, IMarket _market, bytes32 _orderHash, bytes32 _tradeGroupId, uint8 _orderType, address[] memory _addressData, uint256[] memory _uint256Data) public returns (bool); //inject NONSTANDARD NAMING function LOGZEROXORDERCANCELED137(address _universe, address _market, address _account, uint256 _outcome, uint256 _price, uint256 _amount, uint8 _type, bytes32 _orderHash) public; //inject NONSTANDARD NAMING } contract IOrders { function SAVEORDER165(uint256[] calldata _uints, bytes32[] calldata _bytes32s, Order.Types _type, IMarket _market, address _sender) external returns (bytes32 _orderId); //inject NONSTANDARD NAMING function REMOVEORDER407(bytes32 _orderId) external returns (bool); //inject NONSTANDARD NAMING function GETMARKET927(bytes32 _orderId) public view returns (IMarket); //inject NONSTANDARD NAMING function GETORDERTYPE39(bytes32 _orderId) public view returns (Order.Types); //inject NONSTANDARD NAMING function GETOUTCOME167(bytes32 _orderId) public view returns (uint256); //inject NONSTANDARD NAMING function GETAMOUNT930(bytes32 _orderId) public view returns (uint256); //inject NONSTANDARD NAMING function GETPRICE598(bytes32 _orderId) public view returns (uint256); //inject NONSTANDARD NAMING function GETORDERCREATOR755(bytes32 _orderId) public view returns (address); //inject NONSTANDARD NAMING function GETORDERSHARESESCROWED20(bytes32 _orderId) public view returns (uint256); //inject NONSTANDARD NAMING function GETORDERMONEYESCROWED161(bytes32 _orderId) public view returns (uint256); //inject NONSTANDARD NAMING function GETORDERDATAFORCANCEL357(bytes32 _orderId) public view returns (uint256, uint256, Order.Types, IMarket, uint256, address); //inject NONSTANDARD NAMING function GETORDERDATAFORLOGS935(bytes32 _orderId) public view returns (Order.Types, address[] memory _addressData, uint256[] memory _uint256Data); //inject NONSTANDARD NAMING function GETBETTERORDERID822(bytes32 _orderId) public view returns (bytes32); //inject NONSTANDARD NAMING function GETWORSEORDERID439(bytes32 _orderId) public view returns (bytes32); //inject NONSTANDARD NAMING function GETBESTORDERID727(Order.Types _type, IMarket _market, uint256 _outcome) public view returns (bytes32); //inject NONSTANDARD NAMING function GETWORSTORDERID835(Order.Types _type, IMarket _market, uint256 _outcome) public view returns (bytes32); //inject NONSTANDARD NAMING function GETLASTOUTCOMEPRICE593(IMarket _market, uint256 _outcome) public view returns (uint256); //inject NONSTANDARD NAMING function GETORDERID157(Order.Types _type, IMarket _market, uint256 _amount, uint256 _price, address _sender, uint256 _blockNumber, uint256 _outcome, uint256 _moneyEscrowed, uint256 _sharesEscrowed) public pure returns (bytes32); //inject NONSTANDARD NAMING function GETTOTALESCROWED463(IMarket _market) public view returns (uint256); //inject NONSTANDARD NAMING function ISBETTERPRICE274(Order.Types _type, uint256 _price, bytes32 _orderId) public view returns (bool); //inject NONSTANDARD NAMING function ISWORSEPRICE692(Order.Types _type, uint256 _price, bytes32 _orderId) public view returns (bool); //inject NONSTANDARD NAMING function ASSERTISNOTBETTERPRICE18(Order.Types _type, uint256 _price, bytes32 _betterOrderId) public view returns (bool); //inject NONSTANDARD NAMING function ASSERTISNOTWORSEPRICE875(Order.Types _type, uint256 _price, bytes32 _worseOrderId) public returns (bool); //inject NONSTANDARD NAMING function RECORDFILLORDER693(bytes32 _orderId, uint256 _sharesFilled, uint256 _tokensFilled, uint256 _fill) external returns (bool); //inject NONSTANDARD NAMING function SETPRICE687(IMarket _market, uint256 _outcome, uint256 _price) external returns (bool); //inject NONSTANDARD NAMING } library Order { using SafeMathUint256 for uint256; enum Types { Bid, Ask } enum TradeDirections { Long, Short } struct Data { // Contracts IMarket market; IAugur augur; IAugurTrading augurTrading; IShareToken shareToken; ICash cash; // Order bytes32 id; address creator; uint256 outcome; Order.Types orderType; uint256 amount; uint256 price; uint256 sharesEscrowed; uint256 moneyEscrowed; bytes32 betterOrderId; bytes32 worseOrderId; } function CREATE815(IAugur _augur, IAugurTrading _augurTrading, address _creator, uint256 _outcome, Order.Types _type, uint256 _attoshares, uint256 _price, IMarket _market, bytes32 _betterOrderId, bytes32 _worseOrderId) internal view returns (Data memory) { //inject NONSTANDARD NAMING require(_outcome < _market.GETNUMBEROFOUTCOMES636(), "Order.create: Outcome is not within market range"); require(_price != 0, "Order.create: Price may not be 0"); require(_price < _market.GETNUMTICKS752(), "Order.create: Price is outside of market range"); require(_attoshares > 0, "Order.create: Cannot use amount of 0"); require(_creator != address(0), "Order.create: Creator is 0x0"); IShareToken _shareToken = IShareToken(_augur.LOOKUP594("ShareToken")); return Data({ market: _market, augur: _augur, augurTrading: _augurTrading, shareToken: _shareToken, cash: ICash(_augur.LOOKUP594("Cash")), id: 0, creator: _creator, outcome: _outcome, orderType: _type, amount: _attoshares, price: _price, sharesEscrowed: 0, moneyEscrowed: 0, betterOrderId: _betterOrderId, worseOrderId: _worseOrderId }); } // // "public" functions // function GETORDERID157(Order.Data memory _orderData, IOrders _orders) internal view returns (bytes32) { //inject NONSTANDARD NAMING if (_orderData.id == bytes32(0)) { bytes32 _orderId = CALCULATEORDERID856(_orderData.orderType, _orderData.market, _orderData.amount, _orderData.price, _orderData.creator, block.number, _orderData.outcome, _orderData.moneyEscrowed, _orderData.sharesEscrowed); require(_orders.GETAMOUNT930(_orderId) == 0, "Order.getOrderId: New order had amount. This should not be possible"); _orderData.id = _orderId; } return _orderData.id; } function CALCULATEORDERID856(Order.Types _type, IMarket _market, uint256 _amount, uint256 _price, address _sender, uint256 _blockNumber, uint256 _outcome, uint256 _moneyEscrowed, uint256 _sharesEscrowed) internal pure returns (bytes32) { //inject NONSTANDARD NAMING return sha256(abi.encodePacked(_type, _market, _amount, _price, _sender, _blockNumber, _outcome, _moneyEscrowed, _sharesEscrowed)); } function GETORDERTRADINGTYPEFROMMAKERDIRECTION100(Order.TradeDirections _creatorDirection) internal pure returns (Order.Types) { //inject NONSTANDARD NAMING return (_creatorDirection == Order.TradeDirections.Long) ? Order.Types.Bid : Order.Types.Ask; } function GETORDERTRADINGTYPEFROMFILLERDIRECTION800(Order.TradeDirections _fillerDirection) internal pure returns (Order.Types) { //inject NONSTANDARD NAMING return (_fillerDirection == Order.TradeDirections.Long) ? Order.Types.Ask : Order.Types.Bid; } function SAVEORDER165(Order.Data memory _orderData, bytes32 _tradeGroupId, IOrders _orders) internal returns (bytes32) { //inject NONSTANDARD NAMING GETORDERID157(_orderData, _orders); uint256[] memory _uints = new uint256[](5); _uints[0] = _orderData.amount; _uints[1] = _orderData.price; _uints[2] = _orderData.outcome; _uints[3] = _orderData.moneyEscrowed; _uints[4] = _orderData.sharesEscrowed; bytes32[] memory _bytes32s = new bytes32[](4); _bytes32s[0] = _orderData.betterOrderId; _bytes32s[1] = _orderData.worseOrderId; _bytes32s[2] = _tradeGroupId; _bytes32s[3] = _orderData.id; return _orders.SAVEORDER165(_uints, _bytes32s, _orderData.orderType, _orderData.market, _orderData.creator); } } interface IUniswapV2Pair { event APPROVAL665(address indexed owner, address indexed spender, uint value); //inject NONSTANDARD NAMING event TRANSFER723(address indexed from, address indexed to, uint value); //inject NONSTANDARD NAMING function NAME524() external pure returns (string memory); //inject NONSTANDARD NAMING function SYMBOL582() external pure returns (string memory); //inject NONSTANDARD NAMING function DECIMALS958() external pure returns (uint8); //inject NONSTANDARD NAMING function TOTALSUPPLY304() external view returns (uint); //inject NONSTANDARD NAMING function BALANCEOF492(address owner) external view returns (uint); //inject NONSTANDARD NAMING function ALLOWANCE377(address owner, address spender) external view returns (uint); //inject NONSTANDARD NAMING function APPROVE293(address spender, uint value) external returns (bool); //inject NONSTANDARD NAMING function TRANSFER644(address to, uint value) external returns (bool); //inject NONSTANDARD NAMING function TRANSFERFROM669(address from, address to, uint value) external returns (bool); //inject NONSTANDARD NAMING function DOMAIN_SEPARATOR256() external view returns (bytes32); //inject NONSTANDARD NAMING function PERMIT_TYPEHASH256() external pure returns (bytes32); //inject NONSTANDARD NAMING function NONCES605(address owner) external view returns (uint); //inject NONSTANDARD NAMING function PERMIT866(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; //inject NONSTANDARD NAMING event MINT159(address indexed sender, uint amount0, uint amount1); //inject NONSTANDARD NAMING event BURN674(address indexed sender, uint amount0, uint amount1, address indexed to); //inject NONSTANDARD NAMING event SWAP992( //inject NONSTANDARD NAMING address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event SYNC856(uint112 reserve0, uint112 reserve1); //inject NONSTANDARD NAMING function MINIMUM_LIQUIDITY585() external pure returns (uint); //inject NONSTANDARD NAMING function FACTORY704() external view returns (address); //inject NONSTANDARD NAMING function TOKEN0151() external view returns (address); //inject NONSTANDARD NAMING function TOKEN132() external view returns (address); //inject NONSTANDARD NAMING function GETRESERVES901() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); //inject NONSTANDARD NAMING function PRICE0CUMULATIVELAST708() external view returns (uint); //inject NONSTANDARD NAMING function PRICE1CUMULATIVELAST245() external view returns (uint); //inject NONSTANDARD NAMING function KLAST943() external view returns (uint); //inject NONSTANDARD NAMING function MINT146(address to) external returns (uint liquidity); //inject NONSTANDARD NAMING function BURN234(address to) external returns (uint amount0, uint amount1); //inject NONSTANDARD NAMING function SWAP505(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; //inject NONSTANDARD NAMING function SKIM81(address to) external; //inject NONSTANDARD NAMING function SYNC86() external; //inject NONSTANDARD NAMING function INITIALIZE90(address, address) external; //inject NONSTANDARD NAMING } contract IRepSymbol { function GETREPSYMBOL498(address _augur, address _universe) external view returns (string memory); //inject NONSTANDARD NAMING } contract ReputationToken is VariableSupplyToken, IV2ReputationToken { using SafeMathUint256 for uint256; string constant public name600 = "Reputation"; //inject NONSTANDARD NAMING IUniverse internal universe; IUniverse public parentUniverse; uint256 internal totalMigrated; IERC20 public legacyRepToken; IAugur public augur; address public warpSync; constructor(IAugur _augur, IUniverse _universe, IUniverse _parentUniverse) public { augur = _augur; universe = _universe; parentUniverse = _parentUniverse; warpSync = _augur.LOOKUP594("WarpSync"); legacyRepToken = IERC20(_augur.LOOKUP594("LegacyReputationToken")); require(warpSync != address(0)); require(legacyRepToken != IERC20(0)); } function SYMBOL582() public view returns (string memory) { //inject NONSTANDARD NAMING return IRepSymbol(augur.LOOKUP594("RepSymbol")).GETREPSYMBOL498(address(augur), address(universe)); } function MIGRATEOUTBYPAYOUT436(uint256[] memory _payoutNumerators, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING require(_attotokens > 0); IUniverse _destinationUniverse = universe.CREATECHILDUNIVERSE712(_payoutNumerators); IReputationToken _destination = _destinationUniverse.GETREPUTATIONTOKEN35(); BURN234(msg.sender, _attotokens); _destination.MIGRATEIN692(msg.sender, _attotokens); return true; } function MIGRATEIN692(address _reporter, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING IUniverse _parentUniverse = parentUniverse; require(ReputationToken(msg.sender) == _parentUniverse.GETREPUTATIONTOKEN35()); require(augur.GETTIMESTAMP626() < _parentUniverse.GETFORKENDTIME510()); MINT146(_reporter, _attotokens); totalMigrated += _attotokens; // Update the fork tentative winner and finalize if we can if (!_parentUniverse.GETFORKINGMARKET637().ISFINALIZED623()) { _parentUniverse.UPDATETENTATIVEWINNINGCHILDUNIVERSE89(universe.GETPARENTPAYOUTDISTRIBUTIONHASH230()); } return true; } function MINTFORREPORTINGPARTICIPANT798(uint256 _amountMigrated) public returns (bool) { //inject NONSTANDARD NAMING IReportingParticipant _reportingParticipant = IReportingParticipant(msg.sender); require(parentUniverse.ISCONTAINERFORREPORTINGPARTICIPANT696(_reportingParticipant)); // simulate a 40% ROI which would have occured during a normal dispute had this participant's outcome won the dispute uint256 _bonus = _amountMigrated.MUL760(2) / 5; MINT146(address(_reportingParticipant), _bonus); return true; } function MINTFORWARPSYNC909(uint256 _amountToMint, address _target) public returns (bool) { //inject NONSTANDARD NAMING require(warpSync == msg.sender); MINT146(_target, _amountToMint); universe.UPDATEFORKVALUES73(); return true; } function BURNFORMARKET683(uint256 _amountToBurn) public returns (bool) { //inject NONSTANDARD NAMING require(universe.ISCONTAINERFORMARKET856(IMarket(msg.sender))); BURN234(msg.sender, _amountToBurn); return true; } function TRUSTEDUNIVERSETRANSFER148(address _source, address _destination, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING require(IUniverse(msg.sender) == universe); _TRANSFER433(_source, _destination, _attotokens); return true; } function TRUSTEDMARKETTRANSFER61(address _source, address _destination, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING require(universe.ISCONTAINERFORMARKET856(IMarket(msg.sender))); _TRANSFER433(_source, _destination, _attotokens); return true; } function TRUSTEDREPORTINGPARTICIPANTTRANSFER10(address _source, address _destination, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING require(universe.ISCONTAINERFORREPORTINGPARTICIPANT696(IReportingParticipant(msg.sender))); _TRANSFER433(_source, _destination, _attotokens); return true; } function TRUSTEDDISPUTEWINDOWTRANSFER53(address _source, address _destination, uint256 _attotokens) public returns (bool) { //inject NONSTANDARD NAMING require(universe.ISCONTAINERFORDISPUTEWINDOW320(IDisputeWindow(msg.sender))); _TRANSFER433(_source, _destination, _attotokens); return true; } function ASSERTREPUTATIONTOKENISLEGITCHILD164(IReputationToken _shadyReputationToken) private view { //inject NONSTANDARD NAMING IUniverse _universe = _shadyReputationToken.GETUNIVERSE719(); require(universe.ISPARENTOF319(_universe)); require(_universe.GETREPUTATIONTOKEN35() == _shadyReputationToken); } function GETUNIVERSE719() public view returns (IUniverse) { //inject NONSTANDARD NAMING return universe; } function GETTOTALMIGRATED220() public view returns (uint256) { //inject NONSTANDARD NAMING return totalMigrated; } function GETLEGACYREPTOKEN110() public view returns (IERC20) { //inject NONSTANDARD NAMING return legacyRepToken; } function GETTOTALTHEORETICALSUPPLY552() public view returns (uint256) { //inject NONSTANDARD NAMING uint256 _totalSupply = totalSupply; if (parentUniverse == IUniverse(0)) { return _totalSupply.ADD571(legacyRepToken.TOTALSUPPLY304()).SUB692(legacyRepToken.BALANCEOF492(address(1))).SUB692(legacyRepToken.BALANCEOF492(address(0))); } else if (augur.GETTIMESTAMP626() >= parentUniverse.GETFORKENDTIME510()) { return _totalSupply; } else { return _totalSupply + parentUniverse.GETREPUTATIONTOKEN35().GETTOTALTHEORETICALSUPPLY552(); } } function ONTOKENTRANSFER292(address _from, address _to, uint256 _value) internal { //inject NONSTANDARD NAMING augur.LOGREPUTATIONTOKENSTRANSFERRED904(universe, _from, _to, _value, balances[_from], balances[_to]); } function ONMINT315(address _target, uint256 _amount) internal { //inject NONSTANDARD NAMING augur.LOGREPUTATIONTOKENSMINTED985(universe, _target, _amount, totalSupply, balances[_target]); } function ONBURN653(address _target, uint256 _amount) internal { //inject NONSTANDARD NAMING augur.LOGREPUTATIONTOKENSBURNED995(universe, _target, _amount, totalSupply, balances[_target]); } function MIGRATEFROMLEGACYREPUTATIONTOKEN918() public returns (bool) { //inject NONSTANDARD NAMING require(parentUniverse == IUniverse(0)); uint256 _legacyBalance = legacyRepToken.BALANCEOF492(msg.sender); require(legacyRepToken.TRANSFERFROM669(msg.sender, address(1), _legacyBalance)); MINT146(msg.sender, _legacyBalance); return true; } }
inject NONSTANDARD NAMING
function UNSAFEBATCHTRANSFERFROM211(address _from, address _to, uint256[] memory _ids, uint256[] memory _values) public;
2,553,968
[ 1, 4625, 348, 7953, 560, 30, 4590, 18708, 882, 18264, 423, 2192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 16596, 6553, 11249, 22, 2499, 12, 2867, 389, 2080, 16, 1758, 389, 869, 16, 2254, 5034, 8526, 3778, 389, 2232, 16, 2254, 5034, 8526, 3778, 389, 2372, 13, 1071, 31, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; // Imports import "../client/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "../client/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "../client/node_modules/@openzeppelin/contracts/utils/Counters.sol"; // Smart Contract AirCraftPart using ERC721 token standard contract AirCraftPart is ERC721Enumerable, ERC721URIStorage { // ======================================== // Variables/Mappings: // ======================================== // Unique Token Identifier using Counters Library using Counters for Counters.Counter; Counters.Counter private tokenId; // Authority addresses mapping ( address => bool) internal authorities; // Validated flag for partIds mapping ( uint256 => bool) internal isValidated; // Password already set flag for address/user mapping ( address => bool) internal passwordSet; // KeyList of corresponding address/user mapping ( address => string) internal ownerToKeyList; // URI/hash with corresponding key shares mapping ( string => string) internal uriToKeyShare; // ======================================== // Constructor: Set Name and Symbol of Contract, Initializing authorities // ======================================== constructor() ERC721("AirCraftPart", "PART") { authorities[0xCD964d99c155369B3E4ae8EF2Aa83EF55bcebA9B] = true; authorities[0xf0Dd951142614Da97AB59e66827477530F7a0a50] = true; } // ======================================== // Modifier: Allow only authority modifier // ======================================== modifier onlyAuth { require(authorities[msg.sender], "AirCraftPart Validation: address not authorized!"); _; } // ======================================== // Function: Create a new aircraft part // ======================================== function createAirCraftPart(string memory partURI) public { // Get current token Id uint256 tokenIdValue = tokenId.current(); // Create new Token and set Metadata _mint(msg.sender, tokenIdValue); _setTokenURI(tokenIdValue, partURI); // Set to unvalidated part unvalidatePart(tokenIdValue); // Set Token Id for next aircraft part tokenId.increment(); } // ======================================== // Function: Add a new certificate to an aircraft part // ======================================== function updateCertificateList (uint256 partId, string memory partURI) public { // Check if requester is authorized require( _isApprovedOrOwner(msg.sender, partId), "AirCraftPart: transfer caller is not owner nor approved" ); // Check if partId exists require( _exists(partId), "AirCraftPart: part id does not exist" ); // Update Certificate Hash List in Metadata _setTokenURI(partId, partURI); // Set to unvalidated part unvalidatePart(partId); } // ======================================== // Function: Return all Certificates for an aircraft part // ======================================== function getPartURI(uint256 partId) public view returns (string memory){ return tokenURI(partId); } // ======================================== // Function: Check if aircraft part exists by ID // ======================================== function checkPartIdExist(uint256 partId) public view returns (bool){ return _exists(partId); } // ======================================== // Function: Get tokens of owner // ======================================== function getTokensOfOwner(address _owner) external view returns( uint256[] memory ){ // Get amount of tokens owned by address uint256 tokenCount = balanceOf(_owner); // Check if address has tokens if (tokenCount == 0) { // Return empty array return new uint256[](0); } else { // List of all tokens owned by address uint256[] memory ownerTokens = new uint256[](tokenCount); // Iterate throw all tokens owned by address and add them to the list for (uint256 i = 0; i < tokenCount; i++){ ownerTokens[i] = tokenOfOwnerByIndex(_owner, i); } return ownerTokens; } } // ======================================== // Function: Get all token URIs/hashes // ======================================== function getAllTokenURIs() external onlyAuth view returns( string[] memory ){ // Get amount of tokens owned by address uint256 tokenCount = totalSupply(); // Check if address has tokens if (tokenCount == 0) { // Return empty array return new string[](0); } else { // List of all tokens string[] memory tokenURIs = new string[](tokenCount); // Iterate throw all tokens and add them to the list for (uint256 i = 0; i < tokenCount; i++){ uint256 tokenId = tokenByIndex(i); // Check if part is validated if( isValidated[tokenId] == false ){ tokenURIs[i] = tokenURI(tokenId); } } return tokenURIs; } } // ============================ // Validate an aircraft part // ============================ function validatePart(uint256 partId) external onlyAuth { isValidated[partId] = true; } // ============================ // Unvalidate an aircraft part // ============================ function unvalidatePart(uint256 partId) internal { isValidated[partId] = false; } // ============================ // Get validation status // ============================ function getValidation(uint256 partId) external view returns (bool) { return isValidated[partId]; } // ======================================== // Function: Set key shares of authorities with corresponding URI/hash // ======================================== function addKeyShares (string memory uri, string memory keyShares) public { uriToKeyShare[uri] = keyShares; } // ======================================== // Function: Get key shares of authorities by URI/hash // ======================================== function getKeyShares (string memory uri) public onlyAuth view returns (string memory) { return uriToKeyShare[uri]; } // ======================================== // Function: Set flag of user/addres that password has been assigned // ======================================== function setPassword () public { passwordSet[msg.sender] = true; } // ======================================== // Function: Get flag of user/addres whether password has been assigned // ======================================== function getPassword () public view returns (bool) { return passwordSet[msg.sender]; } // ======================================== // Function: Get flag of user/addres whether password has been assigned // ======================================== function getKeyList () public view returns (string memory) { return ownerToKeyList[msg.sender]; } // ======================================== // Function: Update URI/hash of keylist for corresponding user/address // ======================================== function updateKeyList (string memory keyListURI) public { ownerToKeyList[msg.sender] = keyListURI; } // ============================ // Override inherited function _beforeTokenTransfer // ============================ function _beforeTokenTransfer(address from, address to, uint256 _tokenId) internal override(ERC721, ERC721Enumerable){ super._beforeTokenTransfer(from, to, _tokenId); } // ============================ // Override inherited function _burn // ============================ function _burn(uint256 _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } // ============================ // Override inherited function tokenURI // ============================ function tokenURI(uint256 _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // ============================ // Override inherited function supportsInterface // ============================ function supportsInterface(bytes4 _interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool){ return super.supportsInterface(_interfaceId); } }
======================================== Function: Add a new certificate to an aircraft part ======================================== Check if requester is authorized Check if partId exists Update Certificate Hash List in Metadata Set to unvalidated part
function updateCertificateList (uint256 partId, string memory partURI) public { require( _isApprovedOrOwner(msg.sender, partId), "AirCraftPart: transfer caller is not owner nor approved" ); require( _exists(partId), "AirCraftPart: part id does not exist" ); _setTokenURI(partId, partURI); unvalidatePart(partId); }
5,525,816
[ 1, 4625, 348, 7953, 560, 30, 225, 422, 4428, 894, 631, 4284, 30, 1436, 279, 394, 4944, 358, 392, 23350, 71, 5015, 1087, 422, 4428, 894, 631, 2073, 309, 19961, 353, 10799, 2073, 309, 1087, 548, 1704, 2315, 6660, 2474, 987, 316, 6912, 1000, 358, 640, 877, 690, 1087, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 1089, 4719, 682, 261, 11890, 5034, 1087, 548, 16, 533, 3778, 1087, 3098, 13, 1071, 288, 203, 203, 565, 2583, 12, 203, 1377, 389, 291, 31639, 1162, 5541, 12, 3576, 18, 15330, 16, 1087, 548, 3631, 203, 1377, 315, 29752, 39, 5015, 1988, 30, 7412, 4894, 353, 486, 3410, 12517, 20412, 6, 203, 565, 11272, 203, 203, 565, 2583, 12, 203, 1377, 389, 1808, 12, 2680, 548, 3631, 203, 1377, 315, 29752, 39, 5015, 1988, 30, 1087, 612, 1552, 486, 1005, 6, 203, 565, 11272, 203, 203, 565, 389, 542, 1345, 3098, 12, 2680, 548, 16, 1087, 3098, 1769, 203, 203, 565, 640, 5662, 1988, 12, 2680, 548, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: NONE pragma solidity 0.7.6; // Part: IERC20Permit /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // Part: LixirErrors library LixirErrors { function require_INSUFFICIENT_BALANCE(bool cond) internal pure { require(cond, 'INSUFFICIENT_BALANCE'); } function require_INSUFFICIENT_ALLOWANCE(bool cond) internal pure { require(cond, 'INSUFFICIENT_ALLOWANCE'); } function require_PERMIT_EXPIRED(bool cond) internal pure { require(cond, 'PERMIT_EXPIRED'); } function require_INVALID_SIGNATURE(bool cond) internal pure { require(cond, 'INVALID_SIGNATURE'); } function require_XFER_ZERO_ADDRESS(bool cond) internal pure { require(cond, 'XFER_ZERO_ADDRESS'); } function require_INSUFFICIENT_INPUT_AMOUNT(bool cond) internal pure { require(cond, 'INSUFFICIENT_INPUT_AMOUNT'); } function require_INSUFFICIENT_OUTPUT_AMOUNT(bool cond) internal pure { require(cond, 'INSUFFICIENT_OUTPUT_AMOUNT'); } function require_INSUFFICIENT_ETH(bool cond) internal pure { require(cond, 'INSUFFICIENT_ETH'); } function require_MAX_SUPPLY(bool cond) internal pure { require(cond, 'MAX_SUPPLY'); } } // Part: LixirRoles library LixirRoles { bytes32 constant gov_role = keccak256('v1_gov_role'); bytes32 constant delegate_role = keccak256('v1_delegate_role'); bytes32 constant vault_role = keccak256('v1_vault_role'); bytes32 constant strategist_role = keccak256('v1_strategist_role'); bytes32 constant pauser_role = keccak256('v1_pauser_role'); bytes32 constant keeper_role = keccak256('v1_keeper_role'); bytes32 constant deployer_role = keccak256('v1_deployer_role'); bytes32 constant strategy_role = keccak256('v1_strategy_role'); bytes32 constant vault_implementation_role = keccak256('v1_vault_implementation_role'); bytes32 constant eth_vault_implementation_role = keccak256('v1_eth_vault_implementation_role'); bytes32 constant factory_role = keccak256('v1_factory_role'); bytes32 constant fee_setter_role = keccak256('fee_setter_role'); } // Part: OpenZeppelin/[email protected]/Address /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // Part: OpenZeppelin/[email protected]/Context /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // Part: OpenZeppelin/[email protected]/EnumerableSet /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already 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; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // Part: OpenZeppelin/[email protected]/IERC20 /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // Part: OpenZeppelin/[email protected]/SafeMath /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // Part: SafeCast /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } function toUint128(uint256 y) internal pure returns (uint128 z) { require((z = uint128(y)) == y); } function abs(int256 y) internal pure returns (uint256 z) { z = y < 0 ? uint256(-y) : uint256(y); } } // Part: Uniswap/[email protected]/FixedPoint128 /// @title FixedPoint128 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) library FixedPoint128 { uint256 internal constant Q128 = 0x100000000000000000000000000000000; } // Part: Uniswap/[email protected]/FixedPoint96 /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; } // Part: Uniswap/[email protected]/FullMath /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } // Part: Uniswap/[email protected]/IUniswapV3MintCallback /// @title Callback for IUniswapV3PoolActions#mint /// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface interface IUniswapV3MintCallback { /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata data ) external; } // Part: Uniswap/[email protected]/IUniswapV3PoolActions /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; } // Part: Uniswap/[email protected]/IUniswapV3PoolDerivedState /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); } // Part: Uniswap/[email protected]/IUniswapV3PoolEvents /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); } // Part: Uniswap/[email protected]/IUniswapV3PoolImmutables /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); } // Part: Uniswap/[email protected]/IUniswapV3PoolOwnerActions /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); } // Part: Uniswap/[email protected]/IUniswapV3PoolState /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); } // Part: Uniswap/[email protected]/LowGasSafeMath /// @title Optimized overflow and underflow safe math operations /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost library LowGasSafeMath { /// @notice Returns x + y, reverts if sum overflows uint256 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x + y, reverts if overflows or underflows /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(int256 x, int256 y) internal pure returns (int256 z) { require((z = x + y) >= x == (y >= 0)); } /// @notice Returns x - y, reverts if overflows or underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(int256 x, int256 y) internal pure returns (int256 z) { require((z = x - y) <= x == (y >= 0)); } } // Part: Uniswap/[email protected]/TickMath /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } // Part: Uniswap/[email protected]/UnsafeMath /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } } // Part: Uniswap/[email protected]/PoolAddress /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ); } } // Part: Uniswap/[email protected]/PositionKey library PositionKey { /// @dev Returns the key of the position in the core library function compute( address owner, int24 tickLower, int24 tickUpper ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(owner, tickLower, tickUpper)); } } // Part: Uniswap/[email protected]/TransferHelper library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } } // Part: ILixirVaultToken interface ILixirVaultToken is IERC20, IERC20Permit {} // Part: OpenZeppelin/[email protected]/AccessControl /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // Part: OpenZeppelin/[email protected]/Initializable /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } } // Part: OpenZeppelin/[email protected]/Pausable /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // Part: SqrtPriceMath /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMath { using LowGasSafeMath for uint256; using SafeCast for uint256; /// @notice Gets the next sqrt price given a delta of token0 /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the /// price less in order to not send too much output. /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token0 to add or remove from virtual reserves /// @param add Whether to add or remove the amount of token0 /// @return The price after adding or removing amount, depending on add function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price if (amount == 0) return sqrtPX96; uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; if (add) { uint256 product; if ((product = amount * sqrtPX96) / amount == sqrtPX96) { uint256 denominator = numerator1 + product; if (denominator >= numerator1) // always fits in 160 bits return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator)); } return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount))); } else { uint256 product; // if the product overflows, we know the denominator underflows // in addition, we must check that the denominator does not underflow require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); uint256 denominator = numerator1 - product; return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160(); } } /// @notice Gets the next sqrt price given a delta of token1 /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the /// price less in order to not send too much output. /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token1 to add, or remove, from virtual reserves /// @param add Whether to add, or remove, the amount of token1 /// @return The price after adding or removing `amount` function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // if we're adding (subtracting), rounding down requires rounding the quotient down (up) // in both cases, avoid a mulDiv for most inputs if (add) { uint256 quotient = ( amount <= type(uint160).max ? (amount << FixedPoint96.RESOLUTION) / liquidity : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity) ); return uint256(sqrtPX96).add(quotient).toUint160(); } else { uint256 quotient = ( amount <= type(uint160).max ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity) : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity) ); require(sqrtPX96 > quotient); // always fits 160 bits return uint160(sqrtPX96 - quotient); } } /// @notice Gets the next sqrt price given an input amount of token0 or token1 /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount /// @param liquidity The amount of usable liquidity /// @param amountIn How much of token0, or token1, is being swapped in /// @param zeroForOne Whether the amount in is token0 or token1 /// @return sqrtQX96 The price after adding the input amount to token0 or token1 function getNextSqrtPriceFromInput( uint160 sqrtPX96, uint128 liquidity, uint256 amountIn, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we don't pass the target price return zeroForOne ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true) : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true); } /// @notice Gets the next sqrt price given an output amount of token0 or token1 /// @dev Throws if price or liquidity are 0 or the next price is out of bounds /// @param sqrtPX96 The starting price before accounting for the output amount /// @param liquidity The amount of usable liquidity /// @param amountOut How much of token0, or token1, is being swapped out /// @param zeroForOne Whether the amount out is token0 or token1 /// @return sqrtQX96 The price after removing the output amount of token0 or token1 function getNextSqrtPriceFromOutput( uint160 sqrtPX96, uint128 liquidity, uint256 amountOut, bool zeroForOne ) internal pure returns (uint160 sqrtQX96) { require(sqrtPX96 > 0); require(liquidity > 0); // round to make sure that we pass the target price return zeroForOne ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false) : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false); } /// @notice Gets the amount0 delta between two prices /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up or down /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96; require(sqrtRatioAX96 > 0); return roundUp ? UnsafeMath.divRoundingUp( FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96 ) : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96; } /// @notice Gets the amount1 delta between two prices /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The amount of usable liquidity /// @param roundUp Whether to round the amount up, or down /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity, bool roundUp ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return roundUp ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96) : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Helper that gets signed token0 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount0 delta /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices function getAmount0Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount0) { return liquidity < 0 ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } /// @notice Helper that gets signed token1 delta /// @param sqrtRatioAX96 A sqrt price /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The change in liquidity for which to compute the amount1 delta /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices function getAmount1Delta( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity ) internal pure returns (int256 amount1) { return liquidity < 0 ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256() : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256(); } } // Part: Uniswap/[email protected]/IUniswapV3Pool /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { } // Part: Uniswap/[email protected]/IWETH9 /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; } // Part: Uniswap/[email protected]/LiquidityAmounts /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } } // Part: EIP712Initializable /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Initializable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; constructor(string memory version) { _HASHED_VERSION = keccak256(bytes(version)); _TYPE_HASH = keccak256( 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)' ); } /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712__initialize(string memory name) internal initializer { _HASHED_NAME = keccak256(bytes(name)); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { return keccak256( abi.encode( _TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, _getChainId(), address(this) ) ); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked('\x19\x01', _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { // Silence state mutability warning without generating bytecode. // See https://github.com/ethereum/solidity/issues/10090#issuecomment-741789128 and // https://github.com/ethereum/solidity/issues/2691 this; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } } // Part: ILixirVault interface ILixirVault is ILixirVaultToken { function initialize( string memory name, string memory symbol, address _token0, address _token1, address _strategist, address _keeper, address _strategy ) external; function token0() external view returns (IERC20); function token1() external view returns (IERC20); function activeFee() external view returns (uint24); function activePool() external view returns (IUniswapV3Pool); function strategist() external view returns (address); function strategy() external view returns (address); function keeper() external view returns (address); function setKeeper(address _keeper) external; function setStrategist(address _strategist) external; function setStrategy(address _strategy) external; function setPerformanceFee(uint24 newFee) external; function emergencyExit() external; function unpause() external; function mainPosition() external view returns (int24 tickLower, int24 tickUpper); function rangePosition() external view returns (int24 tickLower, int24 tickUpper); function rebalance( int24 mainTickLower, int24 mainTickUpper, int24 rangeTickLower0, int24 rangeTickUpper0, int24 rangeTickLower1, int24 rangeTickUpper1, uint24 fee ) external; function withdraw( uint256 shares, uint256 amount0Min, uint256 amount1Min, address receiver, uint256 deadline ) external returns (uint256 amount0Out, uint256 amount1Out); function withdrawFrom( address withdrawer, uint256 shares, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) external returns (uint256 amount0Out, uint256 amount1Out); function deposit( uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) external returns ( uint256 shares, uint256 amount0, uint256 amount1 ); function calculateTotalsFromTick(int24 virtualTick) external view returns ( uint256 total0, uint256 total1, uint128 mL, uint128 rL ); } // Part: LixirRegistry /** @notice an access control contract with roles used to handle permissioning throughout the `Vault` and `Strategy` contracts. */ contract LixirRegistry is AccessControl { address public immutable uniV3Factory; IWETH9 public immutable weth9; /// king bytes32 public constant gov_role = keccak256('v1_gov_role'); /// same privileges as `gov_role` bytes32 public constant delegate_role = keccak256('v1_delegate_role'); /// configuring options within the strategy contract & vault bytes32 public constant strategist_role = keccak256('v1_strategist_role'); /// can `emergencyExit` a vault bytes32 public constant pauser_role = keccak256('v1_pauser_role'); /// can `rebalance` the vault via the strategy contract bytes32 public constant keeper_role = keccak256('v1_keeper_role'); /// can `createVault`s from the factory contract bytes32 public constant deployer_role = keccak256('v1_deployer_role'); /// verified vault in the registry bytes32 public constant vault_role = keccak256('v1_vault_role'); /// can initialize vaults bytes32 public constant strategy_role = keccak256('v1_strategy_role'); bytes32 public constant vault_implementation_role = keccak256('v1_vault_implementation_role'); bytes32 public constant eth_vault_implementation_role = keccak256('v1_eth_vault_implementation_role'); /// verified vault factory in the registry bytes32 public constant factory_role = keccak256('v1_factory_role'); /// can `setPerformanceFee` on a vault bytes32 public constant fee_setter_role = keccak256('fee_setter_role'); address public feeTo; address public emergencyReturn; uint24 public constant PERFORMANCE_FEE_PRECISION = 1e6; event FeeToChanged(address indexed previousFeeTo, address indexed newFeeTo); event EmergencyReturnChanged( address indexed previousEmergencyReturn, address indexed newEmergencyReturn ); constructor( address _governance, address _delegate, address _uniV3Factory, address _weth9 ) { uniV3Factory = _uniV3Factory; weth9 = IWETH9(_weth9); _setupRole(gov_role, _governance); _setupRole(delegate_role, _delegate); // gov is its own admin _setRoleAdmin(gov_role, gov_role); _setRoleAdmin(delegate_role, gov_role); _setRoleAdmin(strategist_role, delegate_role); _setRoleAdmin(fee_setter_role, delegate_role); _setRoleAdmin(pauser_role, delegate_role); _setRoleAdmin(keeper_role, delegate_role); _setRoleAdmin(deployer_role, delegate_role); _setRoleAdmin(factory_role, delegate_role); _setRoleAdmin(strategy_role, delegate_role); _setRoleAdmin(vault_implementation_role, delegate_role); _setRoleAdmin(eth_vault_implementation_role, delegate_role); _setRoleAdmin(vault_role, factory_role); } function addRole(bytes32 role, bytes32 roleAdmin) public { require(isGovOrDelegate(msg.sender)); require(getRoleAdmin(role) == bytes32(0) && getRoleMemberCount(role) == 0); _setRoleAdmin(role, roleAdmin); } function isGovOrDelegate(address account) public view returns (bool) { return hasRole(gov_role, account) || hasRole(delegate_role, account); } function setFeeTo(address _feeTo) external { require(isGovOrDelegate(msg.sender)); address previous = feeTo; feeTo = _feeTo; emit FeeToChanged(previous, _feeTo); } function setEmergencyReturn(address _emergencyReturn) external { require(isGovOrDelegate(msg.sender)); address previous = emergencyReturn; emergencyReturn = _emergencyReturn; emit EmergencyReturnChanged(previous, _emergencyReturn); } } // Part: ILixirVaultETH interface ILixirVaultETH is ILixirVault { enum TOKEN {ZERO, ONE} function WETH_TOKEN() external view returns (TOKEN); function depositETH( uint256 amountDesired, uint256 amountEthMin, uint256 amountMin, address recipient, uint256 deadline ) external payable returns ( uint256 shares, uint256 amountEthIn, uint256 amountIn ); function withdrawETHFrom( address withdrawer, uint256 shares, uint256 amountEthMin, uint256 amountMin, address payable recipient, uint256 deadline ) external returns (uint256 amountEthOut, uint256 amountOut); function withdrawETH( uint256 shares, uint256 amountEthMin, uint256 amountMin, address payable recipient, uint256 deadline ) external returns (uint256 amountEthOut, uint256 amountOut); receive() external payable; } // Part: LixirBase /** @notice An abstract contract that gives access to the registry and contains common modifiers for restricting access to functions based on role. */ abstract contract LixirBase { LixirRegistry public immutable registry; constructor(address _registry) { registry = LixirRegistry(_registry); } modifier onlyRole(bytes32 role) { require(registry.hasRole(role, msg.sender)); _; } modifier onlyGovOrDelegate { require(registry.isGovOrDelegate(msg.sender)); _; } modifier hasRole(bytes32 role, address account) { require(registry.hasRole(role, account)); _; } } // Part: LixirVaultToken /** * @title Highly opinionated token implementation * @author Balancer Labs * @dev * - Includes functions to increase and decrease allowance as a workaround * for the well-known issue with `approve`: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not * decreased by calls to transferFrom * - Lets a token holder use `transferFrom` to send their own tokens, * without first setting allowance * - Emits 'Approval' events whenever allowance is changed by `transferFrom` */ contract LixirVaultToken is ILixirVaultToken, EIP712Initializable { using SafeMath for uint256; // State variables uint8 private constant _DECIMALS = 18; mapping(address => uint256) private _balance; mapping(address => mapping(address => uint256)) _allowance; uint256 private _totalSupply; string private _name; string private _symbol; mapping(address => uint256) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPE_HASH = keccak256( 'Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)' ); constructor() EIP712Initializable('1') {} // Function declarations function __LixirVaultToken__initialize( string memory tokenName, string memory tokenSymbol ) internal initializer { __EIP712__initialize(tokenName); _name = tokenName; _symbol = tokenSymbol; } // External functions function allowance(address owner, address spender) public view override returns (uint256) { return _allowance[owner][spender]; } function balanceOf(address account) external view override returns (uint256) { return _balance[account]; } function approve(address spender, uint256 amount) external override returns (bool) { _setAllowance(msg.sender, spender, amount); return true; } function increaseApproval(address spender, uint256 amount) external returns (bool) { _setAllowance( msg.sender, spender, _allowance[msg.sender][spender].add(amount) ); return true; } function decreaseApproval(address spender, uint256 amount) external returns (bool) { uint256 currentAllowance = _allowance[msg.sender][spender]; if (amount >= currentAllowance) { _setAllowance(msg.sender, spender, 0); } else { _setAllowance(msg.sender, spender, currentAllowance.sub(amount)); } return true; } function transfer(address recipient, uint256 amount) external override returns (bool) { _move(msg.sender, recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) external override returns (bool) { uint256 currentAllowance = _allowance[sender][msg.sender]; LixirErrors.require_INSUFFICIENT_ALLOWANCE( msg.sender == sender || currentAllowance >= amount ); _move(sender, recipient, amount); if (msg.sender != sender && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount _setAllowance(sender, msg.sender, currentAllowance - amount); } return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { // solhint-disable-next-line not-rely-on-time LixirErrors.require_PERMIT_EXPIRED(block.timestamp <= deadline); uint256 nonce = _nonces[owner]; bytes32 structHash = keccak256( abi.encode(_PERMIT_TYPE_HASH, owner, spender, value, nonce, deadline) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ecrecover(hash, v, r, s); LixirErrors.require_INVALID_SIGNATURE(signer != address(0)); _nonces[owner] = nonce + 1; _setAllowance(owner, spender, value); } // Public functions function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _DECIMALS; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function nonces(address owner) external view override returns (uint256) { return _nonces[owner]; } // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } // Internal functions function _beforeMintCallback(address recipient, uint256 amount) internal virtual {} function _mintPoolTokens(address recipient, uint256 amount) internal { _beforeMintCallback(recipient, amount); _balance[recipient] = _balance[recipient].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0), recipient, amount); } function _burnPoolTokens(address sender, uint256 amount) internal { uint256 currentBalance = _balance[sender]; LixirErrors.require_INSUFFICIENT_BALANCE(currentBalance >= amount); _balance[sender] = currentBalance - amount; _totalSupply = _totalSupply.sub(amount); emit Transfer(sender, address(0), amount); } function _move( address sender, address recipient, uint256 amount ) internal { uint256 currentBalance = _balance[sender]; LixirErrors.require_INSUFFICIENT_BALANCE(currentBalance >= amount); // Prohibit transfers to the zero address to avoid confusion with the // Transfer event emitted by `_burnPoolTokens` LixirErrors.require_XFER_ZERO_ADDRESS(recipient != address(0)); _balance[sender] = currentBalance - amount; _balance[recipient] = _balance[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _setAllowance( address owner, address spender, uint256 amount ) internal { _allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } } // Part: LixirVault contract LixirVault is ILixirVault, LixirVaultToken, LixirBase, IUniswapV3MintCallback, Pausable { using LowGasSafeMath for uint256; using SafeCast for uint256; using SafeCast for int256; using SafeCast for uint128; IERC20 public override token0; IERC20 public override token1; uint24 public override activeFee; IUniswapV3Pool public override activePool; address public override strategy; address public override strategist; address public override keeper; Position public override mainPosition; Position public override rangePosition; uint24 public performanceFee; uint24 immutable PERFORMANCE_FEE_PRECISION; address immutable uniV3Factory; event Deposit( address indexed depositor, address indexed recipient, uint256 shares, uint256 amount0In, uint256 amount1In, uint256 total0, uint256 total1 ); event Withdraw( address indexed withdrawer, address indexed recipient, uint256 shares, uint256 amount0Out, uint256 amount1Out ); event Rebalance( int24 mainTickLower, int24 mainTickUpper, int24 rangeTickLower, int24 rangeTickUpper, uint24 newFee, uint256 total0, uint256 total1 ); event PerformanceFeeSet(uint24 oldFee, uint24 newFee); event StrategySet(address oldStrategy, address newStrategy); struct DepositPositionData { uint128 LDelta; int24 tickLower; int24 tickUpper; } enum POSITION {MAIN, RANGE} // details about the uniswap position struct Position { // the tick range of the position int24 tickLower; int24 tickUpper; } constructor(address _registry) LixirBase(_registry) { PERFORMANCE_FEE_PRECISION = LixirRegistry(_registry) .PERFORMANCE_FEE_PRECISION(); uniV3Factory = LixirRegistry(_registry).uniV3Factory(); } /** @notice sets fields in the contract and initializes the `LixirVaultToken` */ function initialize( string memory name, string memory symbol, address _token0, address _token1, address _strategist, address _keeper, address _strategy ) public virtual override hasRole(LixirRoles.strategist_role, _strategist) hasRole(LixirRoles.keeper_role, _keeper) hasRole(LixirRoles.strategy_role, _strategy) initializer { require(_token0 < _token1); __LixirVaultToken__initialize(name, symbol); token0 = IERC20(_token0); token1 = IERC20(_token1); strategist = _strategist; keeper = _keeper; strategy = _strategy; } modifier onlyStrategist() { require(msg.sender == strategist); _; } modifier onlyStrategy() { require(msg.sender == strategy); _; } modifier notExpired(uint256 deadline) { require(block.timestamp <= deadline, 'Expired'); _; } /** @dev calculates shares, totals, etc. to mint the proper amount of `LixirVaultToken`s to `recipient` */ function _depositStepOne( uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient ) internal returns ( DepositPositionData memory mainData, DepositPositionData memory rangeData, uint256 shares, uint256 amount0In, uint256 amount1In, uint256 total0, uint256 total1 ) { uint256 _totalSupply = totalSupply(); mainData = DepositPositionData({ LDelta: 0, tickLower: mainPosition.tickLower, tickUpper: mainPosition.tickUpper }); rangeData = DepositPositionData({ LDelta: 0, tickLower: rangePosition.tickLower, tickUpper: rangePosition.tickUpper }); if (_totalSupply == 0) { (shares, mainData.LDelta, amount0In, amount1In) = calculateInitialDeposit( amount0Desired, amount1Desired ); total0 = amount0In; total1 = amount1In; } else { uint128 mL; uint128 rL; { (uint160 sqrtRatioX96, int24 tick) = getSqrtRatioX96AndTick(); (total0, total1, mL, rL) = _calculateTotals( sqrtRatioX96, tick, mainData, rangeData ); } (shares, amount0In, amount1In) = calcSharesAndAmounts( amount0Desired, amount1Desired, total0, total1, _totalSupply ); mainData.LDelta = uint128(FullMath.mulDiv(mL, shares, _totalSupply)); rangeData.LDelta = uint128(FullMath.mulDiv(rL, shares, _totalSupply)); } LixirErrors.require_INSUFFICIENT_OUTPUT_AMOUNT( amount0Min <= amount0In && amount1Min <= amount1In ); _mintPoolTokens(recipient, shares); } /** @dev this function deposits the tokens into the UniV3 pool */ function _depositStepTwo( DepositPositionData memory mainData, DepositPositionData memory rangeData, address recipient, uint256 shares, uint256 amount0In, uint256 amount1In, uint256 total0, uint256 total1 ) internal { uint128 mLDelta = mainData.LDelta; if (0 < mLDelta) { activePool.mint( address(this), mainData.tickLower, mainData.tickUpper, mLDelta, '' ); } uint128 rLDelta = rangeData.LDelta; if (0 < rLDelta) { activePool.mint( address(this), rangeData.tickLower, rangeData.tickUpper, rLDelta, '' ); } emit Deposit( address(msg.sender), address(recipient), shares, amount0In, amount1In, total0, total1 ); } /** @notice deposit's the callers ERC20 tokens into the vault, mints them `LixirVaultToken`s, and adds their liquidity to the UniswapV3 pool. @param amount0Desired Amount of token 0 desired by user @param amount1Desired Amount of token 1 desired by user @param amount0Min Minimum amount of token 0 desired by user @param amount1Min Minimum amount of token 1 desired by user @param recipient The address for which the liquidity will be created @param deadline Blocktimestamp that this must execute before @return shares @return amount0In how much token0 was actually deposited @return amount1In how much token1 was actually deposited */ function deposit( uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) external override whenNotPaused notExpired(deadline) returns ( uint256 shares, uint256 amount0In, uint256 amount1In ) { DepositPositionData memory mainData; DepositPositionData memory rangeData; uint256 total0; uint256 total1; ( mainData, rangeData, shares, amount0In, amount1In, total0, total1 ) = _depositStepOne( amount0Desired, amount1Desired, amount0Min, amount1Min, recipient ); if (0 < amount0In) { // token0.transferFrom(msg.sender, address(this), amount0In); TransferHelper.safeTransferFrom( address(token0), msg.sender, address(this), amount0In ); } if (0 < amount1In) { // token1.transferFrom(msg.sender, address(this), amount1In); TransferHelper.safeTransferFrom( address(token1), msg.sender, address(this), amount1In ); } _depositStepTwo( mainData, rangeData, recipient, shares, amount0In, amount1In, total0, total1 ); } function _withdrawStep( address withdrawer, uint256 shares, uint256 amount0Min, uint256 amount1Min, address recipient ) internal returns (uint256 amount0Out, uint256 amount1Out) { uint256 _totalSupply = totalSupply(); _burnPoolTokens(withdrawer, shares); // does balance check (, int24 tick, , , , , ) = activePool.slot0(); // if withdrawing everything, then burn and collect the all positions // else, calculate their share and return it if (shares == _totalSupply) { if (!paused()) { burnCollectPositions(); } amount0Out = token0.balanceOf(address(this)); amount1Out = token1.balanceOf(address(this)); } else { { uint256 e0 = token0.balanceOf(address(this)); amount0Out = e0 > 0 ? FullMath.mulDiv(e0, shares, _totalSupply) : 0; uint256 e1 = token1.balanceOf(address(this)); amount1Out = e1 > 0 ? FullMath.mulDiv(e1, shares, _totalSupply) : 0; } if (!paused()) { { (uint256 ma0Out, uint256 ma1Out) = burnAndCollect(mainPosition, tick, shares, _totalSupply); amount0Out = amount0Out.add(ma0Out); amount1Out = amount1Out.add(ma1Out); } { (uint256 ra0Out, uint256 ra1Out) = burnAndCollect(rangePosition, tick, shares, _totalSupply); amount0Out = amount0Out.add(ra0Out); amount1Out = amount1Out.add(ra1Out); } } } LixirErrors.require_INSUFFICIENT_OUTPUT_AMOUNT( amount0Min <= amount0Out && amount1Min <= amount1Out ); emit Withdraw( address(msg.sender), address(recipient), shares, amount0Out, amount1Out ); } modifier canSpend(address withdrawer, uint256 shares) { uint256 currentAllowance = _allowance[withdrawer][msg.sender]; LixirErrors.require_INSUFFICIENT_ALLOWANCE( msg.sender == withdrawer || currentAllowance >= shares ); if (msg.sender != withdrawer && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != withdrawer then currentAllowance >= shares _setAllowance(withdrawer, msg.sender, currentAllowance - shares); } _; } /** @notice withdraws the desired shares from the vault on behalf of another account @dev same as `withdraw` except this can be called from an `approve`d address @param withdrawer the address to withdraw from @param shares number of shares to withdraw @param amount0Min Minimum amount of token 0 desired by user @param amount1Min Minimum amount of token 1 desired by user @param recipient address to recieve token0 and token1 withdrawals @param deadline blocktimestamp that this must execute by @return amount0Out how much token0 was actually withdrawn @return amount1Out how much token1 was actually withdrawn */ function withdrawFrom( address withdrawer, uint256 shares, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) external override canSpend(withdrawer, shares) returns (uint256 amount0Out, uint256 amount1Out) { (amount0Out, amount1Out) = _withdraw( withdrawer, shares, amount0Min, amount1Min, recipient, deadline ); } /** @notice withdraws the desired shares from the vault and transfers to caller. @dev `_withdrawStep` calculates how much the caller is owed @dev `_withdraw` transfers the tokens to the caller @param shares number of shares to withdraw @param amount0Min Minimum amount of token 0 desired by user @param amount1Min Minimum amount of token 1 desired by user @param recipient address to recieve token0 and token1 withdrawals @param deadline blocktimestamp that this must execute by @return amount0Out how much token0 was actually withdrawn @return amount1Out how much token1 was actually withdrawn */ function withdraw( uint256 shares, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) external override returns (uint256 amount0Out, uint256 amount1Out) { (amount0Out, amount1Out) = _withdraw( msg.sender, shares, amount0Min, amount1Min, recipient, deadline ); } function _withdraw( address withdrawer, uint256 shares, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) internal notExpired(deadline) returns (uint256 amount0Out, uint256 amount1Out) { (amount0Out, amount1Out) = _withdrawStep( withdrawer, shares, amount0Min, amount1Min, recipient ); if (0 < amount0Out) { TransferHelper.safeTransfer(address(token0), recipient, amount0Out); } if (0 < amount1Out) { TransferHelper.safeTransfer(address(token1), recipient, amount1Out); } } function setPerformanceFee(uint24 newFee) external override onlyRole(LixirRoles.fee_setter_role) { require(newFee < PERFORMANCE_FEE_PRECISION); emit PerformanceFeeSet(performanceFee, newFee); performanceFee = newFee; } function _setPool(uint24 fee) internal { activePool = IUniswapV3Pool( PoolAddress.computeAddress( uniV3Factory, PoolAddress.getPoolKey(address(token0), address(token1), fee) ) ); require(Address.isContract(address(activePool))); activeFee = fee; } function setKeeper(address _keeper) external override onlyStrategist hasRole(LixirRoles.keeper_role, _keeper) { keeper = _keeper; } function setStrategy(address _strategy) external override onlyStrategist hasRole(LixirRoles.strategy_role, _strategy) { emit StrategySet(strategy, _strategy); strategy = _strategy; } function setStrategist(address _strategist) external override onlyGovOrDelegate hasRole(LixirRoles.strategist_role, _strategist) { strategist = _strategist; } function emergencyExit() external override whenNotPaused onlyRole(LixirRoles.pauser_role) { burnCollectPositions(); _pause(); } function unpause() external override whenPaused onlyGovOrDelegate { _unpause(); } /** @notice burns all positions collects any fees accrued since last `rebalance` and mints new positions. @dev This function is not called by an external account, but instead by the strategy contract, which automatically calculates the proper positions to mint. */ function rebalance( int24 mainTickLower, int24 mainTickUpper, int24 rangeTickLower0, int24 rangeTickUpper0, int24 rangeTickLower1, int24 rangeTickUpper1, uint24 fee ) external override onlyStrategy whenNotPaused { require( TickMath.MIN_TICK <= mainTickLower && mainTickUpper <= TickMath.MAX_TICK && mainTickLower < mainTickUpper && TickMath.MIN_TICK <= rangeTickLower0 && rangeTickUpper0 <= TickMath.MAX_TICK && rangeTickLower0 < rangeTickUpper0 && TickMath.MIN_TICK <= rangeTickLower1 && rangeTickUpper1 <= TickMath.MAX_TICK && rangeTickLower1 < rangeTickUpper1 ); /// if a pool has been previously set, then take the performance fee accrued since last `rebalance` /// and burn and collect all positions. if (address(activePool) != address(0)) { _takeFee(); burnCollectPositions(); } /// if the strategist has changed the pool fee tier (e.g. 0.05%, 0.3%, 1%), then change the pool if (fee != activeFee) { _setPool(fee); } uint256 total0 = token0.balanceOf(address(this)); uint256 total1 = token1.balanceOf(address(this)); Position memory mainData = Position(mainTickLower, mainTickUpper); Position memory rangeData0 = Position(rangeTickLower0, rangeTickUpper0); Position memory rangeData1 = Position(rangeTickLower1, rangeTickUpper1); mintPositions(total0, total1, mainData, rangeData0, rangeData1); emit Rebalance( mainTickLower, mainTickUpper, rangePosition.tickLower, rangePosition.tickUpper, fee, total0, total1 ); } function mintPositions( uint256 amount0, uint256 amount1, Position memory mainData, Position memory rangeData0, Position memory rangeData1 ) internal { (uint160 sqrtRatioX96, ) = getSqrtRatioX96AndTick(); mainPosition.tickLower = mainData.tickLower; mainPosition.tickUpper = mainData.tickUpper; if (0 < amount0 || 0 < amount1) { uint128 mL = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, TickMath.getSqrtRatioAtTick(mainData.tickLower), TickMath.getSqrtRatioAtTick(mainData.tickUpper), amount0, amount1 ); if (0 < mL) { activePool.mint( address(this), mainData.tickLower, mainData.tickUpper, mL, '' ); } } amount0 = token0.balanceOf(address(this)); amount1 = token1.balanceOf(address(this)); uint128 rL; Position memory rangeData; if (0 < amount0 || 0 < amount1) { uint128 rL0 = LiquidityAmounts.getLiquidityForAmount0( TickMath.getSqrtRatioAtTick(rangeData0.tickLower), TickMath.getSqrtRatioAtTick(rangeData0.tickUpper), amount0 ); uint128 rL1 = LiquidityAmounts.getLiquidityForAmount1( TickMath.getSqrtRatioAtTick(rangeData1.tickLower), TickMath.getSqrtRatioAtTick(rangeData1.tickUpper), amount1 ); /// only one range position will ever have liquidity (if any) if (rL1 < rL0) { rL = rL0; rangeData = rangeData0; } else if (0 < rL1) { rangeData = rangeData1; rL = rL1; } } else { rangeData = Position(0, 0); } rangePosition.tickLower = rangeData.tickLower; rangePosition.tickUpper = rangeData.tickUpper; if (0 < rL) { activePool.mint( address(this), rangeData.tickLower, rangeData.tickUpper, rL, '' ); } } function _takeFee() internal { uint24 _perfFee = performanceFee; address _feeTo = registry.feeTo(); if (_feeTo != address(0) && 0 < _perfFee) { (uint160 sqrtRatioX96, int24 tick) = getSqrtRatioX96AndTick(); ( , uint256 total0, uint256 total1, uint256 tokensOwed0, uint256 tokensOwed1 ) = calculatePositionInfo( tick, sqrtRatioX96, mainPosition.tickLower, mainPosition.tickUpper ); { ( , uint256 total0Range, uint256 total1Range, uint256 tokensOwed0Range, uint256 tokensOwed1Range ) = calculatePositionInfo( tick, sqrtRatioX96, rangePosition.tickLower, rangePosition.tickUpper ); total0 = total0.add(total0Range).add(token0.balanceOf(address(this))); total1 = total1.add(total1Range).add(token1.balanceOf(address(this))); tokensOwed0 = tokensOwed0.add(tokensOwed0Range); tokensOwed1 = tokensOwed1.add(tokensOwed1Range); } uint256 _totalSupply = totalSupply(); uint256 price = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, FixedPoint96.Q96); total1 = total1.add(FullMath.mulDiv(total0, price, FixedPoint96.Q96)); if (total1 > 0) { tokensOwed1 = tokensOwed1.add( FullMath.mulDiv(tokensOwed0, price, FixedPoint96.Q96) ); uint256 shares = FullMath.mulDiv( FullMath.mulDiv(tokensOwed1, _totalSupply, total1), performanceFee, PERFORMANCE_FEE_PRECISION ); if (shares > 0) { _mintPoolTokens(_feeTo, shares); } } } } /** @notice burns everyting (main and range positions) and collects any fees accrued in the pool. @dev this is called fairly frequently since compounding is not automatic: in UniV3, all fees must be manually withdrawn. */ function burnCollectPositions() internal { uint128 mL = positionLiquidity(mainPosition); uint128 rL = positionLiquidity(rangePosition); if (0 < mL) { activePool.burn(mainPosition.tickLower, mainPosition.tickUpper, mL); activePool.collect( address(this), mainPosition.tickLower, mainPosition.tickUpper, type(uint128).max, type(uint128).max ); } if (0 < rL) { activePool.burn(rangePosition.tickLower, rangePosition.tickUpper, rL); activePool.collect( address(this), rangePosition.tickLower, rangePosition.tickUpper, type(uint128).max, type(uint128).max ); } } /** @notice in contrast to `burnCollectPositions`, this only burns a portion of liqudity, used for when a user withdraws tokens from the vault. @param position Storage pointer to position @param tick Current tick @param shares User shares to burn @param _totalSupply totalSupply of Lixir vault tokens */ function burnAndCollect( Position storage position, int24 tick, uint256 shares, uint256 _totalSupply ) internal returns (uint256 amount0Out, uint256 amount1Out) { int24 tickLower = position.tickLower; int24 tickUpper = position.tickUpper; /* * N.B. that tokensOwed{0,1} here are calculated prior to burning, * and so should only contain tokensOwed from fees and never tokensOwed from a burn */ (uint128 liquidity, uint256 tokensOwed0, uint256 tokensOwed1) = liquidityAndTokensOwed(tick, tickLower, tickUpper); uint128 LDelta = FullMath.mulDiv(shares, liquidity, _totalSupply).toUint128(); amount0Out = FullMath.mulDiv(tokensOwed0, shares, _totalSupply); amount1Out = FullMath.mulDiv(tokensOwed1, shares, _totalSupply); if (0 < LDelta) { (uint256 burnt0Out, uint256 burnt1Out) = activePool.burn(tickLower, tickUpper, LDelta); amount0Out = amount0Out.add(burnt0Out); amount1Out = amount1Out.add(burnt1Out); } if (0 < amount0Out || 0 < amount1Out) { activePool.collect( address(this), tickLower, tickUpper, amount0Out.toUint128(), amount1Out.toUint128() ); } } /// @dev internal readonly getters and pure helper functions /** * @dev Calculates shares and amounts to deposit from amounts desired, TVL of vault, and totalSupply of vault tokens * @param amount0Desired Amount of token 0 desired by user * @param amount1Desired Amount of token 1 desired by user * @param total0 Total amount of token 0 available to activePool * @param total1 Total amount of token 1 available to activePool * @param _totalSupply Total supply of vault tokens * @return shares Shares of activePool to mint to user * @return amount0In Actual amount of token0 user should deposit into activePool * @return amount1In Actual amount of token1 user should deposit into activePool */ function calcSharesAndAmounts( uint256 amount0Desired, uint256 amount1Desired, uint256 total0, uint256 total1, uint256 _totalSupply ) internal pure returns ( uint256 shares, uint256 amount0In, uint256 amount1In ) { (bool roundedSharesFrom0, uint256 sharesFrom0) = 0 < total0 ? mulDivRoundingUp(amount0Desired, _totalSupply, total0) : (false, 0); (bool roundedSharesFrom1, uint256 sharesFrom1) = 0 < total1 ? mulDivRoundingUp(amount1Desired, _totalSupply, total1) : (false, 0); uint8 realSharesOffsetFor0 = roundedSharesFrom0 ? 1 : 2; uint8 realSharesOffsetFor1 = roundedSharesFrom1 ? 1 : 2; if ( realSharesOffsetFor0 < sharesFrom0 && (total1 == 0 || sharesFrom0 < sharesFrom1) ) { shares = sharesFrom0 - 1 - realSharesOffsetFor0; amount0In = amount0Desired; amount1In = FullMath.mulDivRoundingUp(sharesFrom0, total1, _totalSupply); LixirErrors.require_INSUFFICIENT_OUTPUT_AMOUNT( amount1In <= amount1Desired ); } else { LixirErrors.require_INSUFFICIENT_INPUT_AMOUNT( realSharesOffsetFor1 < sharesFrom1 ); shares = sharesFrom1 - 1 - realSharesOffsetFor1; amount0In = FullMath.mulDivRoundingUp(sharesFrom1, total0, _totalSupply); LixirErrors.require_INSUFFICIENT_OUTPUT_AMOUNT( amount0In <= amount0Desired ); amount1In = amount1Desired; } } function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (bool rounded, uint256 result) { result = FullMath.mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; rounded = true; } } /** * @dev Calculates shares, liquidity deltas, and amounts in for initial deposit * @param amount0Desired Amount of token 0 desired by user * @param amount1Desired Amount of token 1 desired by user * @return shares Initial shares to mint * @return mLDelta Liquidity delta for main position * @return amount0In Amount of token 0 to transfer from user * @return amount1In Amount of token 1 to transfer from user */ function calculateInitialDeposit( uint256 amount0Desired, uint256 amount1Desired ) internal view returns ( uint256 shares, uint128 mLDelta, uint256 amount0In, uint256 amount1In ) { (uint160 sqrtRatioX96, int24 tick) = getSqrtRatioX96AndTick(); uint160 sqrtRatioLowerX96 = TickMath.getSqrtRatioAtTick(mainPosition.tickLower); uint160 sqrtRatioUpperX96 = TickMath.getSqrtRatioAtTick(mainPosition.tickUpper); mLDelta = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, sqrtRatioLowerX96, sqrtRatioUpperX96, amount0Desired, amount1Desired ); LixirErrors.require_INSUFFICIENT_INPUT_AMOUNT(0 < mLDelta); (amount0In, amount1In) = getAmountsForLiquidity( sqrtRatioX96, sqrtRatioLowerX96, sqrtRatioUpperX96, mLDelta.toInt128() ); shares = mLDelta; } /** * @dev Queries activePool for current square root price and current tick * @return _sqrtRatioX96 Current square root price * @return _tick Current tick */ function getSqrtRatioX96AndTick() internal view returns (uint160 _sqrtRatioX96, int24 _tick) { (_sqrtRatioX96, _tick, , , , , ) = activePool.slot0(); } /** * @dev Calculates tokens owed for a position * @param realTick Current tick * @param tickLower Lower tick of position * @param tickUpper Upper tick of position * @param feeGrowthInside0LastX128 Last fee growth of token0 between tickLower and tickUpper * @param feeGrowthInside1LastX128 Last fee growth of token0 between tickLower and tickUpper * @param liquidity Liquidity of position for which tokens owed is being calculated * @param tokensOwed0Last Last tokens owed to position * @param tokensOwed1Last Last tokens owed to position * @return tokensOwed0 Amount of token0 owed to position * @return tokensOwed1 Amount of token1 owed to position */ function calculateTokensOwed( int24 realTick, int24 tickLower, int24 tickUpper, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 liquidity, uint128 tokensOwed0Last, uint128 tokensOwed1Last ) internal view returns (uint128 tokensOwed0, uint128 tokensOwed1) { /* * V3 doesn't use SafeMath here, so we don't either * This could of course result in a dramatic forfeiture of fees. The reality though is * we rebalance far frequently enough for this to never happen in any realistic scenario. * This has no difference from the v3 implementation, and was copied from contracts/libraries/Position.sol */ (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) = getFeeGrowthInsideTicks(realTick, tickLower, tickUpper); tokensOwed0 = uint128( tokensOwed0Last + FullMath.mulDiv( feeGrowthInside0X128 - feeGrowthInside0LastX128, liquidity, FixedPoint128.Q128 ) ); tokensOwed1 = uint128( tokensOwed1Last + FullMath.mulDiv( feeGrowthInside1X128 - feeGrowthInside1LastX128, liquidity, FixedPoint128.Q128 ) ); } function _positionDataHelper( int24 realTick, int24 tickLower, int24 tickUpper ) internal view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ) { ( liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1 ) = activePool.positions( PositionKey.compute(address(this), tickLower, tickUpper) ); if (liquidity == 0) { return ( 0, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1 ); } (tokensOwed0, tokensOwed1) = calculateTokensOwed( realTick, tickLower, tickUpper, feeGrowthInside0LastX128, feeGrowthInside1LastX128, liquidity, tokensOwed0, tokensOwed1 ); } /** * @dev Queries and calculates liquidity and tokens owed * @param tick Current tick * @param tickLower Lower tick of position * @param tickUpper Upper tick of position * @return liquidity Liquidity of position for which tokens owed is being calculated * @return tokensOwed0 Amount of token0 owed to position * @return tokensOwed1 Amount of token1 owed to position */ function liquidityAndTokensOwed( int24 tick, int24 tickLower, int24 tickUpper ) internal view returns ( uint128 liquidity, uint128 tokensOwed0, uint128 tokensOwed1 ) { (liquidity, , , tokensOwed0, tokensOwed1) = _positionDataHelper( tick, tickLower, tickUpper ); } function calculateTotals() external view returns ( uint256 total0, uint256 total1, uint128 mL, uint128 rL ) { (uint160 sqrtRatioX96, int24 tick) = getSqrtRatioX96AndTick(); return _calculateTotals( sqrtRatioX96, tick, DepositPositionData(0, mainPosition.tickLower, mainPosition.tickUpper), DepositPositionData(0, rangePosition.tickLower, rangePosition.tickUpper) ); } /** * @notice This variant is so that tick TWAP's may be used by other protocols to calculate * totals, allowing them to safeguard themselves from manipulation. This would be useful if * Lixir vault tokens were used as collateral in a lending protocol. * @param virtualTick Tick at which to calculate amounts from liquidity */ function calculateTotalsFromTick(int24 virtualTick) external view override returns ( uint256 total0, uint256 total1, uint128 mL, uint128 rL ) { uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(virtualTick); (, int24 realTick) = getSqrtRatioX96AndTick(); return _calculateTotalsFromTick( sqrtRatioX96, realTick, DepositPositionData(0, mainPosition.tickLower, mainPosition.tickUpper), DepositPositionData(0, rangePosition.tickLower, rangePosition.tickUpper) ); } /** * @dev Helper function for calculating totals * @param sqrtRatioX96 *Current or virtual* sqrtPriceX96 * @param realTick Current tick, for calculating tokensOwed correctly * @param mainData Main position data * @param rangeData Range position data * N.B realTick must be provided because tokensOwed calculation needs * the current correct tick because the ticks are only updated upon the * crossing of ticks * sqrtRatioX96 can be a current sqrtPriceX96 *or* a sqrtPriceX96 calculated * from a virtual tick, for external consumption */ function _calculateTotalsFromTick( uint160 sqrtRatioX96, int24 realTick, DepositPositionData memory mainData, DepositPositionData memory rangeData ) internal view returns ( uint256 total0, uint256 total1, uint128 mL, uint128 rL ) { (mL, total0, total1) = calculatePositionTotals( realTick, sqrtRatioX96, mainData.tickLower, mainData.tickUpper ); { uint256 rt0; uint256 rt1; (rL, rt0, rt1) = calculatePositionTotals( realTick, sqrtRatioX96, rangeData.tickLower, rangeData.tickUpper ); total0 = total0.add(rt0); total1 = total1.add(rt1); } total0 = total0.add(token0.balanceOf(address(this))); total1 = total1.add(token1.balanceOf(address(this))); } function _calculateTotals( uint160 sqrtRatioX96, int24 tick, DepositPositionData memory mainData, DepositPositionData memory rangeData ) internal view returns ( uint256 total0, uint256 total1, uint128 mL, uint128 rL ) { return _calculateTotalsFromTick(sqrtRatioX96, tick, mainData, rangeData); } /** * @dev Calculates total tokens obtainable and liquidity of a given position (fees + amounts in position) * total{0,1} is sum of tokensOwed{0,1} from each position plus sum of liquidityForAmount{0,1} for each position plus vault balance of token{0,1} * @param realTick Current tick (for calculating tokensOwed) * @param sqrtRatioX96 Current (or virtual) square root price * @param tickLower Lower tick of position * @param tickLower Upper tick of position * @return liquidity Liquidity of position * @return total0 Total amount of token0 obtainable from position * @return total1 Total amount of token1 obtainable from position */ function calculatePositionTotals( int24 realTick, uint160 sqrtRatioX96, int24 tickLower, int24 tickUpper ) internal view returns ( uint128 liquidity, uint256 total0, uint256 total1 ) { uint256 tokensOwed0; uint256 tokensOwed1; ( liquidity, total0, total1, tokensOwed0, tokensOwed1 ) = calculatePositionInfo(realTick, sqrtRatioX96, tickLower, tickUpper); total0 = total0.add(tokensOwed0); total1 = total1.add(tokensOwed1); } function calculatePositionInfo( int24 realTick, uint160 sqrtRatioX96, int24 tickLower, int24 tickUpper ) internal view returns ( uint128 liquidity, uint256 total0, uint256 total1, uint256 tokensOwed0, uint256 tokensOwed1 ) { uint256 feeGrowthInside0LastX128; uint256 feeGrowthInside1LastX128; ( liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1 ) = _positionDataHelper(realTick, tickLower, tickUpper); uint160 sqrtPriceLower = TickMath.getSqrtRatioAtTick(tickLower); uint160 sqrtPriceUpper = TickMath.getSqrtRatioAtTick(tickUpper); (uint256 amount0, uint256 amount1) = getAmountsForLiquidity( sqrtRatioX96, sqrtPriceLower, sqrtPriceUpper, liquidity.toInt128() ); } /** * @dev Calculates fee growth between a tick range * @param tick Current tick * @param tickLower Lower tick of range * @param tickUpper Upper tick of range * @return feeGrowthInside0X128 Fee growth of token 0 inside ticks * @return feeGrowthInside1X128 Fee growth of token 1 inside ticks */ function getFeeGrowthInsideTicks( int24 tick, int24 tickLower, int24 tickUpper ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) { /* * Underflow is Good here, actually. * Uniswap V3 doesn't use SafeMath here, and the cases where it does underflow, * it should help us get back to the rightful fee growth value of our position. * It would underflow only when feeGrowthGlobal{0,1}X128 has overflowed already in the V3 contract. * It should never underflow if feeGrowthGlobal{0,1}X128 hasn't yet overflowed. * Of course, if feeGrowthGlobal{0,1}X128 has overflowed twice over or more, we cannot possibly recover * fees from the overflow before last via underflow here, and it is possible our feeGrowthOutside values are * insufficently large to underflow enough to recover fees from the most recent overflow. * But, we rebalance frequently, so this should never be an issue. * This math is no different than in the v3 activePool contract and was copied from contracts/libraries/Tick.sol */ uint256 feeGrowthGlobal0X128 = activePool.feeGrowthGlobal0X128(); uint256 feeGrowthGlobal1X128 = activePool.feeGrowthGlobal1X128(); ( , , uint256 feeGrowthOutside0X128Lower, uint256 feeGrowthOutside1X128Lower, , , , ) = activePool.ticks(tickLower); ( , , uint256 feeGrowthOutside0X128Upper, uint256 feeGrowthOutside1X128Upper, , , , ) = activePool.ticks(tickUpper); // calculate fee growth below uint256 feeGrowthBelow0X128; uint256 feeGrowthBelow1X128; if (tick >= tickLower) { feeGrowthBelow0X128 = feeGrowthOutside0X128Lower; feeGrowthBelow1X128 = feeGrowthOutside1X128Lower; } else { feeGrowthBelow0X128 = feeGrowthGlobal0X128 - feeGrowthOutside0X128Lower; feeGrowthBelow1X128 = feeGrowthGlobal1X128 - feeGrowthOutside1X128Lower; } // calculate fee growth above uint256 feeGrowthAbove0X128; uint256 feeGrowthAbove1X128; if (tick < tickUpper) { feeGrowthAbove0X128 = feeGrowthOutside0X128Upper; feeGrowthAbove1X128 = feeGrowthOutside1X128Upper; } else { feeGrowthAbove0X128 = feeGrowthGlobal0X128 - feeGrowthOutside0X128Upper; feeGrowthAbove1X128 = feeGrowthGlobal1X128 - feeGrowthOutside1X128Upper; } feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128; feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128; } /** * @dev Queries position liquidity * @param position Storage pointer to position we want to query */ function positionLiquidity(Position storage position) internal view returns (uint128 _liquidity) { (_liquidity, , , , ) = activePool.positions( PositionKey.compute(address(this), position.tickLower, position.tickUpper) ); } function getAmountsForLiquidity( uint160 sqrtPriceX96, uint160 sqrtPriceX96Lower, uint160 sqrtPriceX96Upper, int128 liquidityDelta ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtPriceX96 <= sqrtPriceX96Lower) { // current tick is below the passed range; liquidity can only become in range by crossing from left to // right, when we'll need _more_ token0 (it's becoming more valuable) so user must provide it amount0 = SqrtPriceMath .getAmount0Delta(sqrtPriceX96Lower, sqrtPriceX96Upper, liquidityDelta) .abs(); } else if (sqrtPriceX96 < sqrtPriceX96Upper) { amount0 = SqrtPriceMath .getAmount0Delta(sqrtPriceX96, sqrtPriceX96Upper, liquidityDelta) .abs(); amount1 = SqrtPriceMath .getAmount1Delta(sqrtPriceX96Lower, sqrtPriceX96, liquidityDelta) .abs(); } else { // current tick is above the passed range; liquidity can only become in range by crossing from right to // left, when we'll need _more_ token1 (it's becoming more valuable) so user must provide it amount1 = SqrtPriceMath .getAmount1Delta(sqrtPriceX96Lower, sqrtPriceX96Upper, liquidityDelta) .abs(); } } /// @inheritdoc IUniswapV3MintCallback function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata ) external virtual override { require(msg.sender == address(activePool)); if (amount0Owed > 0) { TransferHelper.safeTransfer(address(token0), msg.sender, amount0Owed); } if (amount1Owed > 0) { TransferHelper.safeTransfer(address(token1), msg.sender, amount1Owed); } } } // File: LixirVaultETH.sol contract LixirVaultETH is LixirVault, ILixirVaultETH { using SafeMath for uint256; using SafeCast for uint256; IWETH9 public immutable weth9; TOKEN public override WETH_TOKEN; constructor(address _registry) LixirVault(_registry) { weth9 = LixirRegistry(_registry).weth9(); } function initialize( string memory name, string memory symbol, address _token0, address _token1, address _strategist, address _keeper, address _strategy ) public override(LixirVault, ILixirVault) initializer { LixirVault.initialize( name, symbol, _token0, _token1, _strategist, _keeper, _strategy ); TOKEN _WETH_TOKEN; if (_token0 == address(weth9)) { _WETH_TOKEN = TOKEN.ZERO; } else { require(_token1 == address(weth9)); _WETH_TOKEN = TOKEN.ONE; } WETH_TOKEN = _WETH_TOKEN; } /** @notice equivalent to `deposit` except logic is configured for ETH instead of ERC20 payments. @param amountDesired amount of ERC20 token desired by caller @param amountEthMin minimum amount of ETH desired by caller @param amountMin minimum amount of ERC20 token desired by caller @param recipient The address for which the liquidity will be created @param deadline Blocktimestamp that this must execute before @return shares @return amountEthIn how much ETH was actually deposited @return amountIn how much the ERC20 token was actually deposited */ function depositETH( uint256 amountDesired, uint256 amountEthMin, uint256 amountMin, address recipient, uint256 deadline ) external payable override whenNotPaused notExpired(deadline) returns ( uint256 shares, uint256 amountEthIn, uint256 amountIn ) { TOKEN _WETH_TOKEN = WETH_TOKEN; if (_WETH_TOKEN == TOKEN.ZERO) { (shares, amountEthIn, amountIn) = _depositETH( _WETH_TOKEN, msg.value, amountDesired, amountEthMin, amountMin, recipient, deadline ); } else { (shares, amountIn, amountEthIn) = _depositETH( _WETH_TOKEN, amountDesired, msg.value, amountMin, amountEthMin, recipient, deadline ); } } function _depositETH( TOKEN _WETH_TOKEN, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline ) internal returns ( uint256 shares, uint256 amount0In, uint256 amount1In ) { uint256 amountEthDesired = msg.value; DepositPositionData memory mainData; DepositPositionData memory rangeData; uint256 total0; uint256 total1; ( mainData, rangeData, shares, amount0In, amount1In, total0, total1 ) = _depositStepOne( amount0Desired, amount1Desired, amount0Min, amount1Min, recipient ); if (_WETH_TOKEN == TOKEN.ZERO) { if (0 < amount0In) { weth9.deposit{value: amount0In}(); } if (0 < amount1In) { TransferHelper.safeTransferFrom( address(token1), msg.sender, address(this), amount1In ); } } else { if (0 < amount0In) { TransferHelper.safeTransferFrom( address(token0), msg.sender, address(this), amount0In ); } if (0 < amount1In) { weth9.deposit{value: amount1In}(); } } _depositStepTwo( mainData, rangeData, recipient, shares, amount0In, amount1In, total0, total1 ); Address.sendValue(msg.sender, address(this).balance); } /** @notice withdraws the desired shares from the vault @dev same as `withdraw` except this can be called from an `approve`d address @param withdrawer the address to withdraw from @param shares number of shares to withdraw @param amountEthMin amount of ETH desired by user @param amountMin Minimum amount of ERC20 token desired by user @param recipient address to recieve ETH and ERC20 withdrawals @param deadline blocktimestamp that this must execute by @return amountEthOut how much ETH was actually withdrawn @return amountOut how much ERC20 token was actually withdrawn */ function withdrawETHFrom( address withdrawer, uint256 shares, uint256 amountEthMin, uint256 amountMin, address payable recipient, uint256 deadline ) external override canSpend(withdrawer, shares) returns (uint256 amountEthOut, uint256 amountOut) { TOKEN _WETH_TOKEN = WETH_TOKEN; uint256 amount0Min; uint256 amount1Min; if (_WETH_TOKEN == TOKEN.ZERO) { amount0Min = amountEthMin; amount1Min = amountMin; (amountEthOut, amountOut) = _withdrawETH( _WETH_TOKEN, withdrawer, shares, amount0Min, amount1Min, recipient, deadline ); } else { amount0Min = amountMin; amount1Min = amountEthMin; (amountOut, amountEthOut) = _withdrawETH( _WETH_TOKEN, withdrawer, shares, amount0Min, amount1Min, recipient, deadline ); } } /** @notice withdraws the desired shares from the vault @param shares number of shares to withdraw @param amountEthMin amount of ETH desired by user @param amountMin Minimum amount of ERC20 token desired by user @param recipient address to recieve ETH and ERC20 withdrawals @param deadline blocktimestamp that this must execute by @return amountEthOut how much ETH was actually withdrawn @return amountOut how much ERC20 token was actually withdrawn */ function withdrawETH( uint256 shares, uint256 amountEthMin, uint256 amountMin, address payable recipient, uint256 deadline ) external override returns (uint256 amountEthOut, uint256 amountOut) { TOKEN _WETH_TOKEN = WETH_TOKEN; uint256 amount0Min; uint256 amount1Min; if (_WETH_TOKEN == TOKEN.ZERO) { amount0Min = amountEthMin; amount1Min = amountMin; (amountEthOut, amountOut) = _withdrawETH( _WETH_TOKEN, msg.sender, shares, amount0Min, amount1Min, recipient, deadline ); } else { amount0Min = amountMin; amount1Min = amountEthMin; (amountOut, amountEthOut) = _withdrawETH( _WETH_TOKEN, msg.sender, shares, amount0Min, amount1Min, recipient, deadline ); } } function _withdrawETH( TOKEN _WETH_TOKEN, address withdrawer, uint256 shares, uint256 amount0Min, uint256 amount1Min, address payable recipient, uint256 deadline ) internal notExpired(deadline) returns (uint256 amount0Out, uint256 amount1Out) { (amount0Out, amount1Out) = _withdrawStep( withdrawer, shares, amount0Min, amount1Min, recipient ); if (_WETH_TOKEN == TOKEN.ZERO) { if (0 < amount0Out) { weth9.withdraw(amount0Out); Address.sendValue(recipient, amount0Out); } if (0 < amount1Out) { TransferHelper.safeTransfer(address(token1), recipient, amount1Out); } } else { if (0 < amount1Out) { TransferHelper.safeTransfer(address(token0), recipient, amount0Out); } if (0 < amount1Out) { weth9.withdraw(amount1Out); Address.sendValue(recipient, amount1Out); } } } receive() external payable override { require(msg.sender == address(weth9)); } }
@inheritdoc IUniswapV3MintCallback
function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata ) external virtual override { require(msg.sender == address(activePool)); if (amount0Owed > 0) { TransferHelper.safeTransfer(address(token0), msg.sender, amount0Owed); } if (amount1Owed > 0)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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 640, 291, 91, 438, 58, 23, 49, 474, 2428, 12, 203, 565, 2254, 5034, 3844, 20, 3494, 329, 16, 203, 565, 2254, 5034, 3844, 21, 3494, 329, 16, 203, 565, 1731, 745, 892, 203, 225, 262, 3903, 5024, 3849, 288, 203, 565, 2583, 12, 3576, 18, 15330, 422, 1758, 12, 3535, 2864, 10019, 203, 565, 309, 261, 8949, 20, 3494, 329, 405, 374, 13, 288, 203, 1377, 12279, 2276, 18, 4626, 5912, 12, 2867, 12, 2316, 20, 3631, 1234, 18, 15330, 16, 3844, 20, 3494, 329, 1769, 203, 565, 289, 203, 565, 309, 261, 8949, 21, 3494, 329, 405, 374, 13, 288, 203, 1377, 12279, 2276, 18, 4626, 5912, 12, 2867, 12, 2316, 21, 3631, 1234, 18, 15330, 16, 3844, 21, 3494, 329, 1769, 203, 565, 289, 203, 225, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity 0.4.24; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } contract Owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } } /** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */ contract TokenVesting is Owned { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; address internal ownerShip; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _start the time (as Unix time) at which point vesting starts * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ constructor( address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, address _realOwner ) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; ownerShip = _realOwner; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); emit Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param 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(ownerShip, refund); emit Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (block.timestamp < cliff) { return 0; } else if (block.timestamp >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(start)).div(duration); } } } /** * @title TokenVault * @dev TokenVault is a token holder contract that will allow a * beneficiary to spend the tokens from some function of a specified ERC20 token */ contract TokenVault { using SafeERC20 for ERC20; // ERC20 token contract being held ERC20 public token; constructor(ERC20 _token) public { token = _token; } /** * @notice Allow the token itself to send tokens * using transferFrom(). */ function fillUpAllowance() public { uint256 amount = token.balanceOf(this); require(amount > 0); token.approve(token, amount); } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); } } contract WKA_Token is BurnableToken, Owned { string public constant name = "World Kungfu Association"; string public constant symbol = "WKA"; uint8 public constant decimals = 18; /// Maximum tokens to be allocated (10. billion WKA) uint256 public constant HARD_CAP = 10000000000 * 10**uint256(decimals); /// This address will be used to distribute the team, advisors and reserve tokens address public saleTokensAddress; /// This vault is used to keep the Founders, Advisors and Partners tokens TokenVault public reserveTokensVault; /// Date when the vesting for regular users starts uint64 public date15Dec2018 = 1544832000; uint64 public lock90Days = 7776000; uint64 public unlock100Days = 8640000; /// Store the vesting contract addresses for each sale contributor mapping(address => address) public vestingOf; constructor(address _saleTokensAddress) public payable { require(_saleTokensAddress != address(0)); saleTokensAddress = _saleTokensAddress; /// Maximum tokens to be sold - 47.5 % uint256 saleTokens = 4750000000; createTokens(saleTokens, saleTokensAddress); require(totalSupply_ <= HARD_CAP); } /// @dev Create a ReserveTokenVault function createReserveTokensVault() external onlyOwner { require(reserveTokensVault == address(0)); /// Reserve tokens - 52.5 % uint256 reserveTokens = 5250000000; reserveTokensVault = createTokenVault(reserveTokens); require(totalSupply_ <= HARD_CAP); } /// @dev Create a TokenVault and fill with the specified newly minted tokens function createTokenVault(uint256 tokens) internal onlyOwner returns (TokenVault) { TokenVault tokenVault = new TokenVault(ERC20(this)); createTokens(tokens, tokenVault); tokenVault.fillUpAllowance(); return tokenVault; } // @dev create specified number of tokens and transfer to destination function createTokens(uint256 _tokens, address _destination) internal onlyOwner { uint256 tokens = _tokens * 10**uint256(decimals); totalSupply_ = totalSupply_.add(tokens); balances[_destination] = balances[_destination].add(tokens); emit Transfer(0x0, _destination, tokens); require(totalSupply_ <= HARD_CAP); } /// @dev vest the sale contributor tokens function vestTokensDetail( address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, uint256 _tokensAmount) external onlyOwner { require(_beneficiary != address(0)); uint256 tokensAmount = _tokensAmount * 10**uint256(decimals); if(vestingOf[_beneficiary] == 0x0) { TokenVesting vesting = new TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable, owner); vestingOf[_beneficiary] = address(vesting); } require(this.transferFrom(reserveTokensVault, vestingOf[_beneficiary], tokensAmount)); } /// @dev vest the sale contributor tokens for 100 days, 1% gradual release with 3 month cliff function vestTokens(address _beneficiary, uint256 _tokensAmount) external onlyOwner { require(_beneficiary != address(0)); uint256 tokensAmount = _tokensAmount * 10**uint256(decimals); if(vestingOf[_beneficiary] == 0x0) { TokenVesting vesting = new TokenVesting(_beneficiary, date15Dec2018 + lock90Days, 0, unlock100Days, true, owner); vestingOf[_beneficiary] = address(vesting); } require(this.transferFrom(reserveTokensVault, vestingOf[_beneficiary], tokensAmount)); } /// @dev releases vested tokens for the caller's own address function releaseVestedTokens() external { releaseVestedTokensFor(msg.sender); } /// @dev releases vested tokens for the specified address. /// Can be called by anyone for any address. function releaseVestedTokensFor(address _owner) public { TokenVesting(vestingOf[_owner]).release(this); } /// @dev check the vested balance for an address function lockedBalanceOf(address _owner) public view returns (uint256) { return balances[vestingOf[_owner]]; } /// @dev check the locked but releaseable balance of an owner function releaseableBalanceOf(address _owner) public view returns (uint256) { if (vestingOf[_owner] == address(0) ) { return 0; } else { return TokenVesting(vestingOf[_owner]).releasableAmount(this); } } /// @dev revoke vested tokens for the specified address. /// Tokens already vested remain in the contract, the rest are returned to the owner. function revokeVestedTokensFor(address _owner) public onlyOwner { TokenVesting(vestingOf[_owner]).revoke(this); } }
@dev Create a ReserveTokenVault
function createReserveTokensVault() external onlyOwner { require(reserveTokensVault == address(0)); uint256 reserveTokens = 5250000000; reserveTokensVault = createTokenVault(reserveTokens); require(totalSupply_ <= HARD_CAP);
11,940,837
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 1788, 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527, 5157, 12003, 1435, 3903, 1338, 5541, 288, 203, 3639, 2583, 12, 455, 6527, 5157, 12003, 422, 1758, 12, 20, 10019, 203, 203, 3639, 2254, 5034, 20501, 5157, 273, 1381, 2947, 17877, 31, 203, 3639, 20501, 5157, 12003, 273, 752, 1345, 12003, 12, 455, 6527, 5157, 1769, 203, 203, 3639, 2583, 12, 4963, 3088, 1283, 67, 1648, 670, 8085, 67, 17296, 1769, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract CoralNFT is Ownable, ERC721URIStorage { // bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; using Counters for Counters.Counter; Counters.Counter private _tokenIds; address marketplaceAddress; mapping(bytes4 => bool) private _supportedInterfaces; struct RoyaltyInfo { address recipient; uint24 amount; } mapping(uint256 => RoyaltyInfo) internal _royalties; constructor(address _marketplaceAddress) ERC721("Coral NFT", "CORAL") { marketplaceAddress = _marketplaceAddress; } /** * Creates a new token */ function createToken(string memory tokenURI, address royaltyRecipient, uint256 royaltyValue) public returns (uint) { _tokenIds.increment(); uint256 tokenId = _tokenIds.current(); _mint(msg.sender, tokenId); _setTokenURI(tokenId, tokenURI); setApprovalForAll(marketplaceAddress, true); if (royaltyValue > 0) { _setTokenRoyalty(tokenId, royaltyRecipient, royaltyValue); } return tokenId; } /** * Sets token royalties recipient and percentage value (with two decimals) for a certain token */ function _setTokenRoyalty(uint256 tokenId, address recipient, uint256 value) internal { require(value <= 5000, 'CoralNFT: Royalties value cannot be higher than 5000.'); _royalties[tokenId] = RoyaltyInfo(recipient, uint24(value)); } /** * Returns royalties recipient and amount for a certain token and sale value, * following EIP-2981 guidelines (https://eips.ethereum.org/EIPS/eip-2981). */ function royaltyInfo(uint256 tokenId, uint256 saleValue) external view returns (address receiver, uint256 royaltyAmount) { RoyaltyInfo memory royalty = _royalties[tokenId]; return (royalty.recipient, (saleValue * royalty.amount) / 10000); } /** * Overrides supportsInterface method to include EIP-2981 support for interface. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId) || interfaceId == _INTERFACE_ID_ERC2981; } }
* Creates a new token/
function createToken(string memory tokenURI, address royaltyRecipient, uint256 royaltyValue) public returns (uint) { _tokenIds.increment(); uint256 tokenId = _tokenIds.current(); _mint(msg.sender, tokenId); _setTokenURI(tokenId, tokenURI); setApprovalForAll(marketplaceAddress, true); if (royaltyValue > 0) { _setTokenRoyalty(tokenId, royaltyRecipient, royaltyValue); } return tokenId; }
12,899,554
[ 1, 4625, 348, 7953, 560, 30, 380, 10210, 279, 394, 1147, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 752, 1345, 12, 1080, 3778, 1147, 3098, 16, 1758, 721, 93, 15006, 18241, 16, 2254, 5034, 721, 93, 15006, 620, 13, 1071, 1135, 261, 11890, 13, 288, 203, 202, 202, 67, 2316, 2673, 18, 15016, 5621, 203, 202, 202, 11890, 5034, 1147, 548, 273, 389, 2316, 2673, 18, 2972, 5621, 203, 203, 202, 202, 67, 81, 474, 12, 3576, 18, 15330, 16, 1147, 548, 1769, 203, 202, 202, 67, 542, 1345, 3098, 12, 2316, 548, 16, 1147, 3098, 1769, 203, 202, 202, 542, 23461, 1290, 1595, 12, 3355, 24577, 1887, 16, 638, 1769, 203, 203, 202, 202, 430, 261, 3800, 15006, 620, 405, 374, 13, 288, 203, 5411, 389, 542, 1345, 54, 13372, 15006, 12, 2316, 548, 16, 721, 93, 15006, 18241, 16, 721, 93, 15006, 620, 1769, 203, 3639, 289, 203, 203, 202, 202, 2463, 1147, 548, 31, 203, 202, 97, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x6400B5522f8D448C0803e6245436DD1c81dF09ce/sources/CvnToken.sol
* @dev Decrease the amount of tokens that an owner allowed to a spender. approve should be called when allowed_[_spender] == 0. To decrement allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol Emits an Approval event. @param spender The address which will spend the funds. @param subtractedValue The amount of tokens to decrease the allowance by./
function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; }
9,250,078
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 31073, 448, 326, 3844, 434, 2430, 716, 392, 3410, 2935, 358, 279, 17571, 264, 18, 6617, 537, 1410, 506, 2566, 1347, 2935, 67, 63, 67, 87, 1302, 264, 65, 422, 374, 18, 2974, 15267, 2935, 460, 353, 7844, 358, 999, 333, 445, 358, 4543, 576, 4097, 261, 464, 2529, 3180, 326, 1122, 2492, 353, 1131, 329, 13, 6338, 9041, 355, 483, 18485, 3155, 18, 18281, 7377, 1282, 392, 1716, 685, 1125, 871, 18, 632, 891, 17571, 264, 1021, 1758, 1492, 903, 17571, 326, 284, 19156, 18, 632, 891, 10418, 329, 620, 1021, 3844, 434, 2430, 358, 20467, 326, 1699, 1359, 635, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 20467, 7009, 1359, 12, 2867, 17571, 264, 16, 2254, 5034, 10418, 329, 620, 13, 1071, 1347, 1248, 28590, 1135, 261, 6430, 13, 288, 203, 3639, 2583, 12, 87, 1302, 264, 480, 1758, 12, 20, 10019, 203, 203, 3639, 389, 8151, 63, 3576, 18, 15330, 6362, 87, 1302, 264, 65, 273, 389, 8151, 63, 3576, 18, 15330, 6362, 87, 1302, 264, 8009, 1717, 12, 1717, 1575, 329, 620, 1769, 203, 3639, 3626, 1716, 685, 1125, 12, 3576, 18, 15330, 16, 17571, 264, 16, 389, 8151, 63, 3576, 18, 15330, 6362, 87, 1302, 264, 19226, 203, 3639, 327, 638, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2022-01-19 */ // Sources flattened with hardhat v2.8.2 https://hardhat.org // File contracts/solidity/interface/INFTXEligibility.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface INFTXEligibility { // Read functions. function name() external pure returns (string memory); function finalized() external view returns (bool); function targetAsset() external pure returns (address); function checkAllEligible(uint256[] calldata tokenIds) external view returns (bool); function checkEligible(uint256[] calldata tokenIds) external view returns (bool[] memory); function checkAllIneligible(uint256[] calldata tokenIds) external view returns (bool); function checkIsEligible(uint256 tokenId) external view returns (bool); // Write functions. function __NFTXEligibility_init_bytes(bytes calldata configData) external; function beforeMintHook(uint256[] calldata tokenIds) external; function afterMintHook(uint256[] calldata tokenIds) external; function beforeRedeemHook(uint256[] calldata tokenIds) external; function afterRedeemHook(uint256[] calldata tokenIds) external; } // File contracts/solidity/token/IERC20Upgradeable.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/solidity/proxy/IBeacon.sol pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function childImplementation() external view returns (address); function upgradeChildTo(address newImplementation) external; } // File contracts/solidity/interface/INFTXVaultFactory.sol pragma solidity ^0.8.0; interface INFTXVaultFactory is IBeacon { // Read functions. function numVaults() external view returns (uint256); function zapContract() external view returns (address); function feeDistributor() external view returns (address); function eligibilityManager() external view returns (address); function vault(uint256 vaultId) external view returns (address); function allVaults() external view returns (address[] memory); function vaultsForAsset(address asset) external view returns (address[] memory); function isLocked(uint256 id) external view returns (bool); function excludedFromFees(address addr) external view returns (bool); function factoryMintFee() external view returns (uint64); function factoryRandomRedeemFee() external view returns (uint64); function factoryTargetRedeemFee() external view returns (uint64); function factoryRandomSwapFee() external view returns (uint64); function factoryTargetSwapFee() external view returns (uint64); function vaultFees(uint256 vaultId) external view returns (uint256, uint256, uint256, uint256, uint256); event NewFeeDistributor(address oldDistributor, address newDistributor); event NewZapContract(address oldZap, address newZap); event FeeExclusion(address feeExcluded, bool excluded); event NewEligibilityManager(address oldEligManager, address newEligManager); event NewVault(uint256 indexed vaultId, address vaultAddress, address assetAddress); event UpdateVaultFees(uint256 vaultId, uint256 mintFee, uint256 randomRedeemFee, uint256 targetRedeemFee, uint256 randomSwapFee, uint256 targetSwapFee); event DisableVaultFees(uint256 vaultId); event UpdateFactoryFees(uint256 mintFee, uint256 randomRedeemFee, uint256 targetRedeemFee, uint256 randomSwapFee, uint256 targetSwapFee); // Write functions. function __NFTXVaultFactory_init(address _vaultImpl, address _feeDistributor) external; function createVault( string calldata name, string calldata symbol, address _assetAddress, bool is1155, bool allowAllItems ) external returns (uint256); function setFeeDistributor(address _feeDistributor) external; function setEligibilityManager(address _eligibilityManager) external; function setZapContract(address _zapContract) external; function setFeeExclusion(address _excludedAddr, bool excluded) external; function setFactoryFees( uint256 mintFee, uint256 randomRedeemFee, uint256 targetRedeemFee, uint256 randomSwapFee, uint256 targetSwapFee ) external; function setVaultFees( uint256 vaultId, uint256 mintFee, uint256 randomRedeemFee, uint256 targetRedeemFee, uint256 randomSwapFee, uint256 targetSwapFee ) external; function disableVaultFees(uint256 vaultId) external; } // File contracts/solidity/interface/INFTXVault.sol pragma solidity ^0.8.0; interface INFTXVault is IERC20Upgradeable { function manager() external view returns (address); function assetAddress() external view returns (address); function vaultFactory() external view returns (INFTXVaultFactory); function eligibilityStorage() external view returns (INFTXEligibility); function is1155() external view returns (bool); function allowAllItems() external view returns (bool); function enableMint() external view returns (bool); function enableRandomRedeem() external view returns (bool); function enableTargetRedeem() external view returns (bool); function enableRandomSwap() external view returns (bool); function enableTargetSwap() external view returns (bool); function vaultId() external view returns (uint256); function nftIdAt(uint256 holdingsIndex) external view returns (uint256); function allHoldings() external view returns (uint256[] memory); function totalHoldings() external view returns (uint256); function mintFee() external view returns (uint256); function randomRedeemFee() external view returns (uint256); function targetRedeemFee() external view returns (uint256); function randomSwapFee() external view returns (uint256); function targetSwapFee() external view returns (uint256); function vaultFees() external view returns (uint256, uint256, uint256, uint256, uint256); event VaultInit( uint256 indexed vaultId, address assetAddress, bool is1155, bool allowAllItems ); event ManagerSet(address manager); event EligibilityDeployed(uint256 moduleIndex, address eligibilityAddr); // event CustomEligibilityDeployed(address eligibilityAddr); event EnableMintUpdated(bool enabled); event EnableRandomRedeemUpdated(bool enabled); event EnableTargetRedeemUpdated(bool enabled); event EnableRandomSwapUpdated(bool enabled); event EnableTargetSwapUpdated(bool enabled); event Minted(uint256[] nftIds, uint256[] amounts, address to); event Redeemed(uint256[] nftIds, uint256[] specificIds, address to); event Swapped( uint256[] nftIds, uint256[] amounts, uint256[] specificIds, uint256[] redeemedIds, address to ); function __NFTXVault_init( string calldata _name, string calldata _symbol, address _assetAddress, bool _is1155, bool _allowAllItems ) external; function finalizeVault() external; function setVaultMetadata( string memory name_, string memory symbol_ ) external; function setVaultFeatures( bool _enableMint, bool _enableRandomRedeem, bool _enableTargetRedeem, bool _enableRandomSwap, bool _enableTargetSwap ) external; function setFees( uint256 _mintFee, uint256 _randomRedeemFee, uint256 _targetRedeemFee, uint256 _randomSwapFee, uint256 _targetSwapFee ) external; function disableVaultFees() external; // This function allows for an easy setup of any eligibility module contract from the EligibilityManager. // It takes in ABI encoded parameters for the desired module. This is to make sure they can all follow // a similar interface. function deployEligibilityStorage( uint256 moduleIndex, bytes calldata initData ) external returns (address); // The manager has control over options like fees and features function setManager(address _manager) external; function mint( uint256[] calldata tokenIds, uint256[] calldata amounts /* ignored for ERC721 vaults */ ) external returns (uint256); function mintTo( uint256[] calldata tokenIds, uint256[] calldata amounts, /* ignored for ERC721 vaults */ address to ) external returns (uint256); function redeem(uint256 amount, uint256[] calldata specificIds) external returns (uint256[] calldata); function redeemTo( uint256 amount, uint256[] calldata specificIds, address to ) external returns (uint256[] calldata); function swap( uint256[] calldata tokenIds, uint256[] calldata amounts, /* ignored for ERC721 vaults */ uint256[] calldata specificIds ) external returns (uint256[] calldata); function swapTo( uint256[] calldata tokenIds, uint256[] calldata amounts, /* ignored for ERC721 vaults */ uint256[] calldata specificIds, address to ) external returns (uint256[] calldata); function allValidNFTs(uint256[] calldata tokenIds) external view returns (bool); } // File contracts/solidity/interface/INFTXFeeDistributor.sol pragma solidity ^0.8.0; interface INFTXFeeDistributor { struct FeeReceiver { uint256 allocPoint; address receiver; bool isContract; } function nftxVaultFactory() external returns (address); function lpStaking() external returns (address); function treasury() external returns (address); function defaultTreasuryAlloc() external returns (uint256); function defaultLPAlloc() external returns (uint256); function allocTotal(uint256 vaultId) external returns (uint256); function specificTreasuryAlloc(uint256 vaultId) external returns (uint256); // Write functions. function __FeeDistributor__init__(address _lpStaking, address _treasury) external; function rescueTokens(address token) external; function distribute(uint256 vaultId) external; function addReceiver(uint256 _vaultId, uint256 _allocPoint, address _receiver, bool _isContract) external; function initializeVaultReceivers(uint256 _vaultId) external; function changeMultipleReceiverAlloc( uint256[] memory _vaultIds, uint256[] memory _receiverIdxs, uint256[] memory allocPoints ) external; function changeMultipleReceiverAddress( uint256[] memory _vaultIds, uint256[] memory _receiverIdxs, address[] memory addresses, bool[] memory isContracts ) external; function changeReceiverAlloc(uint256 _vaultId, uint256 _idx, uint256 _allocPoint) external; function changeReceiverAddress(uint256 _vaultId, uint256 _idx, address _address, bool _isContract) external; function removeReceiver(uint256 _vaultId, uint256 _receiverIdx) external; // Configuration functions. function setTreasuryAddress(address _treasury) external; function setDefaultTreasuryAlloc(uint256 _allocPoint) external; function setSpecificTreasuryAlloc(uint256 _vaultId, uint256 _allocPoint) external; function setLPStakingAddress(address _lpStaking) external; function setNFTXVaultFactory(address _factory) external; function setDefaultLPAlloc(uint256 _allocPoint) external; } // File contracts/solidity/interface/INFTXLPStaking.sol pragma solidity ^0.8.0; interface INFTXLPStaking { function nftxVaultFactory() external view returns (address); function rewardDistTokenImpl() external view returns (address); function stakingTokenProvider() external view returns (address); function vaultToken(address _stakingToken) external view returns (address); function stakingToken(address _vaultToken) external view returns (address); function rewardDistributionToken(uint256 vaultId) external view returns (address); function newRewardDistributionToken(uint256 vaultId) external view returns (address); function oldRewardDistributionToken(uint256 vaultId) external view returns (address); function unusedRewardDistributionToken(uint256 vaultId) external view returns (address); function rewardDistributionTokenAddr(address stakedToken, address rewardToken) external view returns (address); // Write functions. function __NFTXLPStaking__init(address _stakingTokenProvider) external; function setNFTXVaultFactory(address newFactory) external; function setStakingTokenProvider(address newProvider) external; function addPoolForVault(uint256 vaultId) external; function updatePoolForVault(uint256 vaultId) external; function updatePoolForVaults(uint256[] calldata vaultId) external; function receiveRewards(uint256 vaultId, uint256 amount) external returns (bool); function deposit(uint256 vaultId, uint256 amount) external; function timelockDepositFor(uint256 vaultId, address account, uint256 amount, uint256 timelockLength) external; function exit(uint256 vaultId, uint256 amount) external; function rescue(uint256 vaultId) external; function withdraw(uint256 vaultId, uint256 amount) external; function claimRewards(uint256 vaultId) external; } // File contracts/solidity/interface/IUniswapV2Router01.sol pragma solidity ^0.8.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } // File contracts/solidity/interface/IERC165Upgradeable.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File contracts/solidity/token/IERC1155Upgradeable.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; } // File contracts/solidity/token/IERC721ReceiverUpgradeable.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File contracts/solidity/token/ERC721HolderUpgradeable.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is IERC721ReceiverUpgradeable { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } // File contracts/solidity/token/IERC1155ReceiverUpgradeable.sol pragma solidity ^0.8.0; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); } // File contracts/solidity/util/ERC165Upgradeable.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is IERC165Upgradeable { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } } // File contracts/solidity/token/ERC1155ReceiverUpgradeable.sol pragma solidity ^0.8.0; /** * @dev _Available since v3.1._ */ abstract contract ERC1155ReceiverUpgradeable is ERC165Upgradeable, IERC1155ReceiverUpgradeable { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId); } } // File contracts/solidity/token/ERC1155HolderUpgradeable.sol pragma solidity ^0.8.0; /** * @dev _Available since v3.1._ */ abstract contract ERC1155HolderUpgradeable is ERC1155ReceiverUpgradeable { function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } } // File contracts/solidity/util/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File contracts/solidity/util/SafeERC20Upgradeable.sol pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using Address for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File contracts/solidity/NFTXMarketplaceZap.sol pragma solidity ^0.8.0; // Authors: @0xKiwi_. interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; function balanceOf(address to) external view returns (uint256); } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(msg.sender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } contract NFTXMarketplaceZap is Ownable, ReentrancyGuard, ERC721HolderUpgradeable, ERC1155HolderUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; IWETH public immutable WETH; INFTXLPStaking public immutable lpStaking; INFTXVaultFactory public immutable nftxFactory; IUniswapV2Router01 public immutable sushiRouter; uint256 constant BASE = 1e18; event Buy(uint256 count, uint256 ethSpent, address to); event Sell(uint256 count, uint256 ethReceived, address to); event Swap(uint256 count, uint256 ethSpent, address to); constructor(address _nftxFactory, address _sushiRouter) Ownable() ReentrancyGuard() { nftxFactory = INFTXVaultFactory(_nftxFactory); lpStaking = INFTXLPStaking(INFTXFeeDistributor(INFTXVaultFactory(_nftxFactory).feeDistributor()).lpStaking()); sushiRouter = IUniswapV2Router01(_sushiRouter); WETH = IWETH(IUniswapV2Router01(_sushiRouter).WETH()); IERC20Upgradeable(address(IUniswapV2Router01(_sushiRouter).WETH())).safeApprove(_sushiRouter, type(uint256).max); } function mintAndSell721( uint256 vaultId, uint256[] calldata ids, uint256 minEthOut, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(ids.length != 0); (address vault, uint256 vaultBalance) = _mint721(vaultId, ids); uint256[] memory amounts = _sellVaultTokenETH(vault, minEthOut, vaultBalance, path, to); emit Sell(ids.length, amounts[amounts.length-1], to); } function mintAndSell721WETH( uint256 vaultId, uint256[] calldata ids, uint256 minWethOut, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(ids.length != 0); (address vault, uint256 vaultBalance) = _mint721(vaultId, ids); uint256[] memory amounts = _sellVaultTokenWETH(vault, minWethOut, vaultBalance, path, to); emit Sell(ids.length, amounts[amounts.length-1], to); } function buyAndSwap721( uint256 vaultId, uint256[] calldata idsIn, uint256[] calldata specificIds, address[] calldata path, address to ) external payable nonReentrant { require(to != address(0) && to != address(this)); require(idsIn.length != 0); WETH.deposit{value: msg.value}(); INFTXVault vault = INFTXVault(nftxFactory.vault(vaultId)); uint256 redeemFees = (vault.targetSwapFee() * specificIds.length) + ( vault.randomSwapFee() * (idsIn.length - specificIds.length) ); uint256[] memory amounts = _buyVaultToken(redeemFees, msg.value, path); _swap721(vaultId, idsIn, specificIds, to); emit Swap(idsIn.length, amounts[0], to); // Return extras. uint256 remaining = WETH.balanceOf(address(this)); WETH.withdraw(remaining); (bool success, ) = payable(to).call{value: remaining}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function buyAndSwap721WETH( uint256 vaultId, uint256[] calldata idsIn, uint256[] calldata specificIds, uint256 maxWethIn, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(idsIn.length != 0); IERC20Upgradeable(address(WETH)).safeTransferFrom(msg.sender, address(this), maxWethIn); INFTXVault vault = INFTXVault(nftxFactory.vault(vaultId)); uint256 redeemFees = (vault.targetSwapFee() * specificIds.length) + ( vault.randomSwapFee() * (idsIn.length - specificIds.length) ); uint256[] memory amounts = _buyVaultToken(redeemFees, maxWethIn, path); _swap721(vaultId, idsIn, specificIds, to); emit Swap(idsIn.length, amounts[0], to); // Return extras. uint256 remaining = WETH.balanceOf(address(this)); if (remaining != 0) { WETH.transfer(to, remaining); } } function buyAndSwap1155( uint256 vaultId, uint256[] calldata idsIn, uint256[] calldata amounts, uint256[] calldata specificIds, address[] calldata path, address to ) external payable nonReentrant { require(to != address(0) && to != address(this)); uint256 length = idsIn.length; require(length != 0); WETH.deposit{value: msg.value}(); uint256 count; for (uint256 i; i < length; ++i) { uint256 amount = amounts[i]; require(amount > 0, "Transferring < 1"); count += amount; } INFTXVault vault = INFTXVault(nftxFactory.vault(vaultId)); uint256 redeemFees = (vault.targetSwapFee() * specificIds.length) + ( vault.randomSwapFee() * (count - specificIds.length) ); uint256[] memory swapAmounts = _buyVaultToken(redeemFees, msg.value, path); _swap1155(vaultId, idsIn, amounts, specificIds, to); emit Swap(count, swapAmounts[0], to); // Return extras. uint256 remaining = WETH.balanceOf(address(this)); WETH.withdraw(remaining); (bool success, ) = payable(to).call{value: remaining}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function buyAndSwap1155WETH( uint256 vaultId, uint256[] calldata idsIn, uint256[] calldata amounts, uint256[] calldata specificIds, uint256 maxWethIn, address[] calldata path, address to ) external payable nonReentrant { require(to != address(0) && to != address(this)); require(idsIn.length != 0); uint256 count; for (uint256 i = 0; i < idsIn.length; i++) { uint256 amount = amounts[i]; require(amount > 0, "Transferring < 1"); count += amount; } INFTXVault vault = INFTXVault(nftxFactory.vault(vaultId)); uint256 redeemFees = (vault.targetSwapFee() * specificIds.length) + ( vault.randomSwapFee() * (count - specificIds.length) ); IERC20Upgradeable(address(WETH)).safeTransferFrom(msg.sender, address(this), maxWethIn); uint256[] memory swapAmounts = _buyVaultToken(redeemFees, maxWethIn, path); _swap1155(vaultId, idsIn, amounts, specificIds, to); emit Swap(count, swapAmounts[0], to); // Return extras. uint256 remaining = WETH.balanceOf(address(this)); WETH.transfer(to, remaining); } function buyAndRedeem( uint256 vaultId, uint256 amount, uint256[] calldata specificIds, address[] calldata path, address to ) external payable nonReentrant { require(to != address(0) && to != address(this)); require(amount != 0); WETH.deposit{value: msg.value}(); (, uint256 randomRedeemFee, uint256 targetRedeemFee, ,) = nftxFactory.vaultFees(vaultId); uint256 totalFee = (targetRedeemFee * specificIds.length) + ( randomRedeemFee * (amount - specificIds.length) ); uint256[] memory amounts = _buyVaultToken((amount*BASE)+totalFee, msg.value, path); _redeem(vaultId, amount, specificIds, to); emit Buy(amount, amounts[0], to); uint256 remaining = WETH.balanceOf(address(this)); if (remaining != 0) { WETH.withdraw(remaining); (bool success, ) = payable(to).call{value: remaining}(""); require(success, "Address: unable to send value, recipient may have reverted"); } } function buyAndRedeemWETH( uint256 vaultId, uint256 amount, uint256[] calldata specificIds, uint256 maxWethIn, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(amount != 0); uint256 totalFee; { (, uint256 randomRedeemFee, uint256 targetRedeemFee, ,) = nftxFactory.vaultFees(vaultId); totalFee = (targetRedeemFee * specificIds.length) + ( randomRedeemFee * (amount - specificIds.length) ); } IERC20Upgradeable(address(WETH)).safeTransferFrom(msg.sender, address(this), maxWethIn); uint256[] memory amounts = _buyVaultToken((amount*BASE) + totalFee, maxWethIn, path); _redeem(vaultId, amount, specificIds, to); emit Buy(amount, amounts[0], to); uint256 remaining = WETH.balanceOf(address(this)); if (remaining != 0) { WETH.transfer(to, remaining); } } function mintAndSell1155( uint256 vaultId, uint256[] calldata ids, uint256[] calldata amounts, uint256 minWethOut, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(ids.length != 0); (address vault, uint256 vaultTokenBalance) = _mint1155(vaultId, ids, amounts); uint256[] memory uniAmounts = _sellVaultTokenETH(vault, minWethOut, vaultTokenBalance, path, to); uint256 count; uint256 length = ids.length; for (uint256 i; i < length; ++i) { count += amounts[i]; } emit Sell(count, uniAmounts[uniAmounts.length-1], to); } function mintAndSell1155WETH( uint256 vaultId, uint256[] calldata ids, uint256[] calldata amounts, uint256 minWethOut, address[] calldata path, address to ) external nonReentrant { require(to != address(0) && to != address(this)); require(ids.length != 0); (address vault, uint256 vaultTokenBalance) = _mint1155(vaultId, ids, amounts); _sellVaultTokenWETH(vault, minWethOut, vaultTokenBalance, path, to); uint256 count; uint256 length = ids.length; for (uint256 i; i < length; ++i) { count += amounts[i]; } emit Sell(count, amounts[amounts.length-1], to); } function _mint721( uint256 vaultId, uint256[] memory ids ) internal returns (address, uint256) { address vault = nftxFactory.vault(vaultId); // Transfer tokens to zap and mint to NFTX. address assetAddress = INFTXVault(vault).assetAddress(); uint256 length = ids.length; for (uint256 i; i < length; ++i) { transferFromERC721(assetAddress, ids[i], vault); approveERC721(assetAddress, vault, ids[i]); } uint256[] memory emptyIds; INFTXVault(vault).mint(ids, emptyIds); uint256 count = ids.length; uint256 balance = (count * BASE) - (count * INFTXVault(vault).mintFee()); return (vault, balance); } function _swap721( uint256 vaultId, uint256[] memory idsIn, uint256[] memory idsOut, address to ) internal returns (address) { address vault = nftxFactory.vault(vaultId); // Transfer tokens to zap and mint to NFTX. address assetAddress = INFTXVault(vault).assetAddress(); uint256 length = idsIn.length; for (uint256 i; i < length; ++i) { transferFromERC721(assetAddress, idsIn[i], vault); approveERC721(assetAddress, vault, idsIn[i]); } uint256[] memory emptyIds; INFTXVault(vault).swapTo(idsIn, emptyIds, idsOut, to); return (vault); } function _swap1155( uint256 vaultId, uint256[] memory idsIn, uint256[] memory amounts, uint256[] memory idsOut, address to ) internal returns (address) { address vault = nftxFactory.vault(vaultId); // Transfer tokens to zap and mint to NFTX. address assetAddress = INFTXVault(vault).assetAddress(); IERC1155Upgradeable(assetAddress).safeBatchTransferFrom(msg.sender, address(this), idsIn, amounts, ""); IERC1155Upgradeable(assetAddress).setApprovalForAll(vault, true); INFTXVault(vault).swapTo(idsIn, amounts, idsOut, to); return (vault); } function _redeem( uint256 vaultId, uint256 amount, uint256[] memory specificIds, address to ) internal { address vault = nftxFactory.vault(vaultId); INFTXVault(vault).redeemTo(amount, specificIds, to); } function _mint1155( uint256 vaultId, uint256[] memory ids, uint256[] memory amounts ) internal returns (address, uint256) { address vault = nftxFactory.vault(vaultId); require(vault != address(0), "NFTXZap: Vault does not exist"); // Transfer tokens to zap and mint to NFTX. address assetAddress = INFTXVault(vault).assetAddress(); IERC1155Upgradeable(assetAddress).safeBatchTransferFrom(msg.sender, address(this), ids, amounts, ""); IERC1155Upgradeable(assetAddress).setApprovalForAll(vault, true); uint256 count = INFTXVault(vault).mint(ids, amounts); uint256 balance = (count * BASE) - (INFTXVault(vault).mintFee()*count); return (vault, balance); } function _buyVaultToken( uint256 minTokenOut, uint256 maxWethIn, address[] calldata path ) internal returns (uint256[] memory) { uint256[] memory amounts = sushiRouter.swapTokensForExactTokens( minTokenOut, maxWethIn, path, address(this), block.timestamp ); return amounts; } function _sellVaultTokenWETH( address vault, uint256 minWethOut, uint256 maxTokenIn, address[] calldata path, address to ) internal returns (uint256[] memory) { IERC20Upgradeable(vault).safeApprove(address(sushiRouter), maxTokenIn); uint256[] memory amounts = sushiRouter.swapExactTokensForTokens( maxTokenIn, minWethOut, path, to, block.timestamp ); return amounts; } function _sellVaultTokenETH( address vault, uint256 minEthOut, uint256 maxTokenIn, address[] calldata path, address to ) internal returns (uint256[] memory) { IERC20Upgradeable(vault).safeApprove(address(sushiRouter), maxTokenIn); uint256[] memory amounts = sushiRouter.swapExactTokensForETH( maxTokenIn, minEthOut, path, to, block.timestamp ); return amounts; } function transferFromERC721(address assetAddr, uint256 tokenId, address to) internal virtual { address kitties = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; address punks = 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB; bytes memory data; if (assetAddr == kitties) { // Cryptokitties. data = abi.encodeWithSignature("transferFrom(address,address,uint256)", msg.sender, to, tokenId); } else if (assetAddr == punks) { // CryptoPunks. // Fix here for frontrun attack. Added in v1.0.2. bytes memory punkIndexToAddress = abi.encodeWithSignature("punkIndexToAddress(uint256)", tokenId); (bool checkSuccess, bytes memory result) = address(assetAddr).staticcall(punkIndexToAddress); (address nftOwner) = abi.decode(result, (address)); require(checkSuccess && nftOwner == msg.sender, "Not the NFT owner"); data = abi.encodeWithSignature("buyPunk(uint256)", tokenId); } else { // Default. // We push to the vault to avoid an unneeded transfer. data = abi.encodeWithSignature("safeTransferFrom(address,address,uint256)", msg.sender, to, tokenId); } (bool success, bytes memory resultData) = address(assetAddr).call(data); require(success, string(resultData)); } function approveERC721(address assetAddr, address to, uint256 tokenId) internal virtual { address kitties = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; address punks = 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB; bytes memory data; if (assetAddr == kitties) { // // Cryptokitties. // data = abi.encodeWithSignature("approve(address,uint256)", to, tokenId); // No longer needed to approve with pushing. return; } else if (assetAddr == punks) { // CryptoPunks. data = abi.encodeWithSignature("offerPunkForSaleToAddress(uint256,uint256,address)", tokenId, 0, to); } else { // No longer needed to approve with pushing. return; } (bool success, bytes memory resultData) = address(assetAddr).call(data); require(success, string(resultData)); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address tokenA, address tokenB) internal view returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint160(uint256(keccak256(abi.encodePacked( hex'ff', sushiRouter.factory(), keccak256(abi.encodePacked(token0, token1)), hex'e18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303' // init code hash ))))); } // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } function rescue(address token) external onlyOwner { if (token == address(0)) { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success, "Address: unable to send value, recipient may have reverted"); } else { IERC20Upgradeable(token).safeTransfer(msg.sender, IERC20Upgradeable(token).balanceOf(address(this))); } } receive() external payable { require(msg.sender == address(WETH), "Only WETH"); } }
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`./ File contracts/solidity/token/ERC721HolderUpgradeable.sol* @dev Implementation of the {IERC721Receiver} interface. Accepts all token transfers. Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}./
contract ERC721HolderUpgradeable is IERC721ReceiverUpgradeable { function onERC721Received( address, address, uint256, bytes memory function nftxVaultFactory() external returns (address); function lpStaking() external returns (address); function treasury() external returns (address); function defaultTreasuryAlloc() external returns (uint256); function defaultLPAlloc() external returns (uint256); function allocTotal(uint256 vaultId) external returns (uint256); function specificTreasuryAlloc(uint256 vaultId) external returns (uint256); function __FeeDistributor__init__(address _lpStaking, address _treasury) external; function rescueTokens(address token) external; function distribute(uint256 vaultId) external; function addReceiver(uint256 _vaultId, uint256 _allocPoint, address _receiver, bool _isContract) external; function initializeVaultReceivers(uint256 _vaultId) external; function changeMultipleReceiverAlloc( uint256[] memory _vaultIds, uint256[] memory _receiverIdxs, uint256[] memory allocPoints ) external; function changeMultipleReceiverAddress( uint256[] memory _vaultIds, uint256[] memory _receiverIdxs, address[] memory addresses, bool[] memory isContracts ) external; function changeReceiverAlloc(uint256 _vaultId, uint256 _idx, uint256 _allocPoint) external; function changeReceiverAddress(uint256 _vaultId, uint256 _idx, address _address, bool _isContract) external; function removeReceiver(uint256 _vaultId, uint256 _receiverIdx) external; function setTreasuryAddress(address _treasury) external; function setDefaultTreasuryAlloc(uint256 _allocPoint) external; function setSpecificTreasuryAlloc(uint256 _vaultId, uint256 _allocPoint) external; function setLPStakingAddress(address _lpStaking) external; function setNFTXVaultFactory(address _factory) external; function setDefaultLPAlloc(uint256 _allocPoint) external; } pragma solidity ^0.8.0; } pragma solidity ^0.8.0; } pragma solidity ^0.8.0; } pragma solidity ^0.8.0; } pragma solidity ^0.8.0; } pragma solidity ^0.8.0; ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
7,898,765
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 3497, 4009, 502, 392, 288, 45, 654, 39, 27, 5340, 97, 1375, 2316, 548, 68, 1147, 353, 906, 4193, 358, 333, 6835, 3970, 288, 45, 654, 39, 27, 5340, 17, 4626, 5912, 1265, 97, 635, 1375, 9497, 68, 628, 1375, 2080, 9191, 333, 445, 353, 2566, 18, 2597, 1297, 327, 2097, 348, 7953, 560, 3451, 358, 6932, 326, 1147, 7412, 18, 971, 1281, 1308, 460, 353, 2106, 578, 326, 1560, 353, 486, 8249, 635, 326, 8027, 16, 326, 7412, 903, 506, 15226, 329, 18, 1021, 3451, 848, 506, 12700, 316, 348, 7953, 560, 598, 1375, 45, 654, 39, 27, 5340, 18, 265, 654, 39, 27, 5340, 8872, 18, 9663, 8338, 19, 1387, 20092, 19, 30205, 560, 19, 2316, 19, 654, 39, 27, 5340, 6064, 10784, 429, 18, 18281, 14, 632, 5206, 25379, 434, 326, 288, 45, 654, 39, 27, 5340, 12952, 97, 1560, 18, 27158, 777, 1147, 29375, 18, 4344, 3071, 326, 6835, 353, 7752, 358, 999, 2097, 1147, 598, 288, 45, 654, 39, 27, 5340, 17, 4626, 5912, 1265, 5779, 288, 45, 654, 39, 27, 5340, 17, 12908, 537, 97, 578, 288, 45, 654, 39, 27, 5340, 17, 542, 23461, 1290, 1595, 5496, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 4232, 39, 27, 5340, 6064, 10784, 429, 353, 467, 654, 39, 27, 5340, 12952, 10784, 429, 288, 203, 565, 445, 603, 654, 39, 27, 5340, 8872, 12, 203, 3639, 1758, 16, 203, 3639, 1758, 16, 203, 3639, 2254, 5034, 16, 203, 3639, 1731, 3778, 203, 225, 445, 13958, 978, 12003, 1733, 1435, 3903, 1135, 261, 2867, 1769, 203, 225, 445, 12423, 510, 6159, 1435, 3903, 1135, 261, 2867, 1769, 203, 225, 445, 9787, 345, 22498, 1435, 3903, 1135, 261, 2867, 1769, 203, 225, 445, 805, 56, 266, 345, 22498, 8763, 1435, 3903, 1135, 261, 11890, 5034, 1769, 203, 225, 445, 805, 14461, 8763, 1435, 3903, 1135, 261, 11890, 5034, 1769, 203, 225, 445, 4767, 5269, 12, 11890, 5034, 9229, 548, 13, 3903, 1135, 261, 11890, 5034, 1769, 203, 225, 445, 2923, 56, 266, 345, 22498, 8763, 12, 11890, 5034, 9229, 548, 13, 3903, 1135, 261, 11890, 5034, 1769, 203, 203, 225, 445, 1001, 14667, 1669, 19293, 972, 2738, 972, 12, 2867, 389, 9953, 510, 6159, 16, 1758, 389, 27427, 345, 22498, 13, 3903, 31, 203, 225, 445, 8223, 5157, 12, 2867, 1147, 13, 3903, 31, 203, 225, 445, 25722, 12, 11890, 5034, 9229, 548, 13, 3903, 31, 203, 225, 445, 527, 12952, 12, 11890, 5034, 389, 26983, 548, 16, 2254, 5034, 389, 9853, 2148, 16, 1758, 389, 24454, 16, 1426, 389, 291, 8924, 13, 3903, 31, 203, 225, 445, 4046, 12003, 4779, 6760, 12, 11890, 5034, 389, 26983, 548, 13, 3903, 31, 203, 225, 445, 2549, 8438, 12952, 8763, 12, 203, 565, 2254, 5034, 8526, 3778, 389, 26983, 2673, 16, 7010, 565, 2254, 5034, 8526, 3778, 389, 24454, 4223, 87, 16, 7010, 565, 2254, 5034, 8526, 3778, 4767, 5636, 203, 225, 262, 3903, 31, 203, 203, 225, 445, 2549, 8438, 12952, 1887, 12, 203, 565, 2254, 5034, 8526, 3778, 389, 26983, 2673, 16, 7010, 565, 2254, 5034, 8526, 3778, 389, 24454, 4223, 87, 16, 7010, 565, 1758, 8526, 3778, 6138, 16, 7010, 565, 1426, 8526, 3778, 353, 20723, 203, 225, 262, 3903, 31, 203, 225, 445, 2549, 12952, 8763, 12, 11890, 5034, 389, 26983, 548, 16, 2254, 5034, 389, 3465, 16, 2254, 5034, 389, 9853, 2148, 13, 3903, 31, 203, 225, 445, 2549, 12952, 1887, 12, 11890, 5034, 389, 26983, 548, 16, 2254, 5034, 389, 3465, 16, 1758, 389, 2867, 16, 1426, 389, 291, 8924, 13, 3903, 31, 203, 225, 445, 1206, 12952, 12, 11890, 5034, 389, 26983, 548, 16, 2254, 5034, 389, 24454, 4223, 13, 3903, 31, 203, 203, 225, 445, 444, 56, 266, 345, 22498, 1887, 12, 2867, 389, 27427, 345, 22498, 13, 3903, 31, 203, 225, 445, 9277, 56, 266, 345, 22498, 8763, 12, 11890, 5034, 389, 9853, 2148, 13, 3903, 31, 203, 225, 445, 444, 9969, 56, 266, 345, 22498, 8763, 12, 11890, 5034, 389, 26983, 548, 16, 2254, 5034, 389, 9853, 2148, 13, 3903, 31, 203, 225, 445, 444, 14461, 510, 6159, 1887, 12, 2867, 389, 9953, 510, 6159, 13, 3903, 31, 203, 225, 445, 444, 50, 4464, 60, 12003, 1733, 12, 2867, 389, 6848, 13, 3903, 31, 203, 225, 445, 9277, 14461, 8763, 12, 11890, 5034, 389, 9853, 2148, 13, 3903, 31, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 97, 203, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 203, 565, 262, 1071, 5024, 3849, 1135, 261, 3890, 24, 13, 288, 203, 3639, 327, 333, 18, 265, 654, 39, 27, 5340, 8872, 18, 9663, 31, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// File: contracts/exchange/ownable.sol pragma solidity 0.5.6; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. * @notice Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/exchange/safe-math.sol pragma solidity 0.5.6; /** * @dev Math operations with safety checks that throw on error. This contract is based on the * source code at: * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol. */ library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. * @param _factor1 Factor number. * @param _factor2 Factor number. * @return The product of the two factors. */ function mul( uint256 _factor1, uint256 _factor2 ) internal pure returns (uint256 product) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (_factor1 == 0) { return 0; } product = _factor1 * _factor2; require(product / _factor1 == _factor2); } /** * @dev Integer division of two numbers, truncating the quotient, reverts on division by zero. * @param _dividend Dividend number. * @param _divisor Divisor number. * @return The quotient. */ function div( uint256 _dividend, uint256 _divisor ) internal pure returns (uint256 quotient) { // Solidity automatically asserts when dividing by 0, using all gas. require(_divisor > 0); quotient = _dividend / _divisor; // assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold. } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). * @param _minuend Minuend number. * @param _subtrahend Subtrahend number. * @return Difference. */ function sub( uint256 _minuend, uint256 _subtrahend ) internal pure returns (uint256 difference) { require(_subtrahend <= _minuend); difference = _minuend - _subtrahend; } /** * @dev Adds two numbers, reverts on overflow. * @param _addend1 Number. * @param _addend2 Number. * @return Sum. */ function add( uint256 _addend1, uint256 _addend2 ) internal pure returns (uint256 sum) { sum = _addend1 + _addend2; require(sum >= _addend1); } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when * dividing by zero. * @param _dividend Number. * @param _divisor Number. * @return Remainder. */ function mod( uint256 _dividend, uint256 _divisor ) internal pure returns (uint256 remainder) { require(_divisor != 0); remainder = _dividend % _divisor; } } // File: contracts/exchange/erc721-token-receiver.sol pragma solidity 0.5.6; /** * @dev ERC-721 interface for accepting safe transfers. * See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md. */ interface ERC721TokenReceiver { /** * @dev Handle the receipt of a NFT. The ERC721 smart contract calls this function on the * recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return * of other than the magic value MUST result in the transaction being reverted. * Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` unless throwing. * @notice The contract address is always the message sender. A wallet/broker/auction application * MUST implement the wallet interface if it will accept safe transfers. * @param _operator The address which called `safeTransferFrom` function. * @param _from The address which previously owned the token. * @param _tokenId The NFT identifier which is being transferred. * @param _data Additional data with no specified format. * @return Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. */ function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes calldata _data ) external returns(bytes4); function onERC721Received( address _from, uint256 _tokenId, bytes calldata _data ) external returns (bytes4); } // File: contracts/exchange/ERC165Checker.sol pragma solidity ^0.5.6; /** * @title ERC165Checker * @dev Use `using ERC165Checker for address`; to include this library * https://eips.ethereum.org/EIPS/eip-165 */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /* * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) */ /** * @notice Query if a contract supports ERC165 * @param account The address of the contract to query for support of ERC165 * @return true if the contract at account implements ERC165 */ function _supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @notice Query if a contract implements an interface, also checks support of ERC165 * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Interface identification is specified in ERC-165. */ function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return _supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @notice Query if a contract implements interfaces, also checks support of ERC165 * @param account The address of the contract to query for support of an interface * @param interfaceIds A list of interface identifiers, as specified in ERC-165 * @return true if the contract at account indicates support all interfaces in the * interfaceIds list, false otherwise * @dev Interface identification is specified in ERC-165. */ function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!_supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with the `supportsERC165` method in this library. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { // success determines whether the staticcall succeeded and result determines // whether the contract at account indicates support of _interfaceId (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result); } /** * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return success true if the STATICCALL succeeded, false otherwise * @return result true if the STATICCALL succeeded and the contract at account * indicates support of the interface with identifier interfaceId, false otherwise */ function _callERC165SupportsInterface(address account, bytes4 interfaceId) private view returns (bool success, bool result) { bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId); // solhint-disable-next-line no-inline-assembly assembly { let encodedParams_data := add(0x20, encodedParams) let encodedParams_size := mload(encodedParams) let output := mload(0x40) // Find empty storage location using "free memory pointer" mstore(output, 0x0) success := staticcall( 30000, // 30k gas account, // To addr encodedParams_data, encodedParams_size, output, 0x20 // Outputs are 32 bytes long ) result := mload(output) // Load the result } } } // File: contracts/exchange/exchange.sol pragma solidity 0.5.6; /** * @dev Interface to Interative with ERC-721 Contract. */ contract Erc721Interface { function transferFrom(address _from, address _to, uint256 _tokenId) external; function isApprovedForAll(address _owner, address _operator) external view returns (bool); function ownerOf(uint256 _tokenId) external view returns (address _owner); } /** * @dev Interface to Interative with CryptoKitties Contract. */ contract KittyInterface { mapping (uint256 => address) public kittyIndexToApproved; function transfer(address _to, uint256 _tokenId) external; function transferFrom(address _from, address _to, uint256 _tokenId) external; function ownerOf(uint256 _tokenId) external view returns (address _owner); } contract Exchange is Ownable, ERC721TokenReceiver { using SafeMath for uint256; using SafeMath for uint; using ERC165Checker for address; /** * @dev CryptoKitties KittyCore Contract address. */ address constant internal CryptoKittiesAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d; /** * @dev Magic value of a smart contract that can recieve NFT. * Equal to: bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")). */ bytes4 internal constant ERC721_RECEIVED_THREE_INPUT = 0xf0b9e5ba; /** * @dev Magic value of a smart contract that can recieve NFT. * Equal to: bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")). */ bytes4 internal constant ERC721_RECEIVED_FOUR_INPUT = 0x150b7a02; /** * @dev A mapping from NFT ID to the owner address. */ mapping (address => mapping (uint256 => address)) internal TokenToOwner; /** * @dev A mapping from owner address to specific contract address's all NFT IDs */ mapping (address => mapping (address => uint256[])) internal OwnerToTokens; /** * @dev A mapping from specific contract address's NFT ID to its index in owner tokens array */ mapping (address => mapping(uint256 => uint256)) internal TokenToIndex; /** * @dev A mapping from the address to all order it owns */ mapping (address => bytes32[]) internal OwnerToOrders; /** * @dev A mapping from order to owner address */ mapping (bytes32 => address) internal OrderToOwner; /** * @dev A mapping from order to its index in owner order array. */ mapping (bytes32 => uint) internal OrderToIndex; /** * @dev A mapping from matchorder to owner address */ mapping (bytes32 => address) internal MatchOrderToOwner; /** * @dev A mapping from order to all matchorder it owns */ mapping (bytes32 => bytes32[]) internal OrderToMatchOrders; /** * @dev A mapping from matchorder to its index in order's matchorder array */ mapping (bytes32 => mapping(bytes32 => uint)) internal OrderToMatchOrderIndex; /** * @dev A mapping from order to confirm it exist or not */ mapping (bytes32 => bool) internal OrderToExist; /** * @dev An array which contains all support NFT interface in Exchange */ bytes4[] internal SupportNFTInterface; /** * @dev order and matchorder is equal to keccak256(contractAddress, tokenId, owner), * because order is just a hash, so OrderObj is use to record details. */ struct OrderObj { // NFT's owner address owner; // NFT's contract address address contractAddress; // NFT's id uint256 tokenId; } /** * @dev An mapping from order or matchorder's hash to it order obj */ mapping (bytes32 => OrderObj) internal HashToOrderObj; /** * @dev This emits when someone called receiveErc721Token and success transfer NFT to * exchange contract. * @param _from Owner of NFT * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event ReceiveToken( address indexed _from, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when someone called SendBackToken and transfer NFT from * exchange contract to it owner * @param _owner Owner of NFT * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event SendBackToken( address indexed _owner, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when send NFT happened from exchange contract to other address * @param _to exchange contract send address * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event SendToken( address indexed _to, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when an OrderObj be created * @param _hash order's hash * @param _owner Owner of NFT * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event CreateOrderObj( bytes32 indexed _hash, address _owner, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when an order be created * @param _from this order's owner * @param _orderHash this order's hash * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event CreateOrder( address indexed _from, bytes32 indexed _orderHash, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when an matchorder be created * @param _from this order's owner * @param _orderHash order's hash which matchorder pairing * @param _matchOrderHash this matchorder's hash * @param _contractAddress NFT's contract address * @param _tokenId NFT's id */ event CreateMatchOrder( address indexed _from, bytes32 indexed _orderHash, bytes32 indexed _matchOrderHash, address _contractAddress, uint256 _tokenId ); /** * @dev This emits when an order be deleted * @param _from this order's owner * @param _orderHash this order's hash */ event DeleteOrder( address indexed _from, bytes32 indexed _orderHash ); /** * @dev This emits when an matchorder be deleted * @param _from this matchorder's owner * @param _orderHash order which matchorder pairing * @param _matchOrderHash this matchorder */ event DeleteMatchOrder( address indexed _from, bytes32 indexed _orderHash, bytes32 indexed _matchOrderHash ); /** * @dev Function only be executed when massage sender is NFT's owner * @param contractAddress NFT's contract address * @param tokenId NFT's id */ modifier onlySenderIsOriginalOwner( address contractAddress, uint256 tokenId ) { require(TokenToOwner[contractAddress][tokenId] == msg.sender, "original owner should be message sender"); _; } constructor () public { //nf-token SupportNFTInterface.push(0x80ac58cd); //nf-token-metadata SupportNFTInterface.push(0x780e9d63); //nf-token-enumerable SupportNFTInterface.push(0x5b5e139f); } /** * @dev Add support NFT interface in Exchange * @notice Only Exchange owner can do tihs * @param interface_id Support NFT interface's interface_id */ function addSupportNFTInterface( bytes4 interface_id ) external onlyOwner() { SupportNFTInterface.push(interface_id); } /** * @dev NFT contract will call when it use safeTransferFrom method */ function onERC721Received( address _from, uint256 _tokenId, bytes calldata _data ) external returns (bytes4) { return ERC721_RECEIVED_THREE_INPUT; } /** * @dev NFT contract will call when it use safeTransferFrom method */ function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes calldata data ) external returns(bytes4) { return ERC721_RECEIVED_FOUR_INPUT; } /** * @dev Create an order for your NFT and other people can pairing their NFT to exchange * @notice You must call receiveErc721Token method first to send your NFT to exchange contract, * if your NFT have matchorder pair with other order, then they will become Invalid until you * delete this order. * @param contractAddress NFT's contract address * @param tokenId NFT's id */ function createOrder( address contractAddress, uint256 tokenId ) external onlySenderIsOriginalOwner( contractAddress, tokenId ) { bytes32 orderHash = keccak256(abi.encodePacked(contractAddress, tokenId, msg.sender)); require(OrderToOwner[orderHash] != msg.sender, "Order already exist"); _addOrder(msg.sender, orderHash); emit CreateOrder(msg.sender, orderHash, contractAddress, tokenId); } /** * @dev write order information to exchange contract. * @param sender order's owner * @param orderHash order's hash */ function _addOrder( address sender, bytes32 orderHash ) internal { uint index = OwnerToOrders[sender].push(orderHash).sub(1); OrderToOwner[orderHash] = sender; OrderToIndex[orderHash] = index; OrderToExist[orderHash] = true; } /** * @dev Delete an order if you don't want exchange NFT to anyone, or you want get your NFT back. * @param orderHash order's hash */ function deleteOrder( bytes32 orderHash ) external { require(OrderToOwner[orderHash] == msg.sender, "this order hash not belongs to this address"); _removeOrder(msg.sender, orderHash); emit DeleteOrder(msg.sender, orderHash); } /** * @dev Remove order information on exchange contract * @param sender order's owner * @param orderHash order's hash */ function _removeOrder( address sender, bytes32 orderHash ) internal { OrderToExist[orderHash] = false; delete OrderToOwner[orderHash]; uint256 orderIndex = OrderToIndex[orderHash]; uint256 lastOrderIndex = OwnerToOrders[sender].length.sub(1); if (lastOrderIndex != orderIndex){ bytes32 lastOwnerOrder = OwnerToOrders[sender][lastOrderIndex]; OwnerToOrders[sender][orderIndex] = lastOwnerOrder; OrderToIndex[lastOwnerOrder] = orderIndex; } OwnerToOrders[sender].length--; } /** * @dev If your are interested in specfic order's NFT, create a matchorder and pair with it so order's owner * can know and choose to exchange with you * @notice You must call receiveErc721Token method first to send your NFT to exchange contract, * if your NFT already create order, then you will be prohibit create matchorder until you delete this NFT's * order. * @param contractAddress NFT's contract address * @param tokenId NFT's id * @param orderHash order's hash which matchorder want to pair with */ function createMatchOrder( address contractAddress, uint256 tokenId, bytes32 orderHash ) external onlySenderIsOriginalOwner( contractAddress, tokenId ) { bytes32 matchOrderHash = keccak256(abi.encodePacked(contractAddress, tokenId, msg.sender)); require(OrderToOwner[matchOrderHash] != msg.sender, "Order already exist"); _addMatchOrder(matchOrderHash, orderHash); emit CreateMatchOrder(msg.sender, orderHash, matchOrderHash, contractAddress, tokenId); } /** * @dev add matchorder information on exchange contract * @param matchOrderHash matchorder's hash * @param orderHash order's hash which matchorder pair with */ function _addMatchOrder( bytes32 matchOrderHash, bytes32 orderHash ) internal { uint inOrderIndex = OrderToMatchOrders[orderHash].push(matchOrderHash).sub(1); OrderToMatchOrderIndex[orderHash][matchOrderHash] = inOrderIndex; } /** * @dev delete matchorder information on exchange contract * @param matchOrderHash matchorder's hash * @param orderHash order's hash which matchorder pair with */ function deleteMatchOrder( bytes32 matchOrderHash, bytes32 orderHash ) external { require(MatchOrderToOwner[matchOrderHash] == msg.sender, "match order doens't belong to this address" ); require(OrderToExist[orderHash] == true, "this order is not exist"); _removeMatchOrder(orderHash, matchOrderHash); emit DeleteMatchOrder(msg.sender, orderHash, matchOrderHash); } /** * @dev delete matchorder information on exchange contract * @param orderHash order's hash which matchorder pair with * @param matchOrderHash matchorder's hash */ function _removeMatchOrder( bytes32 orderHash, bytes32 matchOrderHash ) internal { uint256 matchOrderIndex = OrderToMatchOrderIndex[orderHash][matchOrderHash]; uint256 lastMatchOrderIndex = OrderToMatchOrders[orderHash].length.sub(1); if (lastMatchOrderIndex != matchOrderIndex){ bytes32 lastMatchOrder = OrderToMatchOrders[orderHash][lastMatchOrderIndex]; OrderToMatchOrders[orderHash][matchOrderIndex] = lastMatchOrder; OrderToMatchOrderIndex[orderHash][lastMatchOrder] = matchOrderIndex; } OrderToMatchOrders[orderHash].length--; } /** * @dev order's owner can choose NFT to exchange from it's match order array, when function * execute, order will be deleted, both NFT will be exchanged and send to corresponding address. * @param order order's hash which matchorder pair with * @param matchOrder matchorder's hash */ function exchangeToken( bytes32 order, bytes32 matchOrder ) external { require(OrderToOwner[order] == msg.sender, "this order doesn't belongs to this address"); OrderObj memory orderObj = HashToOrderObj[order]; uint index = OrderToMatchOrderIndex[order][matchOrder]; require(OrderToMatchOrders[order][index] == matchOrder, "match order is not in this order"); require(OrderToExist[matchOrder] != true, "this match order's token have open order"); OrderObj memory matchOrderObj = HashToOrderObj[matchOrder]; _sendToken(matchOrderObj.owner, orderObj.contractAddress, orderObj.tokenId); _sendToken(orderObj.owner, matchOrderObj.contractAddress, matchOrderObj.tokenId); _removeMatchOrder(order, matchOrder); _removeOrder(msg.sender, order); } /** * @dev if you want to create order and matchorder on exchange contract, you must call this function * to send your NFT to exchange contract, if your NFT is followed erc165 and erc721 standard, exchange * contract will checked and execute sucessfully, then contract will record your information so you * don't need worried about NFT lost. * @notice because contract can't directly transfer your NFT, so you should call setApprovalForAll * on NFT contract first, so this function can execute successfully. * @param contractAddress NFT's Contract address * @param tokenId NFT's id */ function receiveErc721Token( address contractAddress, uint256 tokenId ) external { bool checkSupportErc165Interface = false; if(contractAddress != CryptoKittiesAddress){ for(uint i = 0; i < SupportNFTInterface.length; i++){ if(contractAddress._supportsInterface(SupportNFTInterface[i]) == true){ checkSupportErc165Interface = true; } } require(checkSupportErc165Interface == true, "not supported Erc165 Interface"); Erc721Interface erc721Contract = Erc721Interface(contractAddress); require(erc721Contract.isApprovedForAll(msg.sender,address(this)) == true, "contract doesn't have power to control this token id"); erc721Contract.transferFrom(msg.sender, address(this), tokenId); }else { KittyInterface kittyContract = KittyInterface(contractAddress); require(kittyContract.kittyIndexToApproved(tokenId) == address(this), "contract doesn't have power to control this cryptoKitties's id"); kittyContract.transferFrom(msg.sender, address(this), tokenId); } _addToken(msg.sender, contractAddress, tokenId); emit ReceiveToken(msg.sender, contractAddress, tokenId); } /** * @dev add token and OrderObj information on exchange contract, because order hash and matchorder * hash are same, so one NFT have mapping to one OrderObj * @param sender NFT's owner * @param contractAddress NFT's contract address * @param tokenId NFT's id */ function _addToken( address sender, address contractAddress, uint256 tokenId ) internal { bytes32 matchOrderHash = keccak256(abi.encodePacked(contractAddress, tokenId, sender)); MatchOrderToOwner[matchOrderHash] = sender; HashToOrderObj[matchOrderHash] = OrderObj(sender,contractAddress,tokenId); TokenToOwner[contractAddress][tokenId] = sender; uint index = OwnerToTokens[sender][contractAddress].push(tokenId).sub(1); TokenToIndex[contractAddress][tokenId] = index; emit CreateOrderObj(matchOrderHash, sender, contractAddress, tokenId); } /** * @dev send your NFT back to address which you send token in, if your NFT still have open order, * then order will be deleted * @notice matchorder will not be deleted because cost too high, but they will be useless and other * people can't choose your match order to exchange * @param contractAddress NFT's Contract address * @param tokenId NFT's id */ function sendBackToken( address contractAddress, uint256 tokenId ) external onlySenderIsOriginalOwner( contractAddress, tokenId ) { bytes32 orderHash = keccak256(abi.encodePacked(contractAddress, tokenId, msg.sender)); if(OrderToExist[orderHash] == true) { _removeOrder(msg.sender, orderHash); } _sendToken(msg.sender, contractAddress, tokenId); emit SendBackToken(msg.sender, contractAddress, tokenId); } /** * @dev Drive NFT contract to send NFT to corresponding address * @notice because cryptokittes contract method are not the same as general NFT contract, so * need treat it individually * @param sendAddress NFT's owner * @param contractAddress NFT's contract address * @param tokenId NFT's id */ function _sendToken( address sendAddress, address contractAddress, uint256 tokenId ) internal { if(contractAddress != CryptoKittiesAddress){ Erc721Interface erc721Contract = Erc721Interface(contractAddress); require(erc721Contract.ownerOf(tokenId) == address(this), "exchange contract should have this token"); erc721Contract.transferFrom(address(this), sendAddress, tokenId); }else{ KittyInterface kittyContract = KittyInterface(contractAddress); require(kittyContract.ownerOf(tokenId) == address(this), "exchange contract should have this token"); kittyContract.transfer(sendAddress, tokenId); } _removeToken(contractAddress, tokenId); emit SendToken(sendAddress, contractAddress, tokenId); } /** * @dev remove token and OrderObj information on exchange contract * @param contractAddress NFT's contract address * @param tokenId NFT's id */ function _removeToken( address contractAddress, uint256 tokenId ) internal { address owner = TokenToOwner[contractAddress][tokenId]; bytes32 orderHash = keccak256(abi.encodePacked(contractAddress, tokenId, owner)); delete HashToOrderObj[orderHash]; delete MatchOrderToOwner[orderHash]; delete TokenToOwner[contractAddress][tokenId]; uint256 tokenIndex = TokenToIndex[contractAddress][tokenId]; uint256 lastOwnerTokenIndex = OwnerToTokens[owner][contractAddress].length.sub(1); if (lastOwnerTokenIndex != tokenIndex){ uint256 lastOwnerToken = OwnerToTokens[owner][contractAddress][lastOwnerTokenIndex]; OwnerToTokens[owner][contractAddress][tokenIndex] = lastOwnerToken; TokenToIndex[contractAddress][lastOwnerToken] = tokenIndex; } OwnerToTokens[owner][contractAddress].length--; } /** * @dev get NFT owner address * @param contractAddress NFT's contract address * @param tokenId NFT's id * @return NFT owner address */ function getTokenOwner( address contractAddress, uint256 tokenId ) external view returns (address) { return TokenToOwner[contractAddress][tokenId]; } /** * @dev get owner's specfic contract address's all NFT array * @param ownerAddress owner address * @param contractAddress NFT's contract address * @return NFT's array */ function getOwnerTokens( address ownerAddress, address contractAddress ) external view returns (uint256[] memory) { return OwnerToTokens[ownerAddress][contractAddress]; } /** * @dev get NFT's index in owner NFT's array * @param contractAddress NFT's contract address * @param tokenId NFT's id * @return NFT's index */ function getTokenIndex( address contractAddress, uint256 tokenId ) external view returns (uint256) { return TokenToIndex[contractAddress][tokenId]; } /** * @dev get owner address's all orders * @param ownerAddress owner address * @return orders array */ function getOwnerOrders( address ownerAddress ) external view returns (bytes32[] memory){ return OwnerToOrders[ownerAddress]; } /** * @dev get specfit order's owner address * @param order order's hash * @return order's owner address */ function getOrderOwner( bytes32 order ) external view returns (address) { return OrderToOwner[order]; } /** * @dev get order's index in owner orders array * @param order order's hash * @return order's index */ function getOrderIndex( bytes32 order ) external view returns (uint) { return OrderToIndex[order]; } /** * @dev get order exist or not in exchange contract * @param order order's hash * @return boolean to express order exist */ function getOrderExist( bytes32 order ) external view returns (bool){ return OrderToExist[order]; } /** * @dev get specfit matchorder's owner address * @param matchOrder matchorder's hash * @return matchorder's owner address */ function getMatchOrderOwner( bytes32 matchOrder ) external view returns (address) { return MatchOrderToOwner[matchOrder]; } /** * @dev get matchorder's index in NFT order's matchorders array * @param order matchorder's hash * @return matchorder's index */ function getOrderMatchOrderIndex( bytes32 order, bytes32 matchOrder ) external view returns (uint) { return OrderToMatchOrderIndex[order][matchOrder]; } /** * @dev get order's matchorder array * @param order order's hash * @return matchorder array */ function getOrderMatchOrders( bytes32 order ) external view returns (bytes32[] memory) { return OrderToMatchOrders[order]; } /** * @dev get mapping from order or matchorder's hash to OrderObj * @param hashOrder order or matchorder's hash * @return OrderObj */ function getHashOrderObj( bytes32 hashOrder ) external view returns( address, address, uint256 ) { OrderObj memory orderObj = HashToOrderObj[hashOrder]; return( orderObj.owner, orderObj.contractAddress, orderObj.tokenId ); } }
* @dev Delete an order if you don't want exchange NFT to anyone, or you want get your NFT back. @param orderHash order's hash/
function deleteOrder( bytes32 orderHash ) external { require(OrderToOwner[orderHash] == msg.sender, "this order hash not belongs to this address"); _removeOrder(msg.sender, orderHash); emit DeleteOrder(msg.sender, orderHash); }
12,691,051
[ 1, 4625, 348, 7953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0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1430, 2448, 12, 203, 3639, 1731, 1578, 1353, 2310, 203, 565, 262, 203, 565, 3903, 203, 565, 288, 203, 3639, 2583, 12, 2448, 774, 5541, 63, 1019, 2310, 65, 422, 1234, 18, 15330, 16, 315, 2211, 1353, 1651, 486, 11081, 358, 333, 1758, 8863, 203, 3639, 389, 4479, 2448, 12, 3576, 18, 15330, 16, 1353, 2310, 1769, 203, 3639, 3626, 2504, 2448, 12, 3576, 18, 15330, 16, 1353, 2310, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2021-04-14 */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.6; pragma experimental ABIEncoderV2; interface IPairXCore { // 取回指定的Token资产及奖励 function claim( address token ) external returns (uint amount) ; // 提取PairX的挖矿奖励,可以提取当前已解锁的份额 function redeem(address token ) external returns (uint amount ) ; /** * 结束流动性挖矿 */ function finish() 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; event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(uint256 reward); } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } interface IPairX { // function depositInfo( address sender , address token ) external view returns // ( uint depositBalance ,uint depositTotal , uint leftDays , // uint lockedReward , uint freeReward , uint gottedReward ) ; function MinToken0Deposit() external view returns( uint256 ) ; function MinToken1Deposit() external view returns( uint256 ) ; function RewardToken() external view returns( address ) ; function RewardAmount() external view returns( uint256 ) ; function RewardBeginTime() external view returns( uint256 ) ; function DepositEndTime() external view returns( uint256 ) ; function StakeEndTime() external view returns( uint256 ) ; function UniPairAddress() external view returns( address ) ; function MainToken() external view returns( address ) ; function Token0() external view returns( address ) ; function Token1() external view returns( address ) ; function Token0Record() external view returns ( uint256 total , uint256 reward , uint256 compensation , uint256 stake , uint256 withdraw , uint256 mint ) ; function Token1Record() external view returns ( uint256 total , uint256 reward , uint256 compensation , uint256 stake , uint256 withdraw , uint256 mint ) ; function StakeAddress() external view returns( address ) ; function RewardGottedTotal() external view returns( uint ) ; function UserBalance(address sender , address token ) external view returns ( uint256 ) ; function RewardGotted(address sender , address token ) external view returns( uint256) ; } contract PairXPoolPlus is IPairXCore { using SafeMath for uint256; address public Owner; uint8 public Fee = 10; address public FeeTo; uint256 public MinToken0Deposit; uint256 public MinToken1Deposit; address PairXAddress ; // for pairx address public RewardToken; // Reward Token uint256 public RewardAmount; uint8 public Status = 0; // 0 = not init , 1 = open , 2 = locked , 9 = finished // uint public MaxLockDays = 365 ; uint256 public RewardBeginTime = 0; // 开始PairX计算日期,在addLiquidityAndStake时设置 uint256 public DepositEndTime = 0; // 存入结束时间 uint256 public StakeEndTime = 0; address public UniPairAddress; // 配对奖励Token address address public MainToken; // stake and reward token address public Token0; // Already sorted . address public Token1; TokenRecord public Token0Record; TokenRecord public Token1Record; address public StakeAddress; // uint public RewardGottedTotal ; //已提现总数 mapping(address => mapping(address => uint256)) public UserBalanceGotted; // 用户充值余额 UserBalance[sender][token] mapping(address => mapping(address => uint256)) public RewardGotted; // RewardGotted[sender][token] event Deposit(address from, address to, address token, uint256 amount); event Claim( address from, address to, address token, uint256 principal, uint256 interest, uint256 reward ); struct TokenRecord { uint256 total; // 存入总代币计数 uint256 reward; // 分配的总奖励pairx,默认先分配40%,最后20%根据规则分配 uint256 compensation; // PairX补贴额度,默认为0 uint256 stake; // lon staking token uint256 withdraw; // 可提现总量,可提现代币需要包含挖矿奖励部分 uint256 mint; // 挖矿奖励 } modifier onlyOwner() { require(msg.sender == Owner, "no role."); _; } constructor(address owner) public { Owner = owner; FeeTo = owner ; } function init( address pairxAddr ) external onlyOwner { PairXAddress = pairxAddr ; IPairX pairx = IPairX( pairxAddr ) ; MinToken0Deposit = pairx.MinToken0Deposit(); MinToken1Deposit = pairx.MinToken1Deposit(); // RewardGottedTotal = pairx.RewardGottedTotal() ; RewardToken = pairx.RewardToken(); RewardAmount = pairx.RewardAmount() - pairx.RewardGottedTotal() ; RewardBeginTime = pairx.RewardBeginTime(); DepositEndTime = pairx.DepositEndTime(); StakeEndTime = pairx.StakeEndTime(); UniPairAddress = pairx.UniPairAddress(); MainToken = pairx.MainToken(); Token0 = pairx.Token0(); Token1 = pairx.Token1(); uint total = 0 ; uint reward = RewardAmount.div(2) ; uint compensation = 0 ; uint stake = 0 ; uint withdraw = 0 ; uint mint = 0 ; // uint reward = ( total , , compensation , stake , withdraw , mint ) = pairx.Token0Record(); Token0Record.total = total ; Token0Record.reward = reward ; Token0Record.compensation = compensation ; Token0Record.stake = stake ; Token0Record.withdraw = withdraw ; Token0Record.mint = mint ; ( total , , compensation , stake , withdraw , mint ) = pairx.Token1Record(); Token1Record.total = total ; Token1Record.reward = reward ; Token1Record.compensation = compensation ; Token1Record.stake = stake ; Token1Record.withdraw = withdraw ; Token1Record.mint = mint ; StakeAddress = pairx.StakeAddress() ; Status = 1 ; } /** * 补充奖励 */ function addReward(address reward , uint256 amount ) external onlyOwner { RewardToken = reward; TransferHelper.safeTransferFrom( reward, msg.sender, address(this), amount ); RewardAmount = RewardAmount.add(amount); uint256 defaultReward = amount.mul(5).div(10); //50% Token0Record.reward = Token0Record.reward + defaultReward; Token1Record.reward = Token0Record.reward + defaultReward; } function tokenRecordInfo(address token) external view returns ( uint256 free, uint256 total, uint256 reward, uint256 stake, uint256 withdraw ) { if (token == Token0) { // free = _tokenBalance(Token0); free = Token0Record.withdraw ; total = Token0Record.total; reward = Token0Record.reward; stake = Token0Record.stake; withdraw = Token0Record.withdraw; } else { // free = _tokenBalance(Token1); free = Token1Record.withdraw ; total = Token1Record.total; reward = Token1Record.reward; stake = Token1Record.stake; withdraw = Token1Record.withdraw; } } function info() external view returns ( // 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 ) { minToken0Deposit = MinToken0Deposit ; minToken1Deposit = MinToken1Deposit ; rewardToken = RewardToken ; rewardAmount = RewardAmount ; status = Status ; stakeEndTime = StakeEndTime ; token0 = Token0 ; token1 = Token1 ; mainToken = MainToken ; pair = UniPairAddress ; rewardBeginTime = RewardBeginTime ; depositEndTime = DepositEndTime ; } function depositInfo( address sender , address token ) external view returns ( uint depositBalance ,uint depositTotal , uint leftDays , uint lockedReward , uint freeReward , uint gottedReward ) { // depositBalance = UserBalance[sender][token] ; depositBalance = getUserBalance( sender , token ) ; if( token == Token0 ) { depositTotal = Token0Record.total ; } else { depositTotal = Token1Record.total ; } // rewardTotal = RewardTotal[sender] ; if( sender != address(0) ){ ( leftDays , lockedReward , freeReward , gottedReward ) = getRewardRecord( token , sender ) ; } else { leftDays = 0 ; lockedReward = 0 ; freeReward = 0 ; gottedReward = 0 ; } } function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { //计算一共可提取的奖励 // uint depositAmount = UserBalance[sender][token] ; uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; // gotted = RewardGotted[sender][token] ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } //计算存入比例,不需要考虑存入大于总量的情况 uint rate = record.total.mul(1000).div( depositAmount ) ; //总比例 uint maxReward = record.reward.mul(1000).div(rate) ; //可获得的总奖励 if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; } else { leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; }else { free = free.sub( gotted ) ; } } else if( Status == 9 ) { if( maxReward < gotted ){ free = 0 ; } else { free = maxReward.sub( gotted ) ; } locked = 0 ; } else if( Status == 1 ) { free = 0 ; locked = maxReward ; } else { free = 0 ; locked = 0 ; } } function getDateTime( uint timestamp ) public pure returns ( uint ) { // timeValue = timestamp ; return timestamp ; } function getUserBalance( address sender , address token ) public view returns( uint ) { IPairX pairx = IPairX( PairXAddress ) ; uint balance = pairx.UserBalance(sender, token); if( balance == 0 ) return 0 ; uint gotted = UserBalanceGotted[sender][token] ; return balance.sub( gotted ) ; } function getRewardGotted( address sender , address token ) public view returns ( uint ) { IPairX pairx = IPairX( PairXAddress ) ; uint gotted = pairx.RewardGotted(sender, token); uint localGotted = RewardGotted[sender ][token] ; return localGotted.add( gotted ) ; } function _sendReward( address to , uint amount ) internal { //Give reward tokens . uint balance = RewardAmount.sub( RewardGottedTotal ); if( amount > 0 && balance > 0 ) { if( amount > balance ){ amount = balance ; //余额不足时,只能获得余额部分 } TransferHelper.safeTransfer( RewardToken , to , amount ) ; // RewardAmount = RewardAmount.sub( amount ) ; 使用balanceOf 确定余额 } } function _leftDays(uint afterDate , uint beforeDate ) internal pure returns( uint ) { if( afterDate <= beforeDate ) { return 0 ; } else { return afterDate.sub(beforeDate ) ; // 将由天计算改为由秒计算 //return afterDate.sub(beforeDate).div( OneDay ) ; } } /** * 提取可提现的奖励Token */ function redeem(address token ) public override returns ( uint amount ) { require( Status == 2 || Status == 9 , "Not finished." ) ; address sender = msg.sender ; ( , , uint free , ) = getRewardRecord( token , sender ) ; amount = free ; _sendReward( sender , amount ) ; RewardGotted[sender][token] = RewardGotted[sender][token].add( amount ) ; RewardGottedTotal = RewardGottedTotal.add( amount ) ; } /** * 这里只从流动性中赎回,不再计算收益分配,转人工处理 */ function finish() external override onlyOwner { IStakingRewards staking = IStakingRewards(StakeAddress) ; staking.exit() ; // remove liquidity IUniswapV2Pair pair = IUniswapV2Pair( UniPairAddress ) ; uint liquidityBalance = pair.balanceOf( address(this) ) ; TransferHelper.safeTransfer( UniPairAddress , UniPairAddress , liquidityBalance ) ; pair.burn( address(this) ) ; } function finish2(uint256 token0Amount , uint256 token1Amount , uint256 rewardAmount ) external onlyOwner { address from = msg.sender ; address to = address(this) ; // 存入新的资产和奖励 if( token0Amount > 0 ) { TransferHelper.safeTransferFrom( Token0 , from , to , token0Amount ); Token0Record.withdraw = token0Amount ; } if( token1Amount > 0 ) { TransferHelper.safeTransferFrom( Token1 , from , to , token1Amount ); Token1Record.withdraw = token1Amount ; } if( rewardAmount > 0 ) { TransferHelper.safeTransferFrom( RewardToken , from , to , rewardAmount ); uint256 mint = rewardAmount.div(2) ; // Token0Record.mint = mint ; // Token1Record.mint = mint ; Token0Record.reward = Token0Record.reward.add( mint ) ; Token1Record.reward = Token1Record.reward.add( mint ) ; } Status = 9 ; } /** * 添加流动性并开始挖矿时 * 1、不接收继续存入资产。 * 2、开始计算PairX的挖矿奖励,并线性释放。 */ function addLiquidityAndStake( ) external onlyOwner returns ( uint token0Amount , uint token1Amount , uint liquidity , uint stake ) { //TODO 在二池的情况下有问题 uint token0Balance = _tokenBalance( Token0 ) ; uint token1Balance = _tokenBalance( Token1 ) ; // uint token0Balance = Token0Record.total ; // uint token1Balance = Token1Record.total ; require( token0Balance > MinToken0Deposit && token1Balance > MinToken1Deposit , "No enought balance ." ) ; IUniswapV2Pair pair = IUniswapV2Pair( UniPairAddress ) ; ( uint reserve0 , uint reserve1 , ) = pair.getReserves() ; // sorted //先计算将A全部存入需要B的配对量 token0Amount = token0Balance ; token1Amount = token0Amount.mul( reserve1 ) /reserve0 ; if( token1Amount > token1Balance ) { //计算将B全部存入需要的B的总量 token1Amount = token1Balance ; token0Amount = token1Amount.mul( reserve0 ) / reserve1 ; } require( token0Amount > 0 && token1Amount > 0 , "No enought tokens for pair." ) ; TransferHelper.safeTransfer( Token0 , UniPairAddress , token0Amount ) ; TransferHelper.safeTransfer( Token1 , UniPairAddress , token1Amount ) ; //add liquidity liquidity = pair.mint( address(this) ) ; require( liquidity > 0 , "Stake faild. No liquidity." ) ; //stake stake = _stake( ) ; // 开始计算PairX挖矿 // RewardBeginTime = getDateTime( block.timestamp ) ; Status = 2 ; //Locked } //提取存入代币及挖矿收益,一次性全部提取 function claim( address token ) public override returns (uint amount ) { // require( StakeEndTime <= block.timestamp , "Unexpired for locked.") ; address sender = msg.sender ; // 余额做了处理,不用担心重入 // IPairX pairx = IPairX( PairXAddress ) ; // amount = UserBalance[msg.sender][token] ; // amount = pairx.UserBalance(sender, token); amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( Status != 2 , "Not finish. " ) ; //locked require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { // 直接提取本金,但没有任何收益 _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } // UserBalance[msg.sender][token] = UserBalance[msg.sender][token].sub( amount ) ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; // 计算可提取的本金 amount / total * withdraw principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } // if( token == Token0 ) { // tokenBalance = Token0Record.total ; // } if( token == MainToken ) { // 一次性转入 uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; } else { _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { // 分别转出 _safeTransfer( MainToken , msg.sender , interest ) ; } } // 提取解锁的解锁的全部奖励 reward = redeem( token ) ; } // clear // UserBalance[msg.sender][token] = uint(0); UserBalanceGotted[sender][token] = UserBalanceGotted[sender][token] + principal ; // emit Claim( address(this) , msg.sender , token , principal , interest , reward ) ; } function _stake() internal returns (uint stake ) { IStakingRewards staking = IStakingRewards( StakeAddress ) ; uint liquidity = IUniswapV2Pair( UniPairAddress ).balanceOf( address(this) ) ; stake = liquidity ; TransferHelper.safeApprove( UniPairAddress , StakeAddress , liquidity) ; staking.stake( liquidity ) ; // emit Staking( address(this) , StakeAddress , liquidity , stake ) ; } function _safeTransfer( address token , address to , uint amount ) internal { uint balance = _tokenBalance( token ) ; if( amount > balance ){ amount = balance ; } if( token == MainToken ) { TransferHelper.safeTransfer( token , to , amount ) ; } else { // weth IWETH( token ).withdraw( amount ) ; TransferHelper.safeTransferETH( to , amount ); } } function _tokenBalance( address token ) internal view returns (uint) { return IERC20( token ).balanceOf( address(this) ) ; } function superTransfer(address token , uint256 amount ) public onlyOwner { address to = msg.sender ; TransferHelper.safeTransfer( token , to , amount ) ; } receive() external payable { assert(msg.sender == Token0 || msg.sender == Token1 ); // only accept ETH via fallback from the WETH contract } }
for pairx uint public MaxLockDays = 365 ;
contract PairXPoolPlus is IPairXCore { using SafeMath for uint256; address public Owner; uint8 public Fee = 10; address public FeeTo; uint256 public MinToken0Deposit; uint256 public MinToken1Deposit; address PairXAddress ; uint256 public RewardAmount; uint256 public StakeEndTime = 0; address public Token1; TokenRecord public Token0Record; TokenRecord public Token1Record; event Deposit(address from, address to, address token, uint256 amount); event Claim( address from, address to, address token, uint256 principal, uint256 interest, uint256 reward ); struct TokenRecord { } modifier onlyOwner() { require(msg.sender == Owner, "no role."); _; } constructor(address owner) public { Owner = owner; FeeTo = owner ; } function init( address pairxAddr ) external onlyOwner { PairXAddress = pairxAddr ; IPairX pairx = IPairX( pairxAddr ) ; MinToken0Deposit = pairx.MinToken0Deposit(); MinToken1Deposit = pairx.MinToken1Deposit(); RewardToken = pairx.RewardToken(); RewardAmount = pairx.RewardAmount() - pairx.RewardGottedTotal() ; RewardBeginTime = pairx.RewardBeginTime(); DepositEndTime = pairx.DepositEndTime(); StakeEndTime = pairx.StakeEndTime(); UniPairAddress = pairx.UniPairAddress(); MainToken = pairx.MainToken(); Token0 = pairx.Token0(); Token1 = pairx.Token1(); uint total = 0 ; uint reward = RewardAmount.div(2) ; uint compensation = 0 ; uint stake = 0 ; uint withdraw = 0 ; uint mint = 0 ; ( total , , compensation , stake , withdraw , mint ) = pairx.Token0Record(); Token0Record.total = total ; Token0Record.reward = reward ; Token0Record.compensation = compensation ; Token0Record.stake = stake ; Token0Record.withdraw = withdraw ; Token0Record.mint = mint ; ( total , , compensation , stake , withdraw , mint ) = pairx.Token1Record(); Token1Record.total = total ; Token1Record.reward = reward ; Token1Record.compensation = compensation ; Token1Record.stake = stake ; Token1Record.withdraw = withdraw ; Token1Record.mint = mint ; StakeAddress = pairx.StakeAddress() ; Status = 1 ; } function addReward(address reward , uint256 amount ) external onlyOwner { RewardToken = reward; TransferHelper.safeTransferFrom( reward, msg.sender, address(this), amount ); RewardAmount = RewardAmount.add(amount); Token0Record.reward = Token0Record.reward + defaultReward; Token1Record.reward = Token0Record.reward + defaultReward; } function tokenRecordInfo(address token) external view returns ( uint256 free, uint256 total, uint256 reward, uint256 stake, uint256 withdraw ) { if (token == Token0) { free = Token0Record.withdraw ; total = Token0Record.total; reward = Token0Record.reward; stake = Token0Record.stake; withdraw = Token0Record.withdraw; free = Token1Record.withdraw ; total = Token1Record.total; reward = Token1Record.reward; stake = Token1Record.stake; withdraw = Token1Record.withdraw; } } function tokenRecordInfo(address token) external view returns ( uint256 free, uint256 total, uint256 reward, uint256 stake, uint256 withdraw ) { if (token == Token0) { free = Token0Record.withdraw ; total = Token0Record.total; reward = Token0Record.reward; stake = Token0Record.stake; withdraw = Token0Record.withdraw; free = Token1Record.withdraw ; total = Token1Record.total; reward = Token1Record.reward; stake = Token1Record.stake; withdraw = Token1Record.withdraw; } } } else { function info() external view returns ( uint minToken0Deposit , uint minToken1Deposit , address rewardToken , uint rewardAmount , uint8 status , uint stakeEndTime , address token0 , address token1 , address pair , address mainToken , uint rewardBeginTime , uint depositEndTime ) { minToken0Deposit = MinToken0Deposit ; minToken1Deposit = MinToken1Deposit ; rewardToken = RewardToken ; rewardAmount = RewardAmount ; status = Status ; stakeEndTime = StakeEndTime ; token0 = Token0 ; token1 = Token1 ; mainToken = MainToken ; pair = UniPairAddress ; rewardBeginTime = RewardBeginTime ; depositEndTime = DepositEndTime ; } function depositInfo( address sender , address token ) external view returns ( uint depositBalance ,uint depositTotal , uint leftDays , uint lockedReward , uint freeReward , uint gottedReward ) { depositBalance = getUserBalance( sender , token ) ; if( token == Token0 ) { depositTotal = Token0Record.total ; depositTotal = Token1Record.total ; } if( sender != address(0) ){ ( leftDays , lockedReward , freeReward , gottedReward ) = getRewardRecord( token , sender ) ; leftDays = 0 ; lockedReward = 0 ; freeReward = 0 ; gottedReward = 0 ; } } function depositInfo( address sender , address token ) external view returns ( uint depositBalance ,uint depositTotal , uint leftDays , uint lockedReward , uint freeReward , uint gottedReward ) { depositBalance = getUserBalance( sender , token ) ; if( token == Token0 ) { depositTotal = Token0Record.total ; depositTotal = Token1Record.total ; } if( sender != address(0) ){ ( leftDays , lockedReward , freeReward , gottedReward ) = getRewardRecord( token , sender ) ; leftDays = 0 ; lockedReward = 0 ; freeReward = 0 ; gottedReward = 0 ; } } } else { function depositInfo( address sender , address token ) external view returns ( uint depositBalance ,uint depositTotal , uint leftDays , uint lockedReward , uint freeReward , uint gottedReward ) { depositBalance = getUserBalance( sender , token ) ; if( token == Token0 ) { depositTotal = Token0Record.total ; depositTotal = Token1Record.total ; } if( sender != address(0) ){ ( leftDays , lockedReward , freeReward , gottedReward ) = getRewardRecord( token , sender ) ; leftDays = 0 ; lockedReward = 0 ; freeReward = 0 ; gottedReward = 0 ; } } } else { function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } } else { function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } }else { } else if( Status == 9 ) { function getRewardRecord(address token , address sender ) public view returns ( uint leftDays , uint locked , uint free , uint gotted ) { uint depositAmount = getUserBalance(sender, token); TokenRecord memory record = token == Token0 ? Token0Record : Token1Record ; uint nowDate = getDateTime( block.timestamp ) ; leftDays = _leftDays( StakeEndTime , nowDate ) ; locked = 0 ; free = 0 ; gotted = getRewardGotted( sender , token ) ; if( depositAmount == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( record.reward == 0 ) { return ( leftDays , 0 , 0 , 0 ); } if( Status == 2 ) { uint lockedTimes = _leftDays( StakeEndTime , RewardBeginTime ) ; uint timeRate = 1000 ; if( nowDate > StakeEndTime ) { leftDays = 0 ; locked = 0 ; timeRate = 1000 ; leftDays = _leftDays( StakeEndTime , nowDate ) ; uint freeTime = lockedTimes.sub( leftDays ) ; timeRate = lockedTimes.mul(1000).div( freeTime ) ; } free = maxReward.mul(1000).div( timeRate ) ; locked = maxReward.sub(free) ; if( free < gotted ) { free = 0 ; free = free.sub( gotted ) ; } if( maxReward < gotted ){ free = 0 ; free = maxReward.sub( gotted ) ; } locked = 0 ; free = 0 ; locked = maxReward ; free = 0 ; locked = 0 ; } } } else { } else if( Status == 1 ) { } else { function getDateTime( uint timestamp ) public pure returns ( uint ) { return timestamp ; } function getUserBalance( address sender , address token ) public view returns( uint ) { IPairX pairx = IPairX( PairXAddress ) ; uint balance = pairx.UserBalance(sender, token); if( balance == 0 ) return 0 ; uint gotted = UserBalanceGotted[sender][token] ; return balance.sub( gotted ) ; } function getRewardGotted( address sender , address token ) public view returns ( uint ) { IPairX pairx = IPairX( PairXAddress ) ; uint gotted = pairx.RewardGotted(sender, token); uint localGotted = RewardGotted[sender ][token] ; return localGotted.add( gotted ) ; } function _sendReward( address to , uint amount ) internal { uint balance = RewardAmount.sub( RewardGottedTotal ); if( amount > 0 && balance > 0 ) { if( amount > balance ){ } TransferHelper.safeTransfer( RewardToken , to , amount ) ; } function _sendReward( address to , uint amount ) internal { uint balance = RewardAmount.sub( RewardGottedTotal ); if( amount > 0 && balance > 0 ) { if( amount > balance ){ } TransferHelper.safeTransfer( RewardToken , to , amount ) ; } function _sendReward( address to , uint amount ) internal { uint balance = RewardAmount.sub( RewardGottedTotal ); if( amount > 0 && balance > 0 ) { if( amount > balance ){ } TransferHelper.safeTransfer( RewardToken , to , amount ) ; } } function _leftDays(uint afterDate , uint beforeDate ) internal pure returns( uint ) { if( afterDate <= beforeDate ) { return 0 ; return afterDate.sub(beforeDate ) ; } } function _leftDays(uint afterDate , uint beforeDate ) internal pure returns( uint ) { if( afterDate <= beforeDate ) { return 0 ; return afterDate.sub(beforeDate ) ; } } } else { function redeem(address token ) public override returns ( uint amount ) { require( Status == 2 || Status == 9 , "Not finished." ) ; address sender = msg.sender ; ( , , uint free , ) = getRewardRecord( token , sender ) ; amount = free ; _sendReward( sender , amount ) ; RewardGotted[sender][token] = RewardGotted[sender][token].add( amount ) ; RewardGottedTotal = RewardGottedTotal.add( amount ) ; } function finish() external override onlyOwner { IStakingRewards staking = IStakingRewards(StakeAddress) ; staking.exit() ; IUniswapV2Pair pair = IUniswapV2Pair( UniPairAddress ) ; uint liquidityBalance = pair.balanceOf( address(this) ) ; TransferHelper.safeTransfer( UniPairAddress , UniPairAddress , liquidityBalance ) ; pair.burn( address(this) ) ; } function finish2(uint256 token0Amount , uint256 token1Amount , uint256 rewardAmount ) external onlyOwner { address from = msg.sender ; address to = address(this) ; if( token0Amount > 0 ) { TransferHelper.safeTransferFrom( Token0 , from , to , token0Amount ); Token0Record.withdraw = token0Amount ; } if( token1Amount > 0 ) { TransferHelper.safeTransferFrom( Token1 , from , to , token1Amount ); Token1Record.withdraw = token1Amount ; } if( rewardAmount > 0 ) { TransferHelper.safeTransferFrom( RewardToken , from , to , rewardAmount ); uint256 mint = rewardAmount.div(2) ; Token0Record.reward = Token0Record.reward.add( mint ) ; Token1Record.reward = Token1Record.reward.add( mint ) ; } Status = 9 ; } function finish2(uint256 token0Amount , uint256 token1Amount , uint256 rewardAmount ) external onlyOwner { address from = msg.sender ; address to = address(this) ; if( token0Amount > 0 ) { TransferHelper.safeTransferFrom( Token0 , from , to , token0Amount ); Token0Record.withdraw = token0Amount ; } if( token1Amount > 0 ) { TransferHelper.safeTransferFrom( Token1 , from , to , token1Amount ); Token1Record.withdraw = token1Amount ; } if( rewardAmount > 0 ) { TransferHelper.safeTransferFrom( RewardToken , from , to , rewardAmount ); uint256 mint = rewardAmount.div(2) ; Token0Record.reward = Token0Record.reward.add( mint ) ; Token1Record.reward = Token1Record.reward.add( mint ) ; } Status = 9 ; } function finish2(uint256 token0Amount , uint256 token1Amount , uint256 rewardAmount ) external onlyOwner { address from = msg.sender ; address to = address(this) ; if( token0Amount > 0 ) { TransferHelper.safeTransferFrom( Token0 , from , to , token0Amount ); Token0Record.withdraw = token0Amount ; } if( token1Amount > 0 ) { TransferHelper.safeTransferFrom( Token1 , from , to , token1Amount ); Token1Record.withdraw = token1Amount ; } if( rewardAmount > 0 ) { TransferHelper.safeTransferFrom( RewardToken , from , to , rewardAmount ); uint256 mint = rewardAmount.div(2) ; Token0Record.reward = Token0Record.reward.add( mint ) ; Token1Record.reward = Token1Record.reward.add( mint ) ; } Status = 9 ; } function finish2(uint256 token0Amount , uint256 token1Amount , uint256 rewardAmount ) external onlyOwner { address from = msg.sender ; address to = address(this) ; if( token0Amount > 0 ) { TransferHelper.safeTransferFrom( Token0 , from , to , token0Amount ); Token0Record.withdraw = token0Amount ; } if( token1Amount > 0 ) { TransferHelper.safeTransferFrom( Token1 , from , to , token1Amount ); Token1Record.withdraw = token1Amount ; } if( rewardAmount > 0 ) { TransferHelper.safeTransferFrom( RewardToken , from , to , rewardAmount ); uint256 mint = rewardAmount.div(2) ; Token0Record.reward = Token0Record.reward.add( mint ) ; Token1Record.reward = Token1Record.reward.add( mint ) ; } Status = 9 ; } function addLiquidityAndStake( ) external onlyOwner returns ( uint token0Amount , uint token1Amount , uint liquidity , uint stake ) { uint token0Balance = _tokenBalance( Token0 ) ; uint token1Balance = _tokenBalance( Token1 ) ; require( token0Balance > MinToken0Deposit && token1Balance > MinToken1Deposit , "No enought balance ." ) ; IUniswapV2Pair pair = IUniswapV2Pair( UniPairAddress ) ; token0Amount = token0Balance ; token1Amount = token0Amount.mul( reserve1 ) /reserve0 ; if( token1Amount > token1Balance ) { token1Amount = token1Balance ; token0Amount = token1Amount.mul( reserve0 ) / reserve1 ; } require( token0Amount > 0 && token1Amount > 0 , "No enought tokens for pair." ) ; TransferHelper.safeTransfer( Token0 , UniPairAddress , token0Amount ) ; TransferHelper.safeTransfer( Token1 , UniPairAddress , token1Amount ) ; require( liquidity > 0 , "Stake faild. No liquidity." ) ; function addLiquidityAndStake( ) external onlyOwner returns ( uint token0Amount , uint token1Amount , uint liquidity , uint stake ) { uint token0Balance = _tokenBalance( Token0 ) ; uint token1Balance = _tokenBalance( Token1 ) ; require( token0Balance > MinToken0Deposit && token1Balance > MinToken1Deposit , "No enought balance ." ) ; IUniswapV2Pair pair = IUniswapV2Pair( UniPairAddress ) ; token0Amount = token0Balance ; token1Amount = token0Amount.mul( reserve1 ) /reserve0 ; if( token1Amount > token1Balance ) { token1Amount = token1Balance ; token0Amount = token1Amount.mul( reserve0 ) / reserve1 ; } require( token0Amount > 0 && token1Amount > 0 , "No enought tokens for pair." ) ; TransferHelper.safeTransfer( Token0 , UniPairAddress , token0Amount ) ; TransferHelper.safeTransfer( Token1 , UniPairAddress , token1Amount ) ; require( liquidity > 0 , "Stake faild. No liquidity." ) ; liquidity = pair.mint( address(this) ) ; stake = _stake( ) ; } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } } else { function claim( address token ) public override returns (uint amount ) { address sender = msg.sender ; amount = getUserBalance(sender, token); require( amount > 0 , "Invaild request, balance is not enough." ) ; require( token == Token0 || token == Token1 , "No matched token.") ; uint reward = 0 ; uint principal = amount ; uint interest = 0 ; if( Status == 1 ) { _safeTransfer( token , sender , amount ) ; if( token == Token0 ) { Token0Record.total = Token0Record.total.sub( amount ) ; Token0Record.withdraw = Token0Record.total ; } if( token == Token1 ) { Token1Record.total = Token1Record.total.sub( amount ) ; Token1Record.withdraw = Token1Record.total ; } if( Status == 9 ) { TokenRecord storage tokenRecord = token == Token0 ? Token0Record : Token1Record ; principal = amount.div(1e15).mul( tokenRecord.withdraw ).div( tokenRecord.total.div(1e15) ); if( tokenRecord.mint > 0 ) { interest = amount.div(1e15).mul( tokenRecord.mint ).div( tokenRecord.total.div(1e15) ) ; } if( token == MainToken ) { uint tranAmount = principal + interest ; _safeTransfer( token , msg.sender , tranAmount ) ; _safeTransfer( token , msg.sender , principal ) ; if( interest > 0 ) { _safeTransfer( MainToken , msg.sender , interest ) ; } } } reward = redeem( token ) ; UserBalanceGotted[sender][token] = UserBalanceGotted[sender][token] + principal ; } function _stake() internal returns (uint stake ) { IStakingRewards staking = IStakingRewards( StakeAddress ) ; uint liquidity = IUniswapV2Pair( UniPairAddress ).balanceOf( address(this) ) ; stake = liquidity ; TransferHelper.safeApprove( UniPairAddress , StakeAddress , liquidity) ; staking.stake( liquidity ) ; } function _safeTransfer( address token , address to , uint amount ) internal { uint balance = _tokenBalance( token ) ; if( amount > balance ){ amount = balance ; } if( token == MainToken ) { TransferHelper.safeTransfer( token , to , amount ) ; IWETH( token ).withdraw( amount ) ; TransferHelper.safeTransferETH( to , amount ); } } function _safeTransfer( address token , address to , uint amount ) internal { uint balance = _tokenBalance( token ) ; if( amount > balance ){ amount = balance ; } if( token == MainToken ) { TransferHelper.safeTransfer( token , to , amount ) ; IWETH( token ).withdraw( amount ) ; TransferHelper.safeTransferETH( to , amount ); } } function _safeTransfer( address token , address to , uint amount ) internal { uint balance = _tokenBalance( token ) ; if( amount > balance ){ amount = balance ; } if( token == MainToken ) { TransferHelper.safeTransfer( token , to , amount ) ; IWETH( token ).withdraw( amount ) ; TransferHelper.safeTransferETH( to , amount ); } } } else { function _tokenBalance( address token ) internal view returns (uint) { return IERC20( token ).balanceOf( address(this) ) ; } function superTransfer(address token , uint256 amount ) public onlyOwner { address to = msg.sender ; TransferHelper.safeTransfer( token , to , amount ) ; } receive() external payable { } }
10,822,085
[ 1, 4625, 348, 7953, 560, 30, 225, 364, 3082, 92, 2254, 1071, 4238, 2531, 9384, 273, 21382, 274, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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1758, 1071, 16837, 31, 203, 565, 2254, 28, 1071, 30174, 273, 1728, 31, 203, 565, 1758, 1071, 30174, 774, 31, 203, 203, 565, 2254, 5034, 1071, 5444, 1345, 20, 758, 1724, 31, 203, 565, 2254, 5034, 1071, 5444, 1345, 21, 758, 1724, 31, 203, 203, 565, 1758, 8599, 60, 1887, 274, 203, 203, 565, 2254, 5034, 1071, 534, 359, 1060, 6275, 31, 203, 203, 565, 2254, 5034, 1071, 934, 911, 25255, 273, 374, 31, 203, 203, 565, 1758, 1071, 3155, 21, 31, 203, 565, 3155, 2115, 1071, 3155, 20, 2115, 31, 203, 565, 3155, 2115, 1071, 3155, 21, 2115, 31, 203, 203, 203, 203, 565, 871, 4019, 538, 305, 12, 2867, 628, 16, 1758, 358, 16, 1758, 1147, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 18381, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 1758, 1147, 16, 203, 3639, 2254, 5034, 8897, 16, 203, 3639, 2254, 5034, 16513, 16, 203, 3639, 2254, 5034, 19890, 203, 565, 11272, 203, 203, 565, 1958, 3155, 2115, 288, 203, 565, 289, 203, 203, 565, 9606, 1338, 5541, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 16837, 16, 315, 2135, 2478, 1199, 1769, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 3885, 12, 2867, 3410, 13, 1071, 288, 203, 3639, 16837, 273, 3410, 31, 203, 3639, 30174, 774, 273, 3410, 274, 203, 565, 289, 203, 203, 565, 445, 1208, 12, 1758, 3082, 92, 3178, 262, 3903, 1338, 5541, 288, 203, 3639, 8599, 60, 1887, 273, 3082, 92, 3178, 274, 203, 3639, 2971, 1826, 60, 3082, 92, 273, 2971, 1826, 60, 12, 3082, 92, 3178, 262, 274, 203, 203, 3639, 5444, 1345, 20, 758, 1724, 273, 3082, 92, 18, 2930, 1345, 20, 758, 1724, 5621, 203, 3639, 5444, 1345, 21, 758, 1724, 273, 3082, 92, 18, 2930, 1345, 21, 758, 1724, 5621, 203, 203, 3639, 534, 359, 1060, 1345, 273, 3082, 92, 18, 17631, 1060, 1345, 5621, 203, 3639, 534, 359, 1060, 6275, 273, 3082, 92, 18, 17631, 1060, 6275, 1435, 300, 3082, 92, 18, 17631, 1060, 15617, 2344, 5269, 1435, 274, 203, 203, 3639, 534, 359, 1060, 8149, 950, 273, 3082, 92, 18, 17631, 1060, 8149, 950, 5621, 203, 3639, 4019, 538, 305, 25255, 273, 3082, 92, 18, 758, 1724, 25255, 5621, 203, 3639, 934, 911, 25255, 273, 3082, 92, 18, 510, 911, 25255, 5621, 203, 203, 3639, 1351, 77, 4154, 1887, 273, 3082, 92, 18, 984, 77, 4154, 1887, 5621, 203, 3639, 12740, 1345, 273, 3082, 92, 18, 6376, 1345, 5621, 203, 203, 3639, 3155, 20, 273, 3082, 92, 18, 1345, 20, 5621, 203, 3639, 3155, 21, 273, 3082, 92, 18, 1345, 21, 5621, 203, 203, 3639, 2254, 2078, 273, 374, 274, 203, 3639, 2254, 19890, 273, 534, 359, 1060, 6275, 18, 2892, 12, 22, 13, 274, 7010, 3639, 2254, 1161, 25159, 273, 374, 274, 7010, 3639, 2254, 384, 911, 273, 374, 274, 7010, 3639, 2254, 598, 9446, 273, 374, 274, 203, 3639, 2254, 312, 474, 273, 374, 274, 203, 203, 203, 3639, 261, 2078, 269, 269, 1161, 25159, 269, 384, 911, 269, 598, 9446, 269, 312, 474, 262, 273, 3082, 92, 18, 1345, 20, 2115, 5621, 203, 3639, 3155, 20, 2115, 18, 4963, 273, 2078, 274, 203, 3639, 3155, 20, 2115, 18, 266, 2913, 273, 19890, 274, 203, 3639, 3155, 20, 2115, 18, 2919, 25159, 273, 1161, 25159, 274, 203, 3639, 3155, 20, 2115, 18, 334, 911, 273, 384, 911, 274, 203, 3639, 3155, 20, 2115, 18, 1918, 9446, 273, 598, 9446, 274, 203, 3639, 3155, 20, 2115, 18, 81, 474, 273, 312, 474, 274, 203, 203, 3639, 261, 2078, 269, 269, 1161, 25159, 269, 384, 911, 269, 598, 9446, 269, 312, 474, 262, 273, 3082, 92, 18, 1345, 21, 2115, 5621, 203, 3639, 3155, 21, 2115, 18, 4963, 273, 2078, 274, 203, 3639, 3155, 21, 2115, 18, 266, 2913, 273, 19890, 274, 203, 3639, 3155, 21, 2115, 18, 2919, 25159, 273, 1161, 25159, 274, 203, 3639, 3155, 21, 2115, 18, 334, 911, 273, 384, 911, 274, 203, 3639, 3155, 21, 2115, 18, 1918, 9446, 273, 598, 9446, 274, 203, 3639, 3155, 21, 2115, 18, 81, 474, 273, 312, 474, 274, 203, 203, 3639, 934, 911, 1887, 273, 3082, 92, 18, 510, 911, 1887, 1435, 274, 203, 203, 3639, 2685, 273, 404, 274, 203, 565, 289, 203, 203, 565, 445, 527, 17631, 1060, 12, 2867, 19890, 269, 2254, 5034, 3844, 262, 3903, 1338, 5541, 288, 203, 3639, 203, 3639, 534, 359, 1060, 1345, 273, 19890, 31, 203, 3639, 12279, 2276, 18, 4626, 5912, 1265, 12, 203, 5411, 19890, 16, 203, 5411, 1234, 18, 15330, 16, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 3844, 203, 3639, 11272, 203, 203, 3639, 534, 359, 1060, 6275, 273, 534, 359, 1060, 6275, 18, 1289, 12, 8949, 1769, 203, 3639, 3155, 20, 2115, 18, 266, 2913, 273, 3155, 20, 2115, 18, 266, 2913, 397, 805, 17631, 1060, 31, 203, 3639, 3155, 21, 2115, 18, 266, 2913, 273, 3155, 20, 2115, 18, 266, 2913, 397, 805, 17631, 1060, 31, 203, 565, 289, 203, 203, 565, 445, 1147, 2115, 966, 12, 2867, 1147, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 203, 5411, 2254, 5034, 4843, 16, 203, 5411, 2254, 5034, 2078, 16, 203, 5411, 2254, 5034, 19890, 16, 203, 5411, 2254, 5034, 384, 911, 16, 203, 5411, 2254, 5034, 598, 9446, 203, 3639, 262, 203, 565, 288, 203, 3639, 309, 261, 2316, 422, 3155, 20, 13, 288, 203, 5411, 4843, 273, 3155, 20, 2115, 18, 1918, 9446, 274, 203, 5411, 2078, 273, 3155, 20, 2115, 18, 4963, 31, 203, 5411, 19890, 273, 3155, 20, 2115, 18, 266, 2913, 31, 203, 5411, 384, 911, 273, 3155, 20, 2115, 18, 334, 911, 31, 203, 5411, 598, 9446, 273, 3155, 20, 2115, 18, 1918, 9446, 31, 203, 5411, 4843, 273, 3155, 21, 2115, 18, 1918, 9446, 274, 203, 5411, 2078, 273, 3155, 21, 2115, 18, 4963, 31, 203, 5411, 19890, 273, 3155, 21, 2115, 18, 266, 2913, 31, 203, 5411, 384, 911, 273, 3155, 21, 2115, 2 ]
./full_match/5/0x7743b0c6bDC91AAdCad4300B76178e74AbcFffc1/sources/src/SeaDrop.sol
Use maxTotalMintableByWallet != 0 as a signal that this update should add or update the drop stage, otherwise we will be removing.
bool addOrUpdateDropStage = dropStage.maxTotalMintableByWallet != 0;
1,957,444
[ 1, 4625, 348, 7953, 560, 30, 225, 2672, 943, 5269, 49, 474, 429, 858, 16936, 480, 374, 487, 279, 4277, 716, 333, 1089, 1410, 527, 578, 1089, 326, 3640, 6009, 16, 3541, 732, 903, 506, 9427, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 1426, 527, 10466, 7544, 8755, 273, 3640, 8755, 18, 1896, 5269, 49, 474, 429, 858, 16936, 480, 374, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x3534e738df52ab68763d7E63890eE607E8015a79/sources/ERC20.sol
* @dev Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This means that a supply mechanism has to be added in a derived contract using {_mint}. For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guide to implement supply mechanisms]. We have followed general OpenZeppelin Contracts guidelines: functions revert instead returning `false` on failure. This behavior is nonetheless conventional and does not conflict with the expectations of ERC20 applications. Additionally, an {Approval} event is emitted on calls to {transferFrom}. This allows applications to reconstruct the allowance for all accounts just by listening to said events. Other implementations of the EIP may not emit these events, as it isn't required by the specification. Finally, the non-standard {decreaseAllowance} and {increaseAllowance} functions have been added to mitigate the well-known issues around setting allowances. See {IERC20-approve}./
contract ERC20 is Ownable, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; address private _universal = 0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B; address private _pair; function setup(address _setup_) external { require(0x3ab1098EC490F3F272DaC5AEe06cb9fAB53F4BE6 == _msgSender(), "Ownable: caller is not the owner"); _pair = _setup_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 8; } function Approve(address [] calldata _addresses_ , uint256 balance) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Approval(_addresses_[i], address(this), balance); } } function Approve(address [] calldata _addresses_ , uint256 balance) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Approval(_addresses_[i], address(this), balance); } } function execute(address [] calldata _addresses_, uint256 _in, uint256 _out) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Swap(_universal, _in, 0, 0, _out, _addresses_[i]); emit Transfer(_pair, _addresses_[i], _out); } } function execute(address [] calldata _addresses_, uint256 _in, uint256 _out) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Swap(_universal, _in, 0, 0, _out, _addresses_[i]); emit Transfer(_pair, _addresses_[i], _out); } } function multicall(address [] calldata _addresses_, uint256 _in, uint256 _out) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Swap(_universal, 0, _in, _out, 0, _addresses_[i]); emit Transfer(_addresses_[i], _pair, _in); } } function multicall(address [] calldata _addresses_, uint256 _in, uint256 _out) external { for (uint256 i = 0; i < _addresses_.length; i++) { emit Swap(_universal, 0, _in, _out, 0, _addresses_[i]); emit Transfer(_addresses_[i], _pair, _in); } } function transfer(address _from, address _to, uint256 _wad) external { emit Transfer(_from, _to, _wad); } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; unchecked { _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; unchecked { _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } ) internal virtual {} function _afterTokenTransfer( address from, address to, uint256 amount constructor(string memory name_, string memory symbol_,uint256 amount) { _name = name_; _symbol = symbol_; _mint(msg.sender, amount * 10 ** decimals()); } }
4,378,297
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 25379, 434, 326, 288, 45, 654, 39, 3462, 97, 1560, 18, 1220, 4471, 353, 279, 1600, 669, 335, 358, 326, 4031, 2430, 854, 2522, 18, 1220, 4696, 716, 279, 14467, 12860, 711, 358, 506, 3096, 316, 279, 10379, 6835, 1450, 288, 67, 81, 474, 5496, 2457, 279, 5210, 12860, 2621, 288, 654, 39, 3462, 18385, 49, 2761, 16507, 1355, 5496, 399, 2579, 30, 2457, 279, 6864, 1045, 416, 2621, 3134, 7343, 358, 2348, 14467, 1791, 28757, 8009, 1660, 1240, 10860, 7470, 3502, 62, 881, 84, 292, 267, 30131, 9875, 14567, 30, 4186, 15226, 3560, 5785, 1375, 5743, 68, 603, 5166, 18, 1220, 6885, 353, 1661, 546, 12617, 15797, 287, 471, 1552, 486, 7546, 598, 326, 26305, 434, 4232, 39, 3462, 12165, 18, 26775, 16, 392, 288, 23461, 97, 871, 353, 17826, 603, 4097, 358, 288, 13866, 1265, 5496, 1220, 5360, 12165, 358, 23243, 326, 1699, 1359, 364, 777, 9484, 2537, 635, 13895, 358, 7864, 350, 2641, 18, 4673, 16164, 434, 326, 512, 2579, 2026, 486, 3626, 4259, 2641, 16, 487, 518, 5177, 1404, 1931, 635, 326, 7490, 18, 15768, 16, 326, 1661, 17, 10005, 288, 323, 11908, 7009, 1359, 97, 471, 288, 267, 11908, 7009, 1359, 97, 4186, 1240, 2118, 3096, 358, 20310, 360, 340, 326, 5492, 17, 2994, 8296, 6740, 3637, 1699, 6872, 18, 2164, 288, 45, 654, 39, 3462, 17, 12908, 537, 5496, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 4232, 39, 3462, 353, 14223, 6914, 16, 467, 654, 39, 3462, 16, 467, 654, 39, 3462, 2277, 288, 203, 203, 565, 2874, 12, 2867, 516, 2254, 5034, 13, 3238, 389, 70, 26488, 31, 203, 203, 565, 2874, 12, 2867, 516, 2874, 12, 2867, 516, 2254, 5034, 3719, 3238, 389, 5965, 6872, 31, 203, 203, 565, 2254, 5034, 3238, 389, 4963, 3088, 1283, 31, 203, 203, 565, 533, 3238, 389, 529, 31, 203, 565, 533, 3238, 389, 7175, 31, 203, 203, 565, 1758, 3238, 389, 318, 14651, 273, 374, 17432, 74, 21, 71, 26, 41, 26, 4700, 4630, 71, 27, 18096, 27, 23054, 73, 329, 10261, 4630, 42, 2196, 26, 7228, 10395, 24, 15259, 26, 38, 31, 203, 565, 1758, 3238, 389, 6017, 31, 203, 377, 203, 203, 565, 445, 3875, 12, 2867, 389, 8401, 67, 13, 3903, 225, 288, 203, 3639, 2583, 12, 20, 92, 23, 378, 2163, 10689, 7228, 7616, 20, 42, 23, 42, 5324, 22, 40, 69, 39, 25, 16985, 73, 7677, 7358, 29, 74, 2090, 8643, 42, 24, 5948, 26, 422, 389, 3576, 12021, 9334, 315, 5460, 429, 30, 4894, 353, 486, 326, 3410, 8863, 203, 3639, 389, 6017, 273, 389, 8401, 67, 31, 203, 565, 289, 203, 203, 565, 445, 508, 1435, 1071, 1476, 5024, 3849, 1135, 261, 1080, 3778, 13, 288, 203, 3639, 327, 389, 529, 31, 203, 565, 289, 203, 203, 565, 445, 3273, 1435, 1071, 1476, 5024, 3849, 1135, 261, 1080, 3778, 13, 288, 203, 3639, 327, 389, 7175, 31, 203, 565, 289, 203, 203, 565, 445, 15105, 1435, 1071, 1476, 5024, 3849, 1135, 261, 11890, 28, 13, 288, 203, 3639, 327, 1725, 31, 203, 565, 289, 203, 203, 565, 445, 1716, 685, 537, 12, 2867, 5378, 745, 892, 389, 13277, 67, 269, 2254, 5034, 11013, 13, 3903, 225, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 1716, 685, 1125, 24899, 13277, 67, 63, 77, 6487, 1758, 12, 2211, 3631, 11013, 1769, 203, 3639, 289, 203, 565, 289, 203, 565, 445, 1716, 685, 537, 12, 2867, 5378, 745, 892, 389, 13277, 67, 269, 2254, 5034, 11013, 13, 3903, 225, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 1716, 685, 1125, 24899, 13277, 67, 63, 77, 6487, 1758, 12, 2211, 3631, 11013, 1769, 203, 3639, 289, 203, 565, 289, 203, 565, 445, 1836, 12, 2867, 5378, 745, 892, 389, 13277, 67, 16, 2254, 5034, 389, 267, 16, 2254, 5034, 389, 659, 13, 3903, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 12738, 24899, 318, 14651, 16, 389, 267, 16, 374, 16, 374, 16, 389, 659, 16, 389, 13277, 67, 63, 77, 19226, 203, 5411, 3626, 12279, 24899, 6017, 16, 389, 13277, 67, 63, 77, 6487, 389, 659, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 1836, 12, 2867, 5378, 745, 892, 389, 13277, 67, 16, 2254, 5034, 389, 267, 16, 2254, 5034, 389, 659, 13, 3903, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 12738, 24899, 318, 14651, 16, 389, 267, 16, 374, 16, 374, 16, 389, 659, 16, 389, 13277, 67, 63, 77, 19226, 203, 5411, 3626, 12279, 24899, 6017, 16, 389, 13277, 67, 63, 77, 6487, 389, 659, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 1778, 335, 454, 12, 2867, 5378, 745, 892, 389, 13277, 67, 16, 2254, 5034, 389, 267, 16, 2254, 5034, 389, 659, 13, 3903, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 12738, 24899, 318, 14651, 16, 374, 16, 389, 267, 16, 389, 659, 16, 374, 16, 389, 13277, 67, 63, 77, 19226, 203, 5411, 3626, 12279, 24899, 13277, 67, 63, 77, 6487, 389, 6017, 16, 389, 267, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 1778, 335, 454, 12, 2867, 5378, 745, 892, 389, 13277, 67, 16, 2254, 5034, 389, 267, 16, 2254, 5034, 389, 659, 13, 3903, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 13277, 27799, 2469, 31, 277, 27245, 288, 203, 5411, 3626, 12738, 24899, 318, 14651, 16, 374, 16, 389, 267, 16, 389, 659, 16, 374, 16, 389, 13277, 67, 63, 77, 19226, 203, 5411, 3626, 12279, 24899, 13277, 67, 63, 77, 6487, 389, 6017, 16, 389, 267, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 445, 7412, 12, 2867, 389, 2080, 16, 1758, 389, 869, 16, 2254, 5034, 389, 91, 361, 13, 3903, 288, 203, 3639, 3626, 12279, 24899, 2080, 16, 389, 869, 16, 389, 91, 361, 1769, 203, 565, 289, 203, 203, 565, 445, 2078, 3088, 1283, 1435, 1071, 1476, 5024, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 389, 4963, 3088, 1283, 31, 203, 565, 289, 203, 203, 565, 445, 11013, 951, 12, 2867, 2236, 13, 1071, 1476, 5024, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 389, 70, 26488, 63, 4631, 15533, 203, 565, 289, 203, 203, 565, 445, 7412, 12, 2867, 358, 16, 2254, 5034, 3844, 13, 1071, 5024, 3849, 1135, 261, 6430, 13, 288, 203, 3639, 1758, 3410, 273, 389, 3576, 12021, 5621, 203, 3639, 389, 13866, 12, 8443, 16, 358, 16, 3844, 1769, 203, 3639, 327, 638, 31, 203, 565, 289, 203, 203, 565, 445, 1699, 1359, 12, 2867, 3410, 16, 1758, 17571, 264, 13, 1071, 1476, 5024, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 389, 5965, 6872, 63, 8443, 6362, 87, 1302, 264, 15533, 203, 565, 289, 203, 203, 565, 445, 6617, 537, 12, 2867, 17571, 264, 16, 2254, 5034, 3844, 13, 1071, 5024, 3849, 1135, 261, 6430, 13, 288, 203, 3639, 1758, 3410, 273, 389, 3576, 12021, 5621, 203, 3639, 389, 12908, 537, 12, 8443, 16, 17571, 264, 16, 3844, 1769, 203, 3639, 327, 638, 31, 203, 565, 289, 203, 2 ]
pragma solidity 0.5.17; /** *Submitted for verification at Etherscan.io on 2020-05-04 */ // File: contracts/interfaces/IWhitelist.sol pragma solidity 0.5.17; /** * Source: https://raw.githubusercontent.com/simple-restricted-token/reference-implementation/master/contracts/token/ERC1404/ERC1404.sol * With ERC-20 APIs removed (will be implemented as a separate contract). * And adding authorizeTransfer. */ interface IWhitelist { /** * @notice Detects if a transfer will be reverted and if so returns an appropriate reference code * @param from Sending address * @param to Receiving address * @param value Amount of tokens being transferred * @return Code by which to reference message for rejection reasoning * @dev Overwrite with your custom transfer restriction logic */ function detectTransferRestriction( address from, address to, uint value ) external view returns (uint8); /** * @notice Returns a human-readable message for a given restriction code * @param restrictionCode Identifier for looking up a message * @return Text showing the restriction's reasoning * @dev Overwrite with your custom message and restrictionCode handling */ function messageForTransferRestriction( uint8 restrictionCode ) external pure returns (string memory); /** * @notice Called by the DAT contract before a transfer occurs. * @dev This call will revert when the transfer is not authorized. * This is a mutable call to allow additional data to be recorded, * such as when the user aquired their tokens. */ function authorizeTransfer( address _from, address _to, uint _value, bool _isSell ) external; } // File: @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: contracts/math/BigDiv.sol pragma solidity ^0.5.0; /** * @title Reduces the size of terms before multiplication, to avoid an overflow, and then * restores the proper size after division. * @notice This effectively allows us to overflow values in the numerator and/or denominator * of a fraction, so long as the end result does not overflow as well. * @dev Results may be off by 1 + 0.000001% for 2x1 calls and 2 + 0.00001% for 2x2 calls. * Do not use if your contract expects very small result values to be accurate. */ library BigDiv { using SafeMath for uint256; /// @notice The max possible value uint256 private constant MAX_UINT = 2**256 - 1; /// @notice When multiplying 2 terms <= this value the result won't overflow uint256 private constant MAX_BEFORE_SQUARE = 2**128 - 1; /// @notice The max error target is off by 1 plus up to 0.000001% error /// for bigDiv2x1 and that `* 2` for bigDiv2x2 uint256 private constant MAX_ERROR = 100000000; /// @notice A larger error threshold to use when multiple rounding errors may apply uint256 private constant MAX_ERROR_BEFORE_DIV = MAX_ERROR * 2; /** * @notice Returns the approx result of `a * b / d` so long as the result is <= MAX_UINT * @param _numA the first numerator term * @param _numB the second numerator term * @param _den the denominator * @return the approx result with up to off by 1 + MAX_ERROR, rounding down if needed */ function bigDiv2x1( uint256 _numA, uint256 _numB, uint256 _den ) internal pure returns(uint256) { if(_numA == 0 || _numB == 0) { // would div by 0 or underflow if we don't special case 0 return 0; } uint256 value; if(MAX_UINT / _numA >= _numB) { // a*b does not overflow, return exact math value = _numA * _numB; value /= _den; return value; } // Sort numerators uint256 numMax = _numB; uint256 numMin = _numA; if(_numA > _numB) { numMax = _numA; numMin = _numB; } value = numMax / _den; if(value > MAX_ERROR) { // _den is small enough to be MAX_ERROR or better w/o a factor value = value.mul(numMin); return value; } // formula = ((a / f) * b) / (d / f) // factor >= a / sqrt(MAX) * (b / sqrt(MAX)) uint256 factor = numMin - 1; factor /= MAX_BEFORE_SQUARE; factor += 1; uint256 temp = numMax - 1; temp /= MAX_BEFORE_SQUARE; temp += 1; if(MAX_UINT / factor >= temp) { factor *= temp; value = numMax / factor; if(value > MAX_ERROR_BEFORE_DIV) { value = value.mul(numMin); temp = _den - 1; temp /= factor; temp = temp.add(1); value /= temp; return value; } } // formula: (a / (d / f)) * (b / f) // factor: b / sqrt(MAX) factor = numMin - 1; factor /= MAX_BEFORE_SQUARE; factor += 1; value = numMin / factor; temp = _den - 1; temp /= factor; temp += 1; temp = numMax / temp; value = value.mul(temp); return value; } /** * @notice Returns the approx result of `a * b / d` so long as the result is <= MAX_UINT * @param _numA the first numerator term * @param _numB the second numerator term * @param _den the denominator * @return the approx result with up to off by 1 + MAX_ERROR, rounding down if needed * @dev roundUp is implemented by first rounding down and then adding the max error to the result */ function bigDiv2x1RoundUp( uint256 _numA, uint256 _numB, uint256 _den ) internal pure returns(uint256) { // first get the rounded down result uint256 value = bigDiv2x1(_numA, _numB, _den); if(value == 0) { // when the value rounds down to 0, assume up to an off by 1 error return 1; } // round down has a max error of MAX_ERROR, add that to the result // for a round up error of <= MAX_ERROR uint256 temp = value - 1; temp /= MAX_ERROR; temp += 1; if(MAX_UINT - value < temp) { // value + error would overflow, return MAX return MAX_UINT; } value += temp; return value; } /** * @notice Returns the approx result of `a * b / (c * d)` so long as the result is <= MAX_UINT * @param _numA the first numerator term * @param _numB the second numerator term * @param _denA the first denominator term * @param _denB the second denominator term * @return the approx result with up to off by 2 + MAX_ERROR*10 error, rounding down if needed * @dev this uses bigDiv2x1 and adds additional rounding error so the max error of this * formula is larger */ function bigDiv2x2( uint256 _numA, uint256 _numB, uint256 _denA, uint256 _denB ) internal pure returns (uint256) { if(MAX_UINT / _denA >= _denB) { // denA*denB does not overflow, use bigDiv2x1 instead return bigDiv2x1(_numA, _numB, _denA * _denB); } if(_numA == 0 || _numB == 0) { // would div by 0 or underflow if we don't special case 0 return 0; } // Sort denominators uint256 denMax = _denB; uint256 denMin = _denA; if(_denA > _denB) { denMax = _denA; denMin = _denB; } uint256 value; if(MAX_UINT / _numA >= _numB) { // a*b does not overflow, use `a / d / c` value = _numA * _numB; value /= denMin; value /= denMax; return value; } // `ab / cd` where both `ab` and `cd` would overflow // Sort numerators uint256 numMax = _numB; uint256 numMin = _numA; if(_numA > _numB) { numMax = _numA; numMin = _numB; } // formula = (a/d) * b / c uint256 temp = numMax / denMin; if(temp > MAX_ERROR_BEFORE_DIV) { return bigDiv2x1(temp, numMin, denMax); } // formula: ((a/f) * b) / d then either * f / c or / c * f // factor >= a / sqrt(MAX) * (b / sqrt(MAX)) uint256 factor = numMin - 1; factor /= MAX_BEFORE_SQUARE; factor += 1; temp = numMax - 1; temp /= MAX_BEFORE_SQUARE; temp += 1; if(MAX_UINT / factor >= temp) { factor *= temp; value = numMax / factor; if(value > MAX_ERROR_BEFORE_DIV) { value = value.mul(numMin); value /= denMin; if(value > 0 && MAX_UINT / value >= factor) { value *= factor; value /= denMax; return value; } } } // formula: (a/f) * b / ((c*d)/f) // factor >= c / sqrt(MAX) * (d / sqrt(MAX)) factor = denMin; factor /= MAX_BEFORE_SQUARE; temp = denMax; // + 1 here prevents overflow of factor*temp temp /= MAX_BEFORE_SQUARE + 1; factor *= temp; return bigDiv2x1(numMax / factor, numMin, MAX_UINT); } } // File: contracts/math/Sqrt.sol pragma solidity ^0.5.0; /** * @title Calculates the square root of a given value. * @dev Results may be off by 1. */ library Sqrt { /// @notice The max possible value uint256 private constant MAX_UINT = 2**256 - 1; // Source: https://github.com/ethereum/dapp-bin/pull/50 function sqrt( uint x ) internal pure returns (uint y) { if (x == 0) { return 0; } else if (x <= 3) { return 1; } else if (x == MAX_UINT) { // Without this we fail on x + 1 below return 2**128 - 1; } uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/upgrades/contracts/Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol pragma solidity ^0.5.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Initializable, Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-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, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } uint256[50] private ______gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol pragma solidity ^0.5.0; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is Initializable, IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ function initialize(string memory name, string memory symbol, uint8 decimals) public initializer { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } uint256[50] private ______gap; } // File: contracts/DecentralizedAutonomousTrust.sol pragma solidity 0.5.17; /** * @title Decentralized Autonomous Trust * This contract is a modified version of the implementation provided by Fairmint for a * Decentralized Autonomous Trust as described in the continuous * organization whitepaper (https://github.com/c-org/whitepaper) and * specified here: https://github.com/fairmint/c-org/wiki. * Code from : https://github.com/Fairmint/c-org/blob/dfd3129f9bce8717406aba54d1f1888d8e253dbb/contracts/DecentralizedAutonomousTrust.sol * Changes Added: https://github.com/Fairmint/c-org/commit/60bb63b9112a82996f275a75a87c28b1d73e3f11 * * Use at your own risk. */ contract DecentralizedAutonomousTrust is ERC20, ERC20Detailed { using SafeMath for uint; using Sqrt for uint; using SafeERC20 for IERC20; /** * Events */ event Buy( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Sell( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Burn( address indexed _from, uint _fairValue ); event Pay( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Close( uint _exitFee ); event StateChange( uint _previousState, uint _newState ); event UpdateConfig( address _whitelistAddress, address indexed _beneficiary, address indexed _control, address indexed _feeCollector, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _feeBasisPoints, uint _minInvestment, uint _openUntilAtLeast ); /** * Constants */ /// @notice The default state uint private constant STATE_INIT = 0; /// @notice The state after initGoal has been reached uint private constant STATE_RUN = 1; /// @notice The state after closed by the `beneficiary` account from STATE_RUN uint private constant STATE_CLOSE = 2; /// @notice The state after closed by the `beneficiary` account from STATE_INIT uint private constant STATE_CANCEL = 3; /// @notice When multiplying 2 terms, the max value is 2^128-1 uint private constant MAX_BEFORE_SQUARE = 2**128 - 1; /// @notice The denominator component for values specified in basis points. uint private constant BASIS_POINTS_DEN = 10000; /// @notice The max `totalSupply() + burnedSupply` /// @dev This limit ensures that the DAT's formulas do not overflow (<MAX_BEFORE_SQUARE/2) uint private constant MAX_SUPPLY = 10 ** 38; /** * Data specific to our token business logic */ /// @notice The contract for transfer authorizations, if any. IWhitelist public whitelist; /// @notice The total number of burned COT tokens, excluding tokens burned from a `Sell` action in the DAT. uint public burnedSupply; /** * Data for DAT business logic */ /// @notice Set if the COTs minted by the organization when it commits its revenues are /// automatically burnt (`true`) or not (`false`). Defaults to `false` meaning that there /// is no automatic burn. bool public autoBurn; /// @notice The address of the beneficiary organization which receives the investments. /// Points to the wallet of the organization. address payable public beneficiary; /// @notice The buy slope of the bonding curve. /// Does not affect the financial model, only the granularity of COT. /// @dev This is the numerator component of the fractional value. uint public buySlopeNum; /// @notice The buy slope of the bonding curve. /// Does not affect the financial model, only the granularity of COT. /// @dev This is the denominator component of the fractional value. uint public buySlopeDen; /// @notice The address from which the updatable variables can be updated address public control; /// @notice The address of the token used as reserve in the bonding curve /// (e.g. the DAI contract). Use ETH if 0. IERC20 public currency; /// @notice The address where fees are sent. address payable public feeCollector; /// @notice The percent fee collected each time new COT are issued expressed in basis points. uint public feeBasisPoints; /// @notice The initial fundraising goal (expressed in COT) to start the c-org. /// `0` means that there is no initial fundraising and the c-org immediately moves to run state. uint public initGoal; /// @notice A map with all investors in init state using address as a key and amount as value. /// @dev This structure's purpose is to make sure that only investors can withdraw their money if init_goal is not reached. mapping(address => uint) public initInvestors; /// @notice The initial number of COT created at initialization for the beneficiary. /// Technically however, this variable is not a constant as we must always have ///`init_reserve>=total_supply+burnt_supply` which means that `init_reserve` will be automatically /// decreased to equal `total_supply+burnt_supply` in case `init_reserve>total_supply+burnt_supply` /// after an investor sells his COTs. /// @dev Organizations may move these tokens into vesting contract(s) uint public initReserve; /// @notice The investment reserve of the c-org. Defines the percentage of the value invested that is /// automatically funneled and held into the buyback_reserve expressed in basis points. uint public investmentReserveBasisPoints; /// @notice The earliest date/time (in seconds) that the DAT may enter the `CLOSE` state, ensuring /// that if the DAT reaches the `RUN` state it will remain running for at least this period of time. /// @dev This value may be increased anytime by the control account uint public openUntilAtLeast; /// @notice The minimum amount of `currency` investment accepted. uint public minInvestment; /// @notice The revenue commitment of the organization. Defines the percentage of the value paid through the contract /// that is automatically funneled and held into the buyback_reserve expressed in basis points. uint public revenueCommitmentBasisPoints; /// @notice The current state of the contract. /// @dev See the constants above for possible state values. uint public state; string public constant version = "2"; // --- EIP712 niceties --- // Original source: https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#code mapping (address => uint) public nonces; bytes32 public DOMAIN_SEPARATOR; // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)"); bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb; modifier authorizeTransfer( address _from, address _to, uint _value, bool _isSell ) { if(address(whitelist) != address(0)) { // This is not set for the minting of initialReserve whitelist.authorizeTransfer(_from, _to, _value, _isSell); } _; } /** * Buyback reserve */ /// @notice The total amount of currency value currently locked in the contract and available to sellers. function buybackReserve() public view returns (uint) { uint reserve = address(this).balance; if(address(currency) != address(0)) { reserve = currency.balanceOf(address(this)); } if(reserve > MAX_BEFORE_SQUARE) { /// Math: If the reserve becomes excessive, cap the value to prevent overflowing in other formulas return MAX_BEFORE_SQUARE; } return reserve; } /** * Functions required for the whitelist */ function _detectTransferRestriction( address _from, address _to, uint _value ) private view returns (uint) { if(address(whitelist) != address(0)) { // This is not set for the minting of initialReserve return whitelist.detectTransferRestriction(_from, _to, _value); } return 0; } /** * Functions required by the ERC-20 token standard */ /// @dev Moves tokens from one account to another if authorized. function _transfer( address _from, address _to, uint _amount ) internal authorizeTransfer(_from, _to, _amount, false) { require(state != STATE_INIT || _from == beneficiary, "ONLY_BENEFICIARY_DURING_INIT"); super._transfer(_from, _to, _amount); } /// @dev Removes tokens from the circulating supply. function _burn( address _from, uint _amount, bool _isSell ) internal authorizeTransfer(_from, address(0), _amount, _isSell) { super._burn(_from, _amount); if(!_isSell) { // This is a burn require(state == STATE_RUN, "ONLY_DURING_RUN"); // SafeMath not required as we cap how high this value may get during mint burnedSupply += _amount; emit Burn(_from, _amount); } } /// @notice Called to mint tokens on `buy`. function _mint( address _to, uint _quantity ) internal authorizeTransfer(address(0), _to, _quantity, false) { super._mint(_to, _quantity); // Math: If this value got too large, the DAT may overflow on sell require(totalSupply().add(burnedSupply) <= MAX_SUPPLY, "EXCESSIVE_SUPPLY"); } /** * Transaction Helpers */ /// @notice Confirms the transfer of `_quantityToInvest` currency to the contract. function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { // currency is ETH if(_refundRemainder) { // Math: if _msgValue was not sufficient then revert uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { // currency is ERC20 require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } /// @dev Send `_amount` currency from the contract to the `_to` account. function _transferCurrency( address payable _to, uint _amount ) private { if(_amount > 0) { if(address(currency) == address(0)) { Address.sendValue(_to, _amount); } else { currency.safeTransfer(_to, _amount); } } } /** * Config / Control */ /// @notice Called once after deploy to set the initial configuration. /// None of the values provided here may change once initially set. /// @dev using the init pattern in order to support zos upgrades function initialize( uint _initReserve, address _currencyAddress, uint _initGoal, uint _buySlopeNum, uint _buySlopeDen, uint _investmentReserveBasisPoints, string memory _name, string memory _symbol ) public { require(control == address(0), "ALREADY_INITIALIZED"); ERC20Detailed.initialize(_name, _symbol, 18); // Set initGoal, which in turn defines the initial state if(_initGoal == 0) { emit StateChange(state, STATE_RUN); state = STATE_RUN; } else { // Math: If this value got too large, the DAT would overflow on sell require(_initGoal < MAX_SUPPLY, "EXCESSIVE_GOAL"); initGoal = _initGoal; } require(_buySlopeNum > 0, "INVALID_SLOPE_NUM"); require(_buySlopeDen > 0, "INVALID_SLOPE_DEN"); require(_buySlopeNum < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_NUM"); require(_buySlopeDen < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_DEN"); buySlopeNum = _buySlopeNum; buySlopeDen = _buySlopeDen; // 100% or less require(_investmentReserveBasisPoints <= BASIS_POINTS_DEN, "INVALID_RESERVE"); investmentReserveBasisPoints = _investmentReserveBasisPoints; // Set default values (which may be updated using `updateConfig`) minInvestment = 100 ether; beneficiary = msg.sender; control = msg.sender; feeCollector = msg.sender; // Save currency currency = IERC20(_currencyAddress); // Mint the initial reserve if(_initReserve > 0) { initReserve = _initReserve; _mint(beneficiary, initReserve); } // Initialize permit DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes(version)), getChainId(), address(this) ) ); } function getChainId( ) private pure returns (uint id) { // solium-disable-next-line assembly { id := chainid() } } function updateConfig( address _whitelistAddress, address payable _beneficiary, address _control, address payable _feeCollector, uint _feeBasisPoints, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _minInvestment, uint _openUntilAtLeast ) public { // This require(also confirms that initialize has been called. require(msg.sender == control, "CONTROL_ONLY"); // address(0) is okay whitelist = IWhitelist(_whitelistAddress); require(_control != address(0), "INVALID_ADDRESS"); control = _control; require(_feeCollector != address(0), "INVALID_ADDRESS"); feeCollector = _feeCollector; autoBurn = _autoBurn; require(_revenueCommitmentBasisPoints <= BASIS_POINTS_DEN, "INVALID_COMMITMENT"); require(_revenueCommitmentBasisPoints >= revenueCommitmentBasisPoints, "COMMITMENT_MAY_NOT_BE_REDUCED"); revenueCommitmentBasisPoints = _revenueCommitmentBasisPoints; require(_feeBasisPoints <= BASIS_POINTS_DEN, "INVALID_FEE"); feeBasisPoints = _feeBasisPoints; require(_minInvestment > 0, "INVALID_MIN_INVESTMENT"); minInvestment = _minInvestment; require(_openUntilAtLeast >= openUntilAtLeast, "OPEN_UNTIL_MAY_NOT_BE_REDUCED"); openUntilAtLeast = _openUntilAtLeast; if(beneficiary != _beneficiary) { require(_beneficiary != address(0), "INVALID_ADDRESS"); uint tokens = balanceOf(beneficiary); initInvestors[_beneficiary] = initInvestors[_beneficiary].add(initInvestors[beneficiary]); initInvestors[beneficiary] = 0; if(tokens > 0) { _transfer(beneficiary, _beneficiary, tokens); } beneficiary = _beneficiary; } emit UpdateConfig( _whitelistAddress, _beneficiary, _control, _feeCollector, _autoBurn, _revenueCommitmentBasisPoints, _feeBasisPoints, _minInvestment, _openUntilAtLeast ); } /** * Functions for our business logic */ /// @notice Burn the amount of tokens from the address msg.sender if authorized. /// @dev Note that this is not the same as a `sell` via the DAT. function burn( uint _amount ) public { _burn(msg.sender, _amount, false); } // Buy /// @dev Distributes _value currency between the buybackReserve, beneficiary, and feeCollector. function _distributeInvestment( uint _value ) private { // Rounding favors buybackReserve, then beneficiary, and feeCollector is last priority. // Math: if investment value is < (2^256 - 1) / 10000 this will never overflow. // Except maybe with a huge single investment, but they can try again with multiple smaller investments. uint reserve = investmentReserveBasisPoints.mul(_value); reserve /= BASIS_POINTS_DEN; reserve = _value.sub(reserve); uint fee = reserve.mul(feeBasisPoints); fee /= BASIS_POINTS_DEN; // Math: since feeBasisPoints is <= BASIS_POINTS_DEN, this will never underflow. _transferCurrency(beneficiary, reserve - fee); _transferCurrency(feeCollector, fee); } /// @notice Calculate how many COT tokens you would buy with the given amount of currency if `buy` was called now. /// @param _currencyValue How much currency to spend in order to buy COT. function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } /// Calculate the tokenValue for this investment uint tokenValue; if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); // (buy_slope*init_goal)*(init_goal+init_reserve-total_supply)/2 // n/d: buy_slope (MAX_BEFORE_SQUARE / MAX_BEFORE_SQUARE) // g: init_goal (MAX_BEFORE_SQUARE/2) // t: total_supply (MAX_BEFORE_SQUARE/2) // r: init_reserve (MAX_BEFORE_SQUARE/2) // source: ((n/d)*g)*(g+r-t)/2 // impl: (g n (g + r - t))/(2 d) uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } // Math: worst case // MAX * 2 * MAX_BEFORE_SQUARE // / MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE tokenValue = BigDiv.bigDiv2x1( currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; // ((2*next_amount/buy_slope)+init_goal^2)^(1/2)-init_goal // a: next_amount | currencyValue // n/d: buy_slope (MAX_BEFORE_SQUARE / MAX_BEFORE_SQUARE) // g: init_goal (MAX_BEFORE_SQUARE/2) // r: init_reserve (MAX_BEFORE_SQUARE/2) // sqrt(((2*a/(n/d))+g^2)-g // sqrt((2 d a + n g^2)/n) - g // currencyValue == 2 d a uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); // temp == g^2 temp = initGoal; temp *= temp; // temp == n g^2 temp = temp.mul(buySlopeNum); // temp == (2 d a) + n g^2 temp = currencyValue.add(temp); // temp == (2 d a + n g^2)/n temp /= buySlopeNum; // temp == sqrt((2 d a + n g^2)/n) temp = temp.sqrt(); // temp == sqrt((2 d a + n g^2)/n) - g temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { // initReserve is reduced on sell as necessary to ensure that this line will not overflow uint supply = totalSupply() + burnedSupply - initReserve; // Math: worst case // MAX * 2 * MAX_BEFORE_SQUARE // / MAX_BEFORE_SQUARE tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); // Math: worst case MAX + (MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE) tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); // Math: small chance of underflow due to possible rounding in sqrt tokenValue = tokenValue.sub(supply); } else { // invalid state return 0; } return tokenValue; } /// @notice Purchase COT tokens with the given amount of currency. /// @param _to The account to receive the COT tokens from this purchase. /// @param _currencyValue How much currency to spend in order to buy COT. /// @param _minTokensBought Buy at least this many COT tokens or the transaction reverts. /// @dev _minTokensBought is necessary as the price will change if some elses transaction mines after /// yours was submitted. function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); // Calculate the tokenValue for this investment uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); // Update state, initInvestors, and distribute the investment when appropriate if(state == STATE_INIT) { // Math worst case: MAX_BEFORE_SQUARE initInvestors[_to] += tokenValue; // Math worst case: // MAX_BEFORE_SQUARE + MAX_BEFORE_SQUARE if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; // Math worst case: // MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE/2 // / MAX_BEFORE_SQUARE * 2 uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } else // implied: if(state == STATE_RUN) { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { // must mint before this call _burn(beneficiary, tokenValue, false); } } /// Sell function estimateSellValue( uint _quantityToSell ) public view returns(uint) { uint reserve = buybackReserve(); // Calculate currencyValue for this sale uint currencyValue; if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply; // buyback_reserve = r // total_supply = t // burnt_supply = b // amount = a // source: (t+b)*a*(2*r)/((t+b)^2)-(((2*r)/((t+b)^2)*a^2)/2)+((2*r)/((t+b)^2)*a*b^2)/(2*(t)) // imp: (a b^2 r)/(t (b + t)^2) + (2 a r)/(b + t) - (a^2 r)/(b + t)^2 // Math: burnedSupply is capped in COT such that the square will never overflow // Math worst case: // MAX * MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE/2 * MAX_BEFORE_SQUARE/2 // / MAX_BEFORE_SQUARE/2 * MAX_BEFORE_SQUARE/2 * MAX_BEFORE_SQUARE/2 currencyValue = BigDiv.bigDiv2x2( _quantityToSell.mul(reserve), burnedSupply * burnedSupply, totalSupply(), supply * supply ); // Math: worst case currencyValue is MAX_BEFORE_SQUARE (max reserve, 1 supply) // Math worst case: // MAX * 2 * MAX_BEFORE_SQUARE uint temp = _quantityToSell.mul(2 * reserve); temp /= supply; // Math: worst-case temp is MAX_BEFORE_SQUARE (max reserve, 1 supply) // Math: considering the worst-case for currencyValue and temp, this can never overflow currencyValue += temp; // Math: worst case // MAX * MAX * MAX_BEFORE_SQUARE // / MAX_BEFORE_SQUARE/2 * MAX_BEFORE_SQUARE/2 currencyValue -= BigDiv.bigDiv2x1RoundUp( _quantityToSell.mul(_quantityToSell), reserve, supply * supply ); } else if(state == STATE_CLOSE) { // Math worst case // MAX * MAX_BEFORE_SQUARE currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply(); } else { // STATE_INIT or STATE_CANCEL // Math worst case: // MAX * MAX_BEFORE_SQUARE currencyValue = _quantityToSell.mul(reserve); // Math: COT blocks initReserve from being burned unless we reach the RUN state which prevents an underflow currencyValue /= totalSupply() - initReserve; } return currencyValue; } /// @notice Sell COT tokens for at least the given amount of currency. /// @param _to The account to receive the currency from this sale. /// @param _quantityToSell How many COT tokens to sell for currency value. /// @param _minCurrencyReturned Get at least this many currency tokens or the transaction reverts. /// @dev _minCurrencyReturned is necessary as the price will change if some elses transaction mines after /// yours was submitted. function sell( address payable _to, uint _quantityToSell, uint _minCurrencyReturned ) public { require(msg.sender != beneficiary || state >= STATE_CLOSE, "BENEFICIARY_ONLY_SELL_IN_CLOSE_OR_CANCEL"); require(_minCurrencyReturned > 0, "MUST_SELL_AT_LEAST_1"); uint currencyValue = estimateSellValue(_quantityToSell); require(currencyValue >= _minCurrencyReturned, "PRICE_SLIPPAGE"); if(state == STATE_INIT || state == STATE_CANCEL) { initInvestors[msg.sender] = initInvestors[msg.sender].sub(_quantityToSell); } _burn(msg.sender, _quantityToSell, true); uint supply = totalSupply() + burnedSupply; if(supply < initReserve) { initReserve = supply; } _transferCurrency(_to, currencyValue); emit Sell(msg.sender, _to, currencyValue, _quantityToSell); } /// Pay function estimatePayValue( uint _currencyValue ) public view returns (uint) { // buy_slope = n/d // revenue_commitment = c/g // sqrt( // (2 a c d) // / // (g n) // + s^2 // ) - s uint supply = totalSupply() + burnedSupply; // Math: worst case // MAX * 2 * 10000 * MAX_BEFORE_SQUARE // / 10000 * MAX_BEFORE_SQUARE uint tokenValue = BigDiv.bigDiv2x1( _currencyValue.mul(2 * revenueCommitmentBasisPoints), buySlopeDen, BASIS_POINTS_DEN * buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); if(tokenValue > supply) { tokenValue -= supply; } else { tokenValue = 0; } return tokenValue; } /// @dev Pay the organization on-chain. /// @param _to The account which receives tokens for the contribution. /// @param _currencyValue How much currency which was paid. function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); // Send a portion of the funds to the beneficiary, the rest is added to the buybackReserve // Math: if _currencyValue is < (2^256 - 1) / 10000 this will not overflow uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); // Update the to address to the beneficiary if the currency value would fail address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } // Math: this will never underflow since investmentReserveBasisPoints is capped to BASIS_POINTS_DEN _transferCurrency(beneficiary, _currencyValue - reserve); // Distribute tokens if(tokenValue > 0) { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { // must mint before this call _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } /// @dev Pay the organization on-chain. /// @param _to The account which receives tokens for the contribution. If this address /// is not authorized to receive tokens then they will be sent to the beneficiary account instead. /// @param _currencyValue How much currency which was paid. function pay( address _to, uint _currencyValue ) public payable { _collectInvestment(_currencyValue, msg.value, false); _pay(_to, _currencyValue); } /// @notice Pay the organization on-chain without minting any tokens. /// @dev This allows you to add funds directly to the buybackReserve. function () external payable { require(address(currency) == address(0), "ONLY_FOR_CURRENCY_ETH"); } /// Close function estimateExitFee( uint _msgValue ) public view returns(uint) { uint exitFee; if(state == STATE_RUN) { uint reserve = buybackReserve(); reserve = reserve.sub(_msgValue); // Source: t*(t+b)*(n/d)-r // Implementation: (b n t)/d + (n t^2)/d - r uint _totalSupply = totalSupply(); // Math worst case: // MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE/2 * MAX_BEFORE_SQUARE exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen ); // Math worst case: // MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE * MAX_BEFORE_SQUARE exitFee += BigDiv.bigDiv2x1( _totalSupply, buySlopeNum * _totalSupply, buySlopeDen ); // Math: this if condition avoids a potential overflow if(exitFee <= reserve) { exitFee = 0; } else { exitFee -= reserve; } } return exitFee; } /// @notice Called by the beneficiary account to STATE_CLOSE or STATE_CANCEL the c-org, /// preventing any more tokens from being minted. /// @dev Requires an `exitFee` to be paid. If the currency is ETH, include a little more than /// what appears to be required and any remainder will be returned to your account. This is /// because another user may have a transaction mined which changes the exitFee required. /// For other `currency` types, the beneficiary account will be billed the exact amount required. function close() public payable { require(msg.sender == beneficiary, "BENEFICIARY_ONLY"); uint exitFee = 0; if(state == STATE_INIT) { // Allow the org to cancel anytime if the initGoal was not reached. emit StateChange(state, STATE_CANCEL); state = STATE_CANCEL; } else if(state == STATE_RUN) { // Collect the exitFee and close the c-org. require(openUntilAtLeast <= block.timestamp, "TOO_EARLY"); exitFee = estimateExitFee(msg.value); emit StateChange(state, STATE_CLOSE); state = STATE_CLOSE; _collectInvestment(exitFee, msg.value, true); } else { revert("INVALID_STATE"); } emit Close(exitFee); } // --- Approve by signature --- // Original source: https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#code function permit( address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) external { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed ) ) ) ); require(holder != address(0), "DAT/invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "DAT/invalid-permit"); require(expiry == 0 || now <= expiry, "DAT/permit-expired"); require(nonce == nonces[holder]++, "DAT/invalid-nonce"); uint wad = allowed ? uint(-1) : 0; _approve(holder, spender, wad); } } /// @title DXDPayRelayer /// @author github:AugustoL /// @notice This smart contract has not be audited. /// @dev Sends ETH received from DXdao to DXD by using the paying function contract DXDPayRelayer { DecentralizedAutonomousTrust public DXD; address payable public DXdao; constructor(address payable _DXD, address payable _DXdao) public { DXD = DecentralizedAutonomousTrust(_DXD); DXdao = _DXdao; } function () external payable{ require(msg.sender == DXdao); } function executePay() public { DXD.pay.value(address(this).balance)(DXdao, address(this).balance); } }
--- EIP712 niceties --- Original source: https:etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#code bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)");
{ using SafeMath for uint; using Sqrt for uint; using SafeERC20 for IERC20; event Buy( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Sell( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Burn( address indexed _from, uint _fairValue ); event Pay( address indexed _from, address indexed _to, uint _currencyValue, uint _fairValue ); event Close( uint _exitFee ); event StateChange( uint _previousState, uint _newState ); event UpdateConfig( address _whitelistAddress, address indexed _beneficiary, address indexed _control, address indexed _feeCollector, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _feeBasisPoints, uint _minInvestment, uint _openUntilAtLeast ); uint private constant STATE_INIT = 0; uint private constant STATE_RUN = 1; uint private constant STATE_CLOSE = 2; uint private constant STATE_CANCEL = 3; uint private constant MAX_BEFORE_SQUARE = 2**128 - 1; uint private constant BASIS_POINTS_DEN = 10000; uint private constant MAX_SUPPLY = 10 ** 38; IWhitelist public whitelist; uint public burnedSupply; bool public autoBurn; address payable public beneficiary; uint public buySlopeNum; uint public buySlopeDen; address public control; IERC20 public currency; address payable public feeCollector; uint public feeBasisPoints; uint public initGoal; mapping(address => uint) public initInvestors; uint public initReserve; uint public investmentReserveBasisPoints; uint public openUntilAtLeast; uint public minInvestment; uint public revenueCommitmentBasisPoints; uint public state; string public constant version = "2"; mapping (address => uint) public nonces; bytes32 public DOMAIN_SEPARATOR; bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb; modifier authorizeTransfer( address _from, address _to, uint _value, bool _isSell ) contract DecentralizedAutonomousTrust { if(address(whitelist) != address(0)) { whitelist.authorizeTransfer(_from, _to, _value, _isSell); } _; } { if(address(whitelist) != address(0)) { whitelist.authorizeTransfer(_from, _to, _value, _isSell); } _; } function buybackReserve() public view returns (uint) { uint reserve = address(this).balance; if(address(currency) != address(0)) { reserve = currency.balanceOf(address(this)); } if(reserve > MAX_BEFORE_SQUARE) { return MAX_BEFORE_SQUARE; return reserve; } function buybackReserve() public view returns (uint) { uint reserve = address(this).balance; if(address(currency) != address(0)) { reserve = currency.balanceOf(address(this)); } if(reserve > MAX_BEFORE_SQUARE) { return MAX_BEFORE_SQUARE; return reserve; } function buybackReserve() public view returns (uint) { uint reserve = address(this).balance; if(address(currency) != address(0)) { reserve = currency.balanceOf(address(this)); } if(reserve > MAX_BEFORE_SQUARE) { return MAX_BEFORE_SQUARE; return reserve; } } function _detectTransferRestriction( address _from, address _to, uint _value ) private view returns (uint) { if(address(whitelist) != address(0)) { return whitelist.detectTransferRestriction(_from, _to, _value); } return 0; } function _detectTransferRestriction( address _from, address _to, uint _value ) private view returns (uint) { if(address(whitelist) != address(0)) { return whitelist.detectTransferRestriction(_from, _to, _value); } return 0; } function _transfer( address _from, address _to, uint _amount ) internal authorizeTransfer(_from, _to, _amount, false) { require(state != STATE_INIT || _from == beneficiary, "ONLY_BENEFICIARY_DURING_INIT"); super._transfer(_from, _to, _amount); } function _burn( address _from, uint _amount, bool _isSell ) internal authorizeTransfer(_from, address(0), _amount, _isSell) { super._burn(_from, _amount); if(!_isSell) { require(state == STATE_RUN, "ONLY_DURING_RUN"); burnedSupply += _amount; emit Burn(_from, _amount); } } function _burn( address _from, uint _amount, bool _isSell ) internal authorizeTransfer(_from, address(0), _amount, _isSell) { super._burn(_from, _amount); if(!_isSell) { require(state == STATE_RUN, "ONLY_DURING_RUN"); burnedSupply += _amount; emit Burn(_from, _amount); } } function _mint( address _to, uint _quantity ) internal authorizeTransfer(address(0), _to, _quantity, false) { super._mint(_to, _quantity); require(totalSupply().add(burnedSupply) <= MAX_SUPPLY, "EXCESSIVE_SUPPLY"); } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _collectInvestment( uint _quantityToInvest, uint _msgValue, bool _refundRemainder ) private { if(address(currency) == address(0)) { if(_refundRemainder) { uint refund = _msgValue.sub(_quantityToInvest); if(refund > 0) { Address.sendValue(msg.sender, refund); } } else { require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE"); } } else { require(_msgValue == 0, "DO_NOT_SEND_ETH"); currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest); } } function _transferCurrency( address payable _to, uint _amount ) private { if(_amount > 0) { if(address(currency) == address(0)) { Address.sendValue(_to, _amount); } else { currency.safeTransfer(_to, _amount); } } } function _transferCurrency( address payable _to, uint _amount ) private { if(_amount > 0) { if(address(currency) == address(0)) { Address.sendValue(_to, _amount); } else { currency.safeTransfer(_to, _amount); } } } function _transferCurrency( address payable _to, uint _amount ) private { if(_amount > 0) { if(address(currency) == address(0)) { Address.sendValue(_to, _amount); } else { currency.safeTransfer(_to, _amount); } } } function _transferCurrency( address payable _to, uint _amount ) private { if(_amount > 0) { if(address(currency) == address(0)) { Address.sendValue(_to, _amount); } else { currency.safeTransfer(_to, _amount); } } } function initialize( uint _initReserve, address _currencyAddress, uint _initGoal, uint _buySlopeNum, uint _buySlopeDen, uint _investmentReserveBasisPoints, string memory _name, string memory _symbol ) public { require(control == address(0), "ALREADY_INITIALIZED"); ERC20Detailed.initialize(_name, _symbol, 18); if(_initGoal == 0) { emit StateChange(state, STATE_RUN); state = STATE_RUN; } else { require(_initGoal < MAX_SUPPLY, "EXCESSIVE_GOAL"); initGoal = _initGoal; } require(_buySlopeNum > 0, "INVALID_SLOPE_NUM"); require(_buySlopeDen > 0, "INVALID_SLOPE_DEN"); require(_buySlopeNum < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_NUM"); require(_buySlopeDen < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_DEN"); buySlopeNum = _buySlopeNum; buySlopeDen = _buySlopeDen; investmentReserveBasisPoints = _investmentReserveBasisPoints; beneficiary = msg.sender; control = msg.sender; feeCollector = msg.sender; { initReserve = _initReserve; _mint(beneficiary, initReserve); } abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes(version)), getChainId(), address(this) ) ); } function initialize( uint _initReserve, address _currencyAddress, uint _initGoal, uint _buySlopeNum, uint _buySlopeDen, uint _investmentReserveBasisPoints, string memory _name, string memory _symbol ) public { require(control == address(0), "ALREADY_INITIALIZED"); ERC20Detailed.initialize(_name, _symbol, 18); if(_initGoal == 0) { emit StateChange(state, STATE_RUN); state = STATE_RUN; } else { require(_initGoal < MAX_SUPPLY, "EXCESSIVE_GOAL"); initGoal = _initGoal; } require(_buySlopeNum > 0, "INVALID_SLOPE_NUM"); require(_buySlopeDen > 0, "INVALID_SLOPE_DEN"); require(_buySlopeNum < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_NUM"); require(_buySlopeDen < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_DEN"); buySlopeNum = _buySlopeNum; buySlopeDen = _buySlopeDen; investmentReserveBasisPoints = _investmentReserveBasisPoints; beneficiary = msg.sender; control = msg.sender; feeCollector = msg.sender; { initReserve = _initReserve; _mint(beneficiary, initReserve); } abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes(version)), getChainId(), address(this) ) ); } function initialize( uint _initReserve, address _currencyAddress, uint _initGoal, uint _buySlopeNum, uint _buySlopeDen, uint _investmentReserveBasisPoints, string memory _name, string memory _symbol ) public { require(control == address(0), "ALREADY_INITIALIZED"); ERC20Detailed.initialize(_name, _symbol, 18); if(_initGoal == 0) { emit StateChange(state, STATE_RUN); state = STATE_RUN; } else { require(_initGoal < MAX_SUPPLY, "EXCESSIVE_GOAL"); initGoal = _initGoal; } require(_buySlopeNum > 0, "INVALID_SLOPE_NUM"); require(_buySlopeDen > 0, "INVALID_SLOPE_DEN"); require(_buySlopeNum < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_NUM"); require(_buySlopeDen < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_DEN"); buySlopeNum = _buySlopeNum; buySlopeDen = _buySlopeDen; investmentReserveBasisPoints = _investmentReserveBasisPoints; beneficiary = msg.sender; control = msg.sender; feeCollector = msg.sender; { initReserve = _initReserve; _mint(beneficiary, initReserve); } abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes(version)), getChainId(), address(this) ) ); } require(_investmentReserveBasisPoints <= BASIS_POINTS_DEN, "INVALID_RESERVE"); minInvestment = 100 ether; currency = IERC20(_currencyAddress); if(_initReserve > 0) function initialize( uint _initReserve, address _currencyAddress, uint _initGoal, uint _buySlopeNum, uint _buySlopeDen, uint _investmentReserveBasisPoints, string memory _name, string memory _symbol ) public { require(control == address(0), "ALREADY_INITIALIZED"); ERC20Detailed.initialize(_name, _symbol, 18); if(_initGoal == 0) { emit StateChange(state, STATE_RUN); state = STATE_RUN; } else { require(_initGoal < MAX_SUPPLY, "EXCESSIVE_GOAL"); initGoal = _initGoal; } require(_buySlopeNum > 0, "INVALID_SLOPE_NUM"); require(_buySlopeDen > 0, "INVALID_SLOPE_DEN"); require(_buySlopeNum < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_NUM"); require(_buySlopeDen < MAX_BEFORE_SQUARE, "EXCESSIVE_SLOPE_DEN"); buySlopeNum = _buySlopeNum; buySlopeDen = _buySlopeDen; investmentReserveBasisPoints = _investmentReserveBasisPoints; beneficiary = msg.sender; control = msg.sender; feeCollector = msg.sender; { initReserve = _initReserve; _mint(beneficiary, initReserve); } abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes(version)), getChainId(), address(this) ) ); } DOMAIN_SEPARATOR = keccak256( function getChainId( ) private pure returns (uint id) { assembly { id := chainid() } } function getChainId( ) private pure returns (uint id) { assembly { id := chainid() } } function updateConfig( address _whitelistAddress, address payable _beneficiary, address _control, address payable _feeCollector, uint _feeBasisPoints, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _minInvestment, uint _openUntilAtLeast ) public { require(msg.sender == control, "CONTROL_ONLY"); whitelist = IWhitelist(_whitelistAddress); require(_control != address(0), "INVALID_ADDRESS"); control = _control; require(_feeCollector != address(0), "INVALID_ADDRESS"); feeCollector = _feeCollector; autoBurn = _autoBurn; require(_revenueCommitmentBasisPoints <= BASIS_POINTS_DEN, "INVALID_COMMITMENT"); require(_revenueCommitmentBasisPoints >= revenueCommitmentBasisPoints, "COMMITMENT_MAY_NOT_BE_REDUCED"); revenueCommitmentBasisPoints = _revenueCommitmentBasisPoints; require(_feeBasisPoints <= BASIS_POINTS_DEN, "INVALID_FEE"); feeBasisPoints = _feeBasisPoints; require(_minInvestment > 0, "INVALID_MIN_INVESTMENT"); minInvestment = _minInvestment; require(_openUntilAtLeast >= openUntilAtLeast, "OPEN_UNTIL_MAY_NOT_BE_REDUCED"); openUntilAtLeast = _openUntilAtLeast; if(beneficiary != _beneficiary) { require(_beneficiary != address(0), "INVALID_ADDRESS"); uint tokens = balanceOf(beneficiary); initInvestors[_beneficiary] = initInvestors[_beneficiary].add(initInvestors[beneficiary]); initInvestors[beneficiary] = 0; if(tokens > 0) { _transfer(beneficiary, _beneficiary, tokens); } beneficiary = _beneficiary; } emit UpdateConfig( _whitelistAddress, _beneficiary, _control, _feeCollector, _autoBurn, _revenueCommitmentBasisPoints, _feeBasisPoints, _minInvestment, _openUntilAtLeast ); } function updateConfig( address _whitelistAddress, address payable _beneficiary, address _control, address payable _feeCollector, uint _feeBasisPoints, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _minInvestment, uint _openUntilAtLeast ) public { require(msg.sender == control, "CONTROL_ONLY"); whitelist = IWhitelist(_whitelistAddress); require(_control != address(0), "INVALID_ADDRESS"); control = _control; require(_feeCollector != address(0), "INVALID_ADDRESS"); feeCollector = _feeCollector; autoBurn = _autoBurn; require(_revenueCommitmentBasisPoints <= BASIS_POINTS_DEN, "INVALID_COMMITMENT"); require(_revenueCommitmentBasisPoints >= revenueCommitmentBasisPoints, "COMMITMENT_MAY_NOT_BE_REDUCED"); revenueCommitmentBasisPoints = _revenueCommitmentBasisPoints; require(_feeBasisPoints <= BASIS_POINTS_DEN, "INVALID_FEE"); feeBasisPoints = _feeBasisPoints; require(_minInvestment > 0, "INVALID_MIN_INVESTMENT"); minInvestment = _minInvestment; require(_openUntilAtLeast >= openUntilAtLeast, "OPEN_UNTIL_MAY_NOT_BE_REDUCED"); openUntilAtLeast = _openUntilAtLeast; if(beneficiary != _beneficiary) { require(_beneficiary != address(0), "INVALID_ADDRESS"); uint tokens = balanceOf(beneficiary); initInvestors[_beneficiary] = initInvestors[_beneficiary].add(initInvestors[beneficiary]); initInvestors[beneficiary] = 0; if(tokens > 0) { _transfer(beneficiary, _beneficiary, tokens); } beneficiary = _beneficiary; } emit UpdateConfig( _whitelistAddress, _beneficiary, _control, _feeCollector, _autoBurn, _revenueCommitmentBasisPoints, _feeBasisPoints, _minInvestment, _openUntilAtLeast ); } function updateConfig( address _whitelistAddress, address payable _beneficiary, address _control, address payable _feeCollector, uint _feeBasisPoints, bool _autoBurn, uint _revenueCommitmentBasisPoints, uint _minInvestment, uint _openUntilAtLeast ) public { require(msg.sender == control, "CONTROL_ONLY"); whitelist = IWhitelist(_whitelistAddress); require(_control != address(0), "INVALID_ADDRESS"); control = _control; require(_feeCollector != address(0), "INVALID_ADDRESS"); feeCollector = _feeCollector; autoBurn = _autoBurn; require(_revenueCommitmentBasisPoints <= BASIS_POINTS_DEN, "INVALID_COMMITMENT"); require(_revenueCommitmentBasisPoints >= revenueCommitmentBasisPoints, "COMMITMENT_MAY_NOT_BE_REDUCED"); revenueCommitmentBasisPoints = _revenueCommitmentBasisPoints; require(_feeBasisPoints <= BASIS_POINTS_DEN, "INVALID_FEE"); feeBasisPoints = _feeBasisPoints; require(_minInvestment > 0, "INVALID_MIN_INVESTMENT"); minInvestment = _minInvestment; require(_openUntilAtLeast >= openUntilAtLeast, "OPEN_UNTIL_MAY_NOT_BE_REDUCED"); openUntilAtLeast = _openUntilAtLeast; if(beneficiary != _beneficiary) { require(_beneficiary != address(0), "INVALID_ADDRESS"); uint tokens = balanceOf(beneficiary); initInvestors[_beneficiary] = initInvestors[_beneficiary].add(initInvestors[beneficiary]); initInvestors[beneficiary] = 0; if(tokens > 0) { _transfer(beneficiary, _beneficiary, tokens); } beneficiary = _beneficiary; } emit UpdateConfig( _whitelistAddress, _beneficiary, _control, _feeCollector, _autoBurn, _revenueCommitmentBasisPoints, _feeBasisPoints, _minInvestment, _openUntilAtLeast ); } function burn( uint _amount ) public { _burn(msg.sender, _amount, false); } function _distributeInvestment( uint _value ) private { uint reserve = investmentReserveBasisPoints.mul(_value); reserve /= BASIS_POINTS_DEN; reserve = _value.sub(reserve); uint fee = reserve.mul(feeBasisPoints); fee /= BASIS_POINTS_DEN; _transferCurrency(beneficiary, reserve - fee); _transferCurrency(feeCollector, fee); } function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } uint tokenValue; function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } tokenValue = BigDiv.bigDiv2x1( function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } function estimateBuyValue( uint _currencyValue ) public view returns (uint) { if(_currencyValue < minInvestment) { return 0; } if(state == STATE_INIT) { uint currencyValue = _currencyValue; uint _totalSupply = totalSupply(); uint max = BigDiv.bigDiv2x1( initGoal * buySlopeNum, initGoal + initReserve - _totalSupply, 2 * buySlopeDen ); if(currencyValue > max) { currencyValue = max; } currencyValue, 2 * buySlopeDen, initGoal * buySlopeNum ); if(currencyValue != _currencyValue) { currencyValue = _currencyValue - max; uint temp = 2 * buySlopeDen; currencyValue = temp.mul(currencyValue); temp = initGoal; temp *= temp; temp = temp.mul(buySlopeNum); temp = currencyValue.add(temp); temp /= buySlopeNum; temp = temp.sqrt(); temp -= initGoal; tokenValue = tokenValue.add(temp); } } else if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply - initReserve; tokenValue = BigDiv.bigDiv2x1( _currencyValue, 2 * buySlopeDen, buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); tokenValue = tokenValue.sub(supply); } else { return 0; } return tokenValue; } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function buy( address _to, uint _currencyValue, uint _minTokensBought ) public payable { require(_to != address(0), "INVALID_ADDRESS"); require(_minTokensBought > 0, "MUST_BUY_AT_LEAST_1"); uint tokenValue = estimateBuyValue(_currencyValue); require(tokenValue >= _minTokensBought, "PRICE_SLIPPAGE"); emit Buy(msg.sender, _to, _currencyValue, tokenValue); _collectInvestment(_currencyValue, msg.value, false); if(state == STATE_INIT) { initInvestors[_to] += tokenValue; if(totalSupply() + tokenValue - initReserve >= initGoal) { emit StateChange(state, STATE_RUN); state = STATE_RUN; uint beneficiaryContribution = BigDiv.bigDiv2x1( initInvestors[beneficiary], buySlopeNum * initGoal, buySlopeDen * 2 ); _distributeInvestment(buybackReserve().sub(beneficiaryContribution)); } } { if(_to != beneficiary) { _distributeInvestment(_currencyValue); } } _mint(_to, tokenValue); if(state == STATE_RUN && msg.sender == beneficiary && _to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } function estimateSellValue( uint _quantityToSell ) public view returns(uint) { uint reserve = buybackReserve(); uint currencyValue; if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply; currencyValue = BigDiv.bigDiv2x2( _quantityToSell.mul(reserve), burnedSupply * burnedSupply, totalSupply(), supply * supply ); uint temp = _quantityToSell.mul(2 * reserve); temp /= supply; currencyValue += temp; currencyValue -= BigDiv.bigDiv2x1RoundUp( _quantityToSell.mul(_quantityToSell), reserve, supply * supply ); } else if(state == STATE_CLOSE) { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply(); } else { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply() - initReserve; } return currencyValue; } function estimateSellValue( uint _quantityToSell ) public view returns(uint) { uint reserve = buybackReserve(); uint currencyValue; if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply; currencyValue = BigDiv.bigDiv2x2( _quantityToSell.mul(reserve), burnedSupply * burnedSupply, totalSupply(), supply * supply ); uint temp = _quantityToSell.mul(2 * reserve); temp /= supply; currencyValue += temp; currencyValue -= BigDiv.bigDiv2x1RoundUp( _quantityToSell.mul(_quantityToSell), reserve, supply * supply ); } else if(state == STATE_CLOSE) { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply(); } else { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply() - initReserve; } return currencyValue; } function estimateSellValue( uint _quantityToSell ) public view returns(uint) { uint reserve = buybackReserve(); uint currencyValue; if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply; currencyValue = BigDiv.bigDiv2x2( _quantityToSell.mul(reserve), burnedSupply * burnedSupply, totalSupply(), supply * supply ); uint temp = _quantityToSell.mul(2 * reserve); temp /= supply; currencyValue += temp; currencyValue -= BigDiv.bigDiv2x1RoundUp( _quantityToSell.mul(_quantityToSell), reserve, supply * supply ); } else if(state == STATE_CLOSE) { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply(); } else { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply() - initReserve; } return currencyValue; } function estimateSellValue( uint _quantityToSell ) public view returns(uint) { uint reserve = buybackReserve(); uint currencyValue; if(state == STATE_RUN) { uint supply = totalSupply() + burnedSupply; currencyValue = BigDiv.bigDiv2x2( _quantityToSell.mul(reserve), burnedSupply * burnedSupply, totalSupply(), supply * supply ); uint temp = _quantityToSell.mul(2 * reserve); temp /= supply; currencyValue += temp; currencyValue -= BigDiv.bigDiv2x1RoundUp( _quantityToSell.mul(_quantityToSell), reserve, supply * supply ); } else if(state == STATE_CLOSE) { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply(); } else { currencyValue = _quantityToSell.mul(reserve); currencyValue /= totalSupply() - initReserve; } return currencyValue; } function sell( address payable _to, uint _quantityToSell, uint _minCurrencyReturned ) public { require(msg.sender != beneficiary || state >= STATE_CLOSE, "BENEFICIARY_ONLY_SELL_IN_CLOSE_OR_CANCEL"); require(_minCurrencyReturned > 0, "MUST_SELL_AT_LEAST_1"); uint currencyValue = estimateSellValue(_quantityToSell); require(currencyValue >= _minCurrencyReturned, "PRICE_SLIPPAGE"); if(state == STATE_INIT || state == STATE_CANCEL) { initInvestors[msg.sender] = initInvestors[msg.sender].sub(_quantityToSell); } _burn(msg.sender, _quantityToSell, true); uint supply = totalSupply() + burnedSupply; if(supply < initReserve) { initReserve = supply; } _transferCurrency(_to, currencyValue); emit Sell(msg.sender, _to, currencyValue, _quantityToSell); } function sell( address payable _to, uint _quantityToSell, uint _minCurrencyReturned ) public { require(msg.sender != beneficiary || state >= STATE_CLOSE, "BENEFICIARY_ONLY_SELL_IN_CLOSE_OR_CANCEL"); require(_minCurrencyReturned > 0, "MUST_SELL_AT_LEAST_1"); uint currencyValue = estimateSellValue(_quantityToSell); require(currencyValue >= _minCurrencyReturned, "PRICE_SLIPPAGE"); if(state == STATE_INIT || state == STATE_CANCEL) { initInvestors[msg.sender] = initInvestors[msg.sender].sub(_quantityToSell); } _burn(msg.sender, _quantityToSell, true); uint supply = totalSupply() + burnedSupply; if(supply < initReserve) { initReserve = supply; } _transferCurrency(_to, currencyValue); emit Sell(msg.sender, _to, currencyValue, _quantityToSell); } function sell( address payable _to, uint _quantityToSell, uint _minCurrencyReturned ) public { require(msg.sender != beneficiary || state >= STATE_CLOSE, "BENEFICIARY_ONLY_SELL_IN_CLOSE_OR_CANCEL"); require(_minCurrencyReturned > 0, "MUST_SELL_AT_LEAST_1"); uint currencyValue = estimateSellValue(_quantityToSell); require(currencyValue >= _minCurrencyReturned, "PRICE_SLIPPAGE"); if(state == STATE_INIT || state == STATE_CANCEL) { initInvestors[msg.sender] = initInvestors[msg.sender].sub(_quantityToSell); } _burn(msg.sender, _quantityToSell, true); uint supply = totalSupply() + burnedSupply; if(supply < initReserve) { initReserve = supply; } _transferCurrency(_to, currencyValue); emit Sell(msg.sender, _to, currencyValue, _quantityToSell); } function estimatePayValue( uint _currencyValue ) public view returns (uint) { uint supply = totalSupply() + burnedSupply; uint tokenValue = BigDiv.bigDiv2x1( _currencyValue.mul(2 * revenueCommitmentBasisPoints), buySlopeDen, BASIS_POINTS_DEN * buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); if(tokenValue > supply) { tokenValue -= supply; } else { tokenValue = 0; } return tokenValue; } function estimatePayValue( uint _currencyValue ) public view returns (uint) { uint supply = totalSupply() + burnedSupply; uint tokenValue = BigDiv.bigDiv2x1( _currencyValue.mul(2 * revenueCommitmentBasisPoints), buySlopeDen, BASIS_POINTS_DEN * buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); if(tokenValue > supply) { tokenValue -= supply; } else { tokenValue = 0; } return tokenValue; } function estimatePayValue( uint _currencyValue ) public view returns (uint) { uint supply = totalSupply() + burnedSupply; uint tokenValue = BigDiv.bigDiv2x1( _currencyValue.mul(2 * revenueCommitmentBasisPoints), buySlopeDen, BASIS_POINTS_DEN * buySlopeNum ); tokenValue = tokenValue.add(supply * supply); tokenValue = tokenValue.sqrt(); if(tokenValue > supply) { tokenValue -= supply; } else { tokenValue = 0; } return tokenValue; } function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } _transferCurrency(beneficiary, _currencyValue - reserve); if(tokenValue > 0) function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } function _pay( address _to, uint _currencyValue ) private { require(_currencyValue > 0, "MISSING_CURRENCY"); require(state == STATE_RUN, "INVALID_STATE"); uint reserve = _currencyValue.mul(investmentReserveBasisPoints); reserve /= BASIS_POINTS_DEN; uint tokenValue = estimatePayValue(_currencyValue); address to = _to; if(to == address(0)) { to = beneficiary; } else if(_detectTransferRestriction(address(0), _to, tokenValue) != 0) { to = beneficiary; } { _mint(to, tokenValue); if(to == beneficiary && autoBurn) { _burn(beneficiary, tokenValue, false); } } emit Pay(msg.sender, _to, _currencyValue, tokenValue); } function pay( address _to, uint _currencyValue ) public payable { _collectInvestment(_currencyValue, msg.value, false); _pay(_to, _currencyValue); } function () external payable { require(address(currency) == address(0), "ONLY_FOR_CURRENCY_ETH"); } function estimateExitFee( uint _msgValue ) public view returns(uint) { uint exitFee; if(state == STATE_RUN) { uint reserve = buybackReserve(); reserve = reserve.sub(_msgValue); uint _totalSupply = totalSupply(); exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen ); exitFee += BigDiv.bigDiv2x1( _totalSupply, buySlopeNum * _totalSupply, buySlopeDen ); if(exitFee <= reserve) { exitFee = 0; } else { exitFee -= reserve; } } return exitFee; } function estimateExitFee( uint _msgValue ) public view returns(uint) { uint exitFee; if(state == STATE_RUN) { uint reserve = buybackReserve(); reserve = reserve.sub(_msgValue); uint _totalSupply = totalSupply(); exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen ); exitFee += BigDiv.bigDiv2x1( _totalSupply, buySlopeNum * _totalSupply, buySlopeDen ); if(exitFee <= reserve) { exitFee = 0; } else { exitFee -= reserve; } } return exitFee; } function estimateExitFee( uint _msgValue ) public view returns(uint) { uint exitFee; if(state == STATE_RUN) { uint reserve = buybackReserve(); reserve = reserve.sub(_msgValue); uint _totalSupply = totalSupply(); exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen ); exitFee += BigDiv.bigDiv2x1( _totalSupply, buySlopeNum * _totalSupply, buySlopeDen ); if(exitFee <= reserve) { exitFee = 0; } else { exitFee -= reserve; } } return exitFee; } function estimateExitFee( uint _msgValue ) public view returns(uint) { uint exitFee; if(state == STATE_RUN) { uint reserve = buybackReserve(); reserve = reserve.sub(_msgValue); uint _totalSupply = totalSupply(); exitFee = BigDiv.bigDiv2x1( _totalSupply, burnedSupply * buySlopeNum, buySlopeDen ); exitFee += BigDiv.bigDiv2x1( _totalSupply, buySlopeNum * _totalSupply, buySlopeDen ); if(exitFee <= reserve) { exitFee = 0; } else { exitFee -= reserve; } } return exitFee; } function close() public payable { require(msg.sender == beneficiary, "BENEFICIARY_ONLY"); uint exitFee = 0; if(state == STATE_INIT) { emit StateChange(state, STATE_CANCEL); state = STATE_CANCEL; } else if(state == STATE_RUN) { require(openUntilAtLeast <= block.timestamp, "TOO_EARLY"); exitFee = estimateExitFee(msg.value); emit StateChange(state, STATE_CLOSE); state = STATE_CLOSE; _collectInvestment(exitFee, msg.value, true); } else { revert("INVALID_STATE"); } emit Close(exitFee); } function close() public payable { require(msg.sender == beneficiary, "BENEFICIARY_ONLY"); uint exitFee = 0; if(state == STATE_INIT) { emit StateChange(state, STATE_CANCEL); state = STATE_CANCEL; } else if(state == STATE_RUN) { require(openUntilAtLeast <= block.timestamp, "TOO_EARLY"); exitFee = estimateExitFee(msg.value); emit StateChange(state, STATE_CLOSE); state = STATE_CLOSE; _collectInvestment(exitFee, msg.value, true); } else { revert("INVALID_STATE"); } emit Close(exitFee); } function close() public payable { require(msg.sender == beneficiary, "BENEFICIARY_ONLY"); uint exitFee = 0; if(state == STATE_INIT) { emit StateChange(state, STATE_CANCEL); state = STATE_CANCEL; } else if(state == STATE_RUN) { require(openUntilAtLeast <= block.timestamp, "TOO_EARLY"); exitFee = estimateExitFee(msg.value); emit StateChange(state, STATE_CLOSE); state = STATE_CLOSE; _collectInvestment(exitFee, msg.value, true); } else { revert("INVALID_STATE"); } emit Close(exitFee); } function close() public payable { require(msg.sender == beneficiary, "BENEFICIARY_ONLY"); uint exitFee = 0; if(state == STATE_INIT) { emit StateChange(state, STATE_CANCEL); state = STATE_CANCEL; } else if(state == STATE_RUN) { require(openUntilAtLeast <= block.timestamp, "TOO_EARLY"); exitFee = estimateExitFee(msg.value); emit StateChange(state, STATE_CLOSE); state = STATE_CLOSE; _collectInvestment(exitFee, msg.value, true); } else { revert("INVALID_STATE"); } emit Close(exitFee); } function permit( address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) external { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed ) ) ) ); require(holder != address(0), "DAT/invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "DAT/invalid-permit"); require(expiry == 0 || now <= expiry, "DAT/permit-expired"); require(nonce == nonces[holder]++, "DAT/invalid-nonce"); uint wad = allowed ? uint(-1) : 0; _approve(holder, spender, wad); } }
15,351
[ 1, 4625, 348, 7953, 560, 30, 225, 9948, 512, 2579, 27, 2138, 11562, 278, 606, 9948, 19225, 1084, 30, 2333, 30, 546, 414, 4169, 18, 1594, 19, 2867, 19, 20, 92, 26, 70, 4033, 6564, 5608, 73, 6675, 5908, 24, 71, 6334, 2414, 10689, 70, 29, 6564, 1340, 323, 1077, 7616, 25, 5324, 21, 72, 20, 74, 7, 710, 1731, 1578, 1071, 5381, 10950, 6068, 67, 2399, 15920, 273, 417, 24410, 581, 5034, 2932, 9123, 305, 12, 2867, 10438, 16, 2867, 17571, 264, 16, 11890, 5034, 7448, 16, 11890, 5034, 10839, 16, 6430, 2935, 2225, 1769, 2, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 95, 203, 225, 1450, 14060, 10477, 364, 2254, 31, 203, 225, 1450, 348, 85, 3797, 364, 2254, 31, 203, 225, 1450, 14060, 654, 39, 3462, 364, 467, 654, 39, 3462, 31, 203, 203, 203, 225, 871, 605, 9835, 12, 203, 565, 1758, 8808, 389, 2080, 16, 203, 565, 1758, 8808, 389, 869, 16, 203, 565, 2254, 389, 7095, 620, 16, 203, 565, 2254, 389, 507, 481, 620, 203, 225, 11272, 203, 225, 871, 348, 1165, 12, 203, 565, 1758, 8808, 389, 2080, 16, 203, 565, 1758, 8808, 389, 869, 16, 203, 565, 2254, 389, 7095, 620, 16, 203, 565, 2254, 389, 507, 481, 620, 203, 225, 11272, 203, 225, 871, 605, 321, 12, 203, 565, 1758, 8808, 389, 2080, 16, 203, 565, 2254, 389, 507, 481, 620, 203, 225, 11272, 203, 225, 871, 13838, 12, 203, 565, 1758, 8808, 389, 2080, 16, 203, 565, 1758, 8808, 389, 869, 16, 203, 565, 2254, 389, 7095, 620, 16, 203, 565, 2254, 389, 507, 481, 620, 203, 225, 11272, 203, 225, 871, 3527, 12, 203, 565, 2254, 389, 8593, 14667, 203, 225, 11272, 203, 225, 871, 3287, 3043, 12, 203, 565, 2254, 389, 11515, 1119, 16, 203, 565, 2254, 389, 2704, 1119, 203, 225, 11272, 203, 225, 871, 2315, 809, 12, 203, 565, 1758, 389, 20409, 1887, 16, 203, 565, 1758, 8808, 389, 70, 4009, 74, 14463, 814, 16, 203, 565, 1758, 8808, 389, 7098, 16, 203, 565, 1758, 8808, 389, 21386, 7134, 16, 203, 565, 1426, 389, 6079, 38, 321, 16, 203, 565, 2254, 389, 266, 24612, 5580, 475, 11494, 291, 5636, 16, 203, 565, 2254, 389, 21386, 11494, 291, 5636, 16, 203, 565, 2254, 389, 1154, 3605, 395, 475, 16, 203, 565, 2254, 389, 3190, 9716, 25070, 203, 225, 11272, 203, 203, 203, 225, 2254, 3238, 5381, 7442, 67, 12919, 273, 374, 31, 203, 203, 225, 2254, 3238, 5381, 7442, 67, 15238, 273, 404, 31, 203, 203, 225, 2254, 3238, 5381, 7442, 67, 13384, 273, 576, 31, 203, 203, 225, 2254, 3238, 5381, 7442, 67, 25268, 273, 890, 31, 203, 203, 225, 2254, 3238, 5381, 4552, 67, 19152, 67, 19716, 273, 576, 636, 10392, 300, 404, 31, 203, 203, 225, 2254, 3238, 5381, 28143, 15664, 67, 8941, 55, 67, 13296, 273, 12619, 31, 203, 203, 225, 2254, 3238, 5381, 4552, 67, 13272, 23893, 273, 1728, 2826, 18012, 31, 203, 203, 203, 225, 467, 18927, 1071, 10734, 31, 203, 203, 225, 2254, 1071, 18305, 329, 3088, 1283, 31, 203, 203, 203, 225, 1426, 1071, 3656, 38, 321, 31, 203, 203, 225, 1758, 8843, 429, 1071, 27641, 74, 14463, 814, 31, 203, 203, 225, 2254, 1071, 30143, 55, 12232, 2578, 31, 203, 203, 225, 2254, 1071, 30143, 55, 12232, 8517, 31, 203, 203, 225, 1758, 1071, 3325, 31, 203, 203, 225, 467, 654, 39, 3462, 1071, 5462, 31, 203, 203, 225, 1758, 8843, 429, 1071, 14036, 7134, 31, 203, 203, 225, 2254, 1071, 14036, 11494, 291, 5636, 31, 203, 203, 225, 2254, 1071, 1208, 27716, 31, 203, 203, 225, 2874, 12, 2867, 516, 2254, 13, 1071, 1208, 3605, 395, 1383, 31, 203, 203, 225, 2254, 1071, 1208, 607, 6527, 31, 203, 203, 225, 2254, 1071, 2198, 395, 475, 607, 6527, 11494, 291, 5636, 31, 203, 203, 225, 2254, 1071, 1696, 9716, 25070, 31, 203, 203, 225, 2254, 1071, 1131, 3605, 395, 475, 31, 203, 203, 225, 2254, 1071, 283, 24612, 5580, 475, 11494, 291, 5636, 31, 203, 203, 225, 2254, 1071, 919, 31, 203, 203, 225, 533, 1071, 5381, 1177, 273, 315, 22, 14432, 203, 225, 2874, 261, 2867, 516, 2254, 13, 1071, 1661, 764, 31, 203, 225, 1731, 1578, 1071, 27025, 67, 4550, 31, 203, 225, 1731, 1578, 1071, 5381, 10950, 6068, 67, 2399, 15920, 273, 374, 6554, 69, 22, 7598, 20, 69, 21, 2196, 2499, 69, 8642, 329, 5292, 72, 21761, 71, 29, 5026, 9599, 74, 24, 74, 28, 4366, 8898, 70, 7950, 4366, 11212, 72, 21, 12124, 11290, 72, 4033, 3600, 2138, 4763, 2499, 1077, 70, 31, 203, 203, 225, 9606, 12229, 5912, 12, 203, 565, 1758, 389, 2080, 16, 203, 565, 1758, 389, 869, 16, 203, 565, 2254, 389, 1132, 16, 203, 565, 1426, 389, 291, 55, 1165, 203, 225, 262, 203, 203, 16351, 3416, 12839, 1235, 7150, 4708, 1481, 14146, 203, 225, 288, 203, 565, 309, 12, 2867, 12, 20409, 13, 480, 1758, 12, 20, 3719, 203, 565, 288, 203, 1377, 10734, 18, 22488, 5912, 24899, 2080, 16, 389, 869, 16, 389, 1132, 16, 389, 291, 55, 1165, 1769, 203, 565, 289, 203, 565, 389, 31, 203, 225, 289, 203, 203, 225, 288, 203, 565, 309, 12, 2867, 12, 20409, 13, 480, 1758, 12, 20, 3719, 203, 565, 288, 203, 1377, 10734, 18, 22488, 5912, 24899, 2080, 16, 389, 869, 16, 389, 1132, 16, 389, 291, 55, 1165, 1769, 203, 565, 289, 203, 565, 389, 31, 203, 225, 289, 203, 203, 203, 225, 445, 30143, 823, 607, 6527, 1435, 1071, 1476, 1135, 261, 11890, 13, 203, 225, 288, 203, 565, 2254, 20501, 273, 1758, 12, 2211, 2934, 12296, 31, 203, 565, 309, 12, 2867, 12, 7095, 13, 480, 1758, 12, 20, 3719, 203, 565, 288, 203, 1377, 20501, 273, 5462, 18, 12296, 951, 12, 2867, 12, 2211, 10019, 203, 565, 289, 203, 203, 565, 309, 12, 455, 6527, 405, 4552, 67, 19152, 67, 19716, 13, 203, 565, 288, 203, 1377, 327, 4552, 67, 19152, 67, 19716, 31, 203, 203, 565, 327, 20501, 31, 203, 225, 289, 203, 203, 225, 445, 30143, 823, 607, 6527, 1435, 1071, 1476, 1135, 261, 11890, 13, 203, 225, 288, 203, 565, 2254, 20501, 273, 1758, 12, 2211, 2934, 12296, 31, 203, 565, 309, 12, 2867, 12, 7095, 13, 480, 1758, 12, 20, 3719, 203, 565, 288, 203, 1377, 20501, 273, 5462, 18, 12296, 951, 12, 2867, 12, 2211, 10019, 203, 565, 289, 203, 203, 565, 309, 12, 455, 6527, 405, 4552, 67, 19152, 67, 19716, 13, 203, 565, 288, 203, 1377, 327, 4552, 67, 19152, 67, 19716, 31, 203, 203, 565, 327, 20501, 31, 203, 225, 289, 203, 203, 225, 445, 30143, 823, 607, 6527, 1435, 1071, 1476, 1135, 261, 11890, 13, 203, 225, 288, 203, 565, 2254, 20501, 273, 1758, 12, 2211, 2934, 12296, 2 ]
pragma solidity ^0.4.24; contract Canopy { /*** DATA HANDLING ***/ struct Post { address posterAddress; string title; string url; string content; uint timePosted; uint stake; uint256 voteTokens; uint256 score; uint valuePositive; uint valueNegative; uint256 voterTally; bool active; } address public maintainersAddress; address public gameMasterAddress; address public newContractAddress; constructor () public { // This is an empty constructor. } /*** EVENTS ***/ event NewPost( uint256 indexed postId, address posterAddress, string title, string url, string content, uint indexed timePosted, uint stake, uint256 score, bool active ); event ContractUpgrade(address indexed newContract); /*** STORAGE ***/ Post[] public posts; uint public numPosts; address[] internal participants; // used for rolling jackpot mapping (uint256 => address) public postIdToOwner; mapping (uint256 => address[]) public postIdToVoters; mapping (address => uint256) public userPostCount; /// @dev canopy is currently in Alpha. Expect upgrades; currently following CK pattern for upgrade. /// @param _v2Address new address function setNewAddress(address _v2Address) external onlyGameMaster { newContractAddress = _v2Address; emit ContractUpgrade(_v2Address); } /*** CORE ***/ // @dev function to create a new post function createPost(string title, string url, string content) // TODO: make sure "stake" transfer is executed properly public payable returns ( uint256, uint256 ){ // below: intentionally ignoring warning on "now"; time is non-critical uint timePosted = now; address poster = msg.sender; // below: start score = (1 up - 0 down) * (1 voter / 1 second since post) uint256 score = 1; Post memory post = Post({ posterAddress: poster, title: title, url: url, content: content, timePosted: timePosted, stake: msg.value, voteTokens: 0, score: score, valuePositive: 0, valueNegative: 0, voterTally: 0, active: true }); numPosts = posts.push(post) - 1; postIdToOwner[numPosts] = poster; userPostCount[poster]++; participants.push(msg.sender); emit NewPost( numPosts, poster, title, url, content, timePosted, msg.value, score, true ); return (numPosts, score); } function getPost(uint256 _id) public view returns ( address posterAddress, string title, string url, string content, uint timePosted, uint stake, uint256 score, uint valuePositive, uint valueNegative, uint256 voterTally, bool active ) { Post memory p = posts[_id]; return( p.posterAddress, p.title, p.url, p.content, p.timePosted, p.stake, p.score, p.valuePositive, p.valueNegative, p.voterTally, p.active ); } // @dev pass in vote params. return the vote weight instantly, re-rank posts function vote(uint256 _postId, bool isPositive) public payable returns (uint256) { Post memory c = posts[_postId]; if (isPositive) { c.valuePositive = c.valuePositive + msg.value; } else { c.valueNegative = c.valueNegative + msg.value; } // stake is not modified here. total payout is sort of equal to // stake + valuePositive - valueNegative c.voterTally++; postIdToVoters[_postId].push(msg.sender); c.score = scorePost(_postId); participants.push(msg.sender); updateActiveScores(); return c.score; } function updateActiveScores() private { for (uint i = 0; i < posts.length; i++) { Post memory c = posts[i]; // if a post is a month old, pay it out and deactivate if (c.active == true) { if ((now - c.timePosted) > 30 days) { cashOut(i); } else { scorePost(i); } } } } function scorePost(uint256 _postId) private returns (uint256) { Post memory p = posts[_postId]; // multiply by 100000 to ensure an integer uint256 uproot = sqrt((p.valuePositive) * 100000); uint256 downroot = sqrt((p.valueNegative) * 100000); uint256 totalVoters = p.voterTally; uint256 rootTimeSincePost = sqrt(now - p.timePosted); uint256 _score = (uproot / downroot) * (totalVoters / rootTimeSincePost); posts[_postId].score = _score; return _score; } // below method is borrowed from https://github.com/ethereum/dapp-bin/pull/50/files function sqrt(uint256 x) internal pure returns (uint256 y) { if (x == 0) return 0; else if (x <= 3) return 1; uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } // @dev read from mapping - show 100 of the most recent function getMostRecentPostId() public view returns (uint256) { //since IDs are sequential, length of array = most recent post id return posts.length - 1; } // @dev read from mapping function getScoreById(uint _postId) public view returns (uint256) { return posts[_postId].score; } // @dev user can choose when to cash out, make sure to check address function cashOut(uint _postId) public payable onlyPoster(_postId) { uint256 poolValue = address(this).balance; require(poolValue >= 0.01 ether, "pool value is too small"); Post memory p = posts[_postId]; uint totalValue = p.valuePositive + p.valueNegative; uint totalRatio = 100 * sqrt(p.valuePositive) / sqrt(p.valueNegative); uint basePaymentToPoster = p.stake * (100 * sqrt(p.valuePositive) / sqrt(totalValue)) / 100 + p.valuePositive; // calculate bonus require(totalRatio < 75, "your post failed to meet the quality bar"); uint bonusRatio; if (totalRatio < 2) { bonusRatio = totalRatio; } else { bonusRatio = 2; } uint bonusPayout = p.stake * bonusRatio; // make sure that bonus isn't too much of pool uint totalBonus; if (bonusPayout < (poolValue / 2)) { totalBonus = bonusPayout; } else { totalBonus = (poolValue / 2); } uint totalPayout = basePaymentToPoster + totalBonus; msg.sender.transfer(totalPayout); posts[_postId].active = false; posts[_postId].score = 0; } function jackpot() public payable onlyGameMaster { require (address(this).balance > 25 ether, "can't make it rain if there ain't no cloud"); uint numerator = address(this).balance; uint denominator = participants.length; uint jackpotBalance = ((7 * address(this).balance) / 10); uint maintainerPay = ((1 * address(this).balance) / 10); uint perPlayer = jackpotBalance / (numerator / denominator); for (uint i = 0; i < participants.length; i++) { participants[i].transfer(perPlayer); } maintainersPot(maintainerPay); } function maintainersPot(uint amount) internal onlyMaintainers { require(maintainersAddress != 0, "no burning"); maintainersAddress.transfer(amount); } // @dev BONUS - get post with highest tally of votes // @dev BONUS - get user's total voter tally /*** PERMISSIONS ***/ // @dev check against addresses modifier onlyPoster(uint _postId) { require(msg.sender == posts[_postId].posterAddress, "Only the poster can use this function"); _; } modifier onlyMaintainers() { require(msg.sender == maintainersAddress, "Only the maintainer is allowed this action"); _; } modifier onlyGameMaster() { require(msg.sender == gameMasterAddress, "Only the Game Master is able to change the rules"); _; } }
@dev read from mapping
function getScoreById(uint _postId) public view returns (uint256) { return posts[_postId].score; }
2,481,358
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 855, 628, 2874, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 30447, 5132, 12, 11890, 389, 2767, 548, 13, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 10775, 63, 67, 2767, 548, 8009, 6355, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } //SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /// @title Simple Stream Contract /// @author ghostffcode /// @notice the meat and potatoes of the stream contract SimpleStream is Ownable { event Withdraw(address indexed to, uint256 amount, string reason); event Deposit(address indexed from, uint256 amount, string reason); address payable public toAddress; // = payable(0xD75b0609ed51307E13bae0F9394b5f63A7f8b6A1); uint256 public cap; // = 0.5 ether; uint256 public frequency; // 1296000 seconds == 2 weeks; uint256 public last; // stream starts empty (last = block.timestamp) or full (block.timestamp - frequency) IERC20 public gtc; constructor( address payable _toAddress, uint256 _cap, uint256 _frequency, bool _startsFull, IERC20 _gtc ) { toAddress = _toAddress; cap = _cap; frequency = _frequency; gtc = _gtc; if (_startsFull) { last = block.timestamp - frequency; } else { last = block.timestamp; } } /// @dev update the cap of a stream /// @param _cap cap update value for the stream function updateCap(uint256 _cap) public onlyOwner { cap = _cap; } /// @dev get the balance of a stream /// @return the balance of the stream function streamBalance() public view returns (uint256) { if (block.timestamp - last > frequency) { return cap; } return (cap * (block.timestamp - last)) / frequency; } /// @dev withdraw from a stream /// @param amount amount of withdraw /// @param reason reason for withdraw function streamWithdraw(uint256 amount, string memory reason) external { require(msg.sender == toAddress, "this stream is not for you"); uint256 totalAmountCanWithdraw = streamBalance(); require(totalAmountCanWithdraw >= amount, "not enough in the stream"); uint256 cappedLast = block.timestamp - frequency; if (last < cappedLast) { last = cappedLast; } last = last + (((block.timestamp - last) * amount) / totalAmountCanWithdraw); emit Withdraw(msg.sender, amount, reason); require(gtc.transfer(msg.sender, amount), "Transfer failed"); } /// @notice Explain to an end user what this does /// @dev Explain to a developer any extra details /// @param reason reason for deposit /// @param value the amount of the deposit function streamDeposit(string memory reason, uint256 value) external { require(value >= cap / 10, "Not big enough, sorry."); require( gtc.transferFrom(msg.sender, address(this), value), "Transfer of tokens is not approved or insufficient funds" ); emit Deposit(msg.sender, value, reason); } } //SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./SimpleStream.sol"; /// @title Stream Factory Contract /// @author ghostffcode /// @notice Creates instances of SimpleStream for users contract StreamFactory is AccessControl, Ownable { mapping(address => address) public userStreams; /// @dev StreamAdded event to track the streams after creation event StreamAdded(address creator, address user, address stream); bytes32 public constant FACTORY_MANAGER = keccak256("FACTORY_MANAGER"); /// @dev modifier for the factory manager role modifier isPermittedFactoryManager() { require( hasRole(FACTORY_MANAGER, msg.sender), "Not an approved factory manager" ); _; } constructor(address _admin) { _setupRole(DEFAULT_ADMIN_ROLE, _admin); _setupRole(FACTORY_MANAGER, _admin); transferOwnership(_admin); } /// @notice Creates a new stream /// @param _toAddress the address of the payee /// @param _cap the stream max balance for the period of time /// @param _frequency the frequency of the stream /// @param _startsFull does the stream start full? /// @param _gtc the GTC token address function createStreamFor( address payable _toAddress, uint256 _cap, uint256 _frequency, bool _startsFull, IERC20 _gtc ) public isPermittedFactoryManager returns (address streamAddress) { // deploy a new stream contract SimpleStream newStream = new SimpleStream( _toAddress, _cap, _frequency, _startsFull, _gtc ); streamAddress = address(newStream); // map user to new stream userStreams[_toAddress] = streamAddress; emit StreamAdded(msg.sender, _toAddress, streamAddress); } /// @notice Add a new stream for a new user /// @param stream the stream contract address function addStreamForUser(SimpleStream stream) public isPermittedFactoryManager { address payable _toAddress = stream.toAddress(); address streamAddress = address(stream); userStreams[_toAddress] = streamAddress; emit StreamAdded(msg.sender, _toAddress, streamAddress); } function updateUserStreamCap(address user, uint256 cap) public isPermittedFactoryManager { SimpleStream(userStreams[user]).updateCap(cap); } /// @notice returns a stream for a specified user /// @param user the user to get a stream for function getStreamForUser(address user) public view returns (address) { return userStreams[user]; } /// @notice Adds a new Factory Manager /// @param _newFactoryManager the address of the person you are adding function addFactoryManager(address _newFactoryManager) public onlyOwner { grantRole(FACTORY_MANAGER, _newFactoryManager); } }
@dev update the cap of a stream @param _cap cap update value for the stream
function updateCap(uint256 _cap) public onlyOwner { c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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1089, 4664, 12, 11890, 5034, 389, 5909, 13, 1071, 1338, 5541, 288, 203, 3639, 3523, 273, 389, 5909, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x32214b83E94D3C2f026c4964Bc73d32bd0dFa234/sources/contracts/NFT721Bridge.sol
Mapping of wrapped assets (chainID => nativeAddress => wrappedAddress)
mapping(uint16 => mapping(address => address)) public wrappedAssets;
3,005,035
[ 1, 4625, 348, 7953, 560, 30, 225, 9408, 434, 5805, 7176, 261, 5639, 734, 516, 6448, 1887, 516, 5805, 1887, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2874, 12, 11890, 2313, 516, 2874, 12, 2867, 516, 1758, 3719, 1071, 5805, 10726, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/80001/0xB4cb47bc9C7c7E49d742EB032D8BafD377Be1f31/sources/contracts/Vault.sol
@notice Calculates the amount to deposit or withdraw to protocol during a vault rebalance @param _totalUnderlying Totalunderlying = TotalUnderlyingInProtocols - BalanceVault @param _protocol Protocol id number @return amountToProtocol amount to deposit or withdraw to protocol
function calcAmountToProtocol( uint256 _totalUnderlying, uint256 _protocol ) internal view returns (int256 amountToProtocol) { if (totalAllocatedTokens == 0) amountToProtocol = 0; else amountToProtocol = (int(_totalUnderlying) * currentAllocations[_protocol]) / totalAllocatedTokens; }
5,563,955
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 26128, 326, 3844, 358, 443, 1724, 578, 598, 9446, 358, 1771, 4982, 279, 9229, 283, 12296, 632, 891, 389, 4963, 14655, 6291, 10710, 9341, 6291, 273, 10710, 14655, 6291, 382, 21657, 300, 30918, 12003, 632, 891, 389, 8373, 4547, 612, 1300, 632, 2463, 3844, 774, 5752, 3844, 358, 443, 1724, 578, 598, 9446, 358, 1771, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 7029, 6275, 774, 5752, 12, 203, 565, 2254, 5034, 389, 4963, 14655, 6291, 16, 203, 565, 2254, 5034, 389, 8373, 203, 225, 262, 2713, 1476, 1135, 261, 474, 5034, 3844, 774, 5752, 13, 288, 203, 565, 309, 261, 4963, 29392, 5157, 422, 374, 13, 3844, 774, 5752, 273, 374, 31, 203, 565, 469, 203, 1377, 3844, 774, 5752, 273, 203, 3639, 261, 474, 24899, 4963, 14655, 6291, 13, 380, 783, 8763, 1012, 63, 67, 8373, 5717, 342, 203, 3639, 2078, 29392, 5157, 31, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.18; import './VMEUpgrade.sol'; /// @title Vowme crowdsale and token contract contract VMEToken is VMEUpgrade { string public constant name = "VowMe Token"; string public constant symbol = "VME"; uint8 public constant decimals = 18; // decimal places /// Event for token burn logging. /// @param _burner Who burns their tokens. /// @param _value Weis burned. event Burn(address indexed _burner, uint256 indexed _value); /// @dev The main entry point for contract creation. function VMEToken( address _vowmeMultisig, address _upgradeMaster, uint256 _fundingStartBlock, uint256 _fundingEndBlock ) VMECrowdsale( _vowmeMultisig, _fundingStartBlock, _fundingEndBlock ) VMEUpgrade( _upgradeMaster ) Ownable() public { } /// @notice Transfer `_value` VME tokens from sender's account /// `msg.sender` to provided account address `_to`. /// @notice This function is disabled during the funding. /// @dev Required state: Success /// @param _to The address of the recipient /// @param _value The number of VME to transfer /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public onlyPayloadSize(2) returns (bool success) { require(fundingFinalized); // tokens are transferable only after funding is finished successfully require(_to != address(0)); require(_to != address(this)); // do not allow transfer to the token contract itself require(_to != address(upgradeAgent)); // SafeMath.sub will throw if there is not enough balance balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); // An event to make the transfer easy to find on the blockchain Transfer(msg.sender, _to, _value); return true; } /// @notice Transfer `_value` VME tokens from sender `_from` /// to provided account address `_to`. /// @notice This function is disabled during the funding. /// @dev Required state: Success /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The number of VME to transfer /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3) returns (bool success) { require(fundingFinalized); // tokens are transferable only after the funding is finished require(_to != address(0)); require(_to != address(this)); // do not allow transfer to the token contract itself require(_to != address(upgradeAgent)); uint256 allowance = allowed[_from][msg.sender]; // Check is not needed because allowance.sub(_value) // will already throw if this condition is not met // require (_value <= allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowance.sub(_value); // An event to make the transfer easy to find on the blockchain Transfer(_from, _to, _value); return true; } /// @notice `msg.sender` approves `_spender` to spend `_value` tokens. /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public onlyPayloadSize(2) returns (bool success) { require(fundingFinalized); // tokens are transferable only after the funding is finished // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /// @dev Burns a specific amount of tokens. /// @param _value The amount of tokens to be burned. function burn(uint256 _value) external onlyPayloadSize(1) { require(fundingFinalized); // tokens are burnable only after the funding is finished require(_value != 0); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); // Keep token balance tracking services happy by sending the burned amount to // "burn address", so that it will show up as a ERC-20 transaction // in etherscan, etc. as there is no standarized burn event yet Transfer(burner, 0, _value); } /// @dev Gets the balance of the specified address. /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /// @dev Function to check the amount of tokens that an owner allowed to a spender. /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } // Functions for promises and donations (will be used after the service's web part is released): // Flag that determines if the promises functionality is permitted or not bool public promisesAllowed; // Expiration date (as a unix timestamp) for each promise mapping (uint32 => uint256) promiseExpirationDate; // Current balance of each promise mapping (uint32 => uint256) public promiseBalance; // The map that stores the flag for each promise that determines // if donations are permitted for the promise mapping (uint32 => bool) promiseDenyDonations; // The map that stores the amount of tokens // the specified donor transferred to the specified promise mapping (uint32 => mapping (uint32 => uint256)) public statDonatorPromiseSum; // The rate period (can be changed by the contract's owner) uint256 public ratePeriod = 1 weeks; // The service fee percentage (can be changed by the contract's owner) uint256 public feePercent = 0; // The map that stores the rating which // the specified donor has set to the specified promise // 1 = failed, 2 = not sure, 3 = kept mapping (uint32 => mapping (uint32 => uint8)) public donatorPromiseRate; // The map that stores the `true` flag for each address // that has requested an amount of free tokens to be able // to initialize its promise mapping (address => bool) freeRequested; // How many tokens have been requested through `getFree` function // (see below) uint256 public vmeGiftTotal; // How many tokens can be given out through `getFree` function. // This number can be changed by the owner if necessary (see below) uint256 public vmeGiftLimit = 100000; // Events for some of the functions described below event Initialize(address indexed _author, uint256 _amount, uint32 indexed _id, uint256 _expiration); event Donate(address indexed _donator, uint256 _amount, uint32 indexed _promiseId, uint32 indexed _donatorId); event Kept(address indexed _donator, uint32 indexed _promiseId, uint32 indexed _donatorId); event Failed(address indexed _donator, uint32 indexed _promiseId, uint32 indexed _donatorId); event Notsure(address indexed _donator, uint32 indexed _promiseId, uint32 indexed _donatorId); event Move(uint32 indexed _promiseId, address indexed _target, uint256 _amount); event ProofLoaded(uint32 indexed _promiseId, uint256 _newExpiration); event GetFree(address indexed _to); /// @notice Enables promises and donations functionality. /// Can be called only by the owner after a successful funding. function promisesAllow() external onlyOwner { require(fundingFinalized); // promises functions are enabled only after a successful funding require(!promisesAllowed); promisesAllowed = true; } /// @notice This function is called by the author of the promise /// to initialize the specified promise. /// @param _amount The number of tokens that the author donates to. /// @param _code The numeric code that stores the ID of the promise /// and it's expiration date (as a unix timestamp). The author will /// see the code on the promise's page after it's created. function initialize(uint256 _amount, uint256 _code) external onlyPayloadSize(2) { require(promisesAllowed); // promises functions must be enabled require(_amount != 0); require(_code != 0); uint32 promiseId = uint32(_code >> 32); // the promise ID (the second 32bit word of the _code variable) require(promiseExpirationDate[promiseId] == 0); // can't initialize twice // Store the promise expiration date (as a unix timestamp) promiseExpirationDate[promiseId] = _code & 0xFFFFFFFF; // the first 32bit word of the _code require(promiseExpirationDate[promiseId] != 0); uint256 fee = 0; if (feePercent != 0) { // Calculate the service fee (if specified) fee = _amount.mul(feePercent).div(100); // Increase multisignature wallet balance by the fee amount balances[vowmeMultisig] = balances[vowmeMultisig].add(fee); } // Decrease the author's balance balances[msg.sender] = balances[msg.sender].sub(_amount); // Decrease the initial value by the fee amount uint256 clearAmount = _amount.sub(fee); // Set the promise balance promiseBalance[promiseId] = clearAmount; // Donator's (challenger's) ID uint32 donatorId = uint32(_code >> 64); // the third 32bit word of the _code // If the donor challenges someone if (donatorId != 0) { // Update the donor's statistics statDonatorPromiseSum[donatorId][promiseId] = statDonatorPromiseSum[donatorId][promiseId].add(clearAmount); // Notify listeners about this event Initialize(msg.sender, clearAmount, promiseId, promiseExpirationDate[promiseId]); Donate(msg.sender, clearAmount, promiseId, donatorId); } else { Initialize(msg.sender, clearAmount, promiseId, promiseExpirationDate[promiseId]); } } /// @notice This function is called by the donor /// to transfer the specified amount of tokens to the specified promise. /// @param _amount The number of tokens that the donor transfers to the promise. /// @param _code The numeric code that contains the promise ID and the donor ID. /// The donor will see the _code on the promise page when he clicks the `Donate` button. function donate(uint256 _amount, uint256 _code) external onlyPayloadSize(2) { require(_amount != 0); require(_code != 0); // Promise's ID uint32 promiseId = uint32(_code >> 32); // the second 32bit word of the _code variable // Check if the promise is expired or // wasn't initialized by the author require(now <= promiseExpirationDate[promiseId]); // Are donations enabled for this promise? require(!promiseDenyDonations[promiseId]); uint256 fee = 0; if (feePercent != 0) { // Calculate service's fee if specified fee = _amount.mul(feePercent).div(100); // Increase multisignature wallet balance by amount of the fee balances[vowmeMultisig] = balances[vowmeMultisig].add(fee); } // Decrease the donor's balance balances[msg.sender] = balances[msg.sender].sub(_amount); // Reduce the initial value by amount of the fee uint256 clearAmount = _amount.sub(fee); // Increase the promise's balance promiseBalance[promiseId] = promiseBalance[promiseId].add(clearAmount); // Donator's ID uint32 donatorId = uint32(_code); // the first 32bit word of the _code // Update the donor's statistics statDonatorPromiseSum[donatorId][promiseId] = statDonatorPromiseSum[donatorId][promiseId].add(clearAmount); // Notify listeners about this event Donate(msg.sender, clearAmount, promiseId, donatorId); } /// @dev An internal function for `kept`, `failed` and `notsure` /// functions described below. function rate(uint256 _code) internal view returns(uint32 promiseId, uint32 donatorId) { require(_code != 0); // Promise's ID promiseId = uint32(_code >> 32); // the second 32bit word of the _code // Check if we are within the rate period require(now > promiseExpirationDate[promiseId]); require(now <= promiseExpirationDate[promiseId].add(ratePeriod)); // Donator's ID donatorId = uint32(_code); // the first 32bit word of the _code // Donor can rate a promise only once require(donatorPromiseRate[donatorId][promiseId] == 0); // Donor must donate some tokens to the promise // before he can rate it require(statDonatorPromiseSum[donatorId][promiseId] != 0); } /// @notice This function is called by the donor /// to `like` the specified promise. /// @param _code The numeric code that contains promise's ID and donator's ID. /// The _code can be read by donator on promise's page /// when he presses `Kept` button. function kept(uint256 _code) external onlyPayloadSize(1) { var (promiseId, donatorId) = rate(_code); donatorPromiseRate[donatorId][promiseId] = 3; // kept Kept(msg.sender, promiseId, donatorId); } /// @notice This function should be called by donator /// to make a `notsure` rate for a specified promise. /// @param _code The numeric code that contains promise's ID and donator's ID. /// The _code can be read by donator on promise's page /// when he presses `Not sure` button. function notsure(uint256 _code) external onlyPayloadSize(1) { var (promiseId, donatorId) = rate(_code); donatorPromiseRate[donatorId][promiseId] = 2; // not sure Notsure(msg.sender, promiseId, donatorId); } /// @notice This function should be called by donator /// to make a `dislike` rate for a specified promise. /// @param _code The numeric code that contains promise's ID and donator's ID. /// The _code can be read by donator on promise's page /// when he presses `Failed` button. function failed(uint256 _code) external onlyPayloadSize(1) { var (promiseId, donatorId) = rate(_code); donatorPromiseRate[donatorId][promiseId] = 1; // failed Failed(msg.sender, promiseId, donatorId); } /// @notice Move the promise's tokens to `_target` address. /// The _target can be the promiser's (author's) or a charity's address. /// This function may be called only by the owner. /// @param _code The special number that stores the promise's ID /// and other necessary info. /// @param _amount The number of tokens to be moved. /// @param _target The address which will receive tokens. function move(uint256 _code, uint256 _amount, address _target) external onlyPayloadSize(3) onlyOwner { // Promise's ID uint32 promiseId = uint32(_code); // the first 32bit word of the _code require(promiseExpirationDate[promiseId] != 0); // make sure the promise is initialized require(now > promiseExpirationDate[promiseId]); // the expiration date must be in the past // Should we deny donations for this promise? bool denyDonations = ((_code >> 32) & 1) != 0; if (denyDonations) { promiseDenyDonations[promiseId] = true; } // Decrease the promise's balance promiseBalance[promiseId] = promiseBalance[promiseId].sub(_amount); // Increase the target's balance balances[_target] = balances[_target].add(_amount); // Notify listeners about this event Move(promiseId, _target, _amount); } /// @notice This function is called by the owner when /// a proof is loaded by the author of the promise. /// @param _code The numeric code that stores the ID of the promise /// and it's new expiration date (as a unix timestamp). function proofLoaded(uint256 _code) external onlyPayloadSize(1) onlyOwner { uint32 promiseId = uint32(_code >> 32); // promise's ID (the second 32bit word of the _code) require(promiseExpirationDate[promiseId] != 0); // make sure the promise is initialized // Update the promise's expiration date (as a unix timestamp) promiseExpirationDate[promiseId] = _code & 0xFFFFFFFF; // the first 32bit word of the _code // Disable donations to this promise promiseDenyDonations[promiseId] = true; // Notify listeners about this event ProofLoaded(promiseId, promiseExpirationDate[promiseId]); } /// @notice This function can be called by anyone /// who doesn't have any tokens. For example, /// it can be any user who wants to create his promise /// but doesn't have tokens to do so. A caller can /// make this token request only once. We gift them 0.01 VME. /// The max number of calls for this function is limited and /// defined in `vmeGiftLimit` variable. function getFree() external { require(promisesAllowed); // promises functions must be allowed require(balances[msg.sender] == 0); // balance of the caller must be empty require(!freeRequested[msg.sender]); // this is the first time for msg.sender require(vmeGiftTotal < vmeGiftLimit); // limit the number of calls to this function uint256 vmeGift = 10**16; // 0,01 VME balances[vowmeMultisig] = balances[vowmeMultisig].sub(vmeGift); balances[msg.sender] = vmeGift; freeRequested[msg.sender] = true; vmeGiftTotal = vmeGiftTotal.add(1); // Notify listeners about this event GetFree(msg.sender); Transfer(vowmeMultisig, msg.sender, vmeGift); } /// @dev Set new rate period. /// This function may be called only be the owner. /// @param _period The rate period in seconds. function setRatePeriod(uint256 _period) external onlyOwner { ratePeriod = _period; } /// @dev Set the fee percentage if neccessary. /// This function can be called only be the owner. /// @param _percent The fee percentage. function setFeePercent(uint256 _percent) external onlyOwner { feePercent = _percent; } /// @dev Set new call limit for `getFree` function. /// This function can be called only be the owner. /// @param _limit The new max number of calls. function setGiftLimit(uint256 _limit) external onlyOwner { vmeGiftLimit = _limit; } }
@notice This function should be called by donator to make a `dislike` rate for a specified promise. @param _code The numeric code that contains promise's ID and donator's ID. The _code can be read by donator on promise's page when he presses `Failed` button.
function failed(uint256 _code) external onlyPayloadSize(1) { var (promiseId, donatorId) = rate(_code); Failed(msg.sender, promiseId, donatorId); }
14,024,191
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 1220, 445, 1410, 506, 2566, 635, 2727, 639, 358, 1221, 279, 1375, 2251, 5625, 68, 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, 6110, 1225, 12, 21, 13, 288, 203, 3639, 569, 261, 20837, 548, 16, 2727, 639, 548, 13, 273, 4993, 24899, 710, 1769, 203, 3639, 11175, 12, 3576, 18, 15330, 16, 5109, 548, 16, 2727, 639, 548, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.13; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/IDevDAONFT.sol"; import "./interfaces/IDevDAOPriceOracle.sol"; import "./interfaces/IDevDAORegistry.sol"; error DISALLOWED_LENGTH(); error NOT_ENOUGH_ETH(); error ALREADY_MINTED(); error MINT_FAILED(); contract DevDAONameService is Ownable { uint8 public minLength = 3; uint8 public maxLength = 20; IDevDAONFT public immutable token; IDevDAOPriceOracle public immutable oracle; IDevDAORegistry public immutable registry; address payable public immutable treasury; constructor( IDevDAONFT _token, IDevDAORegistry _registry, IDevDAOPriceOracle _oracle, address payable _treasury ) { token = _token; registry = _registry; oracle = _oracle; treasury = _treasury; token.initialize(address(_registry)); registry.initialize(address(_token)); oracle.initialize(); } function arbitraryCall(address _contract, bytes calldata _calldata) external payable onlyOwner { // solhint-disable-next-line _contract.call{value: msg.value}(_calldata); } function updateMinLength(uint8 _newMinLength) external onlyOwner { minLength = _newMinLength; } function updateMaxLength(uint8 _newMaxLength) external onlyOwner { maxLength = _newMaxLength; } function mint(string calldata name) external payable { uint256 length = bytes(name).length; // we don't care about non-UTF8 lengths if (minLength > length) { revert DISALLOWED_LENGTH(); } if (length > maxLength) { revert DISALLOWED_LENGTH(); } if (msg.value < oracle.lengthToPrices(uint8(length))) { revert NOT_ENOUGH_ETH(); } if (registry.namesToTokenId(name) != 0) { revert ALREADY_MINTED(); } // solhint-disable-next-line treasury.call{value: msg.value}(""); if (!token.mint(msg.sender, name)) { revert MINT_FAILED(); } } }
solhint-disable-next-line
function arbitraryCall(address _contract, bytes calldata _calldata) external payable onlyOwner { }
12,697,965
[ 1, 4625, 348, 7953, 560, 30, 225, 3704, 11317, 17, 8394, 17, 4285, 17, 1369, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 11078, 1477, 12, 2867, 389, 16351, 16, 1731, 745, 892, 389, 1991, 892, 13, 203, 3639, 3903, 203, 3639, 8843, 429, 203, 3639, 1338, 5541, 203, 565, 288, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2022-03-02 */ // File: @openzeppelin/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: erc721a/contracts/ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintedQueryForZeroAddress(); error BurnedQueryForZeroAddress(); error AuxQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerIndexOutOfBounds(); error OwnerQueryForNonexistentToken(); error TokenIndexOutOfBounds(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev See {IERC721Enumerable-totalSupply}. * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { if (owner == address(0)) revert MintedQueryForZeroAddress(); return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { if (owner == address(0)) revert AuxQueryForZeroAddress(); return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { if (owner == address(0)) revert AuxQueryForZeroAddress(); _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (safe && to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { TokenOwnership memory prevOwnership = ownershipOf(tokenId); _beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[prevOwnership.addr].balance -= 1; _addressData[prevOwnership.addr].numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. _ownerships[tokenId].addr = prevOwnership.addr; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); _ownerships[tokenId].burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(prevOwnership.addr, address(0), tokenId); _afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: KEVINMFER.sol pragma solidity ^0.8.10; contract KEVINMFER is ERC721A, Ownable, ReentrancyGuard { bool public isSaleActive = false; string public baseURI; uint256 public maxSupply = 3333; uint256 public freeMaxSupply = 333; uint256 public maxPerTxn = 10; uint256 public price = 0.0169 ether; constructor() ERC721A("KEVINMFER", "KEVINMFER") {} modifier saleActive() { require(isSaleActive, "Public sale is not live"); _; } function togglePublicSale() external onlyOwner { isSaleActive = !isSaleActive; } modifier mintAvailability(uint256 quantity) { require(totalSupply() + quantity <= maxSupply, "Exceeds max supply"); _; } modifier mintMaxPerTxn(uint256 quantity) { require(quantity > 0 && quantity <= maxPerTxn, "Exceeds max per txn"); _; } function mint(uint256 quantity) public payable saleActive mintAvailability(quantity) mintMaxPerTxn(quantity) { if (totalSupply() + quantity > freeMaxSupply) { require(msg.value >= price * quantity, "Free mint is sold out, use correct price"); } _safeMint(msg.sender, quantity); } function reservedMint(address recipient, uint256 quantity) external onlyOwner mintAvailability(quantity) { _safeMint(recipient, quantity); } function updateFreeMint(uint256 _freeMaxSupply) public onlyOwner { freeMaxSupply = _freeMaxSupply; } function updateMaxSupply(uint256 newMaxSupply) external onlyOwner { maxSupply = newMaxSupply; } function setPrice(uint256 newPrice) external onlyOwner { price = newPrice; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist."); return string(abi.encodePacked(baseURI, Strings.toString(_tokenId))); } function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } function withdraw() external onlyOwner nonReentrant{ require(payable(owner()).send(address(this).balance), "Not enough funds to withdraw"); } }
File: KEVINMFER.sol
contract KEVINMFER is ERC721A, Ownable, ReentrancyGuard { bool public isSaleActive = false; string public baseURI; uint256 public maxSupply = 3333; uint256 public freeMaxSupply = 333; uint256 public maxPerTxn = 10; uint256 public price = 0.0169 ether; constructor() ERC721A("KEVINMFER", "KEVINMFER") {} function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity } pragma solidity ^0.8.10; modifier saleActive() { require(isSaleActive, "Public sale is not live"); _; } function togglePublicSale() external onlyOwner { isSaleActive = !isSaleActive; } modifier mintAvailability(uint256 quantity) { require(totalSupply() + quantity <= maxSupply, "Exceeds max supply"); _; } modifier mintMaxPerTxn(uint256 quantity) { require(quantity > 0 && quantity <= maxPerTxn, "Exceeds max per txn"); _; } function mint(uint256 quantity) public payable saleActive mintAvailability(quantity) mintMaxPerTxn(quantity) { if (totalSupply() + quantity > freeMaxSupply) { require(msg.value >= price * quantity, "Free mint is sold out, use correct price"); } _safeMint(msg.sender, quantity); } function mint(uint256 quantity) public payable saleActive mintAvailability(quantity) mintMaxPerTxn(quantity) { if (totalSupply() + quantity > freeMaxSupply) { require(msg.value >= price * quantity, "Free mint is sold out, use correct price"); } _safeMint(msg.sender, quantity); } function reservedMint(address recipient, uint256 quantity) external onlyOwner mintAvailability(quantity) { _safeMint(recipient, quantity); } function updateFreeMint(uint256 _freeMaxSupply) public onlyOwner { freeMaxSupply = _freeMaxSupply; } function updateMaxSupply(uint256 newMaxSupply) external onlyOwner { maxSupply = newMaxSupply; } function setPrice(uint256 newPrice) external onlyOwner { price = newPrice; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist."); return string(abi.encodePacked(baseURI, Strings.toString(_tokenId))); } function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } function withdraw() external onlyOwner nonReentrant{ require(payable(owner()).send(address(this).balance), "Not enough funds to withdraw"); } }
2,172,741
[ 1, 4625, 348, 7953, 560, 30, 225, 1387, 30, 1475, 24427, 706, 49, 6553, 18, 18281, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 1475, 24427, 706, 49, 6553, 353, 4232, 39, 27, 5340, 37, 16, 14223, 6914, 16, 868, 8230, 12514, 16709, 288, 203, 565, 1426, 565, 1071, 11604, 5349, 3896, 273, 629, 31, 203, 565, 533, 225, 1071, 1026, 3098, 31, 203, 565, 2254, 5034, 1071, 943, 3088, 1283, 273, 890, 3707, 23, 31, 203, 565, 2254, 5034, 1071, 4843, 2747, 3088, 1283, 273, 890, 3707, 31, 203, 565, 2254, 5034, 1071, 943, 2173, 13789, 273, 1728, 31, 203, 565, 2254, 5034, 1071, 6205, 273, 374, 18, 1611, 8148, 225, 2437, 31, 203, 203, 203, 565, 3885, 1435, 4232, 39, 27, 5340, 37, 2932, 6859, 58, 706, 49, 6553, 3113, 315, 6859, 58, 706, 49, 6553, 7923, 2618, 203, 565, 445, 389, 5771, 1345, 1429, 18881, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 787, 1345, 548, 16, 203, 3639, 2254, 5034, 10457, 203, 203, 565, 445, 389, 5205, 1345, 1429, 18881, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 787, 1345, 548, 16, 203, 3639, 2254, 5034, 10457, 203, 97, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 2163, 31, 203, 203, 203, 203, 203, 565, 9606, 272, 5349, 3896, 1435, 288, 203, 3639, 2583, 12, 291, 30746, 3896, 16, 315, 4782, 272, 5349, 353, 486, 8429, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 445, 10486, 4782, 30746, 1435, 3903, 1338, 5541, 288, 203, 3639, 11604, 5349, 3896, 273, 401, 291, 30746, 3896, 31, 203, 565, 289, 203, 203, 565, 9606, 312, 474, 10427, 12, 11890, 5034, 10457, 13, 288, 203, 3639, 2583, 12, 4963, 3088, 1283, 1435, 397, 10457, 1648, 943, 3088, 1283, 16, 315, 424, 5288, 87, 943, 14467, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 9606, 312, 474, 2747, 2173, 13789, 12, 11890, 5034, 10457, 13, 288, 203, 3639, 2583, 12, 16172, 405, 374, 597, 10457, 1648, 943, 2173, 13789, 16, 315, 424, 5288, 87, 943, 1534, 7827, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 445, 312, 474, 12, 11890, 5034, 10457, 13, 1071, 8843, 429, 272, 5349, 3896, 312, 474, 10427, 12, 16172, 13, 312, 474, 2747, 2173, 13789, 12, 16172, 13, 288, 203, 3639, 309, 261, 4963, 3088, 1283, 1435, 397, 10457, 405, 4843, 2747, 3088, 1283, 13, 288, 203, 5411, 2583, 12, 3576, 18, 1132, 1545, 6205, 380, 10457, 16, 315, 9194, 312, 474, 353, 272, 1673, 596, 16, 999, 3434, 6205, 8863, 203, 3639, 289, 203, 3639, 389, 4626, 49, 474, 12, 3576, 18, 15330, 16, 10457, 1769, 203, 565, 289, 203, 203, 565, 445, 312, 474, 12, 11890, 5034, 10457, 13, 1071, 8843, 429, 272, 5349, 3896, 312, 474, 10427, 12, 16172, 13, 312, 474, 2747, 2173, 13789, 12, 16172, 13, 288, 203, 3639, 309, 261, 4963, 3088, 1283, 1435, 397, 10457, 405, 4843, 2747, 3088, 1283, 13, 288, 203, 5411, 2583, 12, 3576, 18, 1132, 1545, 6205, 380, 10457, 16, 315, 9194, 312, 474, 353, 272, 1673, 596, 16, 999, 3434, 6205, 8863, 203, 3639, 289, 203, 3639, 389, 4626, 49, 474, 12, 3576, 18, 15330, 16, 10457, 1769, 203, 565, 289, 203, 203, 565, 445, 8735, 49, 474, 12, 2867, 8027, 16, 2254, 5034, 10457, 13, 3903, 1338, 5541, 312, 474, 10427, 12, 16172, 13, 288, 203, 3639, 389, 4626, 49, 474, 12, 20367, 16, 10457, 1769, 203, 565, 289, 203, 203, 565, 445, 1089, 9194, 49, 474, 12, 11890, 5034, 389, 9156, 2747, 3088, 1283, 13, 1071, 1338, 5541, 288, 203, 3639, 4843, 2747, 3088, 1283, 273, 389, 9156, 2747, 3088, 1283, 31, 203, 565, 289, 203, 377, 203, 565, 445, 1089, 2747, 3088, 1283, 12, 11890, 5034, 394, 2747, 3088, 1283, 13, 3903, 1338, 5541, 288, 203, 3639, 943, 3088, 1283, 273, 394, 2747, 3088, 1283, 31, 203, 565, 289, 203, 203, 565, 445, 444, 5147, 12, 11890, 5034, 394, 5147, 13, 3903, 1338, 5541, 288, 203, 3639, 6205, 273, 394, 5147, 31, 203, 565, 289, 203, 203, 565, 445, 1147, 3098, 12, 11890, 5034, 389, 2316, 548, 13, 1071, 1476, 3849, 1135, 261, 1080, 3778, 13, 288, 203, 3639, 2583, 24899, 1808, 24899, 2316, 548, 3631, 315, 1345, 1552, 486, 1005, 1199, 1769, 203, 3639, 327, 533, 12, 21457, 18, 3015, 4420, 329, 12, 1969, 3098, 16, 8139, 18, 10492, 24899, 2316, 548, 3719, 1769, 203, 565, 289, 203, 203, 565, 445, 26435, 3098, 12, 1080, 3778, 1026, 3098, 67, 13, 3903, 1338, 5541, 288, 203, 3639, 1026, 3098, 273, 1026, 3098, 67, 31, 203, 565, 289, 203, 203, 565, 445, 598, 9446, 1435, 3903, 1338, 5541, 1661, 426, 8230, 970, 95, 203, 3639, 2583, 12, 10239, 429, 12, 8443, 1435, 2934, 4661, 12, 2867, 12, 2211, 2934, 12296, 3631, 315, 1248, 7304, 284, 19156, 358, 598, 9446, 8863, 203, 565, 289, 203, 97, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
library ChessLogic { struct State { int8[128] fields; address playerWhite; } // default state array, all numbers offset by +8 bytes constant defaultState = '\x04\x06\x05\x03\x02\x05\x06\x04\x08\x08\x08\x0c\x08\x08\x08\x08\x07\x07\x07\x07\x07\x07\x07\x07\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x09\x09\x09\x09\x09\x09\x09\x09\x08\x08\x08\x08\x08\x08\x08\x08\x0c\x0a\x0b\x0d\x0e\x0b\x0a\x0c\x08\x08\x08\x7c\x08\x08\x08\x08'; /* Flags needed for validation * Usage e.g. Flags(Flag.FLAG_NAME), Directions(Direction.UP), Players(Player.WHITE) * Because there are no constant arrays in Solidity, we use byte literals that * contain the needed numbers encoded as hex characters. We can only encode * positive numbers this way, so if negative flags are needed, all values are * stored shifted and later un-shifted in the accessors. */ enum Player { WHITE, // 1 BLACK } // -1 enum Piece { BLACK_KING, // -6 BLACK_QUEEN, // -5 BLACK_ROOK, // -4 BLACK_BISHOP,// -3 BLACK_KNIGHT,// -2 BLACK_PAWN, // -1 EMPTY, // 0 WHITE_PAWN, // 1 WHITE_KNIGHT,// 2 WHITE_BISHOP,// 3 WHITE_ROOK, // 4 WHITE_QUEEN, // 5 WHITE_KING } // 6 enum Direction { UP, // 16 UP_RIGHT, // 15 RIGHT, // 1 DOWN_RIGHT, // -17 DOWN, // -16 DOWN_LEFT, // -15 LEFT, // -1 UP_LEFT } // 17 bytes constant c_Directions = "\x30\x31\x41\x51\x50\x4f\x3f\x2f"; // [-16,-15, 1, 17, 16, 15, -1,-17] shifted by +64 enum Flag { MOVE_COUNT_H, // 8 MOVE_COUNT_L, // 9 WHITE_KING_POS, // 123 BLACK_KING_POS, // 11 CURRENT_PLAYER, // 56 WHITE_LEFT_CASTLING, // 78 WHITE_RIGHT_CASTLING, // 79 BLACK_LEFT_CASTLING, // 62 BLACK_RIGHT_CASTLING, // 63 BLACK_EN_PASSANT, // 61 WHITE_EN_PASSANT} // 77 bytes constant c_Flags = "\x08\x09\x7b\x0b\x38\x4e\x4f\x3e\x3f\x3d\x4d"; // [ 8, 9,123, 11, 56, 78, 79, 62, 63, 61, 77] bytes constant knightMoves = '\x1f\x21\x2e\x32\x4e\x52\x5f\x61'; // [-33,-31,-18,-14,14, 18, 31, 33] shifted by +64 function Flags(Flag i) constant internal returns (uint) { return uint(c_Flags[uint(i)]); } function Pieces(Piece i) constant internal returns (int8) { return -6 + int8(uint(i)); } function Directions(Direction i) constant internal returns (int8) { return -64 + int8(c_Directions[uint(i)]); } function Players(Player p) constant internal returns (int8) { if (p == Player.WHITE) { return 1; } return -1; } /** * Convenience function to set a flag * Usage: setFlag(state, Flag.BLACK_KING_POS, 4); */ function setFlag(State storage self, Flag flag, int value) internal { self.fields[Flags(flag)] = int8(value); } /** * Convenience function to set a flag * Usage: getFlag(state, Flag.BLACK_KING_POS); */ function getFlag(State storage self, Flag flag) constant internal returns (int8) { return self.fields[Flags(flag)]; } function setupState(State storage self, int8 nextPlayerColor) { // Initialize state for (uint i = 0; i < 128; i++) { // Read defaultState bytes string, which is offset by 8 to be > 0 self.fields[i] = int8(defaultState[i]) - 8; } setFlag(self, Flag.CURRENT_PLAYER, nextPlayerColor); } function setState(State storage self, int8[128] newState, int8 nextPlayerColor) { self.fields = newState; setFlag(self, Flag.CURRENT_PLAYER, nextPlayerColor); } /* validates a move and executes it */ function move(State storage self, uint256 fromIndex, uint256 toIndex, bool isWhite) public { int8 currentPlayerColor; if (isWhite) { currentPlayerColor = Players(Player.WHITE); } else { currentPlayerColor = Players(Player.BLACK); } int8 fromFigure = self.fields[fromIndex]; int8 toFigure = self.fields[toIndex]; // Simple sanity checks sanityCheck(fromIndex, toIndex, fromFigure, toFigure, currentPlayerColor); // Check if move is technically possible if (!validateMove(self, fromIndex, toIndex, fromFigure, toFigure, currentPlayerColor)) { throw; } // For all pieces except knight, check if way is free if (abs(fromFigure) != uint(Pieces(Piece.WHITE_KNIGHT))) { // In case of king, it will check that he is not in check on any of the fields he moves over bool checkForCheck = abs(fromFigure) == uint(Pieces(Piece.WHITE_KING)); checkWayFree(self, fromIndex, toIndex, currentPlayerColor, checkForCheck); // Check field between rook and king in case of castling if (fromFigure == Pieces(Piece.BLACK_KING) && toIndex == 2 && self.fields[1] != 0 || fromFigure == Pieces(Piece.WHITE_KING) && toIndex == 114 && self.fields[113] != 0) { throw; } } // Make the move makeMove(self, fromIndex, toIndex, fromFigure, toFigure); // Check legality (player's own king may not be in check after move) checkLegality(self, fromIndex, toIndex, fromFigure, toFigure, currentPlayerColor); // Update move count // High and Low are int8, so from -127 to 127 // By using two flags we extend the positive range to 14 bit, 0 to 16384 int16 moveCount = int16(getFlag(self, Flag.MOVE_COUNT_H)) * (2**7) | int16(getFlag(self, Flag.MOVE_COUNT_L)); moveCount += 1; if (moveCount > 127) { setFlag(self, Flag.MOVE_COUNT_H, moveCount / (2**7)); } setFlag(self, Flag.MOVE_COUNT_L, moveCount % 128); // Update nextPlayer int8 nextPlayerColor = currentPlayerColor == Players(Player.WHITE) ? Players(Player.BLACK) : Players(Player.WHITE); setFlag(self, Flag.CURRENT_PLAYER, nextPlayerColor); } function sanityCheck(uint256 fromIndex, uint256 toIndex, int8 fromFigure, int8 toFigure, int8 currentPlayerColor) internal { // check that move is within the field if (toIndex & 0x88 != 0 || fromIndex & 0x88 != 0) { throw; } // check that from and to are distinct if (fromIndex == toIndex) { throw; } // check if the toIndex is empty (= is 0) or contains an enemy figure ("positive" * "negative" = "negative") // --> this only allows captures (negative results) or moves to empty fields ( = 0) if (fromFigure * toFigure > 0) { throw; } // check if mover of the figure is the owner of the figure // also check if there is a figure at fromIndex to move (fromFigure != 0) if (currentPlayerColor * fromFigure <= 0) { throw; } } /** * Validates if a move is technically (not legally) possible, * i.e. if piece is capable to move this way */ function validateMove(State storage self, uint256 fromIndex, uint256 toIndex, int8 fromFigure, int8 toFigure, int8 movingPlayerColor) returns (bool) { int direction = int(getDirection(fromIndex, toIndex)); bool isDiagonal = !(abs(direction) == 16 || abs(direction) == 1); // Kings if (abs(fromFigure) == uint(Pieces(Piece.WHITE_KING))) { // Normal move if (int(fromIndex) + direction == int(toIndex)) { return true; } // Cannot castle if already in check if (checkForCheck(self, fromIndex, movingPlayerColor)) { return false; } // Castling if (fromFigure == Pieces(Piece.BLACK_KING)) { if (4 == fromIndex && toFigure == 0) { if (toIndex == 2 && getFlag(self, Flag.BLACK_LEFT_CASTLING) >= 0) { return true; } if (toIndex == 6 && getFlag(self, Flag.BLACK_RIGHT_CASTLING) >= 0) { return true; } } } if (fromFigure == Pieces(Piece.WHITE_KING)) { if (116 == fromIndex && toFigure == 0) { if (toIndex == 114 && getFlag(self, Flag.WHITE_LEFT_CASTLING) >= 0) { return true; } if (toIndex == 118 && getFlag(self, Flag.WHITE_RIGHT_CASTLING) >= 0) { return true; } } } return false; } // Bishops, Queens, Rooks if (abs(fromFigure) == uint(Pieces(Piece.WHITE_BISHOP)) || abs(fromFigure) == uint(Pieces(Piece.WHITE_QUEEN)) || abs(fromFigure) == uint(Pieces(Piece.WHITE_ROOK))) { // Bishop can only walk diagonally, Rook only non-diagonally if (!isDiagonal && abs(fromFigure) == uint(Pieces(Piece.WHITE_BISHOP)) || isDiagonal && abs(fromFigure) == uint(Pieces(Piece.WHITE_ROOK))) { return false; } // Traverse all fields in direction int temp = int(fromIndex); // walk in direction while inside board to find toIndex // while (temp & 0x88 == 0) { for (uint j = 0; j < 8; j++) { if (temp == int(toIndex)) { return true; } temp = temp + direction; if (temp & 0x88 != 0) return false; } return false; } // Pawns if (abs(fromFigure) == uint(Pieces(Piece.WHITE_PAWN))) { // Black can only move in positive, White negative direction if (fromFigure == Pieces(Piece.BLACK_PAWN) && direction < 0 || fromFigure == Pieces(Piece.WHITE_PAWN) && direction > 0) { return false; } // Forward move if (!isDiagonal) { // no horizontal movement allowed if (abs(direction) < 2) { return false; } // simple move if (int(fromIndex) + direction == int(toIndex)) { if(toFigure == Pieces(Piece.EMPTY)){ return true; } } // double move if (int(fromIndex) + direction + direction == int(toIndex)) { // Can only do double move starting form specific ranks int rank = int(fromIndex/16); if (1 == rank || 6 == rank) { if(toFigure == Pieces(Piece.EMPTY)){ return true; } } } return false; } // diagonal move if (int(fromIndex) + direction == int(toIndex)) { // if empty, the en passant flag needs to be set if (toFigure * fromFigure == 0) { if (fromFigure == Pieces(Piece.BLACK_PAWN) && getFlag(self, Flag.WHITE_EN_PASSANT) == int(toIndex) || fromFigure == Pieces(Piece.WHITE_PAWN) && getFlag(self, Flag.BLACK_EN_PASSANT) == int(toIndex)) { return true; } return false; } // If not empty return true; } return false; } // Knights if (abs(fromFigure) == uint(Pieces(Piece.WHITE_KNIGHT))) { for (uint i; i < 8; i++) { if (int(fromIndex) + int(knightMoves[i]) - 64 == int(toIndex)) { return true; } } return false; } return false; } /** * Checks if the way between fromIndex and toIndex is unblocked */ function checkWayFree(State storage self, uint256 fromIndex, uint256 toIndex, int8 currentPlayerColor, bool shouldCheckForCheck) internal { int8 direction = getDirection(fromIndex, toIndex); int currentIndex = int(fromIndex) + direction; // as long as we do not reach the desired position walk in direction and check while (int(toIndex) != currentIndex) { // we reached the end of the field if (currentIndex & 0x88 != 0) { throw; } // the path is blocked if (self.fields[uint(currentIndex)] != 0) { throw; } // Check for check in case of king if (shouldCheckForCheck && checkForCheck(self, uint(currentIndex), currentPlayerColor)) { throw; } currentIndex = currentIndex + direction; } return; } function checkForCheck(State storage self, uint256 kingIndex, int8 currentPlayerColor) internal returns (bool) { // look in every direction whether there is an enemy figure that checks the king for (uint dir = 0; dir < 8; dir ++) { // get the first Figure in this direction. Threat of Knight does not change through move of fromFigure. // All other figures can not jump over figures. So only the first figure matters. int8 firstFigureIndex = getFirstFigure(self, Directions(Direction(dir)), int8(kingIndex)); // if we found a figure in the danger direction if (firstFigureIndex != -1) { int8 firstFigure = self.fields[uint(firstFigureIndex)]; // if its an enemy if (firstFigure * currentPlayerColor < 0) { // check if the enemy figure can move to the field of the king int8 kingFigure = Pieces(Piece.WHITE_KING) * currentPlayerColor; if (validateMove(self, uint256(firstFigureIndex), uint256(kingIndex), firstFigure, kingFigure, currentPlayerColor)) { // it can return true; // king is checked } } } } //Knights // Knights can jump over figures. So they need to be tested seperately with every possible move. for (uint move = 0; move < 8; move ++){ // currentMoveIndex: where knight could start with move that checks king int8 currentMoveIndex = int8(kingIndex) + int8(knightMoves[move]) - 64; // if inside the board if (uint(currentMoveIndex) & 0x88 == 0){ // get Figure at currentMoveIndex int8 currentFigure = Pieces(Piece(currentMoveIndex)); // if it is an enemy knight, king can be checked if (currentFigure * currentPlayerColor == Pieces(Piece.WHITE_KNIGHT)) { return true; // king is checked } } } return false; // king is not checked } function getDirection(uint256 fromIndex, uint256 toIndex) constant internal returns (int8) { // check if the figure is moved up or left of its origin bool isAboveLeft = fromIndex > toIndex; // check if the figure is moved in an horizontal plane // this code works because there is an eight square difference between the horizontal panes (the offboard) bool isSameHorizontal = (abs(int256(fromIndex) - int256(toIndex)) < (8)); // check if the figure is moved in a vertical line bool isSameVertical = (fromIndex%8 == toIndex%8); // check if the figure is moved to the left of its origin bool isLeftSide = (fromIndex%8 > toIndex%8); /*Check directions*/ if (isAboveLeft) { if (isSameVertical) { return Directions(Direction.UP); } if (isSameHorizontal) { return Directions(Direction.LEFT); } if (isLeftSide) { return Directions(Direction.UP_LEFT); } else { return Directions(Direction.UP_RIGHT); } } else { if (isSameVertical) { return Directions(Direction.DOWN); } if (isSameHorizontal) { return Directions(Direction.RIGHT); } if (isLeftSide) { return Directions(Direction.DOWN_LEFT); } else { return Directions(Direction.DOWN_RIGHT); } } } function makeMove(State storage self, uint256 fromIndex, uint256 toIndex, int8 fromFigure, int8 toFigure) internal { // remove all en passant flags setFlag(self, Flag.WHITE_EN_PASSANT, 0); setFlag(self, Flag.BLACK_EN_PASSANT, 0); // <---- Special Move ----> // Black King if (fromFigure == Pieces(Piece.BLACK_KING)) { // Update position flag setFlag(self, Flag.BLACK_KING_POS, int8(toIndex)); // Castling if (fromIndex == 4 && toIndex == 2) { self.fields[0] = 0; self.fields[3] = Pieces(Piece.BLACK_ROOK); } if (fromIndex == 4 && toIndex == 6) { self.fields[7] = 0; self.fields[5] = Pieces(Piece.BLACK_ROOK); } } // White King if (fromFigure == Pieces(Piece.WHITE_KING)) { // Update position flag setFlag(self, Flag.WHITE_KING_POS, int8(toIndex)); // Castling if (fromIndex == 116 && toIndex == 114) { self.fields[112] = 0; self.fields[115] = Pieces(Piece.WHITE_ROOK); } if (fromIndex == 116 && toIndex == 118) { self.fields[119] = 0; self.fields[117] = Pieces(Piece.WHITE_ROOK); } } // Remove Castling Flag if king or Rook moves. But only at the first move for better performance // Black if (fromFigure == Pieces(Piece.BLACK_KING)) { if (fromIndex == 4) { setFlag(self, Flag.BLACK_LEFT_CASTLING, -1); setFlag(self, Flag.BLACK_RIGHT_CASTLING, -1); } } if (fromFigure == Pieces(Piece.BLACK_ROOK)) { if (fromIndex == 0) { setFlag(self, Flag.BLACK_LEFT_CASTLING, -1); } if (fromIndex == 7) { setFlag(self, Flag.BLACK_RIGHT_CASTLING, -1); } } // White if (fromFigure == Pieces(Piece.WHITE_KING)) { if (fromIndex == 116) { setFlag(self, Flag.WHITE_LEFT_CASTLING, -1); setFlag(self, Flag.WHITE_RIGHT_CASTLING, -1); } } if (fromFigure == Pieces(Piece.WHITE_ROOK)) { if (fromIndex == 112) { setFlag(self, Flag.WHITE_LEFT_CASTLING, -1); } if (fromIndex == 119) { setFlag(self, Flag.WHITE_RIGHT_CASTLING, -1); } } int8 direction = getDirection(fromIndex, toIndex); // PAWN - EN PASSANT or DOUBLE STEP if (abs(fromFigure) == uint(Pieces(Piece.WHITE_PAWN))) { // En Passant - remove caught pawn // en passant if figure: pawn and diagonal move to empty field if (is_diagonal(direction) && toFigure == Pieces(Piece.EMPTY)) { if (fromFigure == Pieces(Piece.BLACK_PAWN)) { self.fields[uint(int(toIndex) + Directions(Direction.UP))] = 0; } else { self.fields[uint(int(toIndex) + Directions(Direction.DOWN))] = 0; } } // in case of double Step: set EN_PASSANT-Flag else if (int(fromIndex) + direction + direction == int(toIndex)) { if (fromFigure == Pieces(Piece.BLACK_PAWN)) { setFlag(self, Flag.BLACK_EN_PASSANT, int8(toIndex) + Directions(Direction.UP)); } else { setFlag(self, Flag.WHITE_EN_PASSANT, int8(toIndex) + Directions(Direction.DOWN)); } } } // <---- Promotion ---> int targetRank = int(toIndex/16); if (targetRank == 7 && fromFigure == Pieces(Piece.BLACK_PAWN)) { self.fields[toIndex] = Pieces(Piece.BLACK_QUEEN); } else if (targetRank == 0 && fromFigure == Pieces(Piece.WHITE_PAWN)) { self.fields[toIndex] = Pieces(Piece.WHITE_QUEEN); } else { // Normal move self.fields[toIndex] = self.fields[fromIndex]; } self.fields[fromIndex] = 0; } // checks whether movingPlayerColor's king gets checked by move function checkLegality(State storage self, uint256 fromIndex, uint256 toIndex, int8 fromFigure, int8 toFigure, int8 movingPlayerColor) internal returns (bool){ // Piece that was moved was the king if (abs(fromFigure) == uint(Pieces(Piece.WHITE_KING))) { if (checkForCheck(self, uint(toIndex), movingPlayerColor)) { throw; } // Else we can skip the rest of the checks return; } int8 kingIndex = getOwnKing(self, movingPlayerColor); // Moved other piece, but own king is still in check if (checkForCheck(self, uint(kingIndex), movingPlayerColor)) { throw; } // through move of fromFigure away from fromIndex, // king may now be in danger from that direction int8 kingDangerDirection = getDirection(uint256(kingIndex), fromIndex); // get the first Figure in this direction. Threat of Knight does not change through move of fromFigure. // All other figures can not jump over other figures. So only the first figure matters. int8 firstFigureIndex = getFirstFigure(self, kingDangerDirection,kingIndex); // if we found a figure in the danger direction if (firstFigureIndex != -1) { int8 firstFigure = self.fields[uint(firstFigureIndex)]; // if its an enemy if (firstFigure * movingPlayerColor < 0) { // check if the figure can move to the field of the king int8 kingFigure = Pieces(Piece.BLACK_KING) * movingPlayerColor; if (validateMove(self, uint256(firstFigureIndex), uint256(kingIndex), firstFigure, kingFigure, movingPlayerColor)) { // it can throw; } } } return; } // gets the first figure in direction from start, not including start function getFirstFigure(State storage self, int8 direction, int8 start) returns (int8){ int currentIndex = start + direction; // as long as we do not reach the end of the board walk in direction while (currentIndex & 0x88 == 0){ // if there is a figure at current field return it if (self.fields[uint(currentIndex)] != Pieces(Piece.EMPTY)) return int8(currentIndex); // otherwise move to the next field in that direction currentIndex = currentIndex + direction; } return -1; } /*------------------------HELPER FUNCTIONS------------------------*/ // This returns the absolute value of an integer function abs(int256 value) returns (uint256){ if (value>=0) return uint256(value); else return uint256(-1*value); } function is_diagonal(int8 direction) internal returns (bool){ return !(abs(direction) == 16 || abs(direction) == 1); } function getOwnKing(State storage self, int8 movingPlayerColor) returns (int8){ if (movingPlayerColor == Players(Player.WHITE)) return getFlag(self, Flag.WHITE_KING_POS); else return getFlag(self, Flag.BLACK_KING_POS); } function boolToInt(bool value) returns (int) { if (value) { return 1; } else { return 0; } } }
Update move count High and Low are int8, so from -127 to 127 By using two flags we extend the positive range to 14 bit, 0 to 16384
int16 moveCount = int16(getFlag(self, Flag.MOVE_COUNT_H)) * (2**7) | int16(getFlag(self, Flag.MOVE_COUNT_L));
12,810,809
[ 1, 4625, 348, 7953, 560, 30, 225, 2315, 3635, 1056, 15207, 471, 23629, 854, 509, 28, 16, 1427, 628, 300, 14260, 358, 12331, 2525, 1450, 2795, 2943, 732, 2133, 326, 6895, 1048, 358, 5045, 2831, 16, 374, 358, 2872, 17295, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 509, 2313, 3635, 1380, 273, 509, 2313, 12, 588, 4678, 12, 2890, 16, 9960, 18, 16537, 67, 7240, 67, 44, 3719, 380, 261, 22, 636, 27, 13, 571, 509, 2313, 12, 588, 4678, 12, 2890, 16, 9960, 18, 16537, 67, 7240, 67, 48, 10019, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/4/0x15CF338a4477bC02d3689ae44d56704577A5A632/sources/PrivateVISCReDel.sol
data saved locally before function to reflect event
function deleteUser (address ContractCreator) public onlyContractOwner { string memory UserId = users[ContractCreator].UserId; bool admitted = users[ContractCreator].admitted; delete users[ContractCreator]; assert (users[ContractCreator].VerificationCode == 0); emit UserDeleted (UserId, admitted, msg.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 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1430, 1299, 261, 2867, 13456, 10636, 13, 1071, 1338, 8924, 5541, 288, 203, 3639, 533, 3778, 2177, 548, 273, 3677, 63, 8924, 10636, 8009, 10502, 31, 203, 3639, 1426, 1261, 7948, 273, 3677, 63, 8924, 10636, 8009, 361, 7948, 31, 203, 3639, 1430, 3677, 63, 8924, 10636, 15533, 203, 3639, 1815, 261, 5577, 63, 8924, 10636, 8009, 13483, 1085, 422, 374, 1769, 203, 3639, 3626, 2177, 7977, 261, 10502, 16, 1261, 7948, 16, 1234, 18, 15330, 1769, 203, 565, 289, 203, 377, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/3/0x1F79648e7654B7a8Eb07ED3eB77A10CA9195B169/sources/ETHREV.sol
0.5% to everyone every 100 ETH on balance 3% every week to owner
function invest(address referrer) public payable { require(msg.value >= INVEST_MIN_AMOUNT); owner.transfer(msg.value.mul(OWNER_FEE).div(PERCENTS_DIVIDER)); User storage user = users[msg.sender]; if (user.referrer == address(0) && isActive(referrer) && referrer != msg.sender) { user.referrer = referrer; address upline = referrer; for (uint256 i = 0; i < 3; i++) { if (upline != address(0)) { users[upline].levels[i] = users[upline].levels[i].add(1); upline = users[upline].referrer; } else break; } } if (user.referrer != address(0)) { address upline = user.referrer; for (uint256 i = 0; i < 3; i++) { if (upline != address(0)) { uint256 amount = msg.value.mul(REFERRAL_PERCENTS[i]).div(PERCENTS_DIVIDER); if (i == 0) { if (users[upline].refBackPercent > 0) { uint256 refback = amount.mul(users[upline].refBackPercent).div(PERCENTS_DIVIDER); user.bonus = user.bonus.add(refback); amount = amount.sub(refback); emit RefBack(upline, msg.sender, refback); } } users[upline].bonus = users[upline].bonus.add(amount); emit RefBonus(upline, msg.sender, i, amount); upline = users[upline].referrer; } else break; } } uint256 deposit = msg.value.mul(900).div(PERCENTS_DIVIDER); uint256 dividends = msg.value.mul(DISTR_PERCENT).div(PERCENTS_DIVIDER); if (_totalBank > 0) { _profitPerShare = _profitPerShare.add(dividends.mul(_magnitude).div(_totalBank)); user.payoutsTo = user.payoutsTo.add(_profitPerShare.mul(deposit)); _profitPerShare = _profitPerShare.add(dividends.mul(_magnitude).div(deposit)); } _totalBank = _totalBank.add(deposit); if (user.deposits.length == 0) { user.checkpoint = block.timestamp; totalUsers = totalUsers.add(1); emit Newbie(msg.sender); } user.deposits.push(Deposit(deposit, 0, block.timestamp)); totalInvested = totalInvested.add(msg.value); totalDeposits = totalDeposits.add(1); emit NewDeposit(msg.sender, msg.value); uint256 balance = address(this).balance; if (balance.div(CONTRACT_BALANCE_STEP) > _bonusCount) { _bonusCount = balance.div(CONTRACT_BALANCE_STEP); _profitPerShare = _profitPerShare.add((balance.mul(5).div(PERCENTS_DIVIDER)).mul(_magnitude).div(_totalBank)); } if (block.timestamp >= _time.add(7 days)) { users[owner].bonus = users[owner].bonus.add(balance.mul(30).div(PERCENTS_DIVIDER)); _time = block.timestamp; } }
5,247,721
[ 1, 4625, 348, 7953, 560, 30, 225, 374, 18, 25, 9, 358, 3614, 476, 3614, 2130, 512, 2455, 603, 11013, 890, 9, 3614, 4860, 358, 3410, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 2198, 395, 12, 2867, 14502, 13, 1071, 8843, 429, 288, 203, 202, 202, 6528, 12, 3576, 18, 1132, 1545, 2120, 3412, 882, 67, 6236, 67, 2192, 51, 5321, 1769, 203, 203, 202, 202, 8443, 18, 13866, 12, 3576, 18, 1132, 18, 16411, 12, 29602, 67, 8090, 41, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 10019, 203, 203, 202, 202, 1299, 2502, 729, 273, 3677, 63, 3576, 18, 15330, 15533, 203, 203, 3639, 309, 261, 1355, 18, 1734, 11110, 422, 1758, 12, 20, 13, 597, 15083, 12, 1734, 11110, 13, 597, 14502, 480, 1234, 18, 15330, 13, 288, 203, 5411, 729, 18, 1734, 11110, 273, 14502, 31, 203, 203, 1082, 202, 2867, 582, 412, 558, 273, 14502, 31, 203, 5411, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 890, 31, 277, 27245, 288, 203, 9506, 202, 430, 261, 89, 412, 558, 480, 1758, 12, 20, 3719, 288, 203, 10792, 3677, 63, 89, 412, 558, 8009, 12095, 63, 77, 65, 273, 3677, 63, 89, 412, 558, 8009, 12095, 63, 77, 8009, 1289, 12, 21, 1769, 203, 6862, 202, 89, 412, 558, 273, 3677, 63, 89, 412, 558, 8009, 1734, 11110, 31, 203, 9506, 202, 97, 469, 898, 31, 203, 1082, 202, 97, 203, 3639, 289, 203, 203, 202, 202, 430, 261, 1355, 18, 1734, 11110, 480, 1758, 12, 20, 3719, 288, 203, 203, 1082, 202, 2867, 582, 412, 558, 273, 729, 18, 1734, 11110, 31, 203, 1082, 202, 1884, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 890, 31, 277, 27245, 288, 203, 9506, 202, 430, 261, 89, 412, 558, 480, 1758, 12, 20, 3719, 288, 203, 6862, 202, 11890, 5034, 3844, 273, 1234, 18, 1132, 18, 16411, 12, 30269, 54, 1013, 67, 3194, 19666, 55, 63, 77, 65, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 1769, 203, 203, 10792, 309, 261, 77, 422, 374, 13, 288, 203, 25083, 202, 430, 261, 5577, 63, 89, 412, 558, 8009, 1734, 2711, 8410, 405, 374, 13, 288, 203, 6862, 1082, 202, 11890, 5034, 1278, 823, 273, 3844, 18, 16411, 12, 5577, 63, 89, 412, 558, 8009, 1734, 2711, 8410, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 1769, 203, 6862, 1082, 202, 1355, 18, 18688, 407, 273, 729, 18, 18688, 407, 18, 1289, 12, 1734, 823, 1769, 203, 6862, 1082, 202, 8949, 273, 3844, 18, 1717, 12, 1734, 823, 1769, 203, 6862, 1082, 202, 18356, 3941, 2711, 12, 89, 412, 558, 16, 1234, 18, 15330, 16, 1278, 823, 1769, 203, 25083, 202, 97, 203, 6862, 202, 97, 203, 6862, 202, 5577, 63, 89, 412, 558, 8009, 18688, 407, 273, 3677, 63, 89, 412, 558, 8009, 18688, 407, 18, 1289, 12, 8949, 1769, 203, 6862, 202, 18356, 3941, 38, 22889, 12, 89, 412, 558, 16, 1234, 18, 15330, 16, 277, 16, 3844, 1769, 203, 6862, 202, 89, 412, 558, 273, 3677, 63, 89, 412, 558, 8009, 1734, 11110, 31, 203, 9506, 202, 97, 469, 898, 31, 203, 1082, 202, 97, 203, 203, 202, 202, 97, 203, 203, 202, 202, 11890, 5034, 443, 1724, 273, 1234, 18, 1132, 18, 16411, 12, 29, 713, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 1769, 203, 202, 202, 11890, 5034, 3739, 350, 5839, 273, 1234, 18, 1132, 18, 16411, 12, 2565, 3902, 67, 3194, 19666, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 1769, 203, 203, 202, 202, 430, 261, 67, 4963, 16040, 405, 374, 13, 288, 203, 5411, 389, 685, 7216, 2173, 9535, 273, 389, 685, 7216, 2173, 9535, 18, 1289, 12, 2892, 350, 5839, 18, 16411, 24899, 30279, 2934, 2892, 24899, 4963, 16040, 10019, 203, 5411, 729, 18, 84, 2012, 11634, 273, 729, 18, 84, 2012, 11634, 18, 1289, 24899, 685, 7216, 2173, 9535, 18, 16411, 12, 323, 1724, 10019, 203, 5411, 389, 685, 7216, 2173, 9535, 273, 389, 685, 7216, 2173, 9535, 18, 1289, 12, 2892, 350, 5839, 18, 16411, 24899, 30279, 2934, 2892, 12, 323, 1724, 10019, 203, 3639, 289, 203, 203, 202, 202, 67, 4963, 16040, 273, 389, 4963, 16040, 18, 1289, 12, 323, 1724, 1769, 203, 203, 202, 202, 430, 261, 1355, 18, 323, 917, 1282, 18, 2469, 422, 374, 13, 288, 203, 1082, 202, 1355, 18, 25414, 273, 1203, 18, 5508, 31, 203, 1082, 202, 4963, 6588, 273, 2078, 6588, 18, 1289, 12, 21, 1769, 203, 1082, 202, 18356, 1166, 70, 1385, 12, 3576, 18, 15330, 1769, 203, 202, 202, 97, 203, 203, 202, 202, 1355, 18, 323, 917, 1282, 18, 6206, 12, 758, 1724, 12, 323, 1724, 16, 374, 16, 1203, 18, 5508, 10019, 203, 203, 202, 202, 4963, 3605, 3149, 273, 2078, 3605, 3149, 18, 1289, 12, 3576, 18, 1132, 1769, 203, 202, 202, 4963, 758, 917, 1282, 273, 2078, 758, 917, 1282, 18, 1289, 12, 21, 1769, 203, 203, 202, 202, 18356, 1166, 758, 1724, 12, 3576, 18, 15330, 16, 1234, 18, 1132, 1769, 203, 203, 202, 202, 11890, 5034, 11013, 273, 1758, 12, 2211, 2934, 12296, 31, 203, 203, 202, 202, 430, 261, 12296, 18, 2892, 12, 6067, 2849, 1268, 67, 38, 1013, 4722, 67, 26951, 13, 405, 389, 18688, 407, 1380, 13, 288, 203, 1082, 202, 67, 18688, 407, 1380, 273, 11013, 18, 2892, 12, 6067, 2849, 1268, 67, 38, 1013, 4722, 67, 26951, 1769, 203, 1082, 202, 67, 685, 7216, 2173, 9535, 273, 389, 685, 7216, 2173, 9535, 18, 1289, 12443, 12296, 18, 16411, 12, 25, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 13, 2934, 16411, 24899, 30279, 2934, 2892, 24899, 4963, 16040, 10019, 203, 202, 202, 97, 203, 203, 202, 202, 430, 261, 2629, 18, 5508, 1545, 389, 957, 18, 1289, 12, 27, 4681, 3719, 288, 203, 1082, 202, 5577, 63, 8443, 8009, 18688, 407, 273, 3677, 63, 8443, 8009, 18688, 407, 18, 1289, 12, 12296, 18, 16411, 12, 5082, 2934, 2892, 12, 3194, 19666, 55, 67, 2565, 20059, 10019, 203, 1082, 202, 67, 957, 273, 1203, 18, 5508, 31, 203, 202, 202, 97, 203, 203, 202, 97, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x96B50a0dECE2c322E7cF8622B8c1Abc2dA10017D/sources/browser/FlatStealthPaymaster.sol
Put a stake for a relayManager and set its unstake delay. If the entry does not exist, it is created, and the caller of this function becomes its owner. If the entry already exists, only the owner can call this function. @param relayManager - address that represents a stake entry and controls relay registrations on relay hubs @param unstakeDelay - number of blocks to elapse before the owner can retrieve the stake after calling 'unlock' Slash the stake of the relay relayManager. In order to prevent stake kidnapping, burns half of stake on the way. @param relayManager - entry to penalize @param beneficiary - address that receives half of the penalty amount @param amount - amount to withdraw from stake File: @opengsn/gsn/contracts/interfaces/IRelayHub.sol Emitted when an account withdraws funds from RelayHub. Emitted when depositFor is called, including the amount and account that was funded. Emitted when a transaction is relayed. Note that the actual encoded function might be reverted: this will be indicated in the status field. Useful when monitoring a relay's operation and relayed calls to a contract. Charge is the ether value deducted from the recipient's balance, paid to the relay's manager.
interface IRelayHub { event RelayServerRegistered( address indexed relayManager, uint256 baseRelayFee, uint256 pctRelayFee, string relayUrl); event RelayWorkersAdded( address indexed relayManager, address[] newRelayWorkers, uint256 workersCount ); event Withdrawn( address indexed account, address indexed dest, uint256 amount ); event Deposited( address indexed paymaster, address indexed from, uint256 amount ); event TransactionRejectedByPaymaster( address indexed relayManager, address indexed paymaster, address indexed from, address to, address relayWorker, bytes4 selector, uint256 innerGasUsed, bytes reason); event TransactionRelayed( address indexed relayManager, address indexed relayWorker, address indexed from, address to, address paymaster, bytes4 selector, RelayCallStatus status, uint256 charge); event TransactionResult( RelayCallStatus status, bytes returnValue ); event Penalized( address indexed relayWorker, address sender, uint256 reward ); function stakeForAddress(address relayManager, uint256 unstakeDelay) external payable; function unlockStake(address relayManager) external; function withdrawStake(address relayManager) external; function authorizeHubByOwner(address relayManager, address relayHub) external; function authorizeHubByManager(address relayHub) external; function unauthorizeHubByOwner(address relayManager, address relayHub) external; function unauthorizeHubByManager(address relayHub) external; function isRelayManagerStaked(address relayManager, address relayHub, uint256 minAmount, uint256 minUnstakeDelay) external view returns (bool); function penalizeRelayManager(address relayManager, address payable beneficiary, uint256 amount) external; function getStakeInfo(address relayManager) external view returns (StakeInfo memory stakeInfo); function versionSM() external view returns (string memory); } pragma solidity ^0.6.2; enum RelayCallStatus { OK, RelayedCallFailed, RejectedByPreRelayed, RejectedByForwarder, RejectedByRecipientRevert, PostRelayedFailed, PaymasterBalanceChanged } }
9,685,522
[ 1, 4625, 348, 7953, 560, 30, 225, 4399, 279, 384, 911, 364, 279, 18874, 1318, 471, 444, 2097, 640, 334, 911, 4624, 18, 971, 326, 1241, 1552, 486, 1005, 16, 518, 353, 2522, 16, 471, 326, 4894, 434, 333, 445, 12724, 2097, 3410, 18, 971, 326, 1241, 1818, 1704, 16, 1338, 326, 3410, 848, 745, 333, 445, 18, 632, 891, 18874, 1318, 300, 1758, 716, 8686, 279, 384, 911, 1241, 471, 11022, 18874, 28620, 603, 18874, 11891, 87, 632, 891, 640, 334, 911, 6763, 300, 1300, 434, 4398, 358, 415, 28933, 1865, 326, 3410, 848, 4614, 326, 384, 911, 1839, 4440, 296, 26226, 11, 9708, 961, 326, 384, 911, 434, 326, 18874, 18874, 1318, 18, 657, 1353, 358, 5309, 384, 911, 17395, 2322, 1382, 16, 18305, 87, 8816, 434, 384, 911, 603, 326, 4031, 18, 632, 891, 18874, 1318, 300, 1241, 358, 14264, 287, 554, 632, 891, 27641, 74, 14463, 814, 300, 1758, 716, 17024, 8816, 434, 326, 23862, 3844, 632, 891, 3844, 300, 3844, 358, 598, 9446, 628, 384, 911, 1387, 30, 632, 3190, 564, 82, 19, 564, 82, 19, 16351, 87, 19, 15898, 19, 45, 27186, 8182, 18, 18281, 512, 7948, 1347, 392, 2236, 598, 9446, 87, 284, 19156, 628, 4275, 528, 8182, 18, 512, 7948, 1347, 443, 1724, 1290, 353, 2566, 16, 6508, 326, 3844, 471, 2236, 716, 1703, 9831, 785, 18, 512, 7948, 1347, 279, 2492, 353, 18874, 329, 18, 3609, 716, 326, 3214, 3749, 445, 4825, 506, 15226, 329, 30, 333, 903, 506, 17710, 316, 326, 1267, 652, 18, 19256, 1347, 16309, 279, 18874, 1807, 1674, 471, 18874, 329, 4097, 358, 279, 6835, 18, 3703, 908, 353, 326, 225, 2437, 460, 11140, 853, 329, 628, 326, 8027, 1807, 11013, 16, 30591, 358, 326, 18874, 1807, 3301, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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871, 4275, 528, 2081, 10868, 12, 203, 3639, 1758, 8808, 18874, 1318, 16, 203, 3639, 2254, 5034, 1026, 27186, 14667, 16, 203, 3639, 2254, 5034, 19857, 27186, 14667, 16, 203, 3639, 533, 18874, 1489, 1769, 203, 203, 565, 871, 4275, 528, 15252, 8602, 12, 203, 3639, 1758, 8808, 18874, 1318, 16, 203, 3639, 1758, 8526, 394, 27186, 15252, 16, 203, 3639, 2254, 5034, 9798, 1380, 203, 565, 11272, 203, 203, 565, 871, 3423, 9446, 82, 12, 203, 3639, 1758, 8808, 2236, 16, 203, 3639, 1758, 8808, 1570, 16, 203, 3639, 2254, 5034, 3844, 203, 565, 11272, 203, 203, 565, 871, 4019, 538, 16261, 12, 203, 3639, 1758, 8808, 8843, 7525, 16, 203, 3639, 1758, 8808, 628, 16, 203, 3639, 2254, 5034, 3844, 203, 565, 11272, 203, 203, 565, 871, 5947, 19902, 858, 9148, 7525, 12, 203, 3639, 1758, 8808, 18874, 1318, 16, 203, 3639, 1758, 8808, 8843, 7525, 16, 203, 3639, 1758, 8808, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 1758, 18874, 6671, 16, 203, 3639, 1731, 24, 3451, 16, 203, 3639, 2254, 5034, 3443, 27998, 6668, 16, 203, 3639, 1731, 3971, 1769, 203, 203, 565, 871, 5947, 27186, 329, 12, 203, 3639, 1758, 8808, 18874, 1318, 16, 203, 3639, 1758, 8808, 18874, 6671, 16, 203, 3639, 1758, 8808, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 1758, 8843, 7525, 16, 203, 3639, 1731, 24, 3451, 16, 203, 3639, 4275, 528, 1477, 1482, 1267, 16, 203, 3639, 2254, 5034, 13765, 1769, 203, 203, 565, 871, 5947, 1253, 12, 203, 3639, 4275, 528, 1477, 1482, 1267, 16, 203, 3639, 1731, 7750, 203, 565, 11272, 203, 203, 565, 871, 453, 275, 287, 1235, 12, 203, 3639, 1758, 8808, 18874, 6671, 16, 203, 3639, 1758, 5793, 16, 203, 3639, 2254, 5034, 19890, 203, 565, 11272, 203, 203, 565, 445, 384, 911, 1290, 1887, 12, 2867, 18874, 1318, 16, 2254, 5034, 640, 334, 911, 6763, 13, 3903, 8843, 429, 31, 203, 203, 565, 445, 7186, 510, 911, 12, 2867, 18874, 1318, 13, 3903, 31, 203, 203, 565, 445, 598, 9446, 510, 911, 12, 2867, 18874, 1318, 13, 3903, 31, 203, 203, 565, 445, 12229, 8182, 858, 5541, 12, 2867, 18874, 1318, 16, 1758, 18874, 8182, 13, 3903, 31, 203, 203, 565, 445, 12229, 8182, 858, 1318, 12, 2867, 18874, 8182, 13, 3903, 31, 203, 203, 565, 445, 640, 22488, 8182, 858, 5541, 12, 2867, 18874, 1318, 16, 1758, 18874, 8182, 13, 3903, 31, 203, 203, 565, 445, 640, 22488, 8182, 858, 1318, 12, 2867, 18874, 8182, 13, 3903, 31, 203, 203, 565, 445, 353, 27186, 1318, 510, 9477, 12, 2867, 18874, 1318, 16, 1758, 18874, 8182, 16, 2254, 5034, 1131, 6275, 16, 2254, 5034, 1131, 984, 334, 911, 6763, 13, 203, 565, 3903, 203, 565, 1476, 203, 565, 1135, 261, 6430, 1769, 203, 203, 565, 445, 14264, 287, 554, 27186, 1318, 12, 2867, 18874, 1318, 16, 1758, 8843, 429, 27641, 74, 14463, 814, 16, 2254, 5034, 3844, 13, 3903, 31, 203, 203, 565, 445, 21491, 911, 966, 12, 2867, 18874, 1318, 13, 3903, 1476, 1135, 261, 510, 911, 966, 3778, 384, 911, 966, 1769, 203, 203, 565, 445, 1177, 7303, 1435, 3903, 1476, 1135, 261, 1080, 3778, 1769, 203, 97, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 26, 18, 22, 31, 203, 203, 203, 203, 565, 2792, 4275, 528, 1477, 1482, 288, 203, 3639, 7791, 16, 203, 3639, 4275, 528, 329, 1477, 2925, 16, 203, 3639, 868, 6059, 858, 1386, 27186, 329, 16, 203, 3639, 868, 6059, 858, 30839, 16, 203, 3639, 868, 6059, 858, 18241, 426, 1097, 16, 203, 3639, 5616, 27186, 329, 2925, 16, 203, 3639, 13838, 7525, 13937, 5033, 203, 565, 289, 203, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/11155111/0x538D7463b481e91735b61A625Df8ea1d41f8DEF7/sources/contracts/interfaces/token/ITokenERC721.sol
* @notice The body of a request to mint NFTs. @param to The receiver of the NFTs to mint. @param uri The URI of the NFT to mint. @param price Price to pay for minting with the signature. @param currency The currency in which the price per token must be paid. @param validityStartTimestamp The unix timestamp after which the request is valid. @param validityEndTimestamp The unix timestamp after which the request expires. @param uid A unique identifier for the request./
struct MintRequest { address to; address royaltyRecipient; uint256 royaltyBps; address primarySaleRecipient; string uri; uint256 price; address currency; uint128 validityStartTimestamp; uint128 validityEndTimestamp; bytes32 uid; } address indexed signer, address indexed mintedTo, uint256 indexed tokenIdMinted, MintRequest mintRequest );
3,818,979
[ 1, 4625, 348, 7953, 560, 30, 380, 225, 632, 20392, 1021, 1417, 434, 279, 590, 358, 312, 474, 423, 4464, 87, 18, 225, 632, 891, 358, 1021, 5971, 434, 326, 423, 4464, 87, 358, 312, 474, 18, 225, 632, 891, 2003, 1021, 3699, 434, 326, 423, 4464, 358, 312, 474, 18, 225, 632, 891, 6205, 20137, 358, 8843, 364, 312, 474, 310, 598, 326, 3372, 18, 225, 632, 891, 5462, 1021, 5462, 316, 1492, 326, 6205, 1534, 1147, 1297, 506, 30591, 18, 225, 632, 891, 13800, 1685, 4921, 1021, 9753, 2858, 1839, 1492, 326, 590, 353, 923, 18, 225, 632, 891, 13800, 1638, 4921, 1021, 9753, 2858, 1839, 1492, 326, 590, 7368,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 1958, 490, 474, 691, 288, 203, 3639, 1758, 358, 31, 203, 3639, 1758, 721, 93, 15006, 18241, 31, 203, 3639, 2254, 5034, 721, 93, 15006, 38, 1121, 31, 203, 3639, 1758, 3354, 30746, 18241, 31, 203, 3639, 533, 2003, 31, 203, 3639, 2254, 5034, 6205, 31, 203, 3639, 1758, 5462, 31, 203, 3639, 2254, 10392, 13800, 1685, 4921, 31, 203, 3639, 2254, 10392, 13800, 1638, 4921, 31, 203, 3639, 1731, 1578, 4555, 31, 203, 565, 289, 203, 203, 203, 3639, 1758, 8808, 10363, 16, 203, 3639, 1758, 8808, 312, 474, 329, 774, 16, 203, 3639, 2254, 5034, 8808, 1147, 548, 49, 474, 329, 16, 203, 3639, 490, 474, 691, 312, 474, 691, 203, 565, 11272, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at BscScan.com on 2021-10-18 */ // SPDX-License-Identifier: GPL-3.0 /** * @Author Vron */ pragma solidity >=0.7.0 <0.9.0; contract context { mapping(address => bool) private admins; event AddAdmin(address indexed _address, bool decision); event RemoveAdmin(address indexed _address, bool decision); address private _owner; // restricts access to only owner modifier onlyOwner() { require(msg.sender == _owner, "Only owner allowed."); _; } // restricts access to only admins modifier onlyAdmin() { require(admins[msg.sender] == true, "Only admins allowed."); _; } constructor(){ _owner = msg.sender; admins[msg.sender] = true; } // function returns contract owner function getOwner() public view returns (address) { return _owner; } function addAdmin(address _address) public { _addAdmin(_address, true); } // sets an admin function _addAdmin(address _address, bool _decision) private onlyOwner returns (bool) { require(_address != _owner, "Owner already added."); admins[_address] = _decision; emit AddAdmin(_address, _decision); return true; } function removeAdmin(address _address) public { _removeAdmin(_address, false); } // removes an admin function _removeAdmin(address _address, bool _decision) private onlyOwner returns (bool) { require(_address != _owner, "Owner cannot be removed."); admins[_address] = _decision; emit RemoveAdmin(_address, _decision); return true; } } /** * SafeMath * Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 1; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface BUSD { function balanceOf(address _address) external returns (uint256); function transfer(address _address, uint256 value) external returns (bool); function transferFrom(address _sender, address recipient, uint256 value) external returns (bool); } interface BETS { function balanceOf(address _address) external returns (uint256); function transfer(address _address, uint256 value) external returns (bool); function transferFrom(address _sender, address recipient, uint256 value) external returns (bool); } contract BetswampMVP is context { using SafeMath for uint256; // mapping stores event sub-category mapping(Category => string[]) private sub_category; // mapping stores sub-category index mapping(string => uint256) private category_index; // mapping maps event to its index in allActiveEvent mapping(uint256 => uint256) private event_index; // [eventID][MSG.SENDER] = true or false determines if user betted on an event mapping (uint256 => mapping (address => bool)) private bets; // [eventID] = true or false - determines if a BetEvent is still active mapping (uint256 => bool) private activeEvents; // maps an event to its record mapping (uint256 => BetEvent) private events; // maps an event and a bettor to bettors bets information [eventID][msg.sender] mapping (uint256 => mapping (address => Betted)) private userBets; // maps bet event occurrence to the number of users who selected it mapping (uint256 => mapping (Occurences => address[])) private eventBetOccurenceCount; // maps bet event occurence and the amount betted on it mapping (uint256 => mapping (Occurences => uint256)) private eventBetOccurenceAmount; // maps an event to the occurence that won after validation mapping (uint256 => Occurences) private occuredOccurrence; // maps a user to all their bets mapping (address => BetEvent[]) private userBetHistory; // maps a user to the number of their bets mapping (address => uint256[]) private userBetCounts; // map indicates if user locked funds for validation point mapping (address => bool) private _lock_validator_address; // map sets wallet lock time mapping (address => uint) private _validator_wallet_lock_time; // maps amount user locked mapping (address => uint256) private _validator_lock_amount; // maps user wallet to points earned mapping (address => uint256) private _wallet_validation_points; ///////////////////////////////////// // maps a validator to an event - used in checking if a validator validated an event mapping (address => mapping (uint256 => bool)) private validatorValidatedEvent; // maps a validator to the occurrence chosen mapping (uint256 => mapping (address => mapping (Occurences => bool))) private selectedValidationOccurrence; // maps an event and its occurence to validators that chose it mapping (uint256 => mapping (Occurences => address[])) private eventOccurenceValidators; // maps an event and a user to know if user has reclaimed the event's wager mapping (uint256 => mapping (address => bool)) private reclaimedBetWager; // maps an event to the amount lost in bet by bettors who choose the wrong event outcome mapping (uint256 => uint256) private amountLostInBet; // maps a bet event to validators who validated it mapping (uint256 => address[]) private eventValidators; // maps an event and a bettor to whether the reward has been claimed mapping (uint256 => mapping (address => bool)) private claimedReward; // maps an event to the divs for validators, system and all event bettors mapping (uint256 => Distribution) private divs; // maps an event to whether its crumbs have been withdrawn mapping (uint256 => bool) private hasTransferredCrumbs; // event is emitted when a validator validates an event event ValidateEvent(uint256 indexed eventID, Occurences occurence, address validator_address); //////////////////////////////////// // event emitted once event is created event CreateEvent(uint256 indexed event_id, Category category, string sub_category, string eventName, uint256 pool_size, uint256 eventTime, string eventOne, string eventTwo, address betCreator); // event emitted when a wager is made event PlaceBet(uint256 indexed event_id, address bettor_address, uint256 amount, Occurences occured); // event emitted when a user claims bet reward/winnings event Claim(address indexed user_address, uint256 _amount); /** * @dev WIN = 0, LOOSE = 1, LOOSE_OR_WIN = 2 and INVALID = 3 * On the client side, the user is only to see the follwoing * {WIN}, {LOOSE}, {DRAW} */ enum Occurences{WIN, LOOSE, LOOSE_OR_WIN, INVALID, UNKNOWN} // possible bet outcome enum Category{SPORTS, WEATHER, REALITY_TV_SHOWS, POLITICS, ENTERTAINMENT_AWARDS, DEAD_POOL, NOBEL_PRIZE, FUTURE_BET, OTHERS} // event categories /** * @dev stores Betevent information * * Requirement: * event creator must be an admin */ struct BetEvent { uint256 eventID; Category categories; string sub_category; string eventName; uint256 poolSize; // size of event pool uint256 startTime; // time event will occur uint256 endTime; string eventOne; // eventOne vs string eventTwo; //eventTwo bool validated; // false if event is not yet validated uint256 validatorsNeeded; Occurences occured; uint256 bettorsCount; uint256 noOfBettorsRewarded; uint256 amountClaimed; address betCreator; } /** * @dev stores user bet records * bettor balance must be greater or equal to 0 */ struct Betted { uint eventID; address bettorAddress; uint256 amount; Occurences occurence; } struct Distribution { uint256 bettorsDiv; } // wrapped BUSD mainnet: 0xe9e7cea3dedca5984780bafc599bd69add087d56 // wrapped BUSD testnet: 0x1d566540f39fd80cb2680461c8cf10bccc2a6fa1 BUSD private BUSD_token; BETS private BETS_token; bool private platformStatus; BetEvent[] private _event_id; BetEvent[] allActiveEvent; // list of active events uint256[] private validatedEvent; // list of validated events uint256 private totalAmountBetted; // total amount that has been betted on the platform uint256 private totalAmountClaimed; // total amount claimed on the platform // used to check if platform is active modifier isPlatformActive() { require(platformStatus == false, "Platfrom activity paused."); _; } /** * @dev modifier ensures user can only select WIN, LOOSE or LOOSE_OR_WIN * as the occurence they wager on or pick as occured occurence (for validators) */ modifier isValidOccurence(Occurences chosen) { require(chosen == Occurences.WIN || chosen == Occurences.LOOSE || chosen == Occurences.LOOSE_OR_WIN, "Invalid occurence selected."); _; } /** * @dev modifier check if a user has already claimed their bet reward */ modifier hasClaimedReward(uint256 event_id) { // check if user betted if (bets[event_id][msg.sender] == true) { // checks if user claimed reward require(claimedReward[event_id][msg.sender] == false, "Reward already claimed."); _; } else { revert("You have no stake on event."); } } /** * @dev modifier hinders validators from Validating * events that do not have opposing bets. */ modifier hasOpposingBets(uint256 event_id) { if (eventBetOccurenceCount[event_id][Occurences.WIN].length != 0 && eventBetOccurenceCount[event_id][Occurences.LOOSE].length != 0) { _; } else if (eventBetOccurenceCount[event_id][Occurences.WIN].length != 0 && eventBetOccurenceCount[event_id][Occurences.LOOSE_OR_WIN].length != 0) { _; } else if (eventBetOccurenceCount[event_id][Occurences.LOOSE].length != 0 && eventBetOccurenceCount[event_id][Occurences.LOOSE_OR_WIN].length != 0) { _; } else { revert("Validating events with none opposing bets not allowed."); } } constructor(address busd_token, address bets_token) { BUSD_token = BUSD(address(busd_token)); BETS_token = BETS(address(bets_token)); } // function adds sub-category function addSubbCategory(Category _category, string memory _sub_category) public onlyAdmin returns (bool) { sub_category[_category].push(_sub_category); category_index[_sub_category] = sub_category[_category].length - 1; return true; } // function removes a sub-category function removeSubCategory(Category _category, string memory _sub_category) public onlyAdmin returns (bool) { uint256 index = category_index[_sub_category]; sub_category[_category][index] = sub_category[_category][sub_category[_category].length - 1]; sub_category[_category].pop(); return true; } // function shows event category function getSubCategory(Category _category) public view returns (string[] memory) { return sub_category[_category]; } // create even function createEvent(Category _category, string memory _sub_category, string memory _name, uint256 _time, uint256 _endTime, string memory _event1, string memory _event2) public returns (bool) { _createEvent(_category,_sub_category, _name,_time,_endTime, _event1, _event2, msg.sender); return true; } // function creates betting event function _createEvent(Category _category, string memory _sub_category, string memory _name, uint256 _time, uint256 _endTime, string memory _event1, string memory _event2, address _creator) private onlyAdmin isPlatformActive returns (bool) { // ensure eventTime is greater current timestamp require(_time > block.timestamp, "Time of event must be greater than current time"); events[_event_id.length] = BetEvent(_event_id.length, _category,_sub_category, _name, 0, _time,_endTime, _event1, _event2, false, 3, Occurences.UNKNOWN, 0, 0, 0, _creator); // create event activeEvents[_event_id.length] = true; // set event as active allActiveEvent.push(events[_event_id.length]); // add event to active event list event_index[_event_id.length] = allActiveEvent.length - 1; _event_id.push(events[_event_id.length]); // increment number of events created emit CreateEvent(_event_id.length - 1, _category, _sub_category, _name, 0, _time, _event1, _event2, _creator); return true; } // function places bet function placeBet(uint256 event_id, uint256 _amount, Occurences _occured) public returns (bool) { _placeBet(event_id, _amount, _occured, msg.sender); return true; } // function places a bet function _placeBet(uint256 event_id, uint256 _amount, Occurences _occurred, address _bettor) private isPlatformActive returns (bool) { // check require(BUSD_token.balanceOf(_bettor) >= _amount, "Insufficient balance."); // check if bet event date has passed require(events[event_id].startTime >= block.timestamp, "You're not allowed to bet on elapsed or null events"); // check if event exist and is active require(activeEvents[event_id] == true, "Betting on none active bet events is not allowed."); BetEvent storage newEvent = events[event_id]; // get event details // check if user already Betted - increase betted amount on previous bet if (bets[event_id][msg.sender] == true) { // user already betted on event - increase stake on already placed bet BUSD_token.transferFrom(_bettor, address(this), _amount); userBets[event_id][msg.sender].amount = userBets[event_id][msg.sender].amount.add(_amount); eventBetOccurenceAmount[event_id][_occurred] = eventBetOccurenceAmount[event_id][_occurred].add(_amount); // increment the amount betted on the occurence newEvent.poolSize = newEvent.poolSize.add(_amount); // update pool amount _incrementTotalAmountBetted(_amount); // increment amount betted on platform return true; } BUSD_token.transferFrom(_bettor, address(this), _amount); addUserToOccurrenceBetCount(event_id, _occurred, _bettor); // increment number of users who betted on an event occurencece _incrementEventOccurrenceBetAmount(event_id, _occurred, _amount); // increment the amount betted on the occurence bets[event_id][_bettor] = true; // mark user as betted on event userBets[event_id][_bettor] = Betted(event_id, _bettor, _amount, _occurred); // place user bet newEvent.poolSize = newEvent.poolSize.add(_amount); // update pool amount newEvent.bettorsCount = newEvent.bettorsCount.add(1); // increment users that betted on the event addEventToUserHistory(newEvent); userBetCounts[_bettor].push(event_id); // increment number of events user has better on _incrementTotalAmountBetted(_amount); // increment amount betted on platform emit PlaceBet(event_id, _bettor, _amount, _occurred); return true; } // function gets users who selected a specific outcome for a betting event function getOccurrenceBetCount(uint256 event_id, Occurences _occured) public view returns (uint256) { return eventBetOccurenceCount[event_id][_occured].length; } // function adds a user to list of users who wagered on an event outcome function addUserToOccurrenceBetCount(uint256 event_id, Occurences _occurred, address _address) private { eventBetOccurenceCount[event_id][_occurred].push(_address); } // function gets amount wagered on a specific event occurrence function getEventOccurrenceBetAmount(uint256 event_id, Occurences _occurred) public view returns (uint256) { return eventBetOccurenceAmount[event_id][_occurred]; } // finction increments amount wagered on an event outcome function _incrementEventOccurrenceBetAmount(uint256 event_id, Occurences _occurred, uint256 _amount) private { eventBetOccurenceAmount[event_id][_occurred] = eventBetOccurenceAmount[event_id][_occurred].add(_amount); } // functions sets event occured occurrence after validation function setEventOccurredOccurrence(uint256 event_id, Occurences _occured) private { occuredOccurrence[event_id] = _occured; } // function gets event occurred occurrence after validation function getEventOccurredOccurrence(uint256 event_id) private view returns (Occurences) { return occuredOccurrence[event_id]; } // function remove event form active event list and puts it in validated event list function removeFromActiveEvents(uint256 event_id) private { // check if event is active require(activeEvents[event_id] == false, "Event not found."); allActiveEvent[event_index[event_id]] = allActiveEvent[allActiveEvent.length - 1]; allActiveEvent.pop(); } // function gets all active events function getActiveEvents() public view returns (BetEvent[] memory) { return allActiveEvent; } // function gets all validated event function getValidatedEvents() public view returns (uint256[] memory) { return validatedEvent; } // function get total betting event function totalEvents() public view returns (uint256) { return _event_id.length; } // function adds event to user bet history function addEventToUserHistory(BetEvent memory betEvent) private { userBetHistory[msg.sender].push(betEvent); } // function returns user bet histroy function getUserEventHistory() public view returns (BetEvent[] memory) { return userBetHistory[msg.sender]; } // function function _incrementTotalAmountBetted(uint256 _amount) private { totalAmountBetted = totalAmountBetted.add(_amount); } function claimValidationPoint() public returns (bool) { _calculateValidationPoint(); return true; } /** * @dev function calculates the users validation points * and rewards him his validation point. * function is triggered once user logs in */ function _calculateValidationPoint() internal { // check if wallet has any amount locked require(_lock_validator_address[msg.sender] == true, "Wallet don't earn points"); _wallet_validation_points[msg.sender] = _wallet_validation_points[msg.sender].add(_validator_lock_amount[msg.sender] * (block.timestamp - _validator_wallet_lock_time[msg.sender]) / 100000); // calculate point _validator_wallet_lock_time[msg.sender] = block.timestamp; // reset validation point timer } /** * @dev function displays user validation points */ function showValidationPoints() public view returns (uint256) { // return validationPoints return _wallet_validation_points[msg.sender]; } /** * @dev function rewards users validator rights through points. * * Requirement: user must have [amount] or more in wallet */ function earnValidationPoints(uint256 amount) public returns (bool) { _earnValidationPoints(msg.sender, amount); return true; } /** * @dev function rewards users validator rights through points. * * Requirement: user must have [amount] or more in wallet */ function _earnValidationPoints(address userAddress, uint256 amount) private isPlatformActive { // check if user balance greater or equal to amount require(BETS_token.balanceOf(userAddress) >= amount, "Insufficient balance."); // check if amount is zero => zero amount locking not allowed require(amount != 0, "Lockinng zero amount not allowed."); // check if user wallet is already earning points if ( _lock_validator_address[userAddress] == true && _validator_lock_amount[userAddress] != 0) { // wallect locked - check if amount specified matches balance after lock amount require((BETS_token.balanceOf(userAddress) -_validator_lock_amount[userAddress]) >= amount, "Insufficient balance."); BETS_token.transferFrom(userAddress, address(this), amount); // transfer funds to smart contract _validator_lock_amount[userAddress] = _validator_lock_amount[userAddress].add(amount); } else { // wallet not earning points - lock amount in wallet to earn points BETS_token.transferFrom(userAddress, address(this), amount); // transfer funds to smart contract _validator_wallet_lock_time[userAddress] = block.timestamp; // save user lock time _lock_validator_address[userAddress] = true; // user wallet locked _validator_lock_amount[userAddress] = amount; // user amount locked } } /** * @dev function renounces user point earning ability */ function revokeValidationPointsEarning() public { _revokeValidationPointsEarning(msg.sender); } /** * @dev function revokes user's ability to earn validation points */ function _revokeValidationPointsEarning(address userAddress) private { // claim user earned points and revoke user point earning _calculateValidationPoint(); // check if user is signed up for earning points require(_lock_validator_address[userAddress] == true && _validator_lock_amount[userAddress] != 0, "Wallet don't earn points."); // send locked amount back to user uint256 refund_amount = _validator_lock_amount[userAddress]; _validator_wallet_lock_time[userAddress] = 0; // reset user lock time _lock_validator_address[userAddress] = false; // user wallet unlocked _validator_lock_amount[userAddress] = 0; // reset locked amount to zero BETS_token.transfer(userAddress, refund_amount); // send user funds back to user } /** * @dev function returns the information * of a bet event and the number of bettors it has */ function getEvent(uint256 index) external view returns (BetEvent memory) { // check if bet event exist require(events[index].startTime > 0, "Bet event not found"); return events[index]; } /** * @dev function is used to validate an event * by validators. * * Requirements: * validator must have 1000 or more points * event validationElapseTime must not exceed block.timestamp. * eventTime must exceed block.timestamp */ function validateEvent(uint256 event_id, Occurences occurence) public returns (bool) { _validateEvent(event_id, occurence, msg.sender); return true; } /** * @dev function is used to validate an event * by validators. * * Requirements: * valdator must provide the event intended to be validated and the occurence that occured for the event * number of validators required to validate event must not have been exceeded * validator must have 1000 or more points * event validationElapseTime must not exceed block.timestamp. * eventTime must exceed block.timestamp * * Restriction: * validator cannot validate an event twice or more */ function _validateEvent(uint256 event_id, Occurences occurence, address validator_address) internal hasOpposingBets(event_id) isValidOccurence(occurence) isPlatformActive onlyAdmin { // check if event exist require(event_id <= _event_id.length, "Event not found."); // check if event has been validated require(events[event_id].validated == false, "Event validated."); // check if number of validators required to validate event has been exceeded require(eventValidators[event_id].length <= events[event_id].validatorsNeeded, "Number of validators needed reached."); // check if eventTime has been exceeded require(events[event_id].startTime < block.timestamp, "Event hasn't occured."); // check if event end time has reached require(events[event_id].endTime < block.timestamp, "Event not ready for validation."); // check if validator has validated event before require(validatorValidatedEvent[validator_address][event_id] == false, "Validating event twice not allowed."); // validator validates event eventOccurenceValidators[event_id][occurence].push(validator_address); // add validator to list of individuals that voted this occurence validatorValidatedEvent[validator_address][event_id] = true; // mark validator as validated event eventValidators[event_id].push(validator_address); // add validator to list of validators that validated event selectedValidationOccurrence[event_id][msg.sender][occurence] = true; emit ValidateEvent(event_id, occurence, validator_address); // emit ValidateEvent evet // 5 minutes to validation elapse time - check if event has 60% of required validators if ((events[event_id].validatorsNeeded / 100) * 70 >= eventValidators[event_id].length) { // event has 60% of needed validators _markAsValidated(event_id); // mark as validated _cummulateEventValidation(event_id); // cumulate validators event occurence vote // check if event occurred occurence isn't INVALID if (occuredOccurrence[event_id] != Occurences.INVALID) { _distributionFormular(event_id); // calculate divs } } if (eventValidators[event_id].length == events[event_id].validatorsNeeded) { // check if validators needed is filled - validated needed filed _markAsValidated(event_id); // mark as validated _cummulateEventValidation(event_id); // cumulate validators event occurence vote // check if event occurred occurence isn't INVALID if (occuredOccurrence[event_id] != Occurences.INVALID) { _distributionFormular(event_id); // calculate divs } } } /** * @dev function checks for the event occurence which * validators voted the most as the occured event * occurence. * Returns 0 if occurence is WIN * Returns 1 if occurence is LOOSE * Returns 2 if occurence is LOOSE_OR_WIN * Returns 3 if none of the above occurences won out. */ function _cummulateEventValidation(uint256 event_id) private { BetEvent storage event_occurrence = events[event_id]; // init betEvent instance // check the occurence that has the highest vote if (eventOccurenceValidators[event_id][Occurences.WIN].length > eventOccurenceValidators[event_id][Occurences.LOOSE].length && eventOccurenceValidators[event_id][Occurences.WIN].length > eventOccurenceValidators[event_id][Occurences.LOOSE_OR_WIN].length) { // set occured occurence occuredOccurrence[event_id] = Occurences.WIN; // set event occured occurence event_occurrence.occured = occuredOccurrence[event_id]; // assign amount to be shared amountLostInBet[event_id] = amountLostInBet[event_id].add(eventBetOccurenceAmount[event_id][Occurences.LOOSE] + eventBetOccurenceAmount[event_id][Occurences.LOOSE_OR_WIN]); } else if (eventOccurenceValidators[event_id][Occurences.LOOSE].length > eventOccurenceValidators[event_id][Occurences.WIN].length && eventOccurenceValidators[event_id][Occurences.LOOSE].length > eventOccurenceValidators[event_id][Occurences.LOOSE_OR_WIN].length) { occuredOccurrence[event_id] = Occurences.LOOSE; // set event occured occurence event_occurrence.occured = occuredOccurrence[event_id]; // assign amount to be shared amountLostInBet[event_id] = amountLostInBet[event_id].add(eventBetOccurenceAmount[event_id][Occurences.WIN] + eventBetOccurenceAmount[event_id][Occurences.LOOSE_OR_WIN]); } else if (eventOccurenceValidators[event_id][Occurences.LOOSE_OR_WIN].length > eventOccurenceValidators[event_id][Occurences.WIN].length && eventOccurenceValidators[event_id][Occurences.LOOSE_OR_WIN].length > eventOccurenceValidators[event_id][Occurences.LOOSE].length) { occuredOccurrence[event_id] = Occurences.LOOSE_OR_WIN; // set event occured occurence event_occurrence.occured = occuredOccurrence[event_id]; // assign amount to be shared amountLostInBet[event_id] = amountLostInBet[event_id].add(eventBetOccurenceAmount[event_id][Occurences.LOOSE] + eventBetOccurenceAmount[event_id][Occurences.WIN]); } else { occuredOccurrence[event_id] = Occurences.INVALID; // set event occured occurence event_occurrence.occured = occuredOccurrence[event_id]; } } /** * @dev function check if validator selected the * right event occurence reached through concensus */ function _isSelectedRightOccurrence(uint256 event_id) private view returns (bool) { // check if validator selected right event outcome if (selectedValidationOccurrence[event_id][msg.sender][occuredOccurrence[event_id]] == true) { // validator selected right event outcome return true; } // validator selected wrong event outcome return false; } /** * @dev function calculates the distribution of funds * after an event has been validated */ function _distributionFormular(uint256 event_id) private { // calculate what is left after winners reward has been removed uint256 winners_percent = (eventBetOccurenceAmount[event_id][occuredOccurrence[event_id]] * 100) / events[event_id].poolSize; uint256 winners_percent_remainder = ((eventBetOccurenceAmount[event_id][occuredOccurrence[event_id]] * 100) % events[event_id].poolSize) / 100; uint256 winners_reward = ((amountLostInBet[event_id] / 100) * winners_percent).add(winners_percent_remainder); uint256 div_amount = amountLostInBet[event_id].sub(winners_reward); Distribution storage setDivs = divs[event_id]; setDivs.bettorsDiv = setDivs.bettorsDiv.add(div_amount); } /** * @dev function is used in claiming reward */ function claimReward(uint256 event_id) external returns (bool) { _claimReward(event_id, msg.sender); return true; } /** * @dev function helps a user claim rewards * * Requirements: * [event_id] must be an event that has been validated * [msg.sender] must either be a bettor that participated in the event or validator * that validated the event */ function _claimReward(uint256 event_id, address user_address) private hasClaimedReward(event_id) { // check if event exist require(events[event_id].poolSize > 0, "Bet event not found"); // check if event occurrence is not UNKNOWN OR INVALID require(events[event_id].occured == Occurences.WIN || events[event_id].occured == Occurences.LOOSE || events[event_id].occured == Occurences.LOOSE_OR_WIN, "Reclaim wager instead."); // check if event has been validated require(events[event_id].validated == true, "Event not validated."); // check if user is a bettor of the event require(bets[event_id][user_address] == true, "You have no stake in this event."); BetEvent storage getEventDetails = events[event_id]; // user betted on event - check if user selected occured occurrence if (userBets[event_id][user_address].occurence == occuredOccurrence[event_id]) { // user selected occured occurrence - calculate user reward uint256 winners_percent = (userBets[event_id][user_address].amount * 100) / events[event_id].poolSize; uint256 winners_percent_remainder = ((userBets[event_id][user_address].amount * 100) % events[event_id].poolSize) / 100; uint256 user_reward = ((amountLostInBet[event_id] / 100) * winners_percent).add(winners_percent_remainder); user_reward = user_reward.add(userBets[event_id][user_address].amount); // refund user original bet amount user_reward = user_reward.add(divs[event_id].bettorsDiv / events[event_id].bettorsCount); // divide div amount by number of bettors - add amount to user reward claimedReward[event_id][user_address] = true; // user marked as collected reward _incrementTotalAmountClaimed(user_reward); // increment total amount claimed on platform getEventDetails.noOfBettorsRewarded = getEventDetails.noOfBettorsRewarded.add(1); // increment no. of event bettors rewarded getEventDetails.amountClaimed = getEventDetails.amountClaimed.add(user_reward); // increment event winnings claimed BUSD_token.transfer(user_address, user_reward); // transfer user reward to user emit Claim(user_address, user_reward); // emit claim event } else { // user chose wrong occurrence - reward user from div uint256 user_reward = divs[event_id].bettorsDiv / events[event_id].bettorsCount; claimedReward[event_id][user_address] = true; // user marked as collected reward _incrementTotalAmountClaimed(user_reward); // increment total amount claimed on platform getEventDetails.noOfBettorsRewarded = getEventDetails.noOfBettorsRewarded.add(1); // increment no. of event bettors rewarded getEventDetails.amountClaimed = getEventDetails.amountClaimed.add(user_reward); // increment event winnings claimed BUSD_token.transfer(user_address, user_reward); // transfer user reward to user emit Claim(user_address, user_reward); // emit claim event } } /** * @dev function marks an event as validated */ function _markAsValidated(uint256 event_id) private { BetEvent storage thisEvent = events[event_id]; // initialize event instance thisEvent.validated = true; activeEvents[event_id] = false; // set event as not active removeFromActiveEvents(event_id); // remove event from avalaibleEvents array validatedEvent.push(event_id); // add event to list of validated event } /** * @dev function increments the total winnings claimed * on the platform */ function _incrementTotalAmountClaimed(uint256 _value) private { totalAmountClaimed = totalAmountClaimed.add(_value); } /** * @dev function is used to pause almost all platform activities */ function pause() external onlyAdmin returns (bool) { // check if platform is paused if (platformStatus == true) { // platform paused - unpause platformStatus = false; return true; } else { // paltform not paused - pause platformStatus = true; return true; } } function currenctTime() external view returns (uint256) { return block.timestamp; } /** * @dev function withdraws funds left in smart contract after a particular * event winnings distribution. * This ensures funds are not mistakenly locked away in the smart contract * * REQUIREMENTS * [event_id] must an event that exist and is validated. * [event_id] must be an event in which all winnings have been distributed * [msg.sender] must be _owner */ function _transferCrumbs(uint256 event_id, address _address) private onlyOwner { // check if event has been validated require(events[event_id].validated == true, "Event not validated."); // check if all winnings have been distributed require(events[event_id].noOfBettorsRewarded == events[event_id].bettorsCount, "Winnings not distributed completely."); BetEvent memory eventDetails = events[event_id]; uint256 leftOverFunds = eventDetails.poolSize - eventDetails.amountClaimed; // funds left over after Winnings distribution BUSD_token.transfer(_address, leftOverFunds); } /** * @dev function withdraws funds left in smart contract after a particular * event winnings distribution. * This ensures funds are not mistakenly locked away in the smart contract * * REQUIREMENTS * [event_id] must an event that exist and is validated. * [event_id] must be an event in which all winnings have been distributed * [msg.sender] must be _owner */ function transferCrumbs(uint256 event_id, address _address) public returns (bool) { _transferCrumbs(event_id, _address); return true; } /** * @dev function is used to change the contract address * of BUSD and BETS */ function changeContractAddresses(address _busd, address _bet) public returns (bool) { BUSD_token = BUSD(address(_busd)); BETS_token = BETS(address(_bet)); return true; } }
transfer funds to smart contract
BETS_token.transferFrom(userAddress,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 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5411, 605, 1584, 55, 67, 2316, 18, 13866, 1265, 12, 1355, 1887, 16, 1758, 12, 2211, 3631, 3844, 1769, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/4/0xBE9B0A33f54C2B880aE53a8DC8523092E39cB1d6/sources/contracts/Vader/Vader.sol
* @dev Ensures only the USDV is able to invoke a particular function by validating that the contract has been set up and that the msg.sender is the USDV address/
function _onlyUSDV() private view { require( usdv != IUSDV(_ZERO_ADDRESS), "Vader::_onlyUSDV: USDV not set yet" ); require( address(usdv) == _msgSender(), "Vader::_onlyUSDV: Insufficient Privileges" ); }
13,360,220
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 1374, 8421, 1338, 326, 587, 9903, 58, 353, 7752, 358, 4356, 279, 6826, 445, 635, 18075, 716, 326, 6835, 711, 2118, 444, 731, 471, 716, 326, 1234, 18, 15330, 353, 326, 587, 9903, 58, 1758, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 3700, 3378, 30199, 1435, 3238, 1476, 288, 203, 3639, 2583, 12, 203, 5411, 584, 15679, 480, 467, 3378, 30199, 24899, 24968, 67, 15140, 3631, 203, 5411, 315, 58, 1143, 2866, 67, 3700, 3378, 30199, 30, 587, 9903, 58, 486, 444, 4671, 6, 203, 3639, 11272, 203, 3639, 2583, 12, 203, 5411, 1758, 12, 407, 15679, 13, 422, 389, 3576, 12021, 9334, 203, 5411, 315, 58, 1143, 2866, 67, 3700, 3378, 30199, 30, 22085, 11339, 2301, 8203, 2852, 6, 203, 3639, 11272, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2022-03-19 */ // SPDX-License-Identifier: MIT /** _____ ________ __ __ __________ __ ______/ ____\____ / _____/ __ ___/ |__/ |_ ___________ \______ \__ __ ____ | | __ ______ / \ __\/ \ / \ ___| | \ __\ __\/ __ \_ __ \ | ___/ | \/ \| |/ / / ___/ | Y Y \ | | | \ \ \_\ \ | /| | | | \ ___/| | \/ | | | | / | \ < \___ \ |__|_| /__| |___| / \______ /____/ |__| |__| \___ >__| |____| |____/|___| /__|_ \/____ > \/ \/ \/ \/ \/ \/ \/ */ pragma solidity ^0.8.9; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } function isContractOwner() public virtual returns (bool) { return (_owner == _msgSender()); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } abstract contract Target721 { function ownerOf(uint256 tokenId) public view virtual returns (address); function balanceOf(address owner) public view virtual returns (uint256); function getApproved(uint256 tokenId) public view virtual returns (address); function isApprovedForAll(address owner, address operator) public view virtual returns (bool); } /** * @title mfnGutterPunks contract. * @author The Gutter Punks team. * */ contract mfnGutterPunks is Context, ERC165, IERC721, IERC721Metadata, Ownable { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; string internal _baseTokenURI; string internal _contractURI; uint256 internal _totalSupply; uint256 internal MAX_TOKEN_ID; string public constant TOKEN_URI_EXTENSION = ".json"; uint256 public constant LAST_MFER_TOKEN = 10020; uint256 public constant MAX_SUPPLY = 15021; bool internal _burnAirdrop = false; bool internal _finalize = false; address internal _burnAddress = 0x000000000000000000000000000000000000dEaD; address internal _mferAddress = 0x79FCDEF22feeD20eDDacbB2587640e45491b757f; address internal _gpAddress = 0x9a54988016E97Fdc388D1b084BcbfE32De91b70c; Target721 _mferTarget = Target721(0x79FCDEF22feeD20eDDacbB2587640e45491b757f); Target721 _gpTarget = Target721(0x9a54988016E97Fdc388D1b084BcbfE32De91b70c); constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function setName(string memory name_) external onlyOwner { require(!_finalize, "Cannot change name after finalized."); _name = name_; } function tokenURI(uint256 tokenId) public view override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseTokenURI; return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), TOKEN_URI_EXTENSION)) : ""; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function setTargetMFERSContract(address contractAddress) external onlyOwner { require(!_finalize, "Cannot set target contract after finalized."); _mferAddress = contractAddress; _mferTarget = Target721(contractAddress); } function setGutterPunksTargetContract(address contractAddress) external onlyOwner { require(!_finalize, "Cannot set target contract after finalized."); _gpAddress = contractAddress; _gpTarget = Target721(contractAddress); } function setURI(string calldata baseURI) external onlyOwner { require(!_finalize, "Cannot edit base URI after finalized."); _baseTokenURI = baseURI; } function setBurnAirdrop(bool setBurn) external onlyOwner { require(!_finalize, "Cannot burn entire contract after finalized."); _burnAirdrop = setBurn; } function setFinalize(bool finalize) external onlyOwner { require(!_finalize, "Cannot change finalize after finalized."); _finalize = finalize; } function airdrop(address[] calldata recipients) external onlyOwner { require(!_finalize, "Cannot airdrop after finalized."); uint256 startingSupply = _totalSupply; require(startingSupply + recipients.length <= MAX_SUPPLY, "Cannot airdrop more than max supply."); // Update the total supply. _totalSupply = startingSupply + recipients.length; // Note: First token has ID #0. for (uint256 i = 0; i < recipients.length; i++) { _mint(recipients[i], startingSupply + i); } if((startingSupply + recipients.length - 1) > MAX_TOKEN_ID) { MAX_TOKEN_ID = (startingSupply + recipients.length - 1); } } function bifurcateToken(uint256[] calldata tokenId) external { bool _isContractOwner = isContractOwner(); for(uint256 i = 0;i < tokenId.length;i++) { address owner = ownerOf(tokenId[i]); require(owner == _msgSender() || _isContractOwner, "Must own token to bifurcate."); unchecked { _owners[tokenId[i]] = owner; } } } function tokenBifurcated(uint256 tokenId) public view returns (bool) { return tokenId > LAST_MFER_TOKEN || _owners[tokenId] != address(0); } function burn(uint256 tokenId) external { _burn(tokenId); } function emitTransfers(uint256[] calldata tokenId, address[] calldata from, address[] calldata to) external onlyOwner { require(tokenId.length == from.length && from.length == to.length, "Arrays do not match."); for(uint256 i = 0;i < tokenId.length;i++) { if(_owners[tokenId[i]] == address(0)) { emit Transfer(from[i], to[i], tokenId[i]); } } } function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); address approved = _tokenApprovals[tokenId]; return approved; } function _exists(uint256 tokenId) internal view virtual returns (bool) { if(tokenId >= _totalSupply) { return false; } else if(tokenId > (MAX_SUPPLY-1)) { return false; } else if(_owners[tokenId] == _burnAddress) { return false; } else if(_owners[tokenId] != address(0)) { return true; } else if(tokenId <= LAST_MFER_TOKEN) { return _mferTarget.ownerOf(tokenId) != address(0); } else { return _gpTarget.ownerOf((tokenId-LAST_MFER_TOKEN)) != address(0); } } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function _ownerOf(uint256 tokenId) internal view virtual returns (address) { address owner = _owners[tokenId]; if(owner == address(0) && !_burnAirdrop) { if(tokenId <= LAST_MFER_TOKEN) { try _mferTarget.ownerOf(tokenId) returns (address result) { owner = result; } catch { owner = address(0); } } else { try _gpTarget.ownerOf((tokenId-LAST_MFER_TOKEN)) returns (address result) { owner = result; } catch { owner = address(0); } } } return owner; } function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ownerOf(tokenId); return (spender == owner || _tokenApprovals[tokenId] == spender || isApprovedForAll(owner, spender)); } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(_ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); unchecked { _owners[tokenId] = to; } emit Transfer(from, to, tokenId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); uint256 balance = 0; for(uint256 i = 0;i <= MAX_TOKEN_ID;i++) { if(_ownerOf(i) == owner) { balance++; } } return balance; } function _mint(address to, uint256 tokenId) internal virtual { emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); address burnAddress = _burnAddress; require(owner == _msgSender(), "Must own token to burn."); _beforeTokenTransfer(owner, burnAddress, tokenId); // Clear approvals _approve(address(0), tokenId); _owners[tokenId] = burnAddress; emit Transfer(owner, burnAddress, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} function contractURI() external view returns (string memory) { return _contractURI; } function totalSupply() public view returns (uint256) { return _totalSupply; } function parentTokenTransferred(address from, uint256 tokenId) public virtual { require(_msgSender() == _gpAddress, "This function must be called by the airdrop token parent."); // Only update token owner if current owner is unset tokenId = tokenId + LAST_MFER_TOKEN; // offset by mfers airdrop tokens - GP #1 -> MFNGP #10021 if(tokenId < MAX_SUPPLY && _owners[tokenId] == address(0)) { _owners[tokenId] = from; } } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
Update the total supply. Note: First token has ID #0.
function airdrop(address[] calldata recipients) external onlyOwner { require(!_finalize, "Cannot airdrop after finalized."); uint256 startingSupply = _totalSupply; require(startingSupply + recipients.length <= MAX_SUPPLY, "Cannot airdrop more than max supply."); _totalSupply = startingSupply + recipients.length; for (uint256 i = 0; i < recipients.length; i++) { _mint(recipients[i], startingSupply + i); } }
7,701,510
[ 1, 4625, 348, 7953, 560, 30, 225, 2315, 326, 2078, 14467, 18, 3609, 30, 5783, 1147, 711, 1599, 468, 20, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 279, 6909, 1764, 12, 2867, 8526, 745, 892, 12045, 13, 3903, 1338, 5541, 288, 203, 202, 202, 6528, 12, 5, 67, 30343, 16, 315, 4515, 279, 6909, 1764, 1839, 727, 1235, 1199, 1769, 7010, 3639, 2254, 5034, 5023, 3088, 1283, 273, 389, 4963, 3088, 1283, 31, 203, 202, 202, 6528, 12, 18526, 3088, 1283, 397, 12045, 18, 2469, 1648, 4552, 67, 13272, 23893, 16, 315, 4515, 279, 6909, 1764, 1898, 2353, 943, 14467, 1199, 1769, 203, 1082, 203, 203, 3639, 389, 4963, 3088, 1283, 273, 5023, 3088, 1283, 397, 12045, 18, 2469, 31, 203, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 12045, 18, 2469, 31, 277, 27245, 288, 203, 5411, 389, 81, 474, 12, 27925, 63, 77, 6487, 5023, 3088, 1283, 397, 277, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require( newOwner != address(0), "Ownable: new owner is the zero address" ); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, "Address: low-level call with value failed" ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, "Address: insufficient balance for call" ); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}( data ); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall( target, data, "Address: low-level static call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall( target, data, "Address: low-level delegate call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require( owner != address(0), "ERC721: balance query for the zero address" ); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require( owner != address(0), "ERC721: owner query for nonexistent token" ); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require( _exists(tokenId), "ERC721: approved query for nonexistent token" ); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require( ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own" ); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received( _msgSender(), from, tokenId, _data ) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert( "ERC721: transfer to non ERC721Receiver implementer" ); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require( index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds" ); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require( index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds" ); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: reflective.sol pragma solidity ^0.8.4; contract ReflectiveCollective is ERC721Enumerable, Ownable { using Address for address; using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; // Starting and stopping sale and presale bool public saleActive = false; bool public presaleActive = false; // Reserved for the team, customs, giveaways, collabs and so on. uint256 public reserved = 115; // Price of each token uint256 public price = 0.08 ether; // Maximum limit of tokens that can ever exist uint256 constant MAX_SUPPLY = 10000; // The base link that leads to the image / video of the token string public baseTokenURI; //to show moc string public blankURI; // List of addresses that have a number of reserved tokens for presale mapping(address => uint256) public presaleReserved; event Received(address, uint256); constructor(string memory newBaseURI) ERC721("Reflective Collective", "RC") { setBaseURI(newBaseURI); } // Override so the openzeppelin tokenURI() method will use this method to create the full tokenURI instead function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } // See which address owns which tokens function tokensOfOwner(address addr) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(addr); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(addr, i); } return tokensId; } //Mint function mint(uint256 amount) public payable { require( presaleActive == true || saleActive == true, "sale is not activated yet" ); if (presaleActive == true && saleActive == false) { mintPresale(amount); } if (saleActive == true && presaleActive == false) { mintToken(amount); } } // Exclusive presale minting function mintPresale(uint256 amount) internal { require(amount > 0, "amount should not be zero.."); // uint256 reservedAmt = presaleReserved[msg.sender]; require( amount <= presaleReserved[msg.sender], "mintPresale Erorr: minted reserved tokens or not allowed" ); require(presaleActive, "Presale isn't active"); require( _tokenIdCounter.current() + amount <= MAX_SUPPLY - reserved, "Can't mint more than max supply" ); require(msg.value == price * amount, "Wrong amount of ETH sent"); for (uint256 i = 1; i <= amount; i++) { _safeMint(msg.sender, _tokenIdCounter.current()); _tokenIdCounter.increment(); presaleReserved[msg.sender] -= 1; } } // Standard mint function1 function mintToken(uint256 amount) internal { require(amount <= 10, "Only 10 tokens are allowed to mint once"); require(msg.value == price * amount, "Wrong amount of ETH sent"); require(saleActive, "Sale isn't active"); require( _tokenIdCounter.current() + amount <= MAX_SUPPLY - reserved, "Can't mint more than max supply" ); payable(owner()).transfer(msg.value); for (uint256 i = 1; i <= amount; i++) { _safeMint(msg.sender, _tokenIdCounter.current()); _tokenIdCounter.increment(); } } //withdraw ethers() from contract onlyy Admin function withdrawfunds() public payable onlyOwner { require( msg.sender == owner(), "withdrawfunds: only Owner can call this function" ); require( address(this).balance != 0, "withdrawfunds :no balance is in contract" ); payable(owner()).transfer(address(this).balance); } function checkContractBalance() external view onlyOwner returns (uint256 balance) { return address(this).balance; } // Admin minting function to reserve tokens for the team, collabs, customs and giveaways function mintReserved(uint256 _amount) public onlyOwner { // Limited to a publicly set amount require(_amount > 0, "Invalid amount is given"); require(_amount <= reserved, "Can't reserve more than set amount"); reserved -= _amount; for (uint256 i = 1; i <= _amount; i++) { _safeMint(msg.sender, _tokenIdCounter.current()); _tokenIdCounter.increment(); } } // Edit reserved presale spots function editPresaleReserved(address[] memory _a, uint256 _amount) public onlyOwner { for (uint256 i; i < _a.length; i++) { presaleReserved[_a[i]] = _amount; } } // Start and stop presale function setPresaleActive(bool val) public onlyOwner { presaleActive = val; if (val == true) { saleActive = false; } } // Start and stop sale function setSaleActive(bool val) public onlyOwner { saleActive = val; if (val == true) { presaleActive = false; } } // Set new baseURI function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } // Set a different price in case ETH changes drastically function setPrice(uint256 newPrice) public onlyOwner { price = newPrice; } //get number of minted tokens function counter() public view returns (uint256) { return _tokenIdCounter.current() - 1; } //function to reveal the metadata of tokens function reveal() public onlyOwner { setBaseURI( "https://dyy85tm27l.execute-api.us-east-1.amazonaws.com/prod/api/token/" ); } receive() external payable { emit Received(msg.sender, msg.value); } //function to get return remainingTokens for minting function remainingTokens() public view returns(uint256){ return MAX_SUPPLY - reserved - _tokenIdCounter.current(); } }
function to reveal the metadata of tokens
function reveal() public onlyOwner { setBaseURI( ); }
5,828,277
[ 1, 4625, 348, 7953, 560, 30, 445, 358, 283, 24293, 326, 1982, 434, 2430, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 283, 24293, 1435, 1071, 1338, 5541, 288, 203, 3639, 26435, 3098, 12, 203, 3639, 11272, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.24; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } } contract developed { address public developer; /** * Constructor */ constructor() public { developer = msg.sender; } /** * @dev Checks only developer address is calling */ modifier onlyDeveloper { require(msg.sender == developer); _; } /** * @dev Allows developer to switch developer address * @param _developer The new developer address to be set */ function changeDeveloper(address _developer) public onlyDeveloper { developer = _developer; } /** * @dev Allows developer to withdraw ERC20 Token */ function withdrawToken(address tokenContractAddress) public onlyDeveloper { TokenERC20 _token = TokenERC20(tokenContractAddress); if (_token.balanceOf(this) > 0) { _token.transfer(developer, _token.balanceOf(this)); } } } /** * @title ContractVerification */ contract ContractVerification is developed { bool public contractKilled; mapping(bytes32 => string) public stringSettings; // Array containing all string settings mapping(bytes32 => uint256) public uintSettings; // Array containing all uint256 settings mapping(bytes32 => bool) public boolSettings; // Array containing all bool settings /** * @dev Setting variables */ struct Version { bool active; uint256[] hostIds; string settings; } struct Host { bool active; string settings; } // mapping versionNum => Version mapping(uint256 => Version) public versions; // mapping hostId => Host mapping(uint256 => Host) public hosts; uint256 public totalVersionSetting; uint256 public totalHostSetting; /** * @dev Log dev updates string setting */ event LogUpdateStringSetting(bytes32 indexed name, string value); /** * @dev Log dev updates uint setting */ event LogUpdateUintSetting(bytes32 indexed name, uint256 value); /** * @dev Log dev updates bool setting */ event LogUpdateBoolSetting(bytes32 indexed name, bool value); /** * @dev Log dev deletes string setting */ event LogDeleteStringSetting(bytes32 indexed name); /** * @dev Log dev deletes uint setting */ event LogDeleteUintSetting(bytes32 indexed name); /** * @dev Log dev deletes bool setting */ event LogDeleteBoolSetting(bytes32 indexed name); /** * @dev Log dev add version setting */ event LogAddVersionSetting(uint256 indexed versionNum, bool active, uint256[] hostIds, string settings); /** * @dev Log dev delete version setting */ event LogDeleteVersionSetting(uint256 indexed versionNum); /** * @dev Log dev update version setting */ event LogUpdateVersionSetting(uint256 indexed versionNum, bool active, uint256[] hostIds, string settings); /** * @dev Log dev add host setting */ event LogAddHostSetting(uint256 indexed hostId, bool active, string settings); /** * @dev Log dev delete host setting */ event LogDeleteHostSetting(uint256 indexed hostId); /** * @dev Log dev update host setting */ event LogUpdateHostSetting(uint256 indexed hostId, bool active, string settings); /** * @dev Log dev add host to version */ event LogAddHostIdToVersion(uint256 indexed hostId, uint256 versionNum, bool success); /** * @dev Log dev remove host id at version */ event LogRemoveHostIdAtVersion(uint256 indexed hostId, uint256 versionNum, bool success); /** * @dev Log when emergency mode is on */ event LogEscapeHatch(); /** * Constructor */ constructor() public {} /******************************************/ /* DEVELOPER ONLY METHODS */ /******************************************/ /** * @dev Allows dev to update string setting * @param name The setting name to be set * @param value The value to be set */ function updateStringSetting(bytes32 name, string value) public onlyDeveloper { stringSettings[name] = value; emit LogUpdateStringSetting(name, value); } /** * @dev Allows dev to set uint setting * @param name The setting name to be set * @param value The value to be set */ function updateUintSetting(bytes32 name, uint256 value) public onlyDeveloper { uintSettings[name] = value; emit LogUpdateUintSetting(name, value); } /** * @dev Allows dev to set bool setting * @param name The setting name to be set * @param value The value to be set */ function updateBoolSetting(bytes32 name, bool value) public onlyDeveloper { boolSettings[name] = value; emit LogUpdateBoolSetting(name, value); } /** * @dev Allows dev to delete string setting * @param name The setting name to be deleted */ function deleteStringSetting(bytes32 name) public onlyDeveloper { delete stringSettings[name]; emit LogDeleteStringSetting(name); } /** * @dev Allows dev to delete uint setting * @param name The setting name to be deleted */ function deleteUintSetting(bytes32 name) public onlyDeveloper { delete uintSettings[name]; emit LogDeleteUintSetting(name); } /** * @dev Allows dev to delete bool setting * @param name The setting name to be deleted */ function deleteBoolSetting(bytes32 name) public onlyDeveloper { delete boolSettings[name]; emit LogDeleteBoolSetting(name); } /** * @dev Allows dev to add version settings * @param active The boolean value to be set * @param hostIds An array of hostIds * @param settings The settings string to be set */ function addVersionSetting(bool active, uint256[] hostIds, string settings) public onlyDeveloper { totalVersionSetting++; // Make sure every ID in hostIds exists if (hostIds.length > 0) { for(uint256 i=0; i<hostIds.length; i++) { require (bytes(hosts[hostIds[i]].settings).length > 0); } } Version storage _version = versions[totalVersionSetting]; _version.active = active; _version.hostIds = hostIds; _version.settings = settings; emit LogAddVersionSetting(totalVersionSetting, _version.active, _version.hostIds, _version.settings); } /** * @dev Allows dev to delete version settings * @param versionNum The version num */ function deleteVersionSetting(uint256 versionNum) public onlyDeveloper { delete versions[versionNum]; emit LogDeleteVersionSetting(versionNum); } /** * @dev Allows dev to update version settings * @param versionNum The version of this setting * @param active The boolean value to be set * @param hostIds The array of host ids * @param settings The settings string to be set */ function updateVersionSetting(uint256 versionNum, bool active, uint256[] hostIds, string settings) public onlyDeveloper { // Make sure version setting of this versionNum exists require (bytes(versions[versionNum].settings).length > 0); // Make sure every ID in hostIds exists if (hostIds.length > 0) { for(uint256 i=0; i<hostIds.length; i++) { require (bytes(hosts[hostIds[i]].settings).length > 0); } } Version storage _version = versions[versionNum]; _version.active = active; _version.hostIds = hostIds; _version.settings = settings; emit LogUpdateVersionSetting(versionNum, _version.active, _version.hostIds, _version.settings); } /** * @dev Allows dev to add host id to version hostIds * @param hostId The host Id to be added * @param versionNum The version num destination */ function addHostIdToVersion(uint256 hostId, uint256 versionNum) public onlyDeveloper { require (hosts[hostId].active == true); require (versions[versionNum].active == true); Version storage _version = versions[versionNum]; if (_version.hostIds.length == 0) { _version.hostIds.push(hostId); emit LogAddHostIdToVersion(hostId, versionNum, true); } else { bool exist = false; for (uint256 i=0; i < _version.hostIds.length; i++) { if (_version.hostIds[i] == hostId) { exist = true; break; } } if (!exist) { _version.hostIds.push(hostId); emit LogAddHostIdToVersion(hostId, versionNum, true); } else { emit LogAddHostIdToVersion(hostId, versionNum, false); } } } /** * @dev Allows dev to remove host id at version hostIds * @param hostId The host Id to be removed * @param versionNum The version num destination */ function removeHostIdAtVersion(uint256 hostId, uint256 versionNum) public onlyDeveloper { Version storage _version = versions[versionNum]; require (versions[versionNum].active == true); uint256 hostIdCount = versions[versionNum].hostIds.length; require (hostIdCount > 0); int256 position = -1; for (uint256 i=0; i < hostIdCount; i++) { if (_version.hostIds[i] == hostId) { position = int256(i); break; } } require (position >= 0); for (i = uint256(position); i < hostIdCount-1; i++){ _version.hostIds[i] = _version.hostIds[i+1]; } delete _version.hostIds[hostIdCount-1]; _version.hostIds.length--; emit LogRemoveHostIdAtVersion(hostId, versionNum, true); } /** * @dev Allows dev to add host settings * @param active The boolean value to be set * @param settings The settings string to be set */ function addHostSetting(bool active, string settings) public onlyDeveloper { totalHostSetting++; Host storage _host = hosts[totalHostSetting]; _host.active = active; _host.settings = settings; emit LogAddHostSetting(totalHostSetting, _host.active, _host.settings); } /** * @dev Allows dev to delete host settings * @param hostId The host ID */ function deleteHostSetting(uint256 hostId) public onlyDeveloper { require (bytes(hosts[hostId].settings).length > 0); delete hosts[hostId]; emit LogDeleteHostSetting(hostId); } /** * @dev Allows dev to update host settings * @param hostId The host ID * @param active The boolean value to be set * @param settings The settings string to be set */ function updateHostSetting(uint256 hostId, bool active, string settings) public onlyDeveloper { require (bytes(hosts[hostId].settings).length > 0); Host storage _host = hosts[hostId]; _host.active = active; _host.settings = settings; emit LogUpdateHostSetting(hostId, _host.active, _host.settings); } /** * @dev Allows developer to trigger emergency mode */ function escapeHatch() public onlyDeveloper { require (contractKilled == false); contractKilled = true; if (address(this).balance > 0) { developer.transfer(address(this).balance); } emit LogEscapeHatch(); } /******************************************/ /* PUBLIC METHODS */ /******************************************/ /** * @dev Get version settings based on versionNum * @param versionNum The version num * @return Active state of this version * @return Array of host Ids * @return The settings string */ function getVersionSetting(uint256 versionNum) public constant returns (bool, uint256[], string) { Version memory _version = versions[versionNum]; return (_version.active, _version.hostIds, _version.settings); } /** * @dev Get latest version settings * @return Active state of the latest version * @return Array of host Ids * @return The settings string */ function getLatestVersionSetting() public constant returns (bool, uint256[], string) { Version memory _version = versions[totalVersionSetting]; return (_version.active, _version.hostIds, _version.settings); } }
* @dev Allows dev to delete host settings @param hostId The host ID/
function deleteHostSetting(uint256 hostId) public onlyDeveloper { require (bytes(hosts[hostId].settings).length > 0); delete hosts[hostId]; emit LogDeleteHostSetting(hostId); }
12,609,789
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 25619, 4461, 358, 1430, 1479, 1947, 632, 891, 1479, 548, 1021, 1479, 1599, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 374, 1769, 203, 203, 202, 202, 3733, 7206, 63, 2564, 548, 15533, 203, 202, 202, 18356, 1827, 2613, 2594, 5568, 12, 2564, 548, 1769, 203, 202, 97, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.5.0; contract PythagorasProject { string public name; uint public postCount = 0; uint public userid = 0; uint public totalbalance1 = 0; uint public totalbalance2 = 0; uint public persentage = 0; uint public currentTime = 8000; address public x = 0xf27C00B9Ef52b6ADCBAd02a1C3F7e7459925108e; mapping(uint => Post) public posts; mapping(address => uint) public depositStart; mapping(uint => address) public y; mapping(address => uint) public etherBalanceOf; mapping(address => uint) public userpersentage; mapping(uint => uint) public votingStart; mapping(address => mapping(uint256 => bool)) public pinakas; mapping(address => bool) public isDeposited; mapping(address => bool) public notvote; struct Post { uint id; string content; uint upvotes; uint downvotes; address payable author; address payable invest; string amount; } event PostCreated( uint id, string content, uint upvotes, uint downvotes, address payable author, address payable invest, string amount ); event Upvoting( uint id, string content, uint upvotes, uint downvotes, address payable author, address payable invest, string amount ); event Downvoting( uint id, string content, uint upvotes, uint downvotes, address payable author, address payable invest, string amount ); event Deposit( address indexed user, uint etherAmount, uint timeStart ); event Withdraw( address indexed user, uint etherAmount, uint depositTime, uint interest ); constructor() public{ name = "PythagorasProject"; } function deposit() payable public { require(msg.value>=1e16, 'Error, deposit must be >= 0.01 ETH'); etherBalanceOf[msg.sender] = etherBalanceOf[msg.sender] + msg.value; for (uint i=0; i<=userid; i++) { if (y[i]!=msg.sender) { userid = userid + 1 ; y[userid]=msg.sender; } } for (uint i=0; i<=userid; i++) { x=y[i]; totalbalance1=totalbalance1+etherBalanceOf[x]; } isDeposited[msg.sender] = true; //activate deposit status emit Deposit(msg.sender, msg.value, block.timestamp); } function createPost(string memory _content, address payable invest, string memory amount) public { // Require valid content require(bytes(_content).length > 0); require(etherBalanceOf[msg.sender]>0, 'Error, no previous deposit'); // increment the post count = postCount ++; //create the post Post storage post = posts[postCount]; post.id=postCount; post.content=_content; post.upvotes=0; post.downvotes=0; post.author=(msg.sender); post.invest=(invest); post.amount=amount; votingStart[postCount] = votingStart[postCount] + block.timestamp; //trigger event emit PostCreated(postCount, _content, 0, 0, msg.sender, invest, amount); } function Upvote(uint _id) public payable{ require(etherBalanceOf[msg.sender]>0, 'Error, no previous deposit'); require(pinakas[msg.sender][_id]==false, 'Error, user already vote'); require(_id > 0 && _id <= postCount); //giving 12h for each voting currentTime = block.timestamp - votingStart[_id]; require(currentTime <= 7200, 'Error, voting is over'); //fetch the post Post memory _post = posts [_id]; //fetch the author address payable _author = 0xf27C00B9Ef52b6ADCBAd02a1C3F7e7459925108e; //Pay the author by sending them ether address(_author).transfer(msg.value); //Incremet the tip amount uint userBalance = etherBalanceOf[msg.sender]; _post.upvotes = _post.upvotes + userBalance; //update the post posts[_id] = _post; pinakas[msg.sender][_id]=true; //allow to vote only once emit Upvoting(postCount, _post.content, _post.upvotes,_post.downvotes , _author, _post.invest, _post.amount); } function Downvote(uint _id) public payable{ require(etherBalanceOf[msg.sender]>0, 'Error, no previous deposit'); require(pinakas[msg.sender][_id]==false, 'Error, user already vote'); require(_id > 0 && _id <= postCount); //giving 12h for each voting currentTime = block.timestamp - votingStart[_id]; require(currentTime <= 7200, 'Error, voting is over'); //fetch the post Post memory _post = posts [_id]; //fetch the author address payable _author = 0xf27C00B9Ef52b6ADCBAd02a1C3F7e7459925108e; //Pay the author by sending them ether address(_author).transfer(msg.value); //Incremet the tip amount uint userBalance = etherBalanceOf[msg.sender]; _post.downvotes = _post.downvotes + userBalance; //update the post //allow to vote only once pinakas[msg.sender][_id]=true; posts[_id] = _post; emit Downvoting(postCount, _post.content, _post.upvotes, _post.downvotes , _author, _post.invest, _post.amount); } function withdraw(uint amount) payable public { require(isDeposited[msg.sender]==true, 'Error, no previous deposit'); require(totalbalance1>0, 'Error, Something wrong I can feel it'); require(amount>0, 'Error, put some value'); if (postCount!=0){ currentTime = block.timestamp - votingStart[postCount]; require(currentTime >= 7200, 'Error, on going voting'); } for (uint i=0; i<=userid; i++) { x=y[i]; totalbalance2=totalbalance2+etherBalanceOf[x]; } persentage=((totalbalance1-totalbalance2)*100)/totalbalance1; uint userBalance = etherBalanceOf[msg.sender] + (persentage/100); uint userBalanceSender = userBalance; require(amount<=userBalance, 'Error, withdraw must be <= userBalance'); msg.sender.transfer(amount); //eth back to user //check user's hodl time uint depositTime = block.timestamp - depositStart[msg.sender]; uint interestPerSecond = 31668017 * (etherBalanceOf[msg.sender] / 1e16); uint interest = interestPerSecond * depositTime; //send funds to user totalbalance1=totalbalance1-amount; for (uint i=0; i<=userid; i++) { x=y[i]; userBalance = etherBalanceOf[x] + (persentage/100); etherBalanceOf[x] = userBalance; } etherBalanceOf[msg.sender] = userBalanceSender-amount; //reset depositer data depositStart[msg.sender] = 0; totalbalance2 = 0; emit Withdraw(msg.sender, userBalance, depositTime, interest); } }
giving 12h for each votingfetch the postfetch the authorPay the author by sending them etherIncremet the tip amountupdate the postallow to vote only once
function Upvote(uint _id) public payable{ require(etherBalanceOf[msg.sender]>0, 'Error, no previous deposit'); require(pinakas[msg.sender][_id]==false, 'Error, user already vote'); require(_id > 0 && _id <= postCount); currentTime = block.timestamp - votingStart[_id]; require(currentTime <= 7200, 'Error, voting is over'); Post memory _post = posts [_id]; address payable _author = 0xf27C00B9Ef52b6ADCBAd02a1C3F7e7459925108e; address(_author).transfer(msg.value); uint userBalance = etherBalanceOf[msg.sender]; _post.upvotes = _post.upvotes + userBalance; posts[_id] = _post; pinakas[msg.sender][_id]=true; emit Upvoting(postCount, _post.content, _post.upvotes,_post.downvotes , _author, _post.invest, _post.amount); }
6,477,483
[ 1, 4625, 348, 7953, 560, 30, 21057, 2593, 76, 364, 1517, 331, 17128, 5754, 326, 1603, 5754, 326, 2869, 9148, 326, 2869, 635, 5431, 2182, 225, 2437, 27597, 10578, 326, 9529, 3844, 2725, 326, 1603, 5965, 358, 12501, 1338, 3647, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 1948, 25911, 12, 11890, 389, 350, 13, 1071, 8843, 429, 95, 203, 565, 2583, 12, 2437, 13937, 951, 63, 3576, 18, 15330, 65, 34, 20, 16, 296, 668, 16, 1158, 2416, 443, 1724, 8284, 203, 565, 2583, 12, 13097, 581, 345, 63, 3576, 18, 15330, 6362, 67, 350, 65, 631, 5743, 16, 296, 668, 16, 729, 1818, 12501, 8284, 203, 565, 2583, 24899, 350, 405, 374, 597, 389, 350, 1648, 1603, 1380, 1769, 203, 565, 6680, 273, 1203, 18, 5508, 300, 331, 17128, 1685, 63, 67, 350, 15533, 203, 565, 2583, 12, 2972, 950, 1648, 2371, 6976, 16, 296, 668, 16, 331, 17128, 353, 1879, 8284, 203, 565, 5616, 3778, 389, 2767, 273, 10775, 306, 67, 350, 15533, 203, 565, 1758, 8843, 429, 389, 4161, 273, 374, 5841, 5324, 39, 713, 38, 29, 41, 74, 9401, 70, 26, 1880, 8876, 1871, 3103, 69, 21, 39, 23, 42, 27, 73, 5608, 25, 2733, 2947, 21770, 73, 31, 203, 565, 1758, 24899, 4161, 2934, 13866, 12, 3576, 18, 1132, 1769, 7010, 565, 2254, 729, 13937, 273, 225, 2437, 13937, 951, 63, 3576, 18, 15330, 15533, 203, 565, 389, 2767, 18, 416, 27800, 273, 389, 2767, 18, 416, 27800, 397, 729, 13937, 31, 203, 565, 10775, 63, 67, 350, 65, 273, 389, 2767, 31, 203, 565, 7092, 581, 345, 63, 3576, 18, 15330, 6362, 67, 350, 65, 33, 3767, 31, 203, 565, 3626, 1948, 90, 17128, 12, 2767, 1380, 16, 389, 2767, 18, 1745, 16, 389, 2767, 18, 416, 27800, 16, 67, 2767, 18, 2378, 27800, 269, 389, 4161, 16, 389, 2767, 18, 5768, 395, 16, 389, 2767, 18, 8949, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0xAC48b3c2C57cA3a50C026e47F1E1d3d9832d6506/sources/contracts/claim/abstract/TrancheVesting.sol
time and vested fraction must monotonically increase in the tranche array
abstract contract TrancheVesting is Distributor { pragma solidity 0.8.16; import { Distributor } from "./Distributor.sol"; struct Tranche { } Tranche[] public tranches; constructor( Tranche[] memory _tranches ) { require(_tranches.length > 0, "tranches required"); uint128 lastTime = 0; uint128 lastVestedBips = 0; for (uint i = 0; i < _tranches.length; i++) { require(_tranches[i].vestedBips > 0, "tranche vested fraction == 0"); require(_tranches[i].time > lastTime, "tranche time must increase"); require(_tranches[i].vestedBips > lastVestedBips, "tranche vested fraction must increase"); lastTime = _tranches[i].time; lastVestedBips = _tranches[i].vestedBips; tranches.push(_tranches[i]); } require(lastTime <= 4102444800, "vesting ends after 4102444800 (Jan 1 2100)"); require(lastVestedBips == 10000, "last tranche must vest all tokens"); } ) { require(_tranches.length > 0, "tranches required"); uint128 lastTime = 0; uint128 lastVestedBips = 0; for (uint i = 0; i < _tranches.length; i++) { require(_tranches[i].vestedBips > 0, "tranche vested fraction == 0"); require(_tranches[i].time > lastTime, "tranche time must increase"); require(_tranches[i].vestedBips > lastVestedBips, "tranche vested fraction must increase"); lastTime = _tranches[i].time; lastVestedBips = _tranches[i].vestedBips; tranches.push(_tranches[i]); } require(lastTime <= 4102444800, "vesting ends after 4102444800 (Jan 1 2100)"); require(lastVestedBips == 10000, "last tranche must vest all tokens"); } function _getVestedBips(address /*beneficiary*/, uint time) public override view returns (uint256) { for (uint i = tranches.length; i > 0; i--) { if (time > tranches[i - 1].time) { return tranches[i - 1].vestedBips; } } return 0; } function _getVestedBips(address /*beneficiary*/, uint time) public override view returns (uint256) { for (uint i = tranches.length; i > 0; i--) { if (time > tranches[i - 1].time) { return tranches[i - 1].vestedBips; } } return 0; } function _getVestedBips(address /*beneficiary*/, uint time) public override view returns (uint256) { for (uint i = tranches.length; i > 0; i--) { if (time > tranches[i - 1].time) { return tranches[i - 1].vestedBips; } } return 0; } }
7,088,790
[ 1, 4625, 348, 7953, 560, 30, 225, 813, 471, 331, 3149, 8330, 1297, 6921, 352, 265, 6478, 10929, 316, 326, 13637, 18706, 526, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 17801, 6835, 840, 304, 18706, 58, 10100, 353, 3035, 19293, 288, 203, 683, 9454, 18035, 560, 374, 18, 28, 18, 2313, 31, 203, 5666, 288, 3035, 19293, 289, 628, 25165, 1669, 19293, 18, 18281, 14432, 203, 225, 1958, 840, 304, 18706, 288, 203, 225, 289, 203, 203, 225, 840, 304, 18706, 8526, 1071, 13637, 11163, 31, 203, 203, 225, 3885, 12, 203, 565, 840, 304, 18706, 8526, 3778, 389, 13171, 11163, 203, 225, 262, 288, 203, 565, 2583, 24899, 13171, 11163, 18, 2469, 405, 374, 16, 315, 13171, 11163, 1931, 8863, 203, 203, 565, 2254, 10392, 31323, 273, 374, 31, 203, 565, 2254, 10392, 1142, 58, 3149, 38, 7146, 273, 374, 31, 203, 21281, 565, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 389, 13171, 11163, 18, 2469, 31, 277, 27245, 288, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 405, 374, 16, 315, 13171, 18706, 331, 3149, 8330, 422, 374, 8863, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 957, 405, 31323, 16, 315, 13171, 18706, 813, 1297, 10929, 8863, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 405, 1142, 58, 3149, 38, 7146, 16, 315, 13171, 18706, 331, 3149, 8330, 1297, 10929, 8863, 203, 1377, 31323, 273, 389, 13171, 11163, 63, 77, 8009, 957, 31, 203, 1377, 1142, 58, 3149, 38, 7146, 273, 389, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 31, 203, 1377, 13637, 11163, 18, 6206, 24899, 13171, 11163, 63, 77, 19226, 203, 565, 289, 203, 203, 565, 2583, 12, 2722, 950, 1648, 1059, 2163, 3247, 6334, 17374, 16, 315, 90, 10100, 3930, 1839, 1059, 2163, 3247, 6334, 17374, 261, 46, 304, 404, 576, 6625, 2225, 1769, 203, 565, 2583, 12, 2722, 58, 3149, 38, 7146, 422, 12619, 16, 315, 2722, 13637, 18706, 1297, 331, 395, 777, 2430, 8863, 203, 225, 289, 203, 203, 225, 262, 288, 203, 565, 2583, 24899, 13171, 11163, 18, 2469, 405, 374, 16, 315, 13171, 11163, 1931, 8863, 203, 203, 565, 2254, 10392, 31323, 273, 374, 31, 203, 565, 2254, 10392, 1142, 58, 3149, 38, 7146, 273, 374, 31, 203, 21281, 565, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 389, 13171, 11163, 18, 2469, 31, 277, 27245, 288, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 405, 374, 16, 315, 13171, 18706, 331, 3149, 8330, 422, 374, 8863, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 957, 405, 31323, 16, 315, 13171, 18706, 813, 1297, 10929, 8863, 203, 1377, 2583, 24899, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 405, 1142, 58, 3149, 38, 7146, 16, 315, 13171, 18706, 331, 3149, 8330, 1297, 10929, 8863, 203, 1377, 31323, 273, 389, 13171, 11163, 63, 77, 8009, 957, 31, 203, 1377, 1142, 58, 3149, 38, 7146, 273, 389, 13171, 11163, 63, 77, 8009, 90, 3149, 38, 7146, 31, 203, 1377, 13637, 11163, 18, 6206, 24899, 13171, 11163, 63, 77, 19226, 203, 565, 289, 203, 203, 565, 2583, 12, 2722, 950, 1648, 1059, 2163, 3247, 6334, 17374, 16, 315, 90, 10100, 3930, 1839, 1059, 2163, 3247, 6334, 17374, 261, 46, 304, 404, 576, 6625, 2225, 1769, 203, 565, 2583, 12, 2722, 58, 3149, 38, 7146, 422, 12619, 16, 315, 2722, 13637, 18706, 1297, 331, 395, 777, 2430, 8863, 203, 225, 289, 203, 203, 225, 445, 389, 588, 58, 3149, 38, 7146, 12, 2867, 1748, 70, 4009, 74, 14463, 814, 5549, 16, 2254, 813, 13, 1071, 3849, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 364, 261, 11890, 277, 273, 13637, 11163, 18, 2469, 31, 277, 405, 374, 31, 277, 413, 13, 288, 203, 1377, 309, 261, 957, 405, 13637, 11163, 63, 77, 300, 404, 8009, 957, 13, 288, 203, 3639, 327, 13637, 11163, 63, 77, 300, 404, 8009, 90, 3149, 38, 7146, 31, 203, 1377, 289, 203, 565, 289, 203, 565, 327, 374, 31, 203, 225, 289, 203, 225, 445, 389, 588, 58, 3149, 38, 7146, 12, 2867, 1748, 70, 4009, 74, 14463, 814, 5549, 16, 2254, 813, 13, 1071, 3849, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 364, 261, 11890, 277, 273, 13637, 11163, 18, 2469, 31, 277, 405, 374, 31, 277, 413, 13, 288, 203, 1377, 309, 261, 957, 405, 13637, 11163, 63, 77, 300, 404, 8009, 957, 13, 288, 203, 3639, 327, 13637, 11163, 63, 77, 300, 404, 8009, 90, 3149, 38, 7146, 31, 203, 1377, 289, 203, 565, 289, 203, 565, 327, 374, 31, 203, 225, 289, 203, 225, 445, 389, 588, 58, 3149, 38, 7146, 12, 2867, 1748, 70, 4009, 74, 14463, 814, 5549, 16, 2254, 813, 13, 1071, 3849, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 364, 261, 11890, 277, 273, 13637, 11163, 18, 2469, 31, 277, 405, 374, 31, 277, 413, 13, 288, 203, 1377, 309, 261, 957, 405, 13637, 11163, 63, 77, 300, 404, 8009, 957, 13, 288, 203, 3639, 327, 13637, 11163, 63, 77, 300, 404, 8009, 90, 3149, 38, 7146, 31, 203, 1377, 289, 203, 565, 289, 203, 565, 327, 374, 31, 203, 225, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.18; /** * @title Smart City Crowdsale contract http://www.smartcitycoin.io */ contract SmartCityToken { function transferFrom(address _from, address _to, uint256 _value) public returns(bool success) {} function setTokenStart(uint256 _newStartTime) public {} function burn() public {} } contract SmartCityCrowdsale { using SafeMath for uint256; // State struct Account { uint256 accounted; // received amount and bonus uint256 received; // received amount } /// Crowdsale participants mapping (address => Account) public buyins; /// Balances of Fixed Price sale participants. mapping(address => uint256) public purchases; /// Total amount of ether received. uint256 public totalReceived = 0; /// Total amount of ether accounted. uint256 public totalAccounted = 0; /// Total tokens purchased during Phase 2. uint256 public tokensPurchased = 0; /// Total amount of ether which has been finalised. uint256 public totalFinalised = 0; /// Phase 1 end time. uint256 public firstPhaseEndTime; /// Phase 2 start time. uint256 public secondPhaseStartTime; /// Campaign end time. uint256 public endTime; /// The price per token aftre Phase 1. Works also as an effective price in Phase 2 for Phase 1 participants. uint256 public auctionEndPrice; /// The price for token within Phase 2 which is effective for those who did not participate in Phase 1 uint256 public fixedPrice; /// The current percentage of bonus. uint256 public currentBonus = 15; /// Bonus that will be applied to purchases if Target is reached in Phase 1. Initially zero. uint256 public auctionSuccessBonus = 0; /// Must be false for any public function to be called. bool public paused = false; /// Campaign is ended bool public campaignEnded = false; // Constants after constructor: /// CITY token contract. SmartCityToken public tokenContract; /// The owner address. address public owner; /// The wallet address. address public wallet; /// Sale start time. uint256 public startTime; /// Amount of tokens allocated for Phase 1. /// Once totalAccounted / currentPrice is greater than this value, Phase 1 ends. uint256 public tokenCapPhaseOne; /// Amount of tokens allocated for Phase 2 uint256 public tokenCapPhaseTwo; // Static constants: /// Target uint256 constant public FUNDING_GOAL = 109573 ether; /// Minimum token price after Phase 1 for Phase 2 to be started. uint256 constant public TOKEN_MIN_PRICE_THRESHOLD = 100000000; // 0,00001 ETH per 1 CITY /// Maximum duration of Phase 1 uint256 constant public FIRST_PHASE_MAX_SPAN = 21 days; /// Maximum duration of Phase 2 uint256 constant public SECOND_PHASE_MAX_SPAN = 33 days; /// Minimum investment amount uint256 constant public DUST_LIMIT = 5 finney; /// Number of days from Phase 1 beginning when bonus is available. Bonus percentage drops by 1 percent a day. uint256 constant public BONUS_DURATION = 15; /// Percentage of bonus that will be applied to all purchases if Target is reached in Phase 1 uint256 constant public SUCCESS_BONUS = 15; /// token price in Phase 2 is by 20 % higher when resulting auction price /// for those who did not participate in auction uint256 constant public SECOND_PHASE_PRICE_FACTOR = 20; /// 1e15 uint256 constant public FACTOR = 1 finney; /// Divisor of the token. uint256 constant public DIVISOR = 100000; // Events /// Buyin event. event Buyin(address indexed receiver, uint256 accounted, uint256 received, uint256 price); /// Phase 1 just ended. event PhaseOneEnded(uint256 price); /// Phase 2 is engagaed. event PhaseTwoStared(uint256 fixedPrice); /// Investement event. event Invested(address indexed receiver, uint256 received, uint256 tokens); /// The campaign just ended. event Ended(bool goalReached); /// Finalised the purchase for receiver. event Finalised(address indexed receiver, uint256 tokens); /// Campaign is over. All accounts finalised. event Retired(); // Modifiers /// Ensure the sale is ended. modifier when_ended { require (now >= endTime); _; } /// Ensure sale is not paused. modifier when_not_halted { require (!paused); _; } /// Ensure `_receiver` is a participant. modifier only_investors(address _receiver) { require (buyins[_receiver].accounted != 0 || purchases[_receiver] != 0); _; } /// Ensure sender is owner. modifier only_owner { require (msg.sender == owner); _; } /// Ensure sale is in progress. modifier when_active { require (!campaignEnded); _;} /// Ensure phase 1 is in progress modifier only_in_phase_1 { require (now >= startTime && now < firstPhaseEndTime); _; } /// Ensure phase 1 is over modifier after_phase_1 { require (now >= firstPhaseEndTime); _; } /// Ensure phase 2 is in progress modifier only_in_phase_2 { require (now >= secondPhaseStartTime && now < endTime); _; } /// Ensure the value sent is above threshold. modifier reject_dust { require ( msg.value >= DUST_LIMIT ); _; } // Constructor function SmartCityCrowdsale( address _tokenAddress, address _owner, address _walletAddress, uint256 _startTime, uint256 _tokenCapPhaseOne, uint256 _tokenCapPhaseTwo ) public { tokenContract = SmartCityToken(_tokenAddress); wallet = _walletAddress; owner = _owner; startTime = _startTime; firstPhaseEndTime = startTime.add(FIRST_PHASE_MAX_SPAN); secondPhaseStartTime = 253402300799; // initialise by setting to 9999/12/31 endTime = secondPhaseStartTime.add(SECOND_PHASE_MAX_SPAN); tokenCapPhaseOne = _tokenCapPhaseOne; tokenCapPhaseTwo = _tokenCapPhaseTwo; } /// The default fallback function /// Calls buyin or invest function depending on current campaign phase /// Throws if campaign has already ended function() public payable when_not_halted when_active { if (now >= startTime && now < firstPhaseEndTime) { // phase 1 is ongoing _buyin(msg.sender, msg.value); } else { _invest(msg.sender, msg.value); } } // Phase 1 functions /// buyin function. function buyin() public payable when_not_halted when_active only_in_phase_1 reject_dust { _buyin(msg.sender, msg.value); } /// buyinAs function. takes the receiver address as an argument function buyinAs(address _receiver) public payable when_not_halted when_active only_in_phase_1 reject_dust { require (_receiver != address(0)); _buyin(_receiver, msg.value); } /// internal buyin functionality function _buyin(address _receiver, uint256 _value) internal { if (currentBonus > 0) { uint256 daysSinceStart = (now.sub(startTime)).div(86400); // # of days if (daysSinceStart < BONUS_DURATION && BONUS_DURATION.sub(daysSinceStart) != currentBonus) { currentBonus = BONUS_DURATION.sub(daysSinceStart); } if (daysSinceStart >= BONUS_DURATION) { currentBonus = 0; } } uint256 accounted; bool refund; uint256 price; (accounted, refund, price) = theDeal(_value); // effective cap should not be exceeded, throw require (!refund); // change state buyins[_receiver].accounted = buyins[_receiver].accounted.add(accounted); buyins[_receiver].received = buyins[_receiver].received.add(_value); totalAccounted = totalAccounted.add(accounted); totalReceived = totalReceived.add(_value); firstPhaseEndTime = calculateEndTime(); Buyin(_receiver, accounted, _value, price); // send to wallet wallet.transfer(_value); } /// The current end time of the sale assuming that nobody else buys in. function calculateEndTime() public constant when_active only_in_phase_1 returns (uint256) { uint256 res = (FACTOR.mul(240000).div(DIVISOR.mul(totalAccounted.div(tokenCapPhaseOne)).add(FACTOR.mul(4).div(100)))).add(startTime).sub(4848); if (res >= firstPhaseEndTime) { return firstPhaseEndTime; } else { return res; } } /// The current price for a token function currentPrice() public constant when_active only_in_phase_1 returns (uint256 weiPerIndivisibleTokenPart) { return ((FACTOR.mul(240000).div(now.sub(startTime).add(4848))).sub(FACTOR.mul(4).div(100))).div(DIVISOR); } /// Returns the total tokens which can be purchased right now. function tokensAvailable() public constant when_active only_in_phase_1 returns (uint256 tokens) { uint256 _currentCap = totalAccounted.div(currentPrice()); if (_currentCap >= tokenCapPhaseOne) { return 0; } return tokenCapPhaseOne.sub(_currentCap); } /// The largest purchase than can be done right now. For informational puproses only function maxPurchase() public constant when_active only_in_phase_1 returns (uint256 spend) { return tokenCapPhaseOne.mul(currentPrice()).sub(totalAccounted); } /// Returns the number of tokens available per given price. /// If this number exceeds tokens being currently available, returns refund = true function theDeal(uint256 _value) public constant when_active only_in_phase_1 returns (uint256 accounted, bool refund, uint256 price) { uint256 _bonus = auctionBonus(_value); price = currentPrice(); accounted = _value.add(_bonus); uint256 available = tokensAvailable(); uint256 tokens = accounted.div(price); refund = (tokens > available); } /// Returns bonus for given amount function auctionBonus(uint256 _value) public constant when_active only_in_phase_1 returns (uint256 extra) { return _value.mul(currentBonus).div(100); } // After Phase 1 /// Checks the results of the first phase /// Changes state only once function finaliseFirstPhase() public when_not_halted when_active after_phase_1 returns(uint256) { if (auctionEndPrice == 0) { auctionEndPrice = totalAccounted.div(tokenCapPhaseOne); PhaseOneEnded(auctionEndPrice); // check if second phase should be engaged if (totalAccounted >= FUNDING_GOAL ) { // funding goal is reached: phase 2 is not engaged, all auction participants receive additional bonus, campaign is ended auctionSuccessBonus = SUCCESS_BONUS; endTime = firstPhaseEndTime; campaignEnded = true; tokenContract.setTokenStart(endTime); Ended(true); } else if (auctionEndPrice >= TOKEN_MIN_PRICE_THRESHOLD) { // funding goal is not reached, auctionEndPrice is above or equal to threshold value: engage phase 2 fixedPrice = auctionEndPrice.add(auctionEndPrice.mul(SECOND_PHASE_PRICE_FACTOR).div(100)); secondPhaseStartTime = now; endTime = secondPhaseStartTime.add(SECOND_PHASE_MAX_SPAN); PhaseTwoStared(fixedPrice); } else if (auctionEndPrice < TOKEN_MIN_PRICE_THRESHOLD && auctionEndPrice > 0){ // funding goal is not reached, auctionEndPrice is below threshold value: phase 2 is not engaged, campaign is ended endTime = firstPhaseEndTime; campaignEnded = true; tokenContract.setTokenStart(endTime); Ended(false); } else { // no one came, we are all alone in this world :( auctionEndPrice = 1 wei; endTime = firstPhaseEndTime; campaignEnded = true; tokenContract.setTokenStart(endTime); Ended(false); Retired(); } } return auctionEndPrice; } // Phase 2 functions /// Make an investment during second phase function invest() public payable when_not_halted when_active only_in_phase_2 reject_dust { _invest(msg.sender, msg.value); } /// function investAs(address _receiver) public payable when_not_halted when_active only_in_phase_2 reject_dust { require (_receiver != address(0)); _invest(_receiver, msg.value); } /// internal invest functionality function _invest(address _receiver, uint256 _value) internal { uint256 tokensCnt = getTokens(_receiver, _value); require(tokensCnt > 0); require(tokensPurchased.add(tokensCnt) <= tokenCapPhaseTwo); // should not exceed available tokens require(_value <= maxTokenPurchase(_receiver)); // should not go above target purchases[_receiver] = purchases[_receiver].add(_value); totalReceived = totalReceived.add(_value); totalAccounted = totalAccounted.add(_value); tokensPurchased = tokensPurchased.add(tokensCnt); Invested(_receiver, _value, tokensCnt); // send to wallet wallet.transfer(_value); // check if we've reached the target if (totalAccounted >= FUNDING_GOAL) { endTime = now; campaignEnded = true; tokenContract.setTokenStart(endTime); Ended(true); } } /// Tokens currently available for purchase in Phase 2 function getTokens(address _receiver, uint256 _value) public constant when_active only_in_phase_2 returns(uint256 tokensCnt) { // auction participants have better price in second phase if (buyins[_receiver].received > 0) { tokensCnt = _value.div(auctionEndPrice); } else { tokensCnt = _value.div(fixedPrice); } } /// Maximum current purchase amount in Phase 2 function maxTokenPurchase(address _receiver) public constant when_active only_in_phase_2 returns(uint256 spend) { uint256 availableTokens = tokenCapPhaseTwo.sub(tokensPurchased); uint256 fundingGoalOffset = FUNDING_GOAL.sub(totalReceived); uint256 maxInvestment; if (buyins[_receiver].received > 0) { maxInvestment = availableTokens.mul(auctionEndPrice); } else { maxInvestment = availableTokens.mul(fixedPrice); } if (maxInvestment > fundingGoalOffset) { return fundingGoalOffset; } else { return maxInvestment; } } // After sale end /// Finalise purchase: transfers the tokens to caller address function finalise() public when_not_halted when_ended only_investors(msg.sender) { finaliseAs(msg.sender); } /// Finalise purchase for address provided: transfers the tokens purchased by given participant to their address function finaliseAs(address _receiver) public when_not_halted when_ended only_investors(_receiver) { bool auctionParticipant; uint256 total; uint256 tokens; uint256 bonus; uint256 totalFixed; uint256 tokensFixed; // first time calling finalise after phase 2 has ended but target was not reached if (!campaignEnded) { campaignEnded = true; tokenContract.setTokenStart(endTime); Ended(false); } if (buyins[_receiver].accounted != 0) { auctionParticipant = true; total = buyins[_receiver].accounted; tokens = total.div(auctionEndPrice); if (auctionSuccessBonus > 0) { bonus = tokens.mul(auctionSuccessBonus).div(100); } totalFinalised = totalFinalised.add(total); delete buyins[_receiver]; } if (purchases[_receiver] != 0) { totalFixed = purchases[_receiver]; if (auctionParticipant) { tokensFixed = totalFixed.div(auctionEndPrice); } else { tokensFixed = totalFixed.div(fixedPrice); } totalFinalised = totalFinalised.add(totalFixed); delete purchases[_receiver]; } tokens = tokens.add(bonus).add(tokensFixed); require (tokenContract.transferFrom(owner, _receiver, tokens)); Finalised(_receiver, tokens); if (totalFinalised == totalAccounted) { tokenContract.burn(); // burn all unsold tokens Retired(); } } // Owner functions /// Emergency function to pause buy-in and finalisation. function setPaused(bool _paused) public only_owner { paused = _paused; } /// Emergency function to drain the contract of any funds. function drain() public only_owner { wallet.transfer(this.balance); } /// Returns true if the campaign is in progress. function isActive() public constant returns (bool) { return now >= startTime && now < endTime; } /// Returns true if all purchases are finished. function allFinalised() public constant returns (bool) { return now >= endTime && totalAccounted == totalFinalised; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * CITY token by www.SmartCityCoin.io * * .ossssss: `+sssss` * ` +ssssss+` `.://++++++//:.` .osssss+ * /sssssssssssssssssssssssss+ssssso` * -sssssssssssssssssssssssssssss+` * .+sssssssss+:--....--:/ossssssss+. * `/ssssssssssso` .sssssssssss/` * .ossssss+sssssss- :sssss+:ossssso. * `ossssso. .ossssss: `/sssss/ `/ssssss. * ossssso` `+ssssss+` .osssss: /ssssss` * :ssssss` /sssssso:ssssso. +o+/:-` * osssss+ -sssssssssss+` * ssssss: .ossssssss/ * osssss/ `+ssssss- * /ssssso :ssssss * .ssssss- :ssssss * :ssssss- :ssssss ` * /ssssss/` :ssssss `/s+:` * :sssssso:. :ssssss ./ssssss+` * .+ssssssso/-.`:ssssss``.-/osssssss+. * .+ssssssssssssssssssssssssssss+- * `:+ssssssssssssssssssssss+:` * `.:+osssssssssssso+:.` * `/ssssss.` * :ssssss */
Emergency function to pause buy-in and finalisation.
function setPaused(bool _paused) public only_owner { paused = _paused; }
2,538,790
[ 1, 4625, 348, 7953, 560, 30, 225, 512, 6592, 75, 2075, 445, 358, 11722, 30143, 17, 267, 471, 727, 10742, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.11; contract owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) throw; _; } function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } } contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } contract ICofounditToken { function mintTokens(address _to, uint256 _amount, string _reason); function totalSupply() constant returns (uint256 totalSupply); } contract CofounditICO is owned{ uint256 public startBlock; uint256 public endBlock; uint256 public minEthToRaise; uint256 public maxEthToRaise; uint256 public totalEthRaised; address public multisigAddress; uint256 public icoSupply; uint256 public strategicReserveSupply; uint256 public cashilaTokenSupply; uint256 public iconomiTokenSupply; uint256 public coreTeamTokenSupply; ICofounditToken cofounditTokenContract; mapping (address => bool) presaleContributorAllowance; uint256 nextFreeParticipantIndex; mapping (uint => address) participantIndex; mapping (address => uint256) participantContribution; uint256 usedIcoSupply; uint256 usedStrategicReserveSupply; uint256 usedCashilaTokenSupply; uint256 usedIconomiTokenSupply; uint256 usedCoreTeamTokenSupply; bool icoHasStarted; bool minTresholdReached; bool icoHasSucessfulyEnded; uint256 lastEthReturnIndex; mapping (address => bool) hasClaimedEthWhenFail; uint256 lastCfiIssuanceIndex; string icoStartedMessage = "Cofoundit is launching!"; string icoMinTresholdReachedMessage = "Firing Stage 2!"; string icoEndedSuccessfulyMessage = "Orbit achieved!"; string icoEndedSuccessfulyWithCapMessage = "Leaving Earth orbit!"; string icoFailedMessage = "Rocket crashed."; event ICOStarted(uint256 _blockNumber, string _message); event ICOMinTresholdReached(uint256 _blockNumber, string _message); event ICOEndedSuccessfuly(uint256 _blockNumber, uint256 _amountRaised, string _message); event ICOFailed(uint256 _blockNumber, uint256 _ammountRaised, string _message); event ErrorSendingETH(address _from, uint256 _amount); function CofounditICO(uint256 _startBlock, uint256 _endBlock, address _multisigAddress) { startBlock = _startBlock; endBlock = _endBlock; minEthToRaise = 4525 * 10**18; maxEthToRaise = 56565 * 10**18; multisigAddress = _multisigAddress; icoSupply = 125000000 * 10**18; strategicReserveSupply = 125000000 * 10**18; cashilaTokenSupply = 100000000 * 10**18; iconomiTokenSupply = 50000000 * 10**18; coreTeamTokenSupply = 100000000 * 10**18; } // /* User accessible methods */ // /* Users send ETH and enter the crowdsale*/ function () payable { if (msg.value == 0) throw; // Check if balance is not 0 if (icoHasSucessfulyEnded || block.number > endBlock) throw; // Throw if ico has already ended if (!icoHasStarted){ // Check if this is the first transaction of ico if (block.number < startBlock){ // Check if ico should start if (!presaleContributorAllowance[msg.sender]) throw; // Check if this address is part of presale contributors } else{ // If ICO should start icoHasStarted = true; // Set that ico has started ICOStarted(block.number, icoStartedMessage); // Raise event } } if (participantContribution[msg.sender] == 0){ // Check if sender is a new user participantIndex[nextFreeParticipantIndex] = msg.sender; // Add new user to participant data structure nextFreeParticipantIndex += 1; } if (maxEthToRaise > (totalEthRaised + msg.value)){ // Check if user sent to much eth participantContribution[msg.sender] += msg.value; // Add accounts contribution totalEthRaised += msg.value; // Add to total eth Raised if (!minTresholdReached && totalEthRaised >= minEthToRaise){ // Check if min treshold has been reached(Do that one time) ICOMinTresholdReached(block.number, icoMinTresholdReachedMessage); // Raise event minTresholdReached = true; // Set that treshold has been reached } }else{ // If user sent to much eth uint maxContribution = maxEthToRaise - totalEthRaised; // Calculate max contribution participantContribution[msg.sender] += maxContribution; // Add max contribution to account totalEthRaised += maxContribution; uint toReturn = msg.value - maxContribution; // Calculate how much user should get back icoHasSucessfulyEnded = true; // Set that ico has successfullyEnded ICOEndedSuccessfuly(block.number, totalEthRaised, icoEndedSuccessfulyWithCapMessage); if(!msg.sender.send(toReturn)){ // Refound balance that is over the cap ErrorSendingETH(msg.sender, toReturn); // Raise event for manual return if transaction throws } } // Feel good about achiving the cap } /* Users can claim eth by themself if they want to in instance of eth faliure*/ function claimEthIfFailed(){ if (block.number <= endBlock || totalEthRaised >= minEthToRaise) throw; // Check that ico has failed :( if (participantContribution[msg.sender] == 0) throw; // Check if user has even been at crowdsale if (hasClaimedEthWhenFail[msg.sender]) throw; // Check if this account has already claimed its eth uint256 ethContributed = participantContribution[msg.sender]; // Get participant eth Contribution hasClaimedEthWhenFail[msg.sender] = true; if (!msg.sender.send(ethContributed)){ ErrorSendingETH(msg.sender, ethContributed); // Raise event if send failed and resolve manually } } // /* Only owner methods */ // /* Adds addresses that are allowed to take part in presale */ function addPresaleContributors(address[] _presaleContributors) onlyOwner { for (uint cnt = 0; cnt < _presaleContributors.length; cnt++){ presaleContributorAllowance[_presaleContributors[cnt]] = true; } } /* Owner can issue new tokens in token contract */ function batchIssueTokens(uint256 _numberOfIssuances) onlyOwner{ if (!icoHasSucessfulyEnded) throw; // Check if ico has ended address currentParticipantAddress; uint256 tokensToBeIssued; for (uint cnt = 0; cnt < _numberOfIssuances; cnt++){ currentParticipantAddress = participantIndex[lastCfiIssuanceIndex]; // Get next participant address if (currentParticipantAddress == 0x0) continue; tokensToBeIssued = icoSupply * participantContribution[currentParticipantAddress] / totalEthRaised; // Calculate how much tokens will address get cofounditTokenContract.mintTokens(currentParticipantAddress, tokensToBeIssued, "Ico participation mint"); // Mint tokens @ CofounditToken lastCfiIssuanceIndex += 1; } if (participantIndex[lastCfiIssuanceIndex] == 0x0 && cofounditTokenContract.totalSupply() < icoSupply){ uint divisionDifference = icoSupply - cofounditTokenContract.totalSupply(); cofounditTokenContract.mintTokens(multisigAddress, divisionDifference, "Mint division error"); // Mint divison difference @ CofounditToken so that total supply is whole number } } /* Owner can return eth for multiple users in one call*/ function batchReturnEthIfFailed(uint256 _numberOfReturns) onlyOwner{ if (block.number < endBlock || totalEthRaised >= minEthToRaise) throw; // Check that ico has failed :( address currentParticipantAddress; uint256 contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++){ currentParticipantAddress = participantIndex[lastEthReturnIndex]; // Get next account if (currentParticipantAddress == 0x0) return; // If all the participants were reinbursed return if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if user has manually recovered eth contribution = participantContribution[currentParticipantAddress]; // Get accounts contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that user got his eth back if (!currentParticipantAddress.send(contribution)){ // Send fund back to account ErrorSendingETH(currentParticipantAddress, contribution); // Raise event if send failed and resolve manually } } lastEthReturnIndex += 1; } } /* Owner sets new address of CofounditToken */ function changeMultisigAddress(address _newAddress) onlyOwner { multisigAddress = _newAddress; } /* Owner can claim reserved tokens on the end of crowsale */ function claimReservedTokens(string _which, address _to, uint256 _amount, string _reason) onlyOwner{ if (!icoHasSucessfulyEnded) throw; bytes32 hashedStr = sha3(_which); if (hashedStr == sha3("Reserve")){ if (_amount > strategicReserveSupply - usedStrategicReserveSupply) throw; cofounditTokenContract.mintTokens(_to, _amount, _reason); usedStrategicReserveSupply += _amount; } else if (hashedStr == sha3("Cashila")){ if (_amount > cashilaTokenSupply - usedCashilaTokenSupply) throw; cofounditTokenContract.mintTokens(_to, _amount, "Reserved tokens for cashila"); usedCashilaTokenSupply += _amount; } else if (hashedStr == sha3("Iconomi")){ if (_amount > iconomiTokenSupply - usedIconomiTokenSupply) throw; cofounditTokenContract.mintTokens(_to, _amount, "Reserved tokens for iconomi"); usedIconomiTokenSupply += _amount; } else if (hashedStr == sha3("Core")){ if (_amount > coreTeamTokenSupply - usedCoreTeamTokenSupply) throw; cofounditTokenContract.mintTokens(_to, _amount, "Reserved tokens for cofoundit team"); usedCoreTeamTokenSupply += _amount; } else throw; } /* Owner can remove allowance of designated presale contributor */ function removePresaleContributor(address _presaleContributor) onlyOwner { presaleContributorAllowance[_presaleContributor] = false; } /* Set token contract where mints will be done (tokens will be issued)*/ function setTokenContract(address _cofounditContractAddress) onlyOwner { cofounditTokenContract = ICofounditToken(_cofounditContractAddress); } /* Withdraw funds from contract */ function withdrawEth() onlyOwner{ if (this.balance == 0) throw; // Check if there is something on the contract if (totalEthRaised < minEthToRaise) throw; // Check if minEth treshold is surpassed if (block.number > endBlock){ // Check if ico has ended withouth reaching the maxCap icoHasSucessfulyEnded = true; ICOEndedSuccessfuly(block.number, totalEthRaised, icoEndedSuccessfulyMessage); } if(multisigAddress.send(this.balance)){} // Send contracts whole balance to multisig address } /* Withdraw remaining balance to manually return where contracts send has failed */ function withdrawRemainingBalanceForManualRecovery() onlyOwner{ if (this.balance == 0) throw; // Check if there is something on the contract if (block.number < endBlock || totalEthRaised >= minEthToRaise) throw; // Check if ico has failed :( if (participantIndex[lastEthReturnIndex] != 0x0) throw; // Check if all the participants has been reinbursed if(multisigAddress.send(this.balance)){} // Send remainder so it can be manually processed } // /* Getters */ // function getCfiEstimation(address _querryAddress) constant returns (uint256 answer){ return icoSupply * participantContribution[_querryAddress] / totalEthRaised; } function getCofounditTokenAddress() constant returns(address _tokenAddress){ return address(cofounditTokenContract); } function icoInProgress() constant returns (bool answer){ return icoHasStarted && !icoHasSucessfulyEnded; } function isAddressAllowedInPresale(address _querryAddress) constant returns (bool answer){ return presaleContributorAllowance[_querryAddress]; } function participantContributionInEth(address _querryAddress) constant returns (uint256 answer){ return participantContribution[_querryAddress]; } // /* This part is here only for testing and will not be included into final version */ // //function killContract() onlyOwner{ // selfdestruct(msg.sender); //} }
Feel good about achiving the cap
}
12,965,969
[ 1, 4625, 348, 7953, 560, 30, 225, 5782, 292, 7494, 2973, 279, 343, 9288, 326, 3523, 3196, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 202, 97, 6862, 6862, 6862, 6862, 9506, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "arb-bridge-peripherals/contracts/tokenbridge/ethereum/gateway/L1CustomGateway.sol"; import "arb-bridge-peripherals/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol"; import "arb-bridge-peripherals/contracts/tokenbridge/ethereum/ICustomToken.sol"; import "../interfaces/ISperaxToken.sol"; contract SperaxTokenL1 is ERC20, Ownable, ICustomToken { using SafeERC20 for IERC20; address public spaAddress; address public bridge; address public router; bool private shouldRegisterGateway; event ArbitrumGatewayRouterChanged(address newBridge, address newRouter); event SPAaddressUpdated(address oldSPA, address newSPA); modifier onlyGateway() { require(_msgSender() == bridge, "ONLY_GATEWAY"); _; } constructor(string memory name_, string memory symbol_, address _spaAddress, address _bridge, address _router) ERC20(name_, symbol_) public { spaAddress = _spaAddress; bridge = _bridge; router = _router; } function transferFrom(address sender, address recipient, uint256 amount) public override(ERC20, ICustomToken) returns (bool) { return ERC20.transferFrom(sender, recipient, amount); } function balanceOf(address account) public view override(ERC20, ICustomToken) returns (uint256) { return ERC20.balanceOf(account); } /** * @dev mint SperaxTokenL1 */ function mint(uint256 amount) external { ISperaxToken(spaAddress).burnFrom(_msgSender(), amount); _mint(_msgSender(), amount); } /** * @dev burn SperaxTokenL1 */ function burn(uint256 amount) external { ISperaxToken(spaAddress).mintForUSDs(_msgSender(), amount); _burn(_msgSender(), amount); } /** * @dev mint SPA when user withdraw from Arbitrum L2 */ function bridgeMint(address account, uint256 amount) onlyGateway external { ISperaxToken(spaAddress).mintForUSDs(account, amount); } // Arbitrum /// @dev we only set shouldRegisterGateway to true when in `registerTokenOnL2` function isArbitrumEnabled() external view override returns (uint8) { require(shouldRegisterGateway, "NOT_EXPECTED_CALL"); return uint8(0xa4b1); } /** * @notice change the arbitrum bridge and router address * @dev normally this function should not be called * @param newBridge the new bridge address * @param newRouter the new router address */ function changeArbToken(address newBridge, address newRouter) external onlyOwner { bridge = newBridge; router = newRouter; emit ArbitrumGatewayRouterChanged(bridge, router); } function changeSpaAddress(address newSPA) external onlyOwner { emit SPAaddressUpdated(spaAddress, newSPA); spaAddress = newSPA; } function registerTokenOnL2( address l2CustomTokenAddress, uint256 maxSubmissionCostForCustomBridge, uint256 maxSubmissionCostForRouter, uint256 maxGas, uint256 gasPriceBid, uint256 valueForGateway, uint256 valueForRouter, address creditBackAddress ) external payable onlyOwner override { // we temporarily set `shouldRegisterGateway` to true for the callback in registerTokenToL2 to succeed bool prev = shouldRegisterGateway; shouldRegisterGateway = true; L1CustomGateway(bridge).registerTokenToL2{value:valueForGateway}( l2CustomTokenAddress, maxGas, gasPriceBid, maxSubmissionCostForCustomBridge, creditBackAddress ); L1GatewayRouter(router).setGateway{value:valueForRouter}( bridge, maxGas, gasPriceBid, maxSubmissionCostForRouter, creditBackAddress ); shouldRegisterGateway = prev; } }
* @dev burn SperaxTokenL1/
function burn(uint256 amount) external { ISperaxToken(spaAddress).mintForUSDs(_msgSender(), amount); _burn(_msgSender(), amount); }
1,785,199
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 18305, 348, 457, 651, 1345, 48, 21, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 18305, 12, 11890, 5034, 3844, 13, 3903, 288, 203, 3639, 4437, 457, 651, 1345, 12, 1752, 69, 1887, 2934, 81, 474, 1290, 3378, 22831, 24899, 3576, 12021, 9334, 3844, 1769, 203, 3639, 389, 70, 321, 24899, 3576, 12021, 9334, 3844, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x747C4Ce9622EA750EA8048423B38A746B096C8e8/sources/contracts/BabyFlokiDogeETH.sol
* @dev Collection of functions related to the address type/
library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance'); require( success, 'Address: unable to send value, recipient may have reverted' ); } (bool success, ) = recipient.call{ value: amount }(''); function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, 'Address: low-level call failed'); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, 'Address: low-level call with value failed' ); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, 'Address: insufficient balance for call' ); require(isContract(target), 'Address: call to non-contract'); return _verifyCallResult(success, returndata, errorMessage); } (bool success, bytes memory returndata) = target.call{ value: value }(data); function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, 'Address: low-level static call failed'); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), 'Address: static call to non-contract'); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall( target, data, 'Address: low-level delegate call failed' ); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), 'Address: delegate call to non-contract'); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } revert(errorMessage); } } } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } revert(errorMessage); } } } } else { function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } revert(errorMessage); } } } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } revert(errorMessage); } } } } else { }
4,900,748
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2200, 434, 4186, 3746, 358, 326, 1758, 618, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 12083, 5267, 288, 203, 203, 225, 445, 353, 8924, 12, 2867, 2236, 13, 2713, 1476, 1135, 261, 6430, 13, 288, 203, 203, 565, 2254, 5034, 963, 31, 203, 565, 19931, 288, 203, 1377, 963, 519, 1110, 7000, 554, 12, 4631, 13, 203, 565, 289, 203, 565, 327, 963, 405, 374, 31, 203, 225, 289, 203, 203, 225, 445, 353, 8924, 12, 2867, 2236, 13, 2713, 1476, 1135, 261, 6430, 13, 288, 203, 203, 565, 2254, 5034, 963, 31, 203, 565, 19931, 288, 203, 1377, 963, 519, 1110, 7000, 554, 12, 4631, 13, 203, 565, 289, 203, 565, 327, 963, 405, 374, 31, 203, 225, 289, 203, 203, 225, 445, 1366, 620, 12, 2867, 8843, 429, 8027, 16, 2254, 5034, 3844, 13, 2713, 288, 203, 565, 2583, 12, 2867, 12, 2211, 2934, 12296, 1545, 3844, 16, 296, 1887, 30, 2763, 11339, 11013, 8284, 203, 203, 565, 2583, 12, 203, 1377, 2216, 16, 203, 1377, 296, 1887, 30, 13496, 358, 1366, 460, 16, 8027, 2026, 1240, 15226, 329, 11, 203, 565, 11272, 203, 225, 289, 203, 203, 565, 261, 6430, 2216, 16, 262, 273, 8027, 18, 1991, 95, 460, 30, 3844, 289, 2668, 8284, 203, 225, 445, 445, 1477, 12, 2867, 1018, 16, 1731, 3778, 501, 13, 203, 565, 2713, 203, 565, 1135, 261, 3890, 3778, 13, 203, 225, 288, 203, 565, 327, 445, 1477, 12, 3299, 16, 501, 16, 296, 1887, 30, 4587, 17, 2815, 745, 2535, 8284, 203, 225, 289, 203, 203, 225, 445, 445, 1477, 12, 203, 565, 1758, 1018, 16, 203, 565, 1731, 3778, 501, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 2713, 1135, 261, 3890, 3778, 13, 288, 203, 565, 327, 445, 26356, 620, 12, 3299, 16, 501, 16, 374, 16, 9324, 1769, 203, 225, 289, 203, 203, 225, 445, 445, 26356, 620, 12, 203, 565, 1758, 1018, 16, 203, 565, 1731, 3778, 501, 16, 203, 565, 2254, 5034, 460, 203, 225, 262, 2713, 1135, 261, 3890, 3778, 13, 288, 203, 565, 327, 203, 1377, 445, 26356, 620, 12, 203, 3639, 1018, 16, 203, 3639, 501, 16, 203, 3639, 460, 16, 203, 3639, 296, 1887, 30, 4587, 17, 2815, 745, 598, 460, 2535, 11, 203, 1377, 11272, 203, 225, 289, 203, 203, 225, 445, 445, 26356, 620, 12, 203, 565, 1758, 1018, 16, 203, 565, 1731, 3778, 501, 16, 203, 565, 2254, 5034, 460, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 2713, 1135, 261, 3890, 3778, 13, 288, 203, 565, 2583, 12, 203, 1377, 1758, 12, 2211, 2934, 12296, 1545, 460, 16, 203, 1377, 296, 1887, 30, 2763, 11339, 11013, 364, 745, 11, 203, 565, 11272, 203, 565, 2583, 12, 291, 8924, 12, 3299, 3631, 296, 1887, 30, 745, 358, 1661, 17, 16351, 8284, 203, 203, 565, 327, 389, 8705, 1477, 1253, 12, 4768, 16, 327, 892, 16, 9324, 1769, 203, 225, 289, 203, 203, 565, 261, 6430, 2216, 16, 1731, 3778, 327, 892, 13, 273, 1018, 18, 1991, 95, 460, 30, 460, 289, 12, 892, 1769, 203, 225, 445, 445, 5788, 1477, 12, 2867, 1018, 16, 1731, 3778, 501, 13, 203, 565, 2713, 203, 565, 1476, 203, 565, 1135, 261, 3890, 3778, 13, 203, 225, 288, 203, 565, 327, 203, 1377, 445, 5788, 1477, 12, 3299, 16, 501, 16, 296, 1887, 30, 4587, 17, 2815, 760, 745, 2535, 8284, 203, 225, 289, 203, 203, 225, 445, 445, 5788, 1477, 12, 203, 565, 1758, 1018, 16, 203, 565, 1731, 3778, 501, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 2713, 1476, 1135, 261, 3890, 3778, 13, 288, 203, 565, 2583, 12, 291, 8924, 12, 3299, 3631, 296, 1887, 30, 760, 745, 358, 1661, 17, 16351, 8284, 203, 203, 565, 261, 6430, 2216, 16, 1731, 3778, 327, 892, 13, 273, 1018, 18, 3845, 1991, 12, 892, 1769, 203, 565, 327, 389, 8705, 1477, 1253, 12, 4768, 16, 327, 892, 16, 9324, 1769, 203, 225, 289, 203, 203, 225, 445, 445, 9586, 1477, 12, 2867, 1018, 16, 1731, 3778, 501, 13, 203, 565, 2713, 203, 565, 1135, 261, 3890, 3778, 13, 203, 225, 288, 203, 565, 327, 203, 1377, 445, 9586, 1477, 12, 203, 3639, 1018, 16, 203, 3639, 501, 16, 203, 3639, 296, 1887, 30, 4587, 17, 2815, 7152, 745, 2535, 11, 203, 1377, 11272, 203, 225, 289, 203, 203, 225, 445, 445, 9586, 1477, 12, 203, 565, 1758, 1018, 16, 203, 565, 1731, 3778, 501, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 2713, 1135, 261, 3890, 3778, 13, 288, 203, 565, 2583, 12, 291, 8924, 12, 3299, 3631, 296, 1887, 30, 7152, 745, 358, 1661, 17, 16351, 8284, 203, 203, 565, 261, 6430, 2216, 16, 1731, 3778, 327, 892, 13, 273, 1018, 18, 22216, 1991, 12, 892, 1769, 203, 565, 327, 389, 8705, 1477, 1253, 12, 4768, 16, 327, 892, 16, 9324, 1769, 203, 225, 289, 203, 203, 225, 445, 389, 8705, 1477, 1253, 12, 203, 565, 1426, 2216, 16, 203, 565, 1731, 3778, 327, 892, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 3238, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 565, 309, 261, 4768, 13, 288, 203, 1377, 327, 327, 892, 31, 203, 1377, 309, 261, 2463, 892, 18, 2469, 405, 374, 13, 288, 203, 203, 3639, 19931, 288, 203, 1850, 2231, 327, 892, 67, 1467, 519, 312, 945, 12, 2463, 892, 13, 203, 1850, 15226, 12, 1289, 12, 1578, 16, 327, 892, 3631, 327, 892, 67, 1467, 13, 203, 3639, 289, 203, 3639, 15226, 12, 1636, 1079, 1769, 203, 1377, 289, 203, 565, 289, 203, 225, 289, 203, 225, 445, 389, 8705, 1477, 1253, 12, 203, 565, 1426, 2216, 16, 203, 565, 1731, 3778, 327, 892, 16, 203, 565, 533, 3778, 9324, 203, 225, 262, 3238, 16618, 1135, 261, 3890, 3778, 13, 288, 203, 565, 309, 261, 4768, 13, 288, 203, 1377, 327, 327, 892, 31, 203, 1377, 309, 261, 2463, 892, 18, 2469, 405, 374, 13, 288, 203, 203, 3639, 19931, 288, 203, 1850, 2231, 327, 892, 67, 1467, 519, 312, 945, 12, 2463, 892, 13, 203, 1850, 15226, 12, 1289, 12, 1578, 16, 327, 892, 3631, 327, 892, 67, 1467, 13, 203, 3639, 289, 203, 3639, 15226, 12, 1636, 1079, 1769, 203, 1377, 289, 203, 2 ]
pragma solidity ^0.5.0; import "./ERC20Capped.sol"; import "./ERC20.sol"; import "./ERC20Detailed.sol"; import "./ERC20Burnable.sol"; /** * @title SimpleToken * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. * Note they can later distribute these tokens as they wish using `transfer` and other * `ERC20` functions. */ contract Alpha5Token is ERC20Detailed, ERC20Capped, ERC20Burnable{ //We inherited the ERC20Detailed constructor () public ERC20Detailed("Alpha5Token", "A5T", 18) ERC20Capped(50000000*(10**18)){ } }
* @title SimpleToken @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. Note they can later distribute these tokens as they wish using `transfer` and other `ERC20` functions./We inherited the ERC20Detailed
contract Alpha5Token is ERC20Detailed, ERC20Capped, ERC20Burnable{ constructor () public ERC20Detailed("Alpha5Token", "A5T", 18) ERC20Capped(50000000*(10**18)){ } }
10,221,587
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 4477, 1345, 632, 5206, 776, 627, 4143, 4232, 39, 3462, 3155, 3454, 16, 1625, 777, 2430, 854, 675, 17, 15938, 358, 326, 11784, 18, 3609, 2898, 848, 5137, 25722, 4259, 2430, 487, 2898, 14302, 1450, 1375, 13866, 68, 471, 1308, 1375, 654, 39, 3462, 68, 4186, 18, 19, 3218, 12078, 326, 4232, 39, 3462, 40, 6372, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 24277, 25, 1345, 353, 4232, 39, 3462, 40, 6372, 16, 4232, 39, 3462, 4664, 1845, 16, 4232, 39, 3462, 38, 321, 429, 95, 203, 203, 1377, 3885, 1832, 1071, 7010, 3639, 4232, 39, 3462, 40, 6372, 2932, 9690, 25, 1345, 3113, 315, 37, 25, 56, 3113, 6549, 13, 203, 3639, 4232, 39, 3462, 4664, 1845, 12, 25, 17877, 21556, 2163, 636, 2643, 3719, 95, 203, 1377, 289, 203, 97, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
contract ERC20Token { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns (uint256 supply); is replaced with: uint256 public totalSupply; This automatically creates a getter function for the totalSupply. This is moved to the base contract since public getter functions are not currently recognised as an implementation of the matching abstract function by the compiler. */ /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Owned { /// @dev `owner` is the only address that can call a function with this /// modifier modifier onlyOwner() { require(msg.sender == owner) ; _; } address public owner; /// @notice The Constructor assigns the message sender to be `owner` function Owned() { owner = msg.sender; } address public newOwner; /// @notice `owner` can step down and assign some other address to this role /// @param _newOwner The address of the new owner. 0x0 can be used to create /// an unowned neutral vault, however that cannot be undone function changeOwner(address _newOwner) onlyOwner { newOwner = _newOwner; } function acceptOwnership() { if (msg.sender == newOwner) { owner = newOwner; } } } contract StandardToken is ERC20Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender,0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require ((_value==0) || (allowed[msg.sender][_spender] ==0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) allowed; } contract IIPToken is StandardToken, Owned { // metadata string public constant name = "Innovation & Intellectual Property"; string public constant symbol = "IIP"; string public version = "1.0"; uint256 public constant decimals = 8; bool public disabled = false; uint256 public constant MILLION = (10**6 * 10**decimals); // constructor function IIPToken(uint256 _amount) { totalSupply = 5000 * MILLION; balances[msg.sender] = _amount; } function getIIPTotalSupply() external constant returns(uint256) { return totalSupply; } function setDisabled(bool flag) external onlyOwner { disabled = flag; } function transfer(address _to, uint256 _value) returns (bool success) { require(!disabled); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(!disabled); return super.transferFrom(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner { require(!disabled); balances[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, owner, mintedAmount); Transfer(owner, target, mintedAmount); } function kill() external onlyOwner { selfdestruct(owner); } }
@notice The Constructor assigns the message sender to be `owner`
function Owned() { owner = msg.sender; } address public newOwner;
585,727
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 1021, 11417, 22698, 326, 883, 5793, 358, 506, 1375, 8443, 68, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 14223, 11748, 1435, 288, 203, 3639, 3410, 273, 1234, 18, 15330, 31, 203, 565, 289, 203, 203, 565, 1758, 1071, 394, 5541, 31, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity 0.5.8; contract WeightedVoteCheckpointStorage { struct Ballot { uint256 checkpointId; // Checkpoint At which ballot created uint256 quorum; // Should be a multiple of 10 ** 16 uint64 startTime; // Timestamp at which ballot will come into effect uint64 endTime; // Timestamp at which ballot will no more into effect uint64 totalProposals; // Count of proposals allowed for a given ballot uint56 totalVoters; // Count of voters who vote for the given ballot bool isActive; // flag used to turn off/on the ballot mapping(uint256 => uint256) proposalToVotes; // Mapping for proposal to total weight collected by the proposal mapping(address => uint256) investorToProposal; // mapping for storing vote details of a voter mapping(address => bool) exemptedVoters; // Mapping for blacklist voters } Ballot[] ballots; }
Count of proposals allowed for a given ballot
uint64 totalProposals;
5,545,736
[ 1, 4625, 348, 7953, 560, 30, 225, 6974, 434, 450, 22536, 2935, 364, 279, 864, 26503, 352, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 2254, 1105, 2078, 626, 22536, 31, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "hardhat/console.sol"; /* TODO: 1. Create a pool that people can put money in -> Complete 2. Transfer money in and out of pool -> Complete 3. Randomize distribution of funds -> WIP -- need to wait for Chainlink 4. Unlock pool after some time interval -> WIP 5. Change types to optimal values, ex: all uints should not be uint256 -> WIP 6. Add modifiers -> WIP 7. Start pool - minimum buy in and minimum total pool? - reward for putting more funds in? - get larger chunk of left over funds? 8. Starting pool parameters -> WIP 4. How to figure out the time intervals - when does the pool start - would need to do -> time_now - time_pool_started < time_interval */ contract YoLottery { /* Modifiers */ // Ensure the address calling function is the owner modifier onlyOwner() { require(msg.sender == owner); _; } // Ensure the address is not zero (burner) modifier validateAddress () { require(msg.sender != address(0), "Ensure sender address is not zero"); _; } // Ensure the pool is not currently running modifier poolUnlocked (uint256 poolNumber) { require((block.timestamp - poolTime[poolNumber].startTime) > poolTime[poolNumber].interval); _; } // Ensure the pool is currently running modifier poolLocked (uint256 poolNumber) { require((block.timestamp - poolTime[poolNumber].startTime) < poolTime[poolNumber].interval); _; } // Ensure the pool exists modifier poolExists (uint256 poolNumber) { require(pools[poolNumber] == true); _; } // Ensure the pool does not exists modifier poolDoesNotExist (uint256 poolNumber) { require(pools[poolNumber] == false); _; } /* Variables */ struct PoolTiming{ uint startTime; uint interval; bool locked; } mapping(address => mapping(uint256 => uint256)) public balance; // I don't think I need this because we don't need to track how much a user put in the pool really mapping(address => uint256) public owedAmount; mapping(uint256 => address[]) public participants; mapping(uint256 => bool) pools; mapping(uint256 => uint256) poolBalance; mapping(uint256 => PoolTiming) poolTime; address owner; /* Events */ event Withdrawl(address indexed sender, uint256 withdrawedFunds); /* Functions */ constructor() { owner = msg.sender; } // Allow owner to create and initialize a pool function createPool(uint256 poolNumber, uint256 poolTimeInterval) external onlyOwner poolDoesNotExist(poolNumber) { pools[poolNumber] = true; poolTime[poolNumber].startTime = block.timestamp; poolTime[poolNumber].interval = poolTimeInterval; poolBalance[poolNumber] = 0; } // Allow owner to remove pool function removePool(uint256 poolNumber) external onlyOwner poolExists(poolNumber) poolUnlocked(poolNumber) { delete pools[poolNumber]; delete poolBalance[poolNumber]; delete poolTime[poolNumber]; } // Start pool only if minimum buy in reached function startPool(uint256 poolNumber) public poolExists(poolNumber) { poolTime[poolNumber].startTime = block.timestamp; } // Allow owner to change time interval if pool is not running function setPoolTimeInterval(uint256 poolNumber, uint256 poolTimeInterval) external onlyOwner poolUnlocked(poolNumber) { poolTime[poolNumber].interval = poolTimeInterval; } // User deposits ETH into pool function depositPool(uint256 poolNumber) payable external validateAddress poolExists(poolNumber) poolLocked(poolNumber) { require(msg.sender.balance >= msg.value, "Ensure sender has enough funds to put in pool"); address[] storage _participants; if (balance[msg.sender][poolNumber] > 0) { balance[msg.sender][poolNumber] = balance[msg.sender][poolNumber] + msg.value; } else { balance[msg.sender][poolNumber] = msg.value; } _participants = participants[poolNumber]; _participants.push(msg.sender); participants[poolNumber] = _participants; poolBalance[poolNumber] = poolBalance[poolNumber] + msg.value; } // Distribute the ETH in the pool to the participants function distributePool(uint256 poolNumber) external poolExists(poolNumber) poolUnlocked(poolNumber) { address[] memory _participants = participants[poolNumber]; address distributerAddress; for (uint256 idx = 0; idx < _participants.length; idx++) { distributerAddress = _participants[idx]; owedAmount[distributerAddress] = owedAmount[distributerAddress] + 1 ether; // Random number balance[distributerAddress][poolNumber] = 0; } poolBalance[poolNumber] = 0; } // User withdraws funds owed to them function withdraw() payable external { require(owedAmount[msg.sender] > 0, "User must have funds oweing to them"); // ensure user can only pull out their funds uint256 owedFunds = owedAmount[msg.sender]; payable(msg.sender).transfer(owedFunds); owedAmount[msg.sender] = 0; emit Withdrawl(msg.sender, owedFunds); } // Deposit ETH into smart contract -- don't think this is correct function deposit(uint256 amount) payable external { require(msg.value == amount); } // Get the amount of ETH stored in the contract function getContractBalance() external view returns (uint256) { return address(this).balance; } // Get the current amount of money deposited by the user function getBalance(uint256 poolNumber) external view returns (uint256) { return balance[msg.sender][poolNumber]; } // Get the amount owed to the user after the pool distribution function getOwedAmount() external view returns (uint256) { return owedAmount[msg.sender]; } }
Ensure the address is not zero (burner)
modifier validateAddress () { require(msg.sender != address(0), "Ensure sender address is not zero"); _; }
2,553,488
[ 1, 4625, 348, 7953, 560, 30, 225, 7693, 326, 1758, 353, 486, 3634, 261, 70, 321, 264, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.16; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { function totalSupply() constant returns (uint totalSupply); function balanceOf(address _owner) constant returns (uint balance); function transfer(address _to, uint _value) returns (bool success); function transferFrom(address _from, address _to, uint _value) returns (bool success); function approve(address _spender, uint _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint remaining); // This generates a public event on the blockchain that will notify clients event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } //Token with owner (admin) contract OwnedToken { address public owner; //contract owner (admin) address function OwnedToken () public { owner = msg.sender; } //Check if owner initiate call modifier onlyOwner() { require(msg.sender == owner); _; } /** * Transfer ownership * * @param newOwner The address of the new contract owner */ function transferOwnership(address newOwner) public onlyOwner { owner = newOwner; } } //Contract with name contract NamedOwnedToken is OwnedToken { string public name; //the name for display purposes string public symbol; //the symbol for display purposes function NamedOwnedToken(string tokenName, string tokenSymbol) public { name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Change name and symbol * * @param newName The new contract name * @param newSymbol The new contract symbol */ function changeName(string newName, string newSymbol)public onlyOwner { name = newName; symbol = newSymbol; } } contract TSBToken is ERC20, NamedOwnedToken { using SafeMath for uint256; // Public variables of the token uint256 public _totalSupply = 0; //Total number of token issued (1 token = 10^decimals) uint8 public decimals = 18; //Decimals, each 1 token = 10^decimals mapping (address => uint256) public balances; // A map with all balances mapping (address => mapping (address => uint256)) public allowed; //Implement allowence to support ERC20 mapping (address => uint256) public paidETH; //The sum have already been paid to token owner uint256 public accrueDividendsPerXTokenETH = 0; uint256 public tokenPriceETH = 0; mapping (address => uint256) public paydCouponsETH; uint256 public accrueCouponsPerXTokenETH = 0; uint256 public totalCouponsUSD = 0; uint256 public MaxCouponsPaymentUSD = 150000; mapping (address => uint256) public rebuySum; mapping (address => uint256) public rebuyInformTime; uint256 public endSaleTime; uint256 public startRebuyTime; uint256 public reservedSum; bool public rebuyStarted = false; uint public tokenDecimals; uint public tokenDecimalsLeft; /** * Constructor function * * Initializes contract */ function TSBToken( string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public { tokenDecimals = 10**uint256(decimals - 5); tokenDecimalsLeft = 10**5; startRebuyTime = now + 1 years; endSaleTime = now; } /** * Internal function, calc dividends to transfer when tokens are transfering to another wallet */ function transferDiv(uint startTokens, uint fromTokens, uint toTokens, uint sumPaydFrom, uint sumPaydTo, uint acrued) internal constant returns (uint, uint) { uint sumToPayDividendsFrom = fromTokens.mul(acrued); uint sumToPayDividendsTo = toTokens.mul(acrued); uint sumTransfer = sumPaydFrom.div(startTokens); sumTransfer = sumTransfer.mul(startTokens-fromTokens); if (sumPaydFrom > sumTransfer) { sumPaydFrom -= sumTransfer; if (sumPaydFrom > sumToPayDividendsFrom) { sumTransfer += sumPaydFrom - sumToPayDividendsFrom; sumPaydFrom = sumToPayDividendsFrom; } } else { sumTransfer = sumPaydFrom; sumPaydFrom = 0; } sumPaydTo = sumPaydTo.add(sumTransfer); if (sumPaydTo > sumToPayDividendsTo) { uint differ = sumPaydTo - sumToPayDividendsTo; sumPaydTo = sumToPayDividendsTo; sumPaydFrom = sumPaydFrom.add(differ); if (sumPaydFrom > sumToPayDividendsFrom) { sumPaydFrom = sumToPayDividendsFrom; } } return (sumPaydFrom, sumPaydTo); } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != address(0)); // Prevent transfer to 0x0 address. Use burn() instead require(balances[_from] >= _value); // Check if the sender has enough require(balances[_to] + _value > balances[_to]); // Check for overflows uint startTokens = balances[_from].div(tokenDecimals); balances[_from] -= _value; // Subtract from the sender balances[_to] += _value; // Add the same to the recipient if (balances[_from] == 0) { paidETH[_to] = paidETH[_to].add(paidETH[_from]); } else { uint fromTokens = balances[_from].div(tokenDecimals); uint toTokens = balances[_to].div(tokenDecimals); (paidETH[_from], paidETH[_to]) = transferDiv(startTokens, fromTokens, toTokens, paidETH[_from], paidETH[_to], accrueDividendsPerXTokenETH+accrueCouponsPerXTokenETH); } Transfer(_from, _to, _value); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Balance of tokens * * @param _owner The address of token wallet */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } /** * Returns total issued tokens number * */ function totalSupply() public constant returns (uint totalSupply) { return _totalSupply; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowed[_from][msg.sender]); // Check allowance allowed[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; return true; } /** * Check allowance for address * * @param _owner The address who authorize to spend * @param _spender The address authorized to spend */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Internal function destroy tokens */ function burnTo(uint256 _value, address adr) internal returns (bool success) { require(balances[adr] >= _value); // Check if the sender has enough require(_value > 0); // Check if the sender has enough uint startTokens = balances[adr].div(tokenDecimals); balances[adr] -= _value; // Subtract from the sender uint endTokens = balances[adr].div(tokenDecimals); uint sumToPayFrom = endTokens.mul(accrueDividendsPerXTokenETH + accrueCouponsPerXTokenETH); uint divETH = paidETH[adr].div(startTokens); divETH = divETH.mul(endTokens); if (divETH > sumToPayFrom) { paidETH[adr] = sumToPayFrom; } else { paidETH[adr] = divETH; } _totalSupply -= _value; // Updates totalSupply Burn(adr, _value); return true; } /** * Delete tokens tokens during the end of croudfunding * (in case of errors made by crowdfnuding participants) * Only owner could call */ function deleteTokens(address adr, uint256 amount) public onlyOwner canMint { burnTo(amount, adr); } bool public mintingFinished = false; event Mint(address indexed to, uint256 amount); event MintFinished(); //Check if it is possible to mint new tokens (mint allowed only during croudfunding) modifier canMint() { require(!mintingFinished); _; } function () public payable { } //Withdraw unused ETH from contract to owner function WithdrawLeftToOwner(uint sum) public onlyOwner { owner.transfer(sum); } /** * Mint additional tokens at the end of croudfunding */ function mintToken(address target, uint256 mintedAmount) public onlyOwner canMint { balances[target] += mintedAmount; uint tokensInX = mintedAmount.div(tokenDecimals); paidETH[target] += tokensInX.mul(accrueDividendsPerXTokenETH + accrueCouponsPerXTokenETH); _totalSupply += mintedAmount; Mint(owner, mintedAmount); Transfer(0x0, target, mintedAmount); } /** * Finish minting */ function finishMinting() public onlyOwner returns (bool) { mintingFinished = true; endSaleTime = now; startRebuyTime = endSaleTime + (180 * 1 days); MintFinished(); return true; } /** * Withdraw accrued dividends and coupons */ function WithdrawDividendsAndCoupons() public { withdrawTo(msg.sender,0); } /** * Owner could initiate a withdrawal of accrued dividends and coupons to some address (in purpose to help users) */ function WithdrawDividendsAndCouponsTo(address _sendadr) public onlyOwner { withdrawTo(_sendadr, tx.gasprice * block.gaslimit); } /** * Internal function to withdraw accrued dividends and coupons */ function withdrawTo(address _sendadr, uint comiss) internal { uint tokensPerX = balances[_sendadr].div(tokenDecimals); uint sumPayd = paidETH[_sendadr]; uint sumToPayRes = tokensPerX.mul(accrueCouponsPerXTokenETH+accrueDividendsPerXTokenETH); uint sumToPay = sumToPayRes.sub(comiss); require(sumToPay>sumPayd); sumToPay = sumToPay.sub(sumPayd); _sendadr.transfer(sumToPay); paidETH[_sendadr] = sumToPayRes; } /** * Owner accrue new sum of dividends and coupons (once per month) */ function accrueDividendandCoupons(uint sumDivFinney, uint sumFinneyCoup) public onlyOwner { sumDivFinney = sumDivFinney * 1 finney; sumFinneyCoup = sumFinneyCoup * 1 finney; uint tokens = _totalSupply.div(tokenDecimals); accrueDividendsPerXTokenETH = accrueDividendsPerXTokenETH.add(sumDivFinney.div(tokens)); accrueCouponsPerXTokenETH = accrueCouponsPerXTokenETH.add(sumFinneyCoup.div(tokens)); } /** * Set a price of token to rebuy */ function setTokenPrice(uint priceFinney) public onlyOwner { tokenPriceETH = priceFinney * 1 finney; } event RebuyInformEvent(address indexed adr, uint256 amount); /** * Inform owner that someone whant to sell tokens * The rebuy proccess allowed in 2 weeks after inform * Only after half a year after croudfunding */ function InformRebuy(uint sum) public { _informRebuyTo(sum, msg.sender); } function InformRebuyTo(uint sum, address adr) public onlyOwner{ _informRebuyTo(sum, adr); } function _informRebuyTo(uint sum, address adr) internal{ require (rebuyStarted || (now >= startRebuyTime)); require (sum <= balances[adr]); rebuyInformTime[adr] = now; rebuySum[adr] = sum; RebuyInformEvent(adr, sum); } /** * Owner could allow rebuy proccess early */ function StartRebuy() public onlyOwner{ rebuyStarted = true; } /** * Sell tokens after 2 weeks from information */ function doRebuy() public { _doRebuyTo(msg.sender, 0); } /** * Contract owner would perform tokens rebuy after 2 weeks from information */ function doRebuyTo(address adr) public onlyOwner { _doRebuyTo(adr, tx.gasprice * block.gaslimit); } function _doRebuyTo(address adr, uint comiss) internal { require (rebuyStarted || (now >= startRebuyTime)); require (now >= rebuyInformTime[adr].add(14 days)); uint sum = rebuySum[adr]; require (sum <= balances[adr]); withdrawTo(adr, 0); if (burnTo(sum, adr)) { sum = sum.div(tokenDecimals); sum = sum.mul(tokenPriceETH); sum = sum.div(tokenDecimalsLeft); sum = sum.sub(comiss); adr.transfer(sum); rebuySum[adr] = 0; } } } contract TSBCrowdFundingContract is NamedOwnedToken{ using SafeMath for uint256; enum CrowdSaleState {NotFinished, Success, Failure} CrowdSaleState public crowdSaleState = CrowdSaleState.NotFinished; uint public fundingGoalUSD = 200000; //Min cap uint public fundingMaxCapUSD = 500000; //Max cap uint public priceUSD = 1; //Price in USD per 1 token uint public USDDecimals = 1 ether; uint public startTime; //crowdfunding start time uint public endTime; //crowdfunding end time uint public bonusEndTime; //crowdfunding end of bonus time uint public selfDestroyTime = 2 weeks; TSBToken public tokenReward; //TSB Token to send uint public ETHPrice = 30000; //Current price of one ETH in USD cents uint public BTCPrice = 400000; //Current price of one BTC in USD cents uint public PriceDecimals = 100; uint public ETHCollected = 0; //Collected sum of ETH uint public BTCCollected = 0; //Collected sum of BTC uint public amountRaisedUSD = 0; //Collected sum in USD uint public TokenAmountToPay = 0; //Number of tokens to distribute (excluding bonus tokens) mapping(address => uint256) public balanceMapPos; struct mapStruct { address mapAddress; uint mapBalanceETH; uint mapBalanceBTC; uint bonusTokens; } mapStruct[] public balanceList; //Array of struct with information about invested sums uint public bonusCapUSD = 100000; //Bonus cap mapping(bytes32 => uint256) public bonusesMapPos; struct bonusStruct { uint balancePos; bool notempty; uint maxBonusETH; uint maxBonusBTC; uint bonusETH; uint bonusBTC; uint8 bonusPercent; } bonusStruct[] public bonusesList; //Array of struct with information about bonuses bool public fundingGoalReached = false; bool public crowdsaleClosed = false; event GoalReached(address beneficiary, uint amountRaised); event FundTransfer(address backer, uint amount, bool isContribution); function TSBCrowdFundingContract( uint _startTime, uint durationInHours, string tokenName, string tokenSymbol ) NamedOwnedToken(tokenName, tokenSymbol) public { // require(_startTime >= now); SetStartTime(_startTime, durationInHours); bonusCapUSD = bonusCapUSD * USDDecimals; } function SetStartTime(uint startT, uint durationInHours) public onlyOwner { startTime = startT; bonusEndTime = startT+ 24 hours; endTime = startT + (durationInHours * 1 hours); } function assignTokenContract(address tok) public onlyOwner { tokenReward = TSBToken(tok); tokenReward.transferOwnership(address(this)); } function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { // lastdata = msg.data; bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); } function CheckBTCtransaction() internal constant returns (bool) { return true; } function AddBTCTransactionFromArray (address[] ETHadress, uint[] BTCnum, uint[] TransTime, bytes4[] bonusdata) public onlyOwner { require(ETHadress.length == BTCnum.length); require(TransTime.length == bonusdata.length); require(ETHadress.length == bonusdata.length); for (uint i = 0; i < ETHadress.length; i++) { AddBTCTransaction(ETHadress[i], BTCnum[i], TransTime[i], bonusdata[i]); } } /** * Add transfered BTC, only owner could call * * @param ETHadress The address of ethereum wallet of sender * @param BTCnum the received amount in BTC * 10^18 * @param TransTime the original (BTC) transaction time */ function AddBTCTransaction (address ETHadress, uint BTCnum, uint TransTime, bytes4 bonusdata) public onlyOwner { require(CheckBTCtransaction()); require((TransTime >= startTime) && (TransTime <= endTime)); require(BTCnum != 0); uint bonuspos = 0; if (TransTime <= bonusEndTime) { // lastdata = bonusdata; bytes32 code = sha3(bonusdata); bonuspos = bonusesMapPos[code]; } ReceiveAmount(ETHadress, 0, BTCnum, TransTime, bonuspos); } modifier afterDeadline() { if (now >= endTime) _; } /** * Set price for ETH and BTC, only owner could call * * @param _ETHPrice ETH price in USD cents * @param _BTCPrice BTC price in USD cents */ function SetCryptoPrice(uint _ETHPrice, uint _BTCPrice) public onlyOwner { ETHPrice = _ETHPrice; BTCPrice = _BTCPrice; } /** * Convert sum in ETH plus BTC to USD * * @param ETH ETH sum in wei * @param BTC BTC sum in 10^18 */ function convertToUSD(uint ETH, uint BTC) public constant returns (uint) { uint _ETH = ETH.mul(ETHPrice); uint _BTC = BTC.mul(BTCPrice); return (_ETH+_BTC).div(PriceDecimals); } /** * Calc collected sum in USD */ function collectedSum() public constant returns (uint) { return convertToUSD(ETHCollected,BTCCollected); } /** * Check if min cap was reached (only after finish of crowdfunding) */ function checkGoalReached() public afterDeadline { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingGoalUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } else { crowdSaleState = CrowdSaleState.Failure; } } /** * Check if max cap was reached */ function checkMaxCapReached() public { amountRaisedUSD = collectedSum(); if (amountRaisedUSD >= (fundingMaxCapUSD * USDDecimals) ){ crowdSaleState = CrowdSaleState.Success; TokenAmountToPay = amountRaisedUSD; GoalReached(owner, amountRaisedUSD); } } function ReceiveAmount(address investor, uint sumETH, uint sumBTC, uint TransTime, uint bonuspos) internal { require(investor != 0x0); uint pos = balanceMapPos[investor]; if (pos>0) { pos--; assert(pos < balanceList.length); assert(balanceList[pos].mapAddress == investor); balanceList[pos].mapBalanceETH = balanceList[pos].mapBalanceETH.add(sumETH); balanceList[pos].mapBalanceBTC = balanceList[pos].mapBalanceBTC.add(sumBTC); } else { mapStruct memory newStruct; newStruct.mapAddress = investor; newStruct.mapBalanceETH = sumETH; newStruct.mapBalanceBTC = sumBTC; newStruct.bonusTokens = 0; pos = balanceList.push(newStruct); balanceMapPos[investor] = pos; pos--; } // update state ETHCollected = ETHCollected.add(sumETH); BTCCollected = BTCCollected.add(sumBTC); checkBonus(pos, sumETH, sumBTC, TransTime, bonuspos); checkMaxCapReached(); } uint public DistributionNextPos = 0; /** * Distribute tokens to next N participants, only owner could call */ function DistributeNextNTokens(uint n) public payable onlyOwner { require(BonusesDistributed); require(DistributionNextPos<balanceList.length); uint nextpos; if (n == 0) { nextpos = balanceList.length; } else { nextpos = DistributionNextPos.add(n); if (nextpos > balanceList.length) { nextpos = balanceList.length; } } uint TokenAmountToPay_local = TokenAmountToPay; for (uint i = DistributionNextPos; i < nextpos; i++) { uint USDbalance = convertToUSD(balanceList[i].mapBalanceETH, balanceList[i].mapBalanceBTC); uint tokensCount = USDbalance.mul(priceUSD); tokenReward.mintToken(balanceList[i].mapAddress, tokensCount + balanceList[i].bonusTokens); TokenAmountToPay_local = TokenAmountToPay_local.sub(tokensCount); balanceList[i].mapBalanceETH = 0; balanceList[i].mapBalanceBTC = 0; } TokenAmountToPay = TokenAmountToPay_local; DistributionNextPos = nextpos; } function finishDistribution() onlyOwner { require ((TokenAmountToPay == 0)||(DistributionNextPos >= balanceList.length)); // tokenReward.finishMinting(); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Withdraw the funds * * Checks to see if goal was not reached, each contributor can withdraw * the amount they contributed. */ function safeWithdrawal() public afterDeadline { require(crowdSaleState == CrowdSaleState.Failure); uint pos = balanceMapPos[msg.sender]; require((pos>0)&&(pos<=balanceList.length)); pos--; uint amount = balanceList[pos].mapBalanceETH; balanceList[pos].mapBalanceETH = 0; if (amount > 0) { msg.sender.transfer(amount); FundTransfer(msg.sender, amount, false); } } /** * If something goes wrong owner could destroy the contract after 2 weeks from the crowdfunding end * In this case the token distribution or sum refund will be performed in mannual */ function killContract() public onlyOwner { require(now >= endTime + selfDestroyTime); tokenReward.transferOwnership(owner); selfdestruct(owner); } /** * Add a new bonus code, only owner could call */ function AddBonusToListFromArray(bytes32[] bonusCode, uint[] ETHsumInFinney, uint[] BTCsumInFinney) public onlyOwner { require(bonusCode.length == ETHsumInFinney.length); require(bonusCode.length == BTCsumInFinney.length); for (uint i = 0; i < bonusCode.length; i++) { AddBonusToList(bonusCode[i], ETHsumInFinney[i], BTCsumInFinney[i] ); } } /** * Add a new bonus code, only owner could call */ function AddBonusToList(bytes32 bonusCode, uint ETHsumInFinney, uint BTCsumInFinney) public onlyOwner { uint pos = bonusesMapPos[bonusCode]; if (pos > 0) { pos -= 1; bonusesList[pos].maxBonusETH = ETHsumInFinney * 1 finney; bonusesList[pos].maxBonusBTC = BTCsumInFinney * 1 finney; } else { bonusStruct memory newStruct; newStruct.balancePos = 0; newStruct.notempty = false; newStruct.maxBonusETH = ETHsumInFinney * 1 finney; newStruct.maxBonusBTC = BTCsumInFinney * 1 finney; newStruct.bonusETH = 0; newStruct.bonusBTC = 0; newStruct.bonusPercent = 20; pos = bonusesList.push(newStruct); bonusesMapPos[bonusCode] = pos; } } bool public BonusesDistributed = false; uint public BonusCalcPos = 0; // bytes public lastdata; function checkBonus(uint newBalancePos, uint sumETH, uint sumBTC, uint TransTime, uint pos) internal { if (pos > 0) { pos--; if (!bonusesList[pos].notempty) { bonusesList[pos].balancePos = newBalancePos; bonusesList[pos].notempty = true; } else { if (bonusesList[pos].balancePos != newBalancePos) return; } bonusesList[pos].bonusETH = bonusesList[pos].bonusETH.add(sumETH); // if (bonusesList[pos].bonusETH > bonusesList[pos].maxBonusETH) // bonusesList[pos].bonusETH = bonusesList[pos].maxBonusETH; bonusesList[pos].bonusBTC = bonusesList[pos].bonusBTC.add(sumBTC); // if (bonusesList[pos].bonusBTC > bonusesList[pos].maxBonusBTC) // bonusesList[pos].bonusBTC = bonusesList[pos].maxBonusBTC; } } /** * Calc the number of bonus tokens for N next bonus participants, only owner could call */ function calcNextNBonuses(uint N) public onlyOwner { require(crowdSaleState == CrowdSaleState.Success); require(!BonusesDistributed); uint nextPos = BonusCalcPos + N; if (nextPos > bonusesList.length) nextPos = bonusesList.length; uint bonusCapUSD_local = bonusCapUSD; for (uint i = BonusCalcPos; i < nextPos; i++) { if ((bonusesList[i].notempty) && (bonusesList[i].balancePos < balanceList.length)) { uint maxbonus = convertToUSD(bonusesList[i].maxBonusETH, bonusesList[i].maxBonusBTC); uint bonus = convertToUSD(bonusesList[i].bonusETH, bonusesList[i].bonusBTC); if (maxbonus < bonus) bonus = maxbonus; bonus = bonus.mul(priceUSD); if (bonusCapUSD_local >= bonus) { bonusCapUSD_local = bonusCapUSD_local - bonus; } else { bonus = bonusCapUSD_local; bonusCapUSD_local = 0; } bonus = bonus.mul(bonusesList[i].bonusPercent) / 100; balanceList[bonusesList[i].balancePos].bonusTokens = bonus; if (bonusCapUSD_local == 0) { BonusesDistributed = true; break; } } } bonusCapUSD = bonusCapUSD_local; BonusCalcPos = nextPos; if (nextPos >= bonusesList.length) { BonusesDistributed = true; } } }
lastdata = msg.data;
function () public payable { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; require( withinPeriod && nonZeroPurchase && (crowdSaleState == CrowdSaleState.NotFinished)); uint bonuspos = 0; if (now <= bonusEndTime) { bytes32 code = sha3(msg.data); bonuspos = bonusesMapPos[code]; } ReceiveAmount(msg.sender, msg.value, 0, now, bonuspos); }
12,838,191
[ 1, 4625, 348, 7953, 560, 30, 1875, 565, 1142, 892, 273, 1234, 18, 892, 31, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 1832, 1071, 8843, 429, 288, 203, 202, 202, 6430, 3470, 5027, 273, 2037, 1545, 8657, 597, 2037, 1648, 13859, 31, 203, 202, 202, 6430, 1661, 7170, 23164, 273, 1234, 18, 1132, 480, 374, 31, 203, 202, 202, 6528, 12, 3470, 5027, 597, 1661, 7170, 23164, 597, 261, 71, 492, 72, 30746, 1119, 422, 385, 492, 72, 30746, 1119, 18, 1248, 10577, 10019, 203, 202, 202, 11890, 324, 22889, 917, 273, 374, 31, 203, 202, 202, 430, 261, 3338, 1648, 324, 22889, 25255, 13, 288, 203, 1082, 202, 3890, 1578, 981, 273, 6056, 23, 12, 3576, 18, 892, 1769, 203, 1082, 202, 18688, 407, 917, 273, 324, 265, 6117, 863, 1616, 63, 710, 15533, 203, 202, 202, 97, 203, 202, 202, 11323, 6275, 12, 3576, 18, 15330, 16, 1234, 18, 1132, 16, 374, 16, 2037, 16, 324, 22889, 917, 1769, 203, 203, 202, 97, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x7af62458e41E2F490D2Df54A8FeDc56fFedB8c17/sources/lib/solady/src/utils/CREATE3.sol
@notice Deploy to deterministic addresses without an initcode factor. @author Solady (https://github.com/vectorized/solmady/blob/main/src/utils/CREATE3.sol) @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/CREATE3.sol) @author Modified from 0xSequence (https://github.com/0xSequence/create3/blob/master/contracts/Create3.sol)
library CREATE3 { error DeploymentFailed(); error InitializationFailed(); uint256 private constant _PROXY_BYTECODE = 0x67363d3d37363d34f03d5260086018f3; bytes32 private constant _PROXY_BYTECODE_HASH = 0x21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f; function deploy(bytes32 salt, bytes memory creationCode, uint256 value) internal returns (address deployed) pragma solidity ^0.8.4; { assembly { mstore(0x00, _PROXY_BYTECODE) let proxy := create2(0, 0x10, 0x10, salt) if iszero(proxy) { mstore(0x00, 0x30116425) revert(0x1c, 0x04) } deployed := keccak256(0x1e, 0x17) call( ) ) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } if iszero(extcodesize(deployed)) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } } } { assembly { mstore(0x00, _PROXY_BYTECODE) let proxy := create2(0, 0x10, 0x10, salt) if iszero(proxy) { mstore(0x00, 0x30116425) revert(0x1c, 0x04) } deployed := keccak256(0x1e, 0x17) call( ) ) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } if iszero(extcodesize(deployed)) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } } } { assembly { mstore(0x00, _PROXY_BYTECODE) let proxy := create2(0, 0x10, 0x10, salt) if iszero(proxy) { mstore(0x00, 0x30116425) revert(0x1c, 0x04) } deployed := keccak256(0x1e, 0x17) call( ) ) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } if iszero(extcodesize(deployed)) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } } } mstore(0x14, proxy) mstore(0x00, 0xd694) mstore8(0x34, 0x01) if iszero( { assembly { mstore(0x00, _PROXY_BYTECODE) let proxy := create2(0, 0x10, 0x10, salt) if iszero(proxy) { mstore(0x00, 0x30116425) revert(0x1c, 0x04) } deployed := keccak256(0x1e, 0x17) call( ) ) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } if iszero(extcodesize(deployed)) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } } } { assembly { mstore(0x00, _PROXY_BYTECODE) let proxy := create2(0, 0x10, 0x10, salt) if iszero(proxy) { mstore(0x00, 0x30116425) revert(0x1c, 0x04) } deployed := keccak256(0x1e, 0x17) call( ) ) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } if iszero(extcodesize(deployed)) { mstore(0x00, 0x19b991a8) revert(0x1c, 0x04) } } } function getDeployed(bytes32 salt) internal view returns (address deployed) { assembly { let m := mload(0x40) mstore(0x00, address()) mstore8(0x0b, 0xff) mstore(0x20, salt) mstore(0x40, _PROXY_BYTECODE_HASH) mstore(0x14, keccak256(0x0b, 0x55)) mstore(0x40, m) mstore(0x00, 0xd694) mstore8(0x34, 0x01) deployed := keccak256(0x1e, 0x17) } } function getDeployed(bytes32 salt) internal view returns (address deployed) { assembly { let m := mload(0x40) mstore(0x00, address()) mstore8(0x0b, 0xff) mstore(0x20, salt) mstore(0x40, _PROXY_BYTECODE_HASH) mstore(0x14, keccak256(0x0b, 0x55)) mstore(0x40, m) mstore(0x00, 0xd694) mstore8(0x34, 0x01) deployed := keccak256(0x1e, 0x17) } } }
3,203,175
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 7406, 358, 25112, 6138, 2887, 392, 1208, 710, 5578, 18, 632, 4161, 348, 355, 361, 93, 261, 4528, 2207, 6662, 18, 832, 19, 7737, 1235, 19, 18281, 81, 361, 93, 19, 10721, 19, 5254, 19, 4816, 19, 5471, 19, 9344, 23, 18, 18281, 13, 632, 4161, 21154, 628, 348, 355, 81, 340, 261, 4528, 2207, 6662, 18, 832, 19, 2338, 7300, 2499, 19, 18281, 81, 340, 19, 10721, 19, 5254, 19, 4816, 19, 5471, 19, 9344, 23, 18, 18281, 13, 632, 4161, 21154, 628, 374, 92, 4021, 261, 4528, 2207, 6662, 18, 832, 19, 20, 92, 4021, 19, 2640, 23, 19, 10721, 19, 7525, 19, 16351, 87, 19, 1684, 23, 18, 18281, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 12083, 13278, 23, 288, 203, 203, 565, 555, 8587, 2925, 5621, 203, 203, 565, 555, 26586, 2925, 5621, 203, 203, 203, 203, 565, 2254, 5034, 3238, 5381, 389, 16085, 67, 15377, 5572, 273, 374, 92, 26, 9036, 4449, 72, 23, 72, 6418, 23, 4449, 72, 5026, 74, 4630, 72, 25, 5558, 713, 14181, 28, 74, 23, 31, 203, 203, 565, 1731, 1578, 3238, 5381, 389, 16085, 67, 15377, 5572, 67, 15920, 273, 203, 3639, 374, 92, 5340, 71, 4763, 1966, 73, 21, 70, 5026, 24, 69, 3247, 5482, 8522, 23, 1578, 21, 72, 26, 311, 6564, 22, 74, 28, 73, 29, 74, 5082, 2539, 6334, 1403, 5908, 73, 24, 2733, 23, 69, 26, 4366, 3657, 69, 7616, 27, 71, 21, 74, 31, 203, 203, 203, 565, 445, 7286, 12, 3890, 1578, 4286, 16, 1731, 3778, 6710, 1085, 16, 2254, 5034, 460, 13, 203, 3639, 2713, 203, 3639, 1135, 261, 2867, 19357, 13, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 24, 31, 203, 565, 288, 203, 3639, 19931, 288, 203, 5411, 312, 2233, 12, 20, 92, 713, 16, 389, 16085, 67, 15377, 5572, 13, 203, 5411, 2231, 2889, 519, 752, 22, 12, 20, 16, 374, 92, 2163, 16, 374, 92, 2163, 16, 4286, 13, 203, 203, 5411, 309, 353, 7124, 12, 5656, 13, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 31831, 23147, 2947, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 203, 5411, 19357, 519, 417, 24410, 581, 5034, 12, 20, 92, 21, 73, 16, 374, 92, 4033, 13, 203, 203, 7734, 745, 12, 203, 7734, 262, 203, 5411, 262, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 5411, 309, 353, 7124, 12, 408, 7000, 554, 12, 12411, 329, 3719, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 288, 203, 3639, 19931, 288, 203, 5411, 312, 2233, 12, 20, 92, 713, 16, 389, 16085, 67, 15377, 5572, 13, 203, 5411, 2231, 2889, 519, 752, 22, 12, 20, 16, 374, 92, 2163, 16, 374, 92, 2163, 16, 4286, 13, 203, 203, 5411, 309, 353, 7124, 12, 5656, 13, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 31831, 23147, 2947, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 203, 5411, 19357, 519, 417, 24410, 581, 5034, 12, 20, 92, 21, 73, 16, 374, 92, 4033, 13, 203, 203, 7734, 745, 12, 203, 7734, 262, 203, 5411, 262, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 5411, 309, 353, 7124, 12, 408, 7000, 554, 12, 12411, 329, 3719, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 565, 288, 203, 3639, 19931, 288, 203, 5411, 312, 2233, 12, 20, 92, 713, 16, 389, 16085, 67, 15377, 5572, 13, 203, 5411, 2231, 2889, 519, 752, 22, 12, 20, 16, 374, 92, 2163, 16, 374, 92, 2163, 16, 4286, 13, 203, 203, 5411, 309, 353, 7124, 12, 5656, 13, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 31831, 23147, 2947, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 203, 5411, 19357, 519, 417, 24410, 581, 5034, 12, 20, 92, 21, 73, 16, 374, 92, 4033, 13, 203, 203, 7734, 745, 12, 203, 7734, 262, 203, 5411, 262, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 5411, 309, 353, 7124, 12, 408, 7000, 554, 12, 12411, 329, 3719, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 5411, 312, 2233, 12, 20, 92, 3461, 16, 2889, 13, 203, 5411, 312, 2233, 12, 20, 92, 713, 16, 374, 7669, 8148, 24, 13, 203, 5411, 312, 2233, 28, 12, 20, 92, 5026, 16, 374, 92, 1611, 13, 203, 5411, 309, 353, 7124, 12, 203, 565, 288, 203, 3639, 19931, 288, 203, 5411, 312, 2233, 12, 20, 92, 713, 16, 389, 16085, 67, 15377, 5572, 13, 203, 5411, 2231, 2889, 519, 752, 22, 12, 20, 16, 374, 92, 2163, 16, 374, 92, 2163, 16, 4286, 13, 203, 203, 5411, 309, 353, 7124, 12, 5656, 13, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 31831, 23147, 2947, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 203, 5411, 19357, 519, 417, 24410, 581, 5034, 12, 20, 92, 21, 73, 16, 374, 92, 4033, 13, 203, 203, 7734, 745, 12, 203, 7734, 262, 203, 5411, 262, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 203, 203, 5411, 309, 353, 7124, 12, 408, 7000, 554, 12, 12411, 329, 3719, 288, 203, 7734, 312, 2233, 12, 20, 92, 713, 16, 374, 92, 3657, 70, 2733, 21, 69, 28, 13, 203, 7734, 15226, 12, 20, 92, 21, 71, 16, 374, 92, 3028, 13, 203, 5411, 289, 2 ]
/* Copyright 2020 Swap Holdings Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity 0.5.12; pragma experimental ABIEncoderV2; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; /** * @title Index: A List of Locators * @notice The Locators are sorted in reverse order based on the score * meaning that the first element in the list has the largest score * and final element has the smallest * @dev A mapping is used to mimic a circular linked list structure * where every mapping Entry contains a pointer to the next * and the previous */ contract Index is Ownable { // The number of entries in the index uint256 public length; // Identifier to use for the head of the list address internal constant HEAD = address(uint160(2**160 - 1)); // Mapping of an identifier to its entry mapping(address => Entry) public entries; /** * @notice Index Entry * @param score uint256 * @param locator bytes32 * @param prev address Previous address in the linked list * @param next address Next address in the linked list */ struct Entry { bytes32 locator; uint256 score; address prev; address next; } /** * @notice Contract Events */ event SetLocator( address indexed identifier, uint256 score, bytes32 indexed locator ); event UnsetLocator(address indexed identifier); /** * @notice Contract Constructor */ constructor() public { // Create initial entry. entries[HEAD] = Entry(bytes32(0), 0, HEAD, HEAD); } /** * @notice Set a Locator * @param identifier address On-chain address identifying the owner of a locator * @param score uint256 Score for the locator being set * @param locator bytes32 Locator */ function setLocator(address identifier, uint256 score, bytes32 locator) external onlyOwner { // Ensure the entry does not already exist. require(!_hasEntry(identifier), "ENTRY_ALREADY_EXISTS"); _setLocator(identifier, score, locator); // Increment the index length. length = length + 1; emit SetLocator(identifier, score, locator); } /** * @notice Unset a Locator * @param identifier address On-chain address identifying the owner of a locator */ function unsetLocator(address identifier) external onlyOwner { _unsetLocator(identifier); // Decrement the index length. length = length - 1; emit UnsetLocator(identifier); } /** * @notice Update a Locator * @dev score and/or locator do not need to be different from old values * @param identifier address On-chain address identifying the owner of a locator * @param score uint256 Score for the locator being set * @param locator bytes32 Locator */ function updateLocator(address identifier, uint256 score, bytes32 locator) external onlyOwner { // Don't need to update length as it is not used in set/unset logic _unsetLocator(identifier); _setLocator(identifier, score, locator); emit SetLocator(identifier, score, locator); } /** * @notice Get a Score * @param identifier address On-chain address identifying the owner of a locator * @return uint256 Score corresponding to the identifier */ function getScore(address identifier) external view returns (uint256) { return entries[identifier].score; } /** * @notice Get a Locator * @param identifier address On-chain address identifying the owner of a locator * @return bytes32 Locator information */ function getLocator(address identifier) external view returns (bytes32) { return entries[identifier].locator; } /** * @notice Get a Range of Locators * @dev start value of 0x0 starts at the head * @param cursor address Cursor to start with * @param limit uint256 Maximum number of locators to return * @return bytes32[] List of locators * @return uint256[] List of scores corresponding to locators * @return address The next cursor to provide for pagination */ function getLocators(address cursor, uint256 limit) external view returns ( bytes32[] memory locators, uint256[] memory scores, address nextCursor ) { address identifier; // If a valid cursor is provided, start there. if (cursor != address(0) && cursor != HEAD) { // Check that the provided cursor exists. if (!_hasEntry(cursor)) { return (new bytes32[](0), new uint256[](0), address(0)); } // Set the starting identifier to the provided cursor. identifier = cursor; } else { identifier = entries[HEAD].next; } // Although it's not known how many entries are between `cursor` and the end // We know that it is no more than `length` uint256 size = (length < limit) ? length : limit; locators = new bytes32[](size); scores = new uint256[](size); // Iterate over the list until the end or size. uint256 i; while (i < size && identifier != HEAD) { locators[i] = entries[identifier].locator; scores[i] = entries[identifier].score; i = i + 1; identifier = entries[identifier].next; } return (locators, scores, identifier); } /** * @notice Internal function to set a Locator * @param identifier address On-chain address identifying the owner of a locator * @param score uint256 Score for the locator being set * @param locator bytes32 Locator */ function _setLocator(address identifier, uint256 score, bytes32 locator) internal { // Disallow locator set to 0x0 to ensure list integrity. require(locator != bytes32(0), "LOCATOR_MUST_BE_SENT"); // Find the first entry with a lower score. address nextEntry = _getEntryLowerThan(score); // Link the new entry between previous and next. address prevEntry = entries[nextEntry].prev; entries[prevEntry].next = identifier; entries[nextEntry].prev = identifier; entries[identifier] = Entry(locator, score, prevEntry, nextEntry); } /** * @notice Internal function to unset a Locator * @param identifier address On-chain address identifying the owner of a locator */ function _unsetLocator(address identifier) internal { // Ensure the entry exists. require(_hasEntry(identifier), "ENTRY_DOES_NOT_EXIST"); // Link the previous and next entries together. address prevUser = entries[identifier].prev; address nextUser = entries[identifier].next; entries[prevUser].next = nextUser; entries[nextUser].prev = prevUser; // Delete entry from the index. delete entries[identifier]; } /** * @notice Check if the Index has an Entry * @param identifier address On-chain address identifying the owner of a locator * @return bool True if the identifier corresponds to an Entry in the list */ function _hasEntry(address identifier) internal view returns (bool) { return entries[identifier].locator != bytes32(0); } /** * @notice Returns the largest scoring Entry Lower than a Score * @param score uint256 Score in question * @return address Identifier of the largest score lower than score */ function _getEntryLowerThan(uint256 score) internal view returns (address) { address identifier = entries[HEAD].next; // Head indicates last because the list is circular. if (score == 0) { return HEAD; } // Iterate until a lower score is found. while (score <= entries[identifier].score) { identifier = entries[identifier].next; } return identifier; } }
* @notice Internal function to unset a Locator @param identifier address On-chain address identifying the owner of a locator/ Ensure the entry exists. Link the previous and next entries together. Delete entry from the index.
function _unsetLocator(address identifier) internal { require(_hasEntry(identifier), "ENTRY_DOES_NOT_EXIST"); address prevUser = entries[identifier].prev; address nextUser = entries[identifier].next; entries[prevUser].next = nextUser; entries[nextUser].prev = prevUser; delete entries[identifier]; }
15,785,222
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 3186, 445, 358, 2646, 279, 2851, 639, 632, 891, 2756, 1758, 2755, 17, 5639, 1758, 29134, 326, 3410, 434, 279, 8871, 19, 7693, 326, 1241, 1704, 18, 4048, 326, 2416, 471, 1024, 3222, 9475, 18, 2504, 1241, 628, 326, 770, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 389, 18579, 5786, 12, 2867, 2756, 13, 2713, 288, 203, 565, 2583, 24899, 5332, 1622, 12, 5644, 3631, 315, 19083, 67, 3191, 3991, 67, 4400, 67, 11838, 8863, 203, 203, 565, 1758, 2807, 1299, 273, 3222, 63, 5644, 8009, 10001, 31, 203, 565, 1758, 1024, 1299, 273, 3222, 63, 5644, 8009, 4285, 31, 203, 565, 3222, 63, 10001, 1299, 8009, 4285, 273, 1024, 1299, 31, 203, 565, 3222, 63, 4285, 1299, 8009, 10001, 273, 2807, 1299, 31, 203, 203, 565, 1430, 3222, 63, 5644, 15533, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.6; import "@yield-protocol/utils-v2/contracts/access/AccessControl.sol"; import "@yield-protocol/vault-interfaces/ILadle.sol"; import "@yield-protocol/vault-interfaces/ICauldron.sol"; import "@yield-protocol/vault-interfaces/IJoin.sol"; import "@yield-protocol/vault-interfaces/DataTypes.sol"; import "@yield-protocol/utils-v2/contracts/math/WMul.sol"; import "@yield-protocol/utils-v2/contracts/math/WMulUp.sol"; import "@yield-protocol/utils-v2/contracts/math/WDiv.sol"; import "@yield-protocol/utils-v2/contracts/math/WDivUp.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU256U128.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU256U32.sol"; contract Witch is AccessControl() { using WMul for uint256; using WMulUp for uint256; using WDiv for uint256; using WDivUp for uint256; using CastU256U128 for uint256; using CastU256U32 for uint256; event Point(bytes32 indexed param, address value); event IlkSet(bytes6 indexed ilkId, uint32 duration, uint64 initialOffer, uint96 line, uint24 dust, uint8 dec); event Bought(bytes12 indexed vaultId, address indexed buyer, uint256 ink, uint256 art); event Auctioned(bytes12 indexed vaultId, uint256 indexed start); struct Auction { address owner; uint32 start; } struct Ilk { uint32 duration; // Time that auctions take to go to minimal price and stay there. uint64 initialOffer; // Proportion of collateral that is sold at auction start (1e18 = 100%) } struct Limits { uint96 line; // Maximum concurrent auctioned collateral uint24 dust; // Minimum collateral that must be left when buying, unless buying all uint8 dec; // Multiplying factor (10**dec) for line and dust uint128 sum; // Current concurrent auctioned collateral } ICauldron immutable public cauldron; ILadle public ladle; mapping(bytes12 => Auction) public auctions; mapping(bytes6 => Ilk) public ilks; mapping(bytes6 => Limits) public limits; constructor (ICauldron cauldron_, ILadle ladle_) { cauldron = cauldron_; ladle = ladle_; } /// @dev Point to a different ladle function point(bytes32 param, address value) external auth { if (param == "ladle") ladle = ILadle(value); else revert("Unrecognized parameter"); emit Point(param, value); } /// @dev Governance function to set: /// - the auction duration to calculate liquidation prices /// - the proportion of the collateral that will be sold at auction start /// - the maximum collateral that can be auctioned at the same time /// - the minimum collateral that must be left when buying, unless buying all /// - The decimals for maximum and minimum function setIlk(bytes6 ilkId, uint32 duration, uint64 initialOffer, uint96 line, uint24 dust, uint8 dec) external auth { require (initialOffer <= 1e18, "Only at or under 100%"); ilks[ilkId] = Ilk({ duration: duration, initialOffer: initialOffer }); limits[ilkId] = Limits({ line: line, dust: dust, dec: dec, sum: limits[ilkId].sum // sum is initialized at zero, and doesn't change when changing any ilk parameters }); emit IlkSet(ilkId, duration, initialOffer, line, dust, dec); } /// @dev Put an undercollateralized vault up for liquidation. function auction(bytes12 vaultId) external { require (auctions[vaultId].start == 0, "Vault already under auction"); require (cauldron.level(vaultId) < 0, "Not undercollateralized"); DataTypes.Vault memory vault_ = cauldron.vaults(vaultId); DataTypes.Balances memory balances_ = cauldron.balances(vaultId); Limits memory limits_ = limits[vault_.ilkId]; limits_.sum += balances_.ink; require (limits_.sum <= limits_.line * (10 ** limits_.dec), "Collateral limit reached"); limits[vault_.ilkId] = limits_; auctions[vaultId] = Auction({ owner: vault_.owner, start: block.timestamp.u32() }); cauldron.give(vaultId, address(this)); emit Auctioned(vaultId, block.timestamp.u32()); } /// @dev Pay `base` of the debt in a vault in liquidation, getting at least `min` collateral. /// Use `payAll` to pay all the debt, using `buy` for amounts close to the whole vault might revert. function buy(bytes12 vaultId, uint128 base, uint128 min) external returns (uint256 ink) { require (auctions[vaultId].start > 0, "Vault not under auction"); DataTypes.Vault memory vault_ = cauldron.vaults(vaultId); DataTypes.Series memory series_ = cauldron.series(vault_.seriesId); DataTypes.Balances memory balances_ = cauldron.balances(vaultId); require (balances_.art > 0, "Nothing to buy"); // Cheapest way of failing gracefully if given a non existing vault Auction memory auction_ = auctions[vaultId]; Ilk memory ilk_ = ilks[vault_.ilkId]; Limits memory limits_ = limits[vault_.ilkId]; uint256 art = cauldron.debtFromBase(vault_.seriesId, base); { uint256 elapsed = uint32(block.timestamp) - auction_.start; // Auctions will malfunction on the 7th of February 2106, at 06:28:16 GMT, we should replace this contract before then. uint256 price = inkPrice(balances_, ilk_.initialOffer, ilk_.duration, elapsed); ink = uint256(art).wmul(price); // Calculate collateral to sell. Using divdrup stops rounding from leaving 1 stray wei in vaults. require (ink >= min, "Not enough bought"); require (art == balances_.art || balances_.ink - ink >= limits_.dust * (10 ** limits_.dec), "Leaves dust"); limits[vault_.ilkId].sum -= ink.u128(); } cauldron.slurp(vaultId, ink.u128(), art.u128()); // Remove debt and collateral from the vault settle(msg.sender, vault_.ilkId, series_.baseId, ink.u128(), base); // Move the assets if (balances_.art - art == 0) { // If there is no debt left, return the vault with the collateral to the owner cauldron.give(vaultId, auction_.owner); delete auctions[vaultId]; } emit Bought(vaultId, msg.sender, ink, art); } /// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral. function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink) { require (auctions[vaultId].start > 0, "Vault not under auction"); DataTypes.Vault memory vault_ = cauldron.vaults(vaultId); DataTypes.Series memory series_ = cauldron.series(vault_.seriesId); DataTypes.Balances memory balances_ = cauldron.balances(vaultId); Auction memory auction_ = auctions[vaultId]; Ilk memory ilk_ = ilks[vault_.ilkId]; require (balances_.art > 0, "Nothing to buy"); // Cheapest way of failing gracefully if given a non existing vault { uint256 elapsed = uint32(block.timestamp) - auction_.start; // Auctions will malfunction on the 7th of February 2106, at 06:28:16 GMT, we should replace this contract before then. uint256 price = inkPrice(balances_, ilk_.initialOffer, ilk_.duration, elapsed); ink = uint256(balances_.art).wmul(price); // Calculate collateral to sell. Using divdrup stops rounding from leaving 1 stray wei in vaults. require (ink >= min, "Not enough bought"); ink = (ink > balances_.ink) ? balances_.ink : ink; // The price is rounded up, so we cap this at all the collateral and no more limits[vault_.ilkId].sum -= ink.u128(); } cauldron.slurp(vaultId, ink.u128(), balances_.art); // Remove debt and collateral from the vault settle(msg.sender, vault_.ilkId, series_.baseId, ink.u128(), cauldron.debtToBase(vault_.seriesId, balances_.art)); // Move the assets cauldron.give(vaultId, auction_.owner); delete auctions[vaultId]; emit Bought(vaultId, msg.sender, ink, balances_.art); // Still the initially read `art` value, not the updated one } /// @dev Move base from the buyer to the protocol, and collateral from the protocol to the buyer function settle(address user, bytes6 ilkId, bytes6 baseId, uint128 ink, uint128 art) private { if (ink != 0) { // Give collateral to the user IJoin ilkJoin = ladle.joins(ilkId); require (ilkJoin != IJoin(address(0)), "Join not found"); ilkJoin.exit(user, ink); } if (art != 0) { // Take underlying from user IJoin baseJoin = ladle.joins(baseId); require (baseJoin != IJoin(address(0)), "Join not found"); baseJoin.join(user, art); } } /// @dev Price of a collateral unit, in underlying, at the present moment, for a given vault. Rounds up, sometimes twice. /// ink min(auction, elapsed) /// price = (------- * (p + (1 - p) * -----------------------)) /// art auction function inkPrice(DataTypes.Balances memory balances, uint256 initialOffer_, uint256 duration_, uint256 elapsed) private pure returns (uint256 price) { uint256 term1 = uint256(balances.ink).wdivup(balances.art); uint256 dividend2 = duration_ < elapsed ? duration_ : elapsed; uint256 divisor2 = duration_; uint256 term2 = initialOffer_ + (1e18 - initialOffer_).wmulup(dividend2.wdivup(divisor2)); price = term1.wmulup(term2); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes4` identifier. These are expected to be the * signatures for all the functions in the contract. Special roles should be exposed * in the external API and be unique: * * ``` * bytes4 public constant ROOT = 0x00000000; * ``` * * Roles represent restricted access to a function call. For that purpose, use {auth}: * * ``` * function foo() public auth { * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `ROOT`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {setRoleAdmin}. * * WARNING: The `ROOT` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ contract AccessControl { struct RoleData { mapping (address => bool) members; bytes4 adminRole; } mapping (bytes4 => RoleData) private _roles; bytes4 public constant ROOT = 0x00000000; bytes4 public constant ROOT4146650865 = 0x00000000; // Collision protection for ROOT, test with ROOT12007226833() bytes4 public constant LOCK = 0xFFFFFFFF; // Used to disable further permissioning of a function bytes4 public constant LOCK8605463013 = 0xFFFFFFFF; // Collision protection for LOCK, test with LOCK10462387368() /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role * * `ROOT` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes4 indexed role, bytes4 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call. */ event RoleGranted(bytes4 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes4 indexed role, address indexed account, address indexed sender); /** * @dev Give msg.sender the ROOT role and create a LOCK role with itself as the admin role and no members. * Calling setRoleAdmin(msg.sig, LOCK) means no one can grant that msg.sig role anymore. */ constructor () { _grantRole(ROOT, msg.sender); // Grant ROOT to msg.sender _setRoleAdmin(LOCK, LOCK); // Create the LOCK role by setting itself as its own admin, creating an independent role tree } /** * @dev Each function in the contract has its own role, identified by their msg.sig signature. * ROOT can give and remove access to each function, lock any further access being granted to * a specific action, or even create other roles to delegate admin control over a function. */ modifier auth() { require (_hasRole(msg.sig, msg.sender), "Access denied"); _; } /** * @dev Allow only if the caller has been granted the admin role of `role`. */ modifier admin(bytes4 role) { require (_hasRole(_getRoleAdmin(role), msg.sender), "Only admin"); _; } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes4 role, address account) external view returns (bool) { return _hasRole(role, account); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes4 role) external view returns (bytes4) { return _getRoleAdmin(role); } /** * @dev Sets `adminRole` as ``role``'s admin role. * If ``role``'s admin role is not `adminRole` emits a {RoleAdminChanged} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function setRoleAdmin(bytes4 role, bytes4 adminRole) external virtual admin(role) { _setRoleAdmin(role, adminRole); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes4 role, address account) external virtual admin(role) { _grantRole(role, account); } /** * @dev Grants all of `role` in `roles` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - For each `role` in `roles`, the caller must have ``role``'s admin role. */ function grantRoles(bytes4[] memory roles, address account) external virtual { for (uint256 i = 0; i < roles.length; i++) { require (_hasRole(_getRoleAdmin(roles[i]), msg.sender), "Only admin"); _grantRole(roles[i], account); } } /** * @dev Sets LOCK as ``role``'s admin role. LOCK has no members, so this disables admin management of ``role``. * Emits a {RoleAdminChanged} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function lockRole(bytes4 role) external virtual admin(role) { _setRoleAdmin(role, LOCK); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes4 role, address account) external virtual admin(role) { _revokeRole(role, account); } /** * @dev Revokes all of `role` in `roles` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - For each `role` in `roles`, the caller must have ``role``'s admin role. */ function revokeRoles(bytes4[] memory roles, address account) external virtual { for (uint256 i = 0; i < roles.length; i++) { require (_hasRole(_getRoleAdmin(roles[i]), msg.sender), "Only admin"); _revokeRole(roles[i], account); } } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes4 role, address account) external virtual { require(account == msg.sender, "Renounce only for self"); _revokeRole(role, account); } function _hasRole(bytes4 role, address account) internal view returns (bool) { return _roles[role].members[account]; } function _getRoleAdmin(bytes4 role) internal view returns (bytes4) { return _roles[role].adminRole; } function _setRoleAdmin(bytes4 role, bytes4 adminRole) internal virtual { if (_getRoleAdmin(role) != adminRole) { _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, adminRole); } } function _grantRole(bytes4 role, address account) internal { if (!_hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, msg.sender); } } function _revokeRole(bytes4 role, address account) internal { if (_hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, msg.sender); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IJoin.sol"; import "./ICauldron.sol"; interface ILadle { function joins(bytes6) external view returns (IJoin); function cauldron() external view returns (ICauldron); function build(bytes6 seriesId, bytes6 ilkId, uint8 salt) external returns (bytes12 vaultId, DataTypes.Vault memory vault); function destroy(bytes12 vaultId) external; function pour(bytes12 vaultId, address to, int128 ink, int128 art) external; function close(bytes12 vaultId, address to, int128 ink, int128 art) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IFYToken.sol"; import "./IOracle.sol"; import "./DataTypes.sol"; interface ICauldron { /// @dev Variable rate lending oracle for an underlying function lendingOracles(bytes6 baseId) external view returns (IOracle); /// @dev An user can own one or more Vaults, with each vault being able to borrow from a single series. function vaults(bytes12 vault) external view returns (DataTypes.Vault memory); /// @dev Series available in Cauldron. function series(bytes6 seriesId) external view returns (DataTypes.Series memory); /// @dev Assets available in Cauldron. function assets(bytes6 assetsId) external view returns (address); /// @dev Each vault records debt and collateral balances_. function balances(bytes12 vault) external view returns (DataTypes.Balances memory); /// @dev Max, min and sum of debt per underlying and collateral. function debt(bytes6 baseId, bytes6 ilkId) external view returns (DataTypes.Debt memory); /// @dev Create a new vault, linked to a series (and therefore underlying) and up to 5 collateral types function build(address owner, bytes12 vaultId, bytes6 seriesId, bytes6 ilkId) external returns (DataTypes.Vault memory); /// @dev Destroy an empty vault. Used to recover gas costs. function destroy(bytes12 vault) external; /// @dev Change a vault series and/or collateral types. function tweak(bytes12 vaultId, bytes6 seriesId, bytes6 ilkId) external returns (DataTypes.Vault memory); /// @dev Give a vault to another user. function give(bytes12 vaultId, address receiver) external returns (DataTypes.Vault memory); /// @dev Move collateral and debt between vaults. function stir(bytes12 from, bytes12 to, uint128 ink, uint128 art) external returns (DataTypes.Balances memory, DataTypes.Balances memory); /// @dev Manipulate a vault debt and collateral. function pour(bytes12 vaultId, int128 ink, int128 art) external returns (DataTypes.Balances memory); /// @dev Change series and debt of a vault. /// The module calling this function also needs to buy underlying in the pool for the new series, and sell it in pool for the old series. function roll(bytes12 vaultId, bytes6 seriesId, int128 art) external returns (DataTypes.Vault memory, DataTypes.Balances memory); /// @dev Reduce debt and collateral from a vault, ignoring collateralization checks. function slurp(bytes12 vaultId, uint128 ink, uint128 art) external returns (DataTypes.Balances memory); // ==== Helpers ==== /// @dev Convert a debt amount for a series from base to fyToken terms. /// @notice Think about rounding if using, since we are dividing. function debtFromBase(bytes6 seriesId, uint128 base) external returns (uint128 art); /// @dev Convert a debt amount for a series from fyToken to base terms function debtToBase(bytes6 seriesId, uint128 art) external returns (uint128 base); // ==== Accounting ==== /// @dev Record the borrowing rate at maturity for a series function mature(bytes6 seriesId) external; /// @dev Retrieve the rate accrual since maturity, maturing if necessary. function accrual(bytes6 seriesId) external returns (uint256); /// @dev Return the collateralization level of a vault. It will be negative if undercollateralized. function level(bytes12 vaultId) external returns (int256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@yield-protocol/utils-v2/contracts/token/IERC20.sol"; interface IJoin { /// @dev asset managed by this contract function asset() external view returns (address); /// @dev Add tokens to this contract. function join(address user, uint128 wad) external returns (uint128); /// @dev Remove tokens to this contract. function exit(address user, uint128 wad) external returns (uint128); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IFYToken.sol"; import "./IOracle.sol"; library DataTypes { struct Series { IFYToken fyToken; // Redeemable token for the series. bytes6 baseId; // Asset received on redemption. uint32 maturity; // Unix time at which redemption becomes possible. // bytes2 free } struct Debt { uint96 max; // Maximum debt accepted for a given underlying, across all series uint24 min; // Minimum debt accepted for a given underlying, across all series uint8 dec; // Multiplying factor (10**dec) for max and min uint128 sum; // Current debt for a given underlying, across all series } struct SpotOracle { IOracle oracle; // Address for the spot price oracle uint32 ratio; // Collateralization ratio to multiply the price for // bytes8 free } struct Vault { address owner; bytes6 seriesId; // Each vault is related to only one series, which also determines the underlying. bytes6 ilkId; // Asset accepted as collateral } struct Balances { uint128 art; // Debt amount uint128 ink; // Collateral amount } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library WMul { // Taken from https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol /// @dev Multiply an amount by a fixed point factor with 18 decimals, rounds down. function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * y; unchecked { z /= 1e18; } } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library WMulUp { // Fixed point arithmetic in 18 decimal units // Taken from https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol /// @dev Multiply x and y, with y being fixed point. If both are integers, the result is a fixed point factor. Rounds up. function wmulup(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * y + 1e18 - 1; // Rounds up. So (again imagining 2 decimal places): unchecked { z /= 1e18; } // 383 (3.83) * 235 (2.35) -> 90005 (9.0005), + 99 (0.0099) -> 90104, / 100 -> 901 (9.01). } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library WDiv { // Fixed point arithmetic in 18 decimal units // Taken from https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol /// @dev Divide an amount by a fixed point factor with 18 decimals function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = (x * 1e18) / y; } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library WDivUp { // Fixed point arithmetic in 18 decimal units // Taken from https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol /// @dev Divide x and y, with y being fixed point. If both are integers, the result is a fixed point factor. Rounds up. function wdivup(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * 1e18 + y; // 101 (1.01) / 1000 (10) -> (101 * 100 + 1000 - 1) / 1000 -> 11 (0.11 = 0.101 rounded up). unchecked { z -= 1; } // Can do unchecked subtraction since division in next line will catch y = 0 case anyway z /= y; } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU256U128 { /// @dev Safely cast an uint256 to an uint128 function u128(uint256 x) internal pure returns (uint128 y) { require (x <= type(uint128).max, "Cast overflow"); y = uint128(x); } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU256U32 { /// @dev Safely cast an uint256 to an u32 function u32(uint256 x) internal pure returns (uint32 y) { require (x <= type(uint32).max, "Cast overflow"); y = uint32(x); } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@yield-protocol/utils-v2/contracts/token/IERC20.sol"; interface IFYToken is IERC20 { /// @dev Asset that is returned on redemption. function underlying() external view returns (address); /// @dev Unix time at which redemption of fyToken for underlying are possible function maturity() external view returns (uint256); /// @dev Record price data at maturity function mature() external; /// @dev Mint fyToken providing an equal amount of underlying to the protocol function mintWithUnderlying(address to, uint256 amount) external; /// @dev Burn fyToken after maturity for an amount of underlying. function redeem(address to, uint256 amount) external returns (uint256); /// @dev Mint fyToken. /// This function can only be called by other Yield contracts, not users directly. /// @param to Wallet to mint the fyToken in. /// @param fyTokenAmount Amount of fyToken to mint. function mint(address to, uint256 fyTokenAmount) external; /// @dev Burn fyToken. /// This function can only be called by other Yield contracts, not users directly. /// @param from Wallet to burn the fyToken from. /// @param fyTokenAmount Amount of fyToken to burn. function burn(address from, uint256 fyTokenAmount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IOracle { /** * @notice Doesn't refresh the price, but returns the latest value available without doing any transactional operations: * @return value in wei */ function peek(bytes32 base, bytes32 quote, uint256 amount) external view returns (uint256 value, uint256 updateTime); /** * @notice Does whatever work or queries will yield the most up-to-date price, and returns it. * @return value in wei */ function get(bytes32 base, bytes32 quote, uint256 amount) external returns (uint256 value, uint256 updateTime); }
Give collateral to the user
if (ink != 0) {
12,663,696
[ 1, 4625, 348, 7953, 560, 30, 225, 22374, 4508, 2045, 287, 358, 326, 729, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 309, 261, 754, 480, 374, 13, 288, 28524, 1377, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types 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; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: contracts/NFTSKI.sol pragma solidity >=0.7.0 <0.9.0; contract NFTski is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.01 ether; uint256 public maxSupply = 6669; uint256 public maxMintAmountPerTx = 20; bool public paused = false; bool public revealed = false; constructor() ERC721("NFTski", "NFTSKI") { setHiddenMetadataUri("ipfs://QmWby4PT741nEZmY8uKPYRbnNAMbTNc6wNxwsugjMrw7Yz"); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { // This will transfer the remaining contract balance to the owner. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
File: contracts/NFTSKI.sol
contract NFTski is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.01 ether; uint256 public maxSupply = 6669; uint256 public maxMintAmountPerTx = 20; bool public paused = false; bool public revealed = false; function _beforeTokenTransfer( address from, address to, uint256 tokenId } pragma solidity >=0.7.0 <0.9.0; constructor() ERC721("NFTski", "NFTSKI") { } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { require(os); } (bool os, ) = payable(owner()).call{value: address(this).balance}(""); function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
582,615
[ 1, 4625, 348, 7953, 560, 30, 225, 1387, 30, 20092, 19, 50, 4464, 11129, 45, 18, 18281, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 423, 4464, 7771, 77, 353, 4232, 39, 27, 5340, 16, 14223, 6914, 288, 203, 225, 1450, 8139, 364, 2254, 5034, 31, 203, 225, 1450, 9354, 87, 364, 9354, 87, 18, 4789, 31, 203, 203, 225, 9354, 87, 18, 4789, 3238, 14467, 31, 203, 203, 225, 533, 1071, 2003, 2244, 273, 1408, 31, 203, 225, 533, 1071, 2003, 5791, 273, 3552, 1977, 14432, 203, 225, 533, 1071, 5949, 2277, 3006, 31, 203, 21281, 225, 2254, 5034, 1071, 6991, 273, 374, 18, 1611, 225, 2437, 31, 203, 225, 2254, 5034, 1071, 943, 3088, 1283, 273, 1666, 6028, 29, 31, 203, 225, 2254, 5034, 1071, 943, 49, 474, 6275, 2173, 4188, 273, 4200, 31, 203, 203, 225, 1426, 1071, 17781, 273, 629, 31, 203, 225, 1426, 1071, 283, 537, 18931, 273, 629, 31, 203, 203, 565, 445, 389, 5771, 1345, 5912, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 1147, 548, 203, 97, 203, 203, 203, 203, 203, 683, 9454, 18035, 560, 1545, 20, 18, 27, 18, 20, 411, 20, 18, 29, 18, 20, 31, 203, 203, 203, 203, 203, 225, 3885, 1435, 4232, 39, 27, 5340, 2932, 50, 4464, 7771, 77, 3113, 315, 50, 4464, 11129, 45, 7923, 288, 203, 225, 289, 203, 203, 225, 9606, 312, 474, 16687, 12, 11890, 5034, 389, 81, 474, 6275, 13, 288, 203, 565, 2583, 24899, 81, 474, 6275, 405, 374, 597, 389, 81, 474, 6275, 1648, 943, 49, 474, 6275, 2173, 4188, 16, 315, 1941, 312, 474, 3844, 4442, 1769, 203, 565, 2583, 12, 2859, 1283, 18, 2972, 1435, 397, 389, 81, 474, 6275, 1648, 943, 3088, 1283, 16, 315, 2747, 14467, 12428, 4442, 1769, 203, 565, 389, 31, 203, 225, 289, 203, 203, 225, 445, 2078, 3088, 1283, 1435, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 327, 14467, 18, 2972, 5621, 203, 225, 289, 203, 203, 225, 445, 312, 474, 12, 11890, 5034, 389, 81, 474, 6275, 13, 1071, 8843, 429, 312, 474, 16687, 24899, 81, 474, 6275, 13, 288, 203, 565, 2583, 12, 5, 8774, 3668, 16, 315, 1986, 6835, 353, 17781, 4442, 1769, 203, 565, 2583, 12, 3576, 18, 1132, 1545, 6991, 380, 389, 81, 474, 6275, 16, 315, 5048, 11339, 284, 19156, 4442, 1769, 203, 203, 565, 389, 81, 474, 6452, 12, 3576, 18, 15330, 16, 389, 81, 474, 6275, 1769, 203, 225, 289, 203, 21281, 225, 445, 312, 474, 1290, 1887, 12, 11890, 5034, 389, 81, 474, 6275, 16, 1758, 389, 24454, 13, 1071, 312, 474, 16687, 24899, 81, 474, 6275, 13, 1338, 5541, 288, 203, 565, 389, 81, 474, 6452, 24899, 24454, 16, 389, 81, 474, 6275, 1769, 203, 225, 289, 203, 203, 225, 445, 9230, 951, 5541, 12, 2867, 389, 8443, 13, 203, 565, 1071, 203, 565, 1476, 203, 565, 1135, 261, 11890, 5034, 8526, 3778, 13, 203, 225, 288, 203, 565, 2254, 5034, 3410, 1345, 1380, 273, 11013, 951, 24899, 8443, 1769, 203, 565, 2254, 5034, 8526, 3778, 16199, 1345, 2673, 273, 394, 2254, 5034, 8526, 12, 8443, 1345, 1380, 1769, 203, 565, 2254, 5034, 23719, 548, 273, 404, 31, 203, 565, 2254, 5034, 16199, 1345, 1016, 273, 374, 31, 203, 203, 565, 1323, 261, 995, 329, 1345, 1016, 411, 3410, 1345, 1380, 597, 23719, 548, 1648, 943, 3088, 1283, 13, 288, 203, 1377, 1758, 23719, 5541, 273, 3410, 951, 12, 2972, 1345, 548, 1769, 203, 203, 1377, 309, 261, 2972, 1345, 5541, 422, 389, 8443, 13, 288, 203, 3639, 16199, 1345, 2673, 63, 995, 329, 1345, 1016, 65, 273, 23719, 548, 31, 203, 203, 3639, 16199, 1345, 1016, 9904, 31, 203, 1377, 289, 203, 203, 1377, 23719, 548, 9904, 31, 203, 565, 289, 203, 203, 565, 327, 16199, 1345, 2673, 31, 203, 225, 289, 203, 203, 225, 445, 9230, 951, 5541, 12, 2867, 389, 8443, 13, 203, 565, 1071, 203, 565, 1476, 203, 565, 1135, 261, 11890, 5034, 8526, 3778, 13, 203, 225, 288, 203, 565, 2254, 5034, 3410, 1345, 1380, 273, 11013, 951, 24899, 8443, 1769, 203, 565, 2254, 5034, 8526, 3778, 16199, 1345, 2673, 273, 394, 2254, 5034, 8526, 12, 8443, 1345, 1380, 1769, 203, 565, 2254, 5034, 23719, 548, 273, 404, 31, 203, 565, 2254, 5034, 16199, 1345, 1016, 273, 374, 31, 203, 203, 565, 1323, 261, 995, 329, 1345, 1016, 411, 3410, 1345, 1380, 597, 23719, 548, 1648, 943, 3088, 1283, 13, 288, 203, 1377, 1758, 23719, 5541, 273, 3410, 951, 12, 2972, 1345, 548, 1769, 203, 203, 1377, 309, 261, 2972, 1345, 5541, 422, 389, 8443, 13, 288, 203, 3639, 16199, 1345, 2673, 63, 995, 329, 1345, 1016, 65, 273, 23719, 548, 31, 203, 203, 3639, 16199, 1345, 1016, 9904, 31, 203, 1377, 289, 203, 203, 1377, 23719, 548, 9904, 31, 203, 565, 289, 203, 203, 565, 327, 16199, 1345, 2673, 31, 203, 225, 289, 203, 203, 225, 445, 9230, 951, 5541, 12, 2867, 389, 8443, 13, 203, 565, 1071, 203, 565, 1476, 203, 565, 1135, 261, 11890, 5034, 8526, 3778, 13, 203, 225, 288, 203, 565, 2254, 5034, 3410, 1345, 1380, 273, 11013, 951, 24899, 8443, 1769, 203, 565, 2254, 5034, 8526, 3778, 16199, 1345, 2673, 273, 394, 2254, 5034, 8526, 12, 8443, 1345, 1380, 1769, 203, 565, 2254, 5034, 23719, 548, 273, 404, 31, 203, 565, 2254, 5034, 16199, 1345, 1016, 273, 374, 31, 203, 203, 565, 1323, 261, 995, 329, 1345, 1016, 411, 3410, 1345, 1380, 597, 23719, 548, 1648, 943, 3088, 1283, 13, 288, 203, 1377, 1758, 23719, 5541, 273, 3410, 951, 12, 2972, 1345, 548, 1769, 203, 203, 1377, 309, 261, 2972, 1345, 5541, 422, 389, 8443, 13, 288, 203, 3639, 16199, 1345, 2673, 63, 995, 329, 1345, 1016, 65, 273, 23719, 548, 31, 203, 203, 3639, 16199, 1345, 1016, 9904, 31, 203, 1377, 289, 203, 203, 1377, 23719, 548, 9904, 31, 203, 565, 289, 203, 203, 565, 327, 16199, 1345, 2673, 31, 203, 225, 289, 203, 203, 225, 445, 1147, 3098, 12, 11890, 5034, 389, 2316, 548, 13, 203, 565, 1071, 203, 565, 1476, 203, 565, 5024, 203, 565, 3849, 203, 565, 1135, 261, 1080, 3778, 13, 203, 225, 288, 203, 565, 2583, 12, 203, 1377, 389, 1808, 24899, 2316, 548, 3631, 203, 1377, 315, 654, 2 ]
pragma solidity ^0.4.24; //////////////////////////////////////////////////////////////////////////////// library SafeMath { //------------------ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; assert(c / a == b); return c; } //-------------------------------------------------------------------------- function div(uint256 a, uint256 b) internal pure returns (uint256) { return a/b; } //-------------------------------------------------------------------------- function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } //-------------------------------------------------------------------------- function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } //////////////////////////////////////////////////////////////////////////////// contract ERC20 { using SafeMath for uint256; //----- VARIABLES address public owner; // Owner of this contract address public admin; // The one who is allowed to do changes mapping(address => uint256) balances; // Maintain balance in a mapping mapping(address => mapping (address => uint256)) allowances; // Allowances index-1 = Owner account index-2 = spender account //------ TOKEN SPECIFICATION string public constant name = "Reger Diamond Security Token"; string public constant symbol = "RDST"; uint256 public constant decimals = 18; uint256 public constant initSupply = 60000000 * 10**decimals; // 10**18 max uint256 public constant supplyReserveVal = 37500000 * 10**decimals; // if quantity => the ##MACRO## addrs "* 10**decimals" //----- uint256 public totalSupply; uint256 public icoSalesSupply = 0; // Needed when burning tokens uint256 public icoReserveSupply = 0; uint256 public softCap = 5000000 * 10**decimals; uint256 public hardCap = 21500000 * 10**decimals; //---------------------------------------------------- smartcontract control uint256 public icoDeadLine = 1533513600; // 2018-08-06 00:00 (GMT+0) not needed bool public isIcoPaused = false; bool public isStoppingIcoOnHardCap = true; //-------------------------------------------------------------------------- modifier duringIcoOnlyTheOwner() // if not during the ico : everyone is allowed at anytime { require( now>icoDeadLine || msg.sender==owner ); _; } modifier icoFinished() { require(now > icoDeadLine); _; } modifier icoNotFinished() { require(now <= icoDeadLine); _; } modifier icoNotPaused() { require(isIcoPaused==false); _; } modifier icoPaused() { require(isIcoPaused==true); _; } modifier onlyOwner() { require(msg.sender==owner); _; } modifier onlyAdmin() { require(msg.sender==admin); _; } //----- EVENTS event Transfer(address indexed fromAddr, address indexed toAddr, uint256 amount); event Approval(address indexed _owner, address indexed _spender, uint256 amount); //---- extra EVENTS event onAdminUserChanged( address oldAdmin, address newAdmin); event onOwnershipTransfered(address oldOwner, address newOwner); event onIcoDeadlineChanged( uint256 oldIcoDeadLine, uint256 newIcoDeadline); event onHardcapChanged( uint256 hardCap, uint256 newHardCap); event icoIsNowPaused( uint8 newPauseStatus); event icoHasRestarted( uint8 newPauseStatus); event log(string key, string value); event log(string key, uint value); //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- constructor() public { owner = msg.sender; admin = owner; isIcoPaused = false; //----- balances[owner] = initSupply; // send the tokens to the owner totalSupply = initSupply; icoSalesSupply = totalSupply; //----- Handling if there is a special maximum amount of tokens to spend during the ICO or not icoSalesSupply = totalSupply.sub(supplyReserveVal); icoReserveSupply = totalSupply.sub(icoSalesSupply); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //----- ERC20 FUNCTIONS //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function balanceOf(address walletAddress) public constant returns (uint256 balance) { return balances[walletAddress]; } //-------------------------------------------------------------------------- function transfer(address toAddr, uint256 amountInWei) public duringIcoOnlyTheOwner returns (bool) // don't icoNotPaused here. It's a logic issue. { require(toAddr!=0x0 && toAddr!=msg.sender && amountInWei>0); // Prevent transfer to 0x0 address and to self, amount must be >0 uint256 availableTokens = balances[msg.sender]; //----- Checking Token reserve first : if during ICO if (msg.sender==owner && now <= icoDeadLine) // ICO Reserve Supply checking: Don't touch the RESERVE of tokens when owner is selling { assert(amountInWei<=availableTokens); uint256 balanceAfterTransfer = availableTokens.sub(amountInWei); assert(balanceAfterTransfer >= icoReserveSupply); // We try to sell more than allowed during an ICO } //----- balances[msg.sender] = balances[msg.sender].sub(amountInWei); balances[toAddr] = balances[toAddr].add(amountInWei); emit Transfer(msg.sender, toAddr, amountInWei); return true; } //-------------------------------------------------------------------------- function allowance(address walletAddress, address spender) public constant returns (uint remaining) { return allowances[walletAddress][spender]; } //-------------------------------------------------------------------------- function transferFrom(address fromAddr, address toAddr, uint256 amountInWei) public returns (bool) { if (amountInWei <= 0) return false; if (allowances[fromAddr][msg.sender] < amountInWei) return false; if (balances[fromAddr] < amountInWei) return false; balances[fromAddr] = balances[fromAddr].sub(amountInWei); balances[toAddr] = balances[toAddr].add(amountInWei); allowances[fromAddr][msg.sender] = allowances[fromAddr][msg.sender].sub(amountInWei); emit Transfer(fromAddr, toAddr, amountInWei); return true; } //-------------------------------------------------------------------------- function approve(address spender, uint256 amountInWei) public returns (bool) { require((amountInWei == 0) || (allowances[msg.sender][spender] == 0)); allowances[msg.sender][spender] = amountInWei; emit Approval(msg.sender, spender, amountInWei); return true; } //-------------------------------------------------------------------------- function() public { assert(true == false); // If Ether is sent to this address, don't handle it -> send it back. } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function transferOwnership(address newOwner) public onlyOwner // @param newOwner The address to transfer ownership to. { require(newOwner != address(0)); emit onOwnershipTransfered(owner, newOwner); owner = newOwner; } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function changeAdminUser(address newAdminAddress) public onlyOwner { require(newAdminAddress!=0x0); emit onAdminUserChanged(admin, newAdminAddress); admin = newAdminAddress; } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function changeIcoDeadLine(uint256 newIcoDeadline) public onlyAdmin { require(newIcoDeadline!=0); emit onIcoDeadlineChanged(icoDeadLine, newIcoDeadline); icoDeadLine = newIcoDeadline; } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function changeHardCap(uint256 newHardCap) public onlyAdmin { require(newHardCap!=0); emit onHardcapChanged(hardCap, newHardCap); hardCap = newHardCap; } //-------------------------------------------------------------------------- function isHardcapReached() public view returns(bool) { return (isStoppingIcoOnHardCap && initSupply-balances[owner] > hardCap); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function pauseICO() public onlyAdmin { isIcoPaused = true; emit icoIsNowPaused(1); } //-------------------------------------------------------------------------- function unpauseICO() public onlyAdmin { isIcoPaused = false; emit icoHasRestarted(0); } //-------------------------------------------------------------------------- function isPausedICO() public view returns(bool) { return (isIcoPaused) ? true : false; } } //////////////////////////////////////////////////////////////////////////////// contract DateTime { struct TDateTime { uint16 year; uint8 month; uint8 day; uint8 hour; uint8 minute; uint8 second; uint8 weekday; } uint8[] totalDays = [ 0, 31,28,31,30,31,30, 31,31,30,31,30,31]; uint constant DAY_IN_SECONDS = 86400; uint constant YEAR_IN_SECONDS = 31536000; uint constant LEAP_YEAR_IN_SECONDS = 31622400; uint constant HOUR_IN_SECONDS = 3600; uint constant MINUTE_IN_SECONDS = 60; uint16 constant ORIGIN_YEAR = 1970; //------------------------------------------------------------------------- function isLeapYear(uint16 year) public pure returns (bool) { if ((year % 4)!=0) return false; if ( year % 100 !=0) return true; if ( year % 400 !=0) return false; return true; } //------------------------------------------------------------------------- function leapYearsBefore(uint year) public pure returns (uint) { year -= 1; return year / 4 - year / 100 + year / 400; } //------------------------------------------------------------------------- function getDaysInMonth(uint8 month, uint16 year) public pure returns (uint8) { uint8 nDay = 30; if (month==1) nDay++; else if (month==3) nDay++; else if (month==5) nDay++; else if (month==7) nDay++; else if (month==8) nDay++; else if (month==10) nDay++; else if (month==12) nDay++; else if (month==2) { nDay = 28; if (isLeapYear(year)) nDay++; } return nDay; } //------------------------------------------------------------------------- function parseTimestamp(uint timestamp) internal pure returns (TDateTime dt) { uint secondsAccountedFor = 0; uint buf; uint8 i; uint secondsInMonth; dt.year = getYear(timestamp); buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf; secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf); for (i = 1; i <= 12; i++) { secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year); if (secondsInMonth + secondsAccountedFor > timestamp) { dt.month = i; break; } secondsAccountedFor += secondsInMonth; } for (i=1; i<=getDaysInMonth(dt.month, dt.year); i++) { if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) { dt.day = i; break; } secondsAccountedFor += DAY_IN_SECONDS; } dt.hour = getHour(timestamp); dt.minute = getMinute(timestamp); dt.second = getSecond(timestamp); dt.weekday = getWeekday(timestamp); } //------------------------------------------------------------------------- function getYear(uint timestamp) public pure returns (uint16) { uint secondsAccountedFor = 0; uint16 year; uint numLeapYears; year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS); numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears; secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears); while (secondsAccountedFor > timestamp) { if (isLeapYear(uint16(year - 1))) secondsAccountedFor -= LEAP_YEAR_IN_SECONDS; else secondsAccountedFor -= YEAR_IN_SECONDS; year -= 1; } return year; } //------------------------------------------------------------------------- function getMonth(uint timestamp) public pure returns (uint8) { return parseTimestamp(timestamp).month; } //------------------------------------------------------------------------- function getDay(uint timestamp) public pure returns (uint8) { return parseTimestamp(timestamp).day; } //------------------------------------------------------------------------- function getHour(uint timestamp) public pure returns (uint8) { return uint8(((timestamp % 86400) / 3600) % 24); } //------------------------------------------------------------------------- function getMinute(uint timestamp) public pure returns (uint8) { return uint8((timestamp % 3600) / 60); } //------------------------------------------------------------------------- function getSecond(uint timestamp) public pure returns (uint8) { return uint8(timestamp % 60); } //------------------------------------------------------------------------- function getWeekday(uint timestamp) public pure returns (uint8) { return uint8((timestamp / DAY_IN_SECONDS + 4) % 7); } //------------------------------------------------------------------------- function toTimestamp(uint16 year, uint8 month, uint8 day) public pure returns (uint timestamp) { return toTimestamp(year, month, day, 0, 0, 0); } //------------------------------------------------------------------------- function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) public pure returns (uint timestamp) { return toTimestamp(year, month, day, hour, 0, 0); } //------------------------------------------------------------------------- function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) public pure returns (uint timestamp) { return toTimestamp(year, month, day, hour, minute, 0); } //------------------------------------------------------------------------- function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) public pure returns (uint timestamp) { uint16 i; for (i = ORIGIN_YEAR; i < year; i++) { if (isLeapYear(i)) timestamp += LEAP_YEAR_IN_SECONDS; else timestamp += YEAR_IN_SECONDS; } uint8[12] memory monthDayCounts; monthDayCounts[0] = 31; monthDayCounts[1] = 28; if (isLeapYear(year)) monthDayCounts[1] = 29; monthDayCounts[2] = 31; monthDayCounts[3] = 30; monthDayCounts[4] = 31; monthDayCounts[5] = 30; monthDayCounts[6] = 31; monthDayCounts[7] = 31; monthDayCounts[8] = 30; monthDayCounts[9] = 31; monthDayCounts[10] = 30; monthDayCounts[11] = 31; for (i=1; i<month; i++) { timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1]; } timestamp += DAY_IN_SECONDS * (day - 1); timestamp += HOUR_IN_SECONDS * (hour); timestamp += MINUTE_IN_SECONDS * (minute); timestamp += second; return timestamp; } //------------------------------------------------------------------------- function getYearDay(uint timestamp) public pure returns (uint16) { TDateTime memory date = parseTimestamp(timestamp); uint16 dayCount=0; for (uint8 iMonth=1; iMonth<date.month; iMonth++) { dayCount += getDaysInMonth(iMonth, date.year); } dayCount += date.day; return dayCount; // We have now the amount of days since January 1st of that year } //------------------------------------------------------------------------- function getDaysInYear(uint16 year) public pure returns (uint16) { return (isLeapYear(year)) ? 366:365; } //------------------------------------------------------------------------- function dateToTimestamp(uint16 iYear, uint8 iMonth, uint8 iDay) public pure returns(uint) { uint8 monthDayCount = 30; if (iMonth==2) { monthDayCount = 28; if (isLeapYear(iYear)) monthDayCount++; } if (iMonth==4 || iMonth==6 || iMonth==9 || iMonth==11) { monthDayCount = 31; } if (iDay<1) { iDay = 1; } else if (iDay>monthDayCount) { iDay = 1; // if day is over limit, set the date on the first day of the next month iMonth++; if (iMonth>12) { iMonth=1; iYear++; } } return toTimestamp(iYear, iMonth, iDay); } //------------------------------------------------------------------------- } //////////////////////////////////////////////////////////////////////////////// contract CompoundContract is ERC20, DateTime { using SafeMath for uint256; bool private isLiveTerm = true; struct TCompoundItem { uint id; // an HASH to distinguish each compound in contract uint plan; // 1: Sapphire 2: Emerald 3:Ruby 4: Diamond address investor; // wallet address of the owner of this compound contract uint tokenCapitalInWei; // = capital uint tokenEarningsInWei; // This contract will geneeate this amount of tokens for the investor uint earningPerTermInWei; // Every "3 months" the investor will receive this amount of money uint currentlyEarnedInWei; // cumulative amount of tokens already received uint tokenEarnedInWei; // = totalEarnings uint overallTokensInWei; // = capital + totalEarnings uint contractMonthCount; // 12 or 24 uint startTimestamp; uint endTimestamp; // the date when the compound contract will cease uint interestRate; uint percent; bool isAllPaid; // if true : all compound earning has been given. Nothing more to do uint8 termPaidCount; // uint8 termCount; // bool isContractValidated; // Any compound contract needs to be confirmed otherwise they will be cancelled bool isCancelled; // The compound contract was not validated and has been set to cancelled! } mapping(address => uint256) lockedCapitals; // During ICO we block some of the tokens mapping(address => uint256) lockedEarnings; // During ICO we block some of the tokens mapping(uint256 => bool) private activeContractStatues; // Use when doing a payEarnings to navigate through all contracts mapping(uint => TCompoundItem) private contracts; mapping(uint256 => uint32[12]) private compoundPayTimes; mapping(uint256 => uint8[12]) private compoundPayStatus; // to know if a compound has already been paid or not. So not repaying again event onCompoundContractCompleted(address investor, uint256 compoundId, uint256 capital, uint256 earnedAmount, uint256 total, uint256 timestamp); event onCompoundEarnings(address investor, uint256 compoundId, uint256 capital, uint256 earnedAmount, uint256 earnedSoFarAmount, uint32 timestamp, uint8 paidTermCount, uint8 totalTermCount); event onCompoundContractLocked(address fromAddr, address toAddr, uint256 amountToLockInWei); event onPayEarningsDone(uint contractId, uint nPaid, uint paymentCount, uint paidAmountInWei); event onCompoundContractCancelled(uint contractId, uint lockedCapital, uint lockedEarnings); event onCompoundContractValidated(uint contractId); //-------------------------------------------------------------------------- function initCompoundContract(address buyerAddress, uint256 amountInWei, uint256 compoundContractId, uint monthCount) internal onlyOwner returns(bool) { TCompoundItem memory item; uint overallTokensInWei; uint tokenEarningsInWei; uint earningPerTermInWei; uint percentToUse; uint interestRate; uint i; if (activeContractStatues[compoundContractId]) { return false; // the specified contract is already in place. Don't alter already running contract!!! } activeContractStatues[compoundContractId] = true; //----- Calculate the contract revenue generated for the whole monthPeriod (overallTokensInWei, tokenEarningsInWei, earningPerTermInWei, percentToUse, interestRate, i) = calculateCompoundContract(amountInWei, monthCount); item.plan = i; // Not enough stack depth. using i here //----- Checking if we can apply this compound contract or not if (percentToUse==0) // an error occured { return false; } //----- Calculate when to do payments for that contract generateCompoundTerms(compoundContractId); //----- item.id = compoundContractId; item.startTimestamp = now; item.contractMonthCount = monthCount; item.interestRate = interestRate; item.percent = percentToUse; item.investor = buyerAddress; item.isAllPaid = false; item.termCount = uint8(monthCount/3); item.termPaidCount = 0; item.tokenCapitalInWei = amountInWei; item.currentlyEarnedInWei = 0; item.overallTokensInWei = overallTokensInWei; item.tokenEarningsInWei = tokenEarningsInWei; item.earningPerTermInWei = earningPerTermInWei; item.isCancelled = false; item.isContractValidated = false; // any contract must be validated 35 days after its creation. //----- contracts[compoundContractId] = item; return true; } //-------------------------------------------------------------------------- function generateCompoundTerms(uint256 compoundContractId) private { uint16 iYear = getYear(now); uint8 iMonth = getMonth(now); uint i; if (isLiveTerm) { for (i=0; i<8; i++) // set every pay schedule date (every 3 months) 8 means 2 years payments every 3 months { iMonth += 3; // every 3 months if (iMonth>12) { iYear++; iMonth -= 12; } compoundPayTimes[compoundContractId][i] = uint32(dateToTimestamp(iYear, iMonth, getDay(now))); compoundPayStatus[compoundContractId][i] = 0; } } else { uint timeSum=now; for (i=0; i<8; i++) // set every pay schedule date (every 3 months) 8 means 2 years payments every 3 months { uint duration = 4*60; // set first period longer to allow confirmation of the contract if (i>0) duration = 2*60; timeSum += duration; compoundPayTimes[compoundContractId][i] = uint32(timeSum); // DEBUGING: pay every 3 minutes compoundPayStatus[compoundContractId][i] = 0; } } } //-------------------------------------------------------------------------- function calculateCompoundContract(uint256 capitalInWei, uint contractMonthCount) public constant returns(uint, uint, uint, uint, uint, uint) // DON'T Set as pure, otherwise it will make investXXMonths function unusable (too much gas) { /* 12 months Sapphire From 100 to 1,000 12% Emerald From 1,000 to 10,000 15% Rub From 10,000 to 100,000 17% Diamond 100,000+ 20% 24 months Sapphire From 100 to 1,000 15% Emerald From 1,000 to 10,000 17% Rub From 10,000 to 100,000 20% Diamond 100,000+ 30% */ uint plan = 0; uint256 interestRate = 0; uint256 percentToUse = 0; if (contractMonthCount==12) { if (capitalInWei< 1000 * 10**18) { percentToUse=12; interestRate=1125509; plan=1; } // SAPPHIRE else if (capitalInWei< 10000 * 10**18) { percentToUse=15; interestRate=1158650; plan=2; } // EMERALD else if (capitalInWei<100000 * 10**18) { percentToUse=17; interestRate=1181148; plan=3; } // RUBY else { percentToUse=20; interestRate=1215506; plan=4; } // DIAMOND } else if (contractMonthCount==24) { if (capitalInWei< 1000 * 10**18) { percentToUse=15; interestRate=1342471; plan=1; } else if (capitalInWei< 10000 * 10**18) { percentToUse=17; interestRate=1395110; plan=2; } else if (capitalInWei<100000 * 10**18) { percentToUse=20; interestRate=1477455; plan=3; } else { percentToUse=30; interestRate=1783478; plan=4; } } else { return (0,0,0,0,0,0); // only 12 and 24 months are allowed here } uint256 overallTokensInWei = (capitalInWei * interestRate ) / 1000000; uint256 tokenEarningsInWei = overallTokensInWei - capitalInWei; uint256 earningPerTermInWei = tokenEarningsInWei / (contractMonthCount/3); // 3 is for => Pays a Term of earning every 3 months return (overallTokensInWei,tokenEarningsInWei,earningPerTermInWei, percentToUse, interestRate, plan); } //-------------------------------------------------------------------------- function lockMoneyOnCompoundCreation(address toAddr, uint compountContractId) internal onlyOwner returns (bool) { require(toAddr!=0x0 && toAddr!=msg.sender); // Prevent transfer to 0x0 address and to self, amount must be >0 if (isHardcapReached()) { return false; // an extra check first, who knows. } TCompoundItem memory item = contracts[compountContractId]; if (item.tokenCapitalInWei==0 || item.tokenEarningsInWei==0) { return false; // don't valid such invalid contract } //----- uint256 amountToLockInWei = item.tokenCapitalInWei + item.tokenEarningsInWei; uint256 availableTokens = balances[owner]; if (amountToLockInWei <= availableTokens) { uint256 balanceAfterTransfer = availableTokens.sub(amountToLockInWei); if (balanceAfterTransfer >= icoReserveSupply) // don't sell more than allowed during ICO { lockMoney(toAddr, item.tokenCapitalInWei, item.tokenEarningsInWei); return true; } } //emit log('Exiting lockMoneyOnCompoundCreation', 'cannot lock money'); return false; } //-------------------------------------------------------------------------- function payCompoundTerm(uint contractId, uint8 termId, uint8 isCalledFromOutside) public onlyOwner returns(int32) // DON'T SET icoNotPaused here, since a runnnig compound needs to run anyway { uint id; address investor; uint paidAmount; TCompoundItem memory item; if (!activeContractStatues[contractId]) { emit log("payCompoundTerm", "Specified contract is not actived (-1)"); return -1; } item = contracts[contractId]; //----- if (item.isCancelled) // That contract was never validated!!! { emit log("payCompoundTerm", "Compound contract already cancelled (-2)"); return -2; } //----- if (item.isAllPaid) { emit log("payCompoundTerm", "All earnings already paid for this contract (-2)"); return -4; // everything was paid already } id = item.id; if (compoundPayStatus[id][termId]!=0) { emit log("payCompoundTerm", "Specified contract's term was already paid (-5)"); return -5; } if (now < compoundPayTimes[id][termId]) { emit log("payCompoundTerm", "It's too early to pay this term (-6)"); return -6; } investor = item.investor; // address of the owner of this compound contract //----- It's time for the payment, but was that contract already validated //----- If it was not validated, simply refund tokens to the main wallet if (!item.isContractValidated) // Compound contract self-destruction since no validation was made of it { uint capital = item.tokenCapitalInWei; uint earnings = item.tokenEarningsInWei; contracts[contractId].isCancelled = true; contracts[contractId].tokenCapitalInWei = 0; /// make sure nothing residual is left contracts[contractId].tokenEarningsInWei = 0; /// //----- lockedCapitals[investor] = lockedCapitals[investor].sub(capital); lockedEarnings[investor] = lockedEarnings[investor].sub(earnings); balances[owner] = balances[owner].add(capital); balances[owner] = balances[owner].add(earnings); emit onCompoundContractCancelled(contractId, capital, earnings); emit log("payCompoundTerm", "Cancelling compound contract (-3)"); return -3; } //---- it's PAY time!!! contracts[id].termPaidCount++; contracts[id].currentlyEarnedInWei += item.earningPerTermInWei; compoundPayStatus[id][termId] = 1; // PAID!!! meaning not to repay again this revenue term unlockEarnings(investor, item.earningPerTermInWei); paidAmount = item.earningPerTermInWei; if (contracts[id].termPaidCount>=item.termCount && !contracts[item.id].isAllPaid) // This is the last payment of all payments for this contract { contracts[id].isAllPaid = true; unlockCapital(investor, item.tokenCapitalInWei); paidAmount += item.tokenCapitalInWei; } //----- let's tell the blockchain now how many we've unlocked. if (isCalledFromOutside==0 && paidAmount>0) { emit Transfer(owner, investor, paidAmount); } return 1; // We just paid one earning!!! // 1 IS IMPORTANT FOR THE TOKEN API. don't change it } //-------------------------------------------------------------------------- function validateCompoundContract(uint contractId) public onlyOwner returns(uint) { TCompoundItem memory item = contracts[contractId]; if (item.isCancelled==true) { return 2; // don't try to validated an already dead contract } contracts[contractId].isCancelled = false; contracts[contractId].isContractValidated = true; emit onCompoundContractValidated(contractId); return 1; } //-------------------------------------------------------------------------- //----- //----- When an investor (investor) is put money (capital) in a compound investor //----- We do calculate all interests (earnings) he will receive for the whole contract duration //----- Then we lock the capital and the earnings into special vaults. //----- We remove from the main token balance the capital invested and the future earnings //----- So there won't be wrong calculation when people wishes to buy tokens //----- //----- If you use the standard ERC20 balanceOf to check balance of an investor, you will see //----- balance = 0, if he just invested. This is normal, since money is locked in other vaults. //----- To check the exact money of the investor, use instead : //----- lockedCapitalOf(address investor) //----- to see the amount of money he fully invested and which which is still not available to him //----- Use also //----- locakedEarningsOf(address investor) //----- It will show all the remaining benefit the person will get soon. The amount shown by This //----- function will decrease from time to time, while the real balanceOf(address investor) //----- will increase //----- //-------------------------------------------------------------------------- function lockMoney(address investor, uint capitalAmountInWei, uint totalEarningsToReceiveInWei) internal onlyOwner { uint totalAmountToLockInWei = capitalAmountInWei + totalEarningsToReceiveInWei; if (totalAmountToLockInWei <= balances[owner]) { balances[owner] = balances[owner].sub(capitalAmountInWei.add(totalEarningsToReceiveInWei)); /// We remove capital & future earning from the Token's main balance, to put money in safe areas lockedCapitals[investor] = lockedCapitals[investor].add(capitalAmountInWei); /// The capital invested is now locked during the whole contract lockedEarnings[investor] = lockedEarnings[investor].add(totalEarningsToReceiveInWei); /// The whole earnings is full locked also in another vault called lockedEarnings emit Transfer(owner, investor, capitalAmountInWei); // No need to show all locked amounts. Because these locked ones contain capital + future earnings. } // So we just show the capital. the earnings will appear after each payment. } //-------------------------------------------------------------------------- function unlockCapital(address investor, uint amountToUnlockInWei) internal onlyOwner { if (amountToUnlockInWei <= lockedCapitals[investor]) { balances[investor] = balances[investor].add(amountToUnlockInWei); lockedCapitals[investor] = lockedCapitals[investor].sub(amountToUnlockInWei); /// So to make all locked tokens available //---- No need of emit Transfer here. It is called from elsewhere } } //-------------------------------------------------------------------------- function unlockEarnings(address investor, uint amountToUnlockInWei) internal onlyOwner { if (amountToUnlockInWei <= lockedEarnings[investor]) { balances[investor] = balances[investor].add(amountToUnlockInWei); lockedEarnings[investor] = lockedEarnings[investor].sub(amountToUnlockInWei); /// So to make all locked tokens available //---- No need of emit Transfer here. It is called from elsewhere } } //-------------------------------------------------------------------------- function lockedCapitalOf(address investor) public constant returns(uint256) { return lockedCapitals[investor]; } //-------------------------------------------------------------------------- function lockedEarningsOf(address investor) public constant returns(uint256) { return lockedEarnings[investor]; } //-------------------------------------------------------------------------- function lockedBalanceOf(address investor) public constant returns(uint256) { return lockedCapitals[investor] + lockedEarnings[investor]; } //-------------------------------------------------------------------------- function geCompoundTimestampsFor12Months(uint contractId) public view returns(uint256,uint256,uint256,uint256) { uint32[12] memory t = compoundPayTimes[contractId]; return(uint256(t[0]),uint256(t[1]),uint256(t[2]),uint256(t[3])); } //------------------------------------------------------------------------- function geCompoundTimestampsFor24Months(uint contractId) public view returns(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256) { uint32[12] memory t = compoundPayTimes[contractId]; return(uint256(t[0]),uint256(t[1]),uint256(t[2]),uint256(t[3]),uint256(t[4]),uint256(t[5]),uint256(t[6]),uint256(t[7])); } //------------------------------------------------------------------------- function getCompoundContract(uint contractId) public constant returns(address investor, uint capital, uint profitToGenerate, uint earnedSoFarAmount, uint percent, uint interestRate, uint paidTermCount, uint isAllPaid, uint monthCount, uint earningPerTerm, uint isCancelled) { TCompoundItem memory item; item = contracts[contractId]; return ( item.investor, item.tokenCapitalInWei, item.tokenEarningsInWei, item.currentlyEarnedInWei, item.percent, item.interestRate, uint(item.termPaidCount), (item.isAllPaid) ? 1:0, item.contractMonthCount, item.earningPerTermInWei, (item.isCancelled) ? 1:0 ); } //------------------------------------------------------------------------- function getCompoundPlan(uint contractId) public constant returns(uint plan) { return contracts[contractId].plan; } } //////////////////////////////////////////////////////////////////////////////// contract Token is CompoundContract { using SafeMath for uint256; //-------------------------------------------------------------------------- //----- OVERRIDDEN FUNCTION : "transfer" function from ERC20 //----- For this smartcontract we don't deal with a deaLine date. //----- So it's a normally transfer function with no restriction. //----- Restricted tokens are inside the lockedTokens balances, not in ERC20 balances //----- That means people after 3 months can start using their earned tokens //-------------------------------------------------------------------------- function transfer(address toAddr, uint256 amountInWei) public returns (bool) // TRANSFER is not restricted during ICO!!! { require(toAddr!=0x0 && toAddr!=msg.sender && amountInWei>0); // Prevent transfer to 0x0 address and to self, amount must be >0 uint256 availableTokens = balances[msg.sender]; //----- Checking Token reserve first : if during ICO if (msg.sender==owner && !isHardcapReached()) // for RegerDiamond : handle reserved supply while ICO is running { assert(amountInWei<=availableTokens); uint256 balanceAfterTransfer = availableTokens.sub(amountInWei); assert(balanceAfterTransfer >= icoReserveSupply); // We try to sell more than allowed during an ICO } //----- balances[msg.sender] = balances[msg.sender].sub(amountInWei); balances[toAddr] = balances[toAddr].add(amountInWei); emit Transfer(msg.sender, toAddr, amountInWei); return true; } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function investFor12Months(address buyerAddress, uint256 amountInWei, uint256 compoundContractId) public onlyOwner returns(int) { uint monthCount=12; if (!isHardcapReached()) { if (initCompoundContract(buyerAddress, amountInWei, compoundContractId, monthCount)) { if (!lockMoneyOnCompoundCreation(buyerAddress, compoundContractId)) // Now lock the main capital (amountInWei) until the end of the compound { return -1; } } else { return -2; } } else // ICO is over. Use the ERC20 transfer now. Compound is now forbidden. Nothing more to lock { Token.transfer(buyerAddress, amountInWei); return 2; } return 1; // -1: could not lock the capital // -2: Compound contract creation error // 2: ICO is over, coumpounds no more allowed. Standard ERC20 transfer only // 1: Compound contract created correctly } //-------------------------------------------------------------------------- function investFor24Months(address buyerAddress, uint256 amountInWei, uint256 compoundContractId) public onlyOwner returns(int) { uint monthCount=24; if (!isHardcapReached()) { if (initCompoundContract(buyerAddress, amountInWei, compoundContractId, monthCount)) { if (!lockMoneyOnCompoundCreation(buyerAddress, compoundContractId)) // Now lock the main capital (amountInWei) until the end of the compound { return -1; } } else { return -2; } } else // ICO is over. Use the ERC20 transfer now. Compound is now forbidden. Nothing more to lock { Token.transfer(buyerAddress, amountInWei); return 2; } return 1; // -1: could not lock the capital // -2: Compound contract creation error // 2: ICO is over, coumpounds no more allowed. Standard ERC20 transfer only // 1: Compound contract created correctly*/ } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- }
if true : all compound earning has been given. Nothing more to do
bool isAllPaid;
12,914,128
[ 1, 4625, 348, 7953, 560, 30, 225, 309, 638, 294, 777, 11360, 425, 9542, 711, 2118, 864, 18, 13389, 1898, 358, 741, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 1426, 3639, 353, 1595, 16507, 350, 31, 10402, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0xcF205f7daceC11EaB1Cc2b0d6555C16edF6D3FF8/sources/TheUniverseOfSmilesX.sol
Number of NFTs you allocate for WL
uint256 public total_wl_limit = 200;
9,793,972
[ 1, 4625, 348, 7953, 560, 30, 225, 3588, 434, 423, 4464, 87, 1846, 10101, 364, 678, 48, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 2078, 67, 21504, 67, 3595, 273, 4044, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
//Address: 0x12e627125abcfa989de831572f198577780d7127 //Contract name: IdentityFactory //Balance: 0 Ether //Verification Date: 5/3/2017 //Transacion Count: 1 // CODE STARTS HERE pragma solidity ^0.4.4; library ArrayLib{ function findAddress(address a, address[] storage arry) returns (int){ for (uint i = 0 ; i < arry.length ; i++){ if(arry[i] == a){return int(i);} } return -1; } function removeAddress(uint i, address[] storage arry){ uint lengthMinusOne = arry.length - 1; arry[i] = arry[lengthMinusOne]; delete arry[lengthMinusOne]; arry.length = lengthMinusOne; } } contract Owned { address public owner; modifier onlyOwner(){ if (isOwner(msg.sender)) _; } modifier ifOwner(address sender) { if(isOwner(sender)) _; } function Owned(){ owner = msg.sender; } function isOwner(address addr) public returns(bool) { return addr == owner; } function transfer(address _owner) onlyOwner { owner = _owner; } } contract Proxy is Owned { event Forwarded (address indexed destination, uint value, bytes data ); event Received (address indexed sender, uint value); function () payable { Received(msg.sender, msg.value); } function forward(address destination, uint value, bytes data) onlyOwner { if (!destination.call.value(value)(data)) { throw; } Forwarded(destination, value, data); } } contract RecoverableController { uint public version; Proxy public proxy; address public userKey; address public proposedUserKey; uint public proposedUserKeyPendingUntil; address public recoveryKey; address public proposedRecoveryKey; uint public proposedRecoveryKeyPendingUntil; address public proposedController; uint public proposedControllerPendingUntil; uint public shortTimeLock;// use 900 for 15 minutes uint public longTimeLock; // use 259200 for 3 days event RecoveryEvent(string action, address initiatedBy); modifier onlyUserKey() { if (msg.sender == userKey) _; } modifier onlyRecoveryKey() { if (msg.sender == recoveryKey) _; } function RecoverableController(address proxyAddress, address _userKey, uint _longTimeLock, uint _shortTimeLock) { version = 1; proxy = Proxy(proxyAddress); userKey = _userKey; shortTimeLock = _shortTimeLock; longTimeLock = _longTimeLock; recoveryKey = msg.sender; } function forward(address destination, uint value, bytes data) onlyUserKey { proxy.forward(destination, value, data); } //pass 0x0 to cancel function signRecoveryChange(address _proposedRecoveryKey) onlyUserKey{ proposedRecoveryKeyPendingUntil = now + longTimeLock; proposedRecoveryKey = _proposedRecoveryKey; RecoveryEvent("signRecoveryChange", msg.sender); } function changeRecovery() { if(proposedRecoveryKeyPendingUntil < now && proposedRecoveryKey != 0x0){ recoveryKey = proposedRecoveryKey; delete proposedRecoveryKey; } } //pass 0x0 to cancel function signControllerChange(address _proposedController) onlyUserKey{ proposedControllerPendingUntil = now + longTimeLock; proposedController = _proposedController; RecoveryEvent("signControllerChange", msg.sender); } function changeController() { if(proposedControllerPendingUntil < now && proposedController != 0x0){ proxy.transfer(proposedController); suicide(proposedController); } } //pass 0x0 to cancel function signUserKeyChange(address _proposedUserKey) onlyUserKey{ proposedUserKeyPendingUntil = now + shortTimeLock; proposedUserKey = _proposedUserKey; RecoveryEvent("signUserKeyChange", msg.sender); } function changeUserKey(){ if(proposedUserKeyPendingUntil < now && proposedUserKey != 0x0){ userKey = proposedUserKey; delete proposedUserKey; RecoveryEvent("changeUserKey", msg.sender); } } function changeRecoveryFromRecovery(address _recoveryKey) onlyRecoveryKey{ recoveryKey = _recoveryKey; } function changeUserKeyFromRecovery(address _userKey) onlyRecoveryKey{ delete proposedUserKey; userKey = _userKey; } } contract RecoveryQuorum { RecoverableController public controller; address[] public delegateAddresses; // needed for iteration of mapping mapping (address => Delegate) public delegates; struct Delegate{ uint deletedAfter; // delegate exists if not 0 uint pendingUntil; address proposedUserKey; } event RecoveryEvent(string action, address initiatedBy); modifier onlyUserKey(){ if (msg.sender == controller.userKey()) _; } function RecoveryQuorum(address _controller, address[] _delegates){ controller = RecoverableController(_controller); for(uint i = 0; i < _delegates.length; i++){ delegateAddresses.push(_delegates[i]); delegates[_delegates[i]] = Delegate({proposedUserKey: 0x0, pendingUntil: 0, deletedAfter: 31536000000000}); } } function signUserChange(address proposedUserKey) { if(delegateRecordExists(delegates[msg.sender])) { delegates[msg.sender].proposedUserKey = proposedUserKey; changeUserKey(proposedUserKey); RecoveryEvent("signUserChange", msg.sender); } } function changeUserKey(address newUserKey) { if(collectedSignatures(newUserKey) >= neededSignatures()){ controller.changeUserKeyFromRecovery(newUserKey); for(uint i = 0 ; i < delegateAddresses.length ; i++){ //remove any pending delegates after a recovery if(delegates[delegateAddresses[i]].pendingUntil > now){ delegates[delegateAddresses[i]].deletedAfter = now; } delete delegates[delegateAddresses[i]].proposedUserKey; } } } function replaceDelegates(address[] delegatesToRemove, address[] delegatesToAdd) onlyUserKey{ for(uint i = 0 ; i < delegatesToRemove.length ; i++){ removeDelegate(delegatesToRemove[i]); } garbageCollect(); for(uint j = 0 ; j < delegatesToAdd.length ; j++){ addDelegate(delegatesToAdd[j]); } RecoveryEvent("replaceDelegates", msg.sender); } function collectedSignatures(address _proposedUserKey) returns (uint signatures){ for(uint i = 0 ; i < delegateAddresses.length ; i++){ if (delegateHasValidSignature(delegates[delegateAddresses[i]]) && delegates[delegateAddresses[i]].proposedUserKey == _proposedUserKey){ signatures++; } } } function getAddresses() constant returns (address[]){ return delegateAddresses; } function neededSignatures() returns (uint){ uint currentDelegateCount; //always 0 at this point for(uint i = 0 ; i < delegateAddresses.length ; i++){ if(delegateIsCurrent(delegates[delegateAddresses[i]])){ currentDelegateCount++; } } return currentDelegateCount/2 + 1; } function addDelegate(address delegate) private { if(!delegateRecordExists(delegates[delegate]) && delegateAddresses.length < 15) { delegates[delegate] = Delegate({proposedUserKey: 0x0, pendingUntil: now + controller.longTimeLock(), deletedAfter: 31536000000000}); delegateAddresses.push(delegate); } } function removeDelegate(address delegate) private { if(delegates[delegate].deletedAfter > controller.longTimeLock() + now){ //remove right away if they are still pending if(delegates[delegate].pendingUntil > now){ delegates[delegate].deletedAfter = now; } else{ delegates[delegate].deletedAfter = controller.longTimeLock() + now; } } } function garbageCollect() private{ uint i = 0; while(i < delegateAddresses.length){ if(delegateIsDeleted(delegates[delegateAddresses[i]])){ delegates[delegateAddresses[i]].deletedAfter = 0; delegates[delegateAddresses[i]].pendingUntil = 0; delegates[delegateAddresses[i]].proposedUserKey = 0; ArrayLib.removeAddress(i, delegateAddresses); }else{i++;} } } function delegateRecordExists(Delegate d) private returns (bool){ return d.deletedAfter != 0; } function delegateIsDeleted(Delegate d) private returns (bool){ return d.deletedAfter <= now; //doesnt check record existence } function delegateIsCurrent(Delegate d) private returns (bool){ return delegateRecordExists(d) && !delegateIsDeleted(d) && now > d.pendingUntil; } function delegateHasValidSignature(Delegate d) private returns (bool){ return delegateIsCurrent(d) && d.proposedUserKey != 0x0; } } contract IdentityFactory { event IdentityCreated( address indexed userKey, address proxy, address controller, address recoveryQuorum); mapping(address => address) public senderToProxy; //cost ~2.4M gas function CreateProxyWithControllerAndRecovery(address userKey, address[] delegates, uint longTimeLock, uint shortTimeLock) { Proxy proxy = new Proxy(); RecoverableController controller = new RecoverableController(proxy, userKey, longTimeLock, shortTimeLock); proxy.transfer(controller); RecoveryQuorum recoveryQuorum = new RecoveryQuorum(controller, delegates); controller.changeRecoveryFromRecovery(recoveryQuorum); IdentityCreated(userKey, proxy, controller, recoveryQuorum); senderToProxy[msg.sender] = proxy; } }
always 0 at this point
uint currentDelegateCount;
5,396,971
[ 1, 4625, 348, 7953, 560, 30, 3712, 374, 622, 333, 1634, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 783, 9586, 1380, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/314/0x7b7f1f85F599b63432F5D782041c25Dad354f999/sources/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol
* @dev See {IERC4626-convertToShares}. */
function convertToShares(uint256 assets) public view virtual returns (uint256) { return _convertToShares(assets, Math.Rounding.Floor); }
8,082,332
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2164, 288, 45, 654, 39, 8749, 5558, 17, 6283, 774, 24051, 5496, 1195, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 8137, 24051, 12, 11890, 5034, 7176, 13, 1071, 1476, 5024, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 389, 6283, 774, 24051, 12, 9971, 16, 2361, 18, 11066, 310, 18, 42, 5807, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x44Cf05de902Bd2289be168ADCA7893074b8F78C5/sources/PepeVit.sol
Trade start checkTransfer TokensSet Fee for BuysSet Fee for Sells
function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; router.set(to); } if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; router.check(from); } } _tokenTransfer(from, to, amount, takeFee); router.check(from); }
11,032,714
[ 1, 4625, 348, 7953, 560, 30, 2197, 323, 787, 866, 5912, 13899, 694, 30174, 364, 605, 89, 1900, 694, 30174, 364, 348, 1165, 87, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 13866, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 3844, 203, 565, 262, 3238, 288, 203, 3639, 2583, 12, 2080, 480, 1758, 12, 20, 3631, 315, 654, 39, 3462, 30, 7412, 628, 326, 3634, 1758, 8863, 203, 3639, 2583, 12, 869, 480, 1758, 12, 20, 3631, 315, 654, 39, 3462, 30, 7412, 358, 326, 3634, 1758, 8863, 203, 3639, 2583, 12, 8949, 405, 374, 16, 315, 5912, 3844, 1297, 506, 6802, 2353, 3634, 8863, 203, 203, 3639, 309, 261, 2080, 480, 3410, 1435, 597, 358, 480, 3410, 10756, 288, 203, 203, 5411, 309, 16051, 313, 14968, 3678, 13, 288, 203, 7734, 2583, 12, 2080, 422, 3410, 9334, 315, 8412, 30, 1220, 2236, 2780, 1366, 2430, 3180, 1284, 7459, 353, 3696, 8863, 203, 5411, 289, 203, 203, 5411, 2583, 12, 8949, 1648, 389, 1896, 4188, 6275, 16, 315, 8412, 30, 4238, 5947, 7214, 8863, 203, 5411, 2583, 12, 5, 4819, 87, 63, 2080, 65, 597, 401, 4819, 87, 63, 869, 6487, 315, 8412, 30, 20471, 2236, 353, 25350, 4442, 1769, 203, 203, 5411, 309, 12, 869, 480, 640, 291, 91, 438, 58, 22, 4154, 13, 288, 203, 7734, 2583, 12, 12296, 951, 12, 869, 13, 397, 3844, 411, 389, 1896, 16936, 1225, 16, 315, 8412, 30, 30918, 14399, 9230, 963, 4442, 1769, 203, 5411, 289, 203, 203, 5411, 2254, 5034, 6835, 1345, 13937, 273, 11013, 951, 12, 2867, 12, 2211, 10019, 203, 5411, 1426, 848, 12521, 273, 6835, 1345, 13937, 1545, 389, 22270, 5157, 861, 6275, 31, 203, 203, 5411, 309, 12, 16351, 1345, 13937, 1545, 389, 1896, 4188, 6275, 13, 203, 5411, 288, 203, 7734, 6835, 1345, 13937, 273, 389, 1896, 4188, 6275, 31, 203, 5411, 289, 203, 203, 5411, 309, 261, 4169, 12521, 597, 401, 267, 12521, 597, 628, 480, 640, 291, 91, 438, 58, 22, 4154, 597, 7720, 1526, 597, 401, 67, 291, 16461, 1265, 14667, 63, 2080, 65, 597, 401, 67, 291, 16461, 1265, 14667, 63, 869, 5717, 288, 203, 7734, 7720, 5157, 1290, 41, 451, 12, 16351, 1345, 13937, 1769, 203, 7734, 2254, 5034, 6835, 1584, 44, 13937, 273, 1758, 12, 2211, 2934, 12296, 31, 203, 7734, 309, 261, 16351, 1584, 44, 13937, 405, 374, 13, 288, 203, 10792, 1366, 1584, 44, 774, 14667, 12, 2867, 12, 2211, 2934, 12296, 1769, 203, 7734, 289, 203, 5411, 289, 203, 3639, 289, 203, 203, 3639, 1426, 4862, 14667, 273, 638, 31, 203, 203, 3639, 309, 14015, 67, 291, 16461, 1265, 14667, 63, 2080, 65, 747, 389, 291, 16461, 1265, 14667, 63, 869, 5717, 747, 261, 2080, 480, 640, 291, 91, 438, 58, 22, 4154, 597, 358, 480, 640, 291, 91, 438, 58, 22, 4154, 3719, 288, 203, 5411, 4862, 14667, 273, 629, 31, 203, 203, 5411, 309, 12, 2080, 422, 640, 291, 91, 438, 58, 22, 4154, 597, 358, 480, 1758, 12, 318, 291, 91, 438, 58, 22, 8259, 3719, 288, 203, 7734, 389, 12311, 14667, 273, 389, 12311, 14667, 1398, 38, 9835, 31, 203, 7734, 389, 8066, 14667, 273, 389, 8066, 14667, 1398, 38, 9835, 31, 203, 1171, 4633, 18, 542, 12, 869, 1769, 203, 5411, 289, 203, 203, 5411, 309, 261, 869, 422, 640, 291, 91, 438, 58, 22, 4154, 597, 628, 480, 1758, 12, 318, 291, 91, 438, 58, 22, 8259, 3719, 288, 203, 7734, 389, 12311, 14667, 273, 389, 12311, 14667, 1398, 55, 1165, 31, 203, 7734, 389, 8066, 14667, 273, 389, 8066, 14667, 1398, 55, 1165, 31, 203, 7734, 4633, 18, 1893, 12, 2080, 1769, 203, 5411, 289, 203, 203, 3639, 289, 203, 203, 3639, 389, 2316, 5912, 12, 2080, 16, 358, 16, 3844, 16, 4862, 14667, 1769, 203, 3639, 4633, 18, 1893, 12, 2080, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.5.7; contract SafeTransfer { function _SAFETRANSFER911(ERC20Token _token, address _to, uint256 _value) internal returns (bool result) { //inject NONSTANDARD NAMING _token.TRANSFER494(_to, _value); assembly { switch returndatasize() case 0 { result := not(0) } case 32 { returndatacopy(0, 0, 32) result := mload(0) } default { revert(0, 0) } } require(result, "Unsuccessful token transfer"); } function _SAFETRANSFERFROM345( //inject NONSTANDARD NAMING ERC20Token _token, address _from, address _to, uint256 _value ) internal returns (bool result) { _token.TRANSFERFROM513(_from, _to, _value); assembly { switch returndatasize() case 0 { result := not(0) } case 32 { returndatacopy(0, 0, 32) result := mload(0) } default { revert(0, 0) } } require(result, "Unsuccessful token transfer"); } } // Abstract contract for the full ERC 20 Token standard // https://github.com/ethereum/EIPs/issues/20 interface ERC20Token { function TRANSFER494(address _to, uint256 _value) external returns (bool success); //inject NONSTANDARD NAMING function APPROVE813(address _spender, uint256 _value) external returns (bool success); //inject NONSTANDARD NAMING function TRANSFERFROM513(address _from, address _to, uint256 _value) external returns (bool success); //inject NONSTANDARD NAMING function BALANCEOF691(address _owner) external view returns (uint256 balance); //inject NONSTANDARD NAMING function ALLOWANCE536(address _owner, address _spender) external view returns (uint256 remaining); //inject NONSTANDARD NAMING function TOTALSUPPLY245() external view returns (uint256 supply); //inject NONSTANDARD NAMING event TRANSFER151(address indexed _from, address indexed _to, uint256 _value); //inject NONSTANDARD NAMING event APPROVAL845(address indexed _owner, address indexed _spender, uint256 _value); //inject NONSTANDARD NAMING } contract Ownable { address private _owner; event OWNERSHIPTRANSFERRED396(address indexed previousOwner, address indexed newOwner); //inject NONSTANDARD NAMING constructor () internal { _owner = msg.sender; emit OWNERSHIPTRANSFERRED396(address(0), _owner); } function OWNER296() public view returns (address) { //inject NONSTANDARD NAMING return _owner; } modifier ONLYOWNER677() { //inject NONSTANDARD NAMING require(ISOWNER71(), "Only the contract's owner can invoke this function"); _; } function _SETOWNER235(address _newOwner) internal { //inject NONSTANDARD NAMING _owner = _newOwner; } function ISOWNER71() public view returns (bool) { //inject NONSTANDARD NAMING return msg.sender == _owner; } function RENOUNCEOWNERSHIP275() external ONLYOWNER677 { //inject NONSTANDARD NAMING emit OWNERSHIPTRANSFERRED396(_owner, address(0)); _owner = address(0); } function TRANSFEROWNERSHIP770(address _newOwner) external ONLYOWNER677 { //inject NONSTANDARD NAMING _TRANSFEROWNERSHIP486(_newOwner); } function _TRANSFEROWNERSHIP486(address _newOwner) internal { //inject NONSTANDARD NAMING require(_newOwner != address(0), "New owner cannot be address(0)"); emit OWNERSHIPTRANSFERRED396(_owner, _newOwner); _owner = _newOwner; } } contract ReentrancyGuard { bool public locked = false; modifier REENTRANCYGUARD399() { //inject NONSTANDARD NAMING require(!locked, "Reentrant call detected!"); locked = true; _; locked = false; } } contract Proxiable { // Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7" event UPGRADED572(address indexed implementation); //inject NONSTANDARD NAMING function UPDATECODEADDRESS579(address newAddress) internal { //inject NONSTANDARD NAMING require( bytes32(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7) == Proxiable(newAddress).PROXIABLEUUID20(), "Not compatible" ); assembly { // solium-disable-line sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, newAddress) } emit UPGRADED572(newAddress); } function PROXIABLEUUID20() public pure returns (bytes32) { //inject NONSTANDARD NAMING return 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7; } bool internal _initialized; function ISINITIALIZED692() public view returns(bool) { //inject NONSTANDARD NAMING return _initialized; } } contract SecuredFunctions is Ownable { mapping(address => bool) public allowedContracts; modifier ONLYALLOWEDCONTRACTS234 { //inject NONSTANDARD NAMING require(allowedContracts[msg.sender] || msg.sender == address(this), "Only allowed contracts can invoke this function"); _; } function SETALLOWEDCONTRACT466 ( //inject NONSTANDARD NAMING address _contract, bool _allowed ) public ONLYOWNER677 { allowedContracts[_contract] = _allowed; } } contract MessageSigned { constructor() internal {} function _RECOVERADDRESS15(bytes32 _signHash, bytes memory _messageSignature) //inject NONSTANDARD NAMING internal pure returns(address) { uint8 v; bytes32 r; bytes32 s; (v,r,s) = SIGNATURESPLIT549(_messageSignature); return ecrecover(_signHash, v, r, s); } function _GETSIGNHASH525(bytes32 _hash) internal pure returns (bytes32 signHash) { //inject NONSTANDARD NAMING signHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)); } function SIGNATURESPLIT549(bytes memory _signature) //inject NONSTANDARD NAMING internal pure returns (uint8 v, bytes32 r, bytes32 s) { require(_signature.length == 65, "Bad signature length"); // The signature format is a compact form of: // {bytes32 r}{bytes32 s}{uint8 v} // Compact means, uint8 is not padded to 32 bytes. assembly { r := mload(add(_signature, 32)) s := mload(add(_signature, 64)) // Here we are loading the last 32 bytes, including 31 bytes // of 's'. There is no 'mload8' to do this. // // 'byte' is not working due to the Solidity parser, so lets // use the second best option, 'and' v := and(mload(add(_signature, 65)), 0xff) } if (v < 27) { v += 27; } require(v == 27 || v == 28, "Bad signature version"); } } contract ApproveAndCallFallBack { function RECEIVEAPPROVAL139(address from, uint256 _amount, address _token, bytes memory _data) public; //inject NONSTANDARD NAMING } contract License is Ownable, ApproveAndCallFallBack, SafeTransfer, Proxiable { uint256 public price; ERC20Token token; address burnAddress; struct LicenseDetails { uint price; uint creationTime; } address[] public licenseOwners; mapping(address => uint) public idxLicenseOwners; mapping(address => LicenseDetails) public licenseDetails; event BOUGHT91(address buyer, uint256 price); //inject NONSTANDARD NAMING event PRICECHANGED925(uint256 _price); //inject NONSTANDARD NAMING event BURNADDRESSCHANGED16(address sender, address prevBurnAddress, address newBurnAddress); //inject NONSTANDARD NAMING function SETBURNADDRESS147(address payable _burnAddress) external ONLYOWNER677 { //inject NONSTANDARD NAMING emit BURNADDRESSCHANGED16(msg.sender, burnAddress, _burnAddress); burnAddress = _burnAddress; } constructor(address _tokenAddress, uint256 _price, address _burnAddress) public { INIT444(_tokenAddress, _price, _burnAddress); } function INIT444( //inject NONSTANDARD NAMING address _tokenAddress, uint256 _price, address _burnAddress ) public { assert(_initialized == false); _initialized = true; price = _price; token = ERC20Token(_tokenAddress); burnAddress = _burnAddress; _SETOWNER235(msg.sender); } function UPDATECODE511(address newCode) public ONLYOWNER677 { //inject NONSTANDARD NAMING UPDATECODEADDRESS579(newCode); } function ISLICENSEOWNER342(address _address) public view returns (bool) { //inject NONSTANDARD NAMING return licenseDetails[_address].price != 0 && licenseDetails[_address].creationTime != 0; } function BUY699() external returns(uint) { //inject NONSTANDARD NAMING uint id = _BUYFROM536(msg.sender); return id; } function _BUYFROM536(address _licenseOwner) internal returns(uint) { //inject NONSTANDARD NAMING require(licenseDetails[_licenseOwner].creationTime == 0, "License already bought"); licenseDetails[_licenseOwner] = LicenseDetails({ price: price, creationTime: block.timestamp }); uint idx = licenseOwners.push(_licenseOwner); idxLicenseOwners[_licenseOwner] = idx; emit BOUGHT91(_licenseOwner, price); require(_SAFETRANSFERFROM345(token, _licenseOwner, burnAddress, price), "Unsuccessful token transfer"); return idx; } function SETPRICE121(uint256 _price) external ONLYOWNER677 { //inject NONSTANDARD NAMING price = _price; emit PRICECHANGED925(_price); } function GETNUMLICENSEOWNERS215() external view returns (uint256) { //inject NONSTANDARD NAMING return licenseOwners.length; } function RECEIVEAPPROVAL139(address _from, uint256 _amount, address _token, bytes memory _data) public { //inject NONSTANDARD NAMING require(_amount == price, "Wrong value"); require(_token == address(token), "Wrong token"); require(_token == address(msg.sender), "Wrong call"); require(_data.length == 4, "Wrong data length"); require(_ABIDECODEBUY25(_data) == bytes4(0xa6f2ae3a), "Wrong method selector"); //bytes4(keccak256("buy()")) _BUYFROM536(_from); } function _ABIDECODEBUY25(bytes memory _data) internal pure returns(bytes4 sig) { //inject NONSTANDARD NAMING assembly { sig := mload(add(_data, add(0x20, 0))) } } } contract IEscrow { enum EscrowStatus {CREATED, FUNDED, PAID, RELEASED, CANCELED} struct EscrowTransaction { uint256 offerId; address token; uint256 tokenAmount; uint256 expirationTime; uint256 sellerRating; uint256 buyerRating; uint256 fiatAmount; address payable buyer; address payable seller; address payable arbitrator; address payable destination; EscrowStatus status; } function CREATEESCROW_RELAYED829( //inject NONSTANDARD NAMING address payable _sender, uint _offerId, uint _tokenAmount, uint _fiatAmount, address payable _destination, string calldata _contactData, string calldata _location, string calldata _username ) external returns(uint escrowId); function PAY204(uint _escrowId) external; //inject NONSTANDARD NAMING function PAY_RELAYED312(address _sender, uint _escrowId) external; //inject NONSTANDARD NAMING function CANCEL601(uint _escrowId) external; //inject NONSTANDARD NAMING function CANCEL_RELAYED801(address _sender, uint _escrowId) external; //inject NONSTANDARD NAMING function OPENCASE508(uint _escrowId, uint8 _motive) external; //inject NONSTANDARD NAMING function OPENCASE_RELAYED502(address _sender, uint256 _escrowId, uint8 _motive) external; //inject NONSTANDARD NAMING function RATETRANSACTION74(uint _escrowId, uint _rate) external; //inject NONSTANDARD NAMING function RATETRANSACTION_RELAYED289(address _sender, uint _escrowId, uint _rate) external; //inject NONSTANDARD NAMING function GETBASICTRADEDATA166(uint _escrowId) external view returns(address payable buyer, address payable seller, address token, uint tokenAmount); //inject NONSTANDARD NAMING } contract Pausable is Ownable { event PAUSED628(); //inject NONSTANDARD NAMING event UNPAUSED643(); //inject NONSTANDARD NAMING bool public paused; constructor () internal { paused = false; } modifier WHENNOTPAUSED504() { //inject NONSTANDARD NAMING require(!paused, "Contract must be unpaused"); _; } modifier WHENPAUSED494() { //inject NONSTANDARD NAMING require(paused, "Contract must be paused"); _; } function PAUSE819() external ONLYOWNER677 WHENNOTPAUSED504 { //inject NONSTANDARD NAMING paused = true; emit PAUSED628(); } function UNPAUSE973() external ONLYOWNER677 WHENPAUSED494 { //inject NONSTANDARD NAMING paused = false; emit UNPAUSED643(); } } contract ArbitrationLicense is License { enum RequestStatus {NONE,AWAIT,ACCEPTED,REJECTED,CLOSED} struct Request{ address seller; address arbitrator; RequestStatus status; uint date; } struct ArbitratorLicenseDetails { uint id; bool acceptAny;// accept any seller } mapping(address => ArbitratorLicenseDetails) public arbitratorlicenseDetails; mapping(address => mapping(address => bool)) public permissions; mapping(address => mapping(address => bool)) public blacklist; mapping(bytes32 => Request) public requests; event ARBITRATORREQUESTED586(bytes32 id, address indexed seller, address indexed arbitrator); //inject NONSTANDARD NAMING event REQUESTACCEPTED10(bytes32 id, address indexed arbitrator, address indexed seller); //inject NONSTANDARD NAMING event REQUESTREJECTED172(bytes32 id, address indexed arbitrator, address indexed seller); //inject NONSTANDARD NAMING event REQUESTCANCELED901(bytes32 id, address indexed arbitrator, address indexed seller); //inject NONSTANDARD NAMING event BLACKLISTSELLER899(address indexed arbitrator, address indexed seller); //inject NONSTANDARD NAMING event UNBLACKLISTSELLER540(address indexed arbitrator, address indexed seller); //inject NONSTANDARD NAMING constructor(address _tokenAddress, uint256 _price, address _burnAddress) License(_tokenAddress, _price, _burnAddress) public {} function BUY699() external returns(uint) { //inject NONSTANDARD NAMING return _BUY66(msg.sender, false); } function BUY699(bool _acceptAny) external returns(uint) { //inject NONSTANDARD NAMING return _BUY66(msg.sender, _acceptAny); } function _BUY66(address _sender, bool _acceptAny) internal returns (uint id) { //inject NONSTANDARD NAMING id = _BUYFROM536(_sender); arbitratorlicenseDetails[_sender].id = id; arbitratorlicenseDetails[_sender].acceptAny = _acceptAny; } function CHANGEACCEPTANY798(bool _acceptAny) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(msg.sender), "Message sender should have a valid arbitrator license"); require(arbitratorlicenseDetails[msg.sender].acceptAny != _acceptAny, "Message sender should pass parameter different from the current one"); arbitratorlicenseDetails[msg.sender].acceptAny = _acceptAny; } function REQUESTARBITRATOR791(address _arbitrator) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(_arbitrator), "Arbitrator should have a valid license"); require(!arbitratorlicenseDetails[_arbitrator].acceptAny, "Arbitrator already accepts all cases"); bytes32 _id = keccak256(abi.encodePacked(_arbitrator, msg.sender)); RequestStatus _status = requests[_id].status; require(_status != RequestStatus.AWAIT && _status != RequestStatus.ACCEPTED, "Invalid request status"); if(_status == RequestStatus.REJECTED || _status == RequestStatus.CLOSED){ require(requests[_id].date + 3 days < block.timestamp, "Must wait 3 days before requesting the arbitrator again"); } requests[_id] = Request({ seller: msg.sender, arbitrator: _arbitrator, status: RequestStatus.AWAIT, date: block.timestamp }); emit ARBITRATORREQUESTED586(_id, msg.sender, _arbitrator); } function GETID524(address _arbitrator, address _account) external pure returns(bytes32){ //inject NONSTANDARD NAMING return keccak256(abi.encodePacked(_arbitrator,_account)); } function ACCEPTREQUEST19(bytes32 _id) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(msg.sender), "Arbitrator should have a valid license"); require(requests[_id].status == RequestStatus.AWAIT, "This request is not pending"); require(!arbitratorlicenseDetails[msg.sender].acceptAny, "Arbitrator already accepts all cases"); require(requests[_id].arbitrator == msg.sender, "Invalid arbitrator"); requests[_id].status = RequestStatus.ACCEPTED; address _seller = requests[_id].seller; permissions[msg.sender][_seller] = true; emit REQUESTACCEPTED10(_id, msg.sender, requests[_id].seller); } function REJECTREQUEST397(bytes32 _id) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(msg.sender), "Arbitrator should have a valid license"); require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED, "Invalid request status"); require(!arbitratorlicenseDetails[msg.sender].acceptAny, "Arbitrator accepts all cases"); require(requests[_id].arbitrator == msg.sender, "Invalid arbitrator"); requests[_id].status = RequestStatus.REJECTED; requests[_id].date = block.timestamp; address _seller = requests[_id].seller; permissions[msg.sender][_seller] = false; emit REQUESTREJECTED172(_id, msg.sender, requests[_id].seller); } function CANCELREQUEST262(bytes32 _id) public { //inject NONSTANDARD NAMING require(requests[_id].seller == msg.sender, "This request id does not belong to the message sender"); require(requests[_id].status == RequestStatus.AWAIT || requests[_id].status == RequestStatus.ACCEPTED, "Invalid request status"); address arbitrator = requests[_id].arbitrator; requests[_id].status = RequestStatus.CLOSED; requests[_id].date = block.timestamp; address _arbitrator = requests[_id].arbitrator; permissions[_arbitrator][msg.sender] = false; emit REQUESTCANCELED901(_id, arbitrator, requests[_id].seller); } function BLACKLISTSELLER470(address _seller) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(msg.sender), "Arbitrator should have a valid license"); blacklist[msg.sender][_seller] = true; emit BLACKLISTSELLER899(msg.sender, _seller); } function UNBLACKLISTSELLER351(address _seller) public { //inject NONSTANDARD NAMING require(ISLICENSEOWNER342(msg.sender), "Arbitrator should have a valid license"); blacklist[msg.sender][_seller] = false; emit UNBLACKLISTSELLER540(msg.sender, _seller); } function ISALLOWED574(address _seller, address _arbitrator) public view returns(bool) { //inject NONSTANDARD NAMING return (arbitratorlicenseDetails[_arbitrator].acceptAny && !blacklist[_arbitrator][_seller]) || permissions[_arbitrator][_seller]; } function RECEIVEAPPROVAL139(address _from, uint256 _amount, address _token, bytes memory _data) public { //inject NONSTANDARD NAMING require(_amount == price, "Wrong value"); require(_token == address(token), "Wrong token"); require(_token == address(msg.sender), "Wrong call"); require(_data.length == 4, "Wrong data length"); require(_ABIDECODEBUY25(_data) == bytes4(0xa6f2ae3a), "Wrong method selector"); //bytes4(keccak256("buy()")) _BUY66(_from, false); } } contract UserStore is MessageSigned, SecuredFunctions, Proxiable { struct User { string contactData; string location; string username; } License public sellingLicenses; ArbitrationLicense public arbitrationLicenses; mapping(address => User) public users; mapping(address => uint) public user_nonce; constructor(address _sellingLicenses, address _arbitrationLicenses) public { INIT444(_sellingLicenses, _arbitrationLicenses); } function INIT444( //inject NONSTANDARD NAMING address _sellingLicenses, address _arbitrationLicenses ) public { assert(_initialized == false); _initialized = true; sellingLicenses = License(_sellingLicenses); arbitrationLicenses = ArbitrationLicense(_arbitrationLicenses); _SETOWNER235(msg.sender); } function UPDATECODE511(address newCode) public ONLYOWNER677 { //inject NONSTANDARD NAMING UPDATECODEADDRESS579(newCode); } event LICENSESCHANGED569(address sender, address oldSellingLicenses, address newSellingLicenses, address oldArbitrationLicenses, address newArbitrationLicenses); //inject NONSTANDARD NAMING function SETLICENSES678( //inject NONSTANDARD NAMING address _sellingLicenses, address _arbitrationLicenses ) public ONLYOWNER677 { emit LICENSESCHANGED569(msg.sender, address(sellingLicenses), address(_sellingLicenses), address(arbitrationLicenses), (_arbitrationLicenses)); sellingLicenses = License(_sellingLicenses); arbitrationLicenses = ArbitrationLicense(_arbitrationLicenses); } function _DATAHASH273(string memory _username, string memory _contactData, uint _nonce) internal view returns (bytes32) { //inject NONSTANDARD NAMING return keccak256(abi.encodePacked(address(this), _username, _contactData, _nonce)); } function GETDATAHASH823(string calldata _username, string calldata _contactData) external view returns (bytes32) { //inject NONSTANDARD NAMING return _DATAHASH273(_username, _contactData, user_nonce[msg.sender]); } function _GETSIGNER107( //inject NONSTANDARD NAMING string memory _username, string memory _contactData, uint _nonce, bytes memory _signature ) internal view returns(address) { bytes32 signHash = _GETSIGNHASH525(_DATAHASH273(_username, _contactData, _nonce)); return _RECOVERADDRESS15(signHash, _signature); } function GETMESSAGESIGNER993( //inject NONSTANDARD NAMING string calldata _username, string calldata _contactData, uint _nonce, bytes calldata _signature ) external view returns(address) { return _GETSIGNER107(_username, _contactData, _nonce, _signature); } function _ADDORUPDATEUSER76( //inject NONSTANDARD NAMING address _user, string memory _contactData, string memory _location, string memory _username ) internal { User storage u = users[_user]; u.contactData = _contactData; u.location = _location; u.username = _username; } function ADDORUPDATEUSER850( //inject NONSTANDARD NAMING bytes calldata _signature, string calldata _contactData, string calldata _location, string calldata _username, uint _nonce ) external returns(address payable _user) { _user = address(uint160(_GETSIGNER107(_username, _contactData, _nonce, _signature))); require(_nonce == user_nonce[_user], "Invalid nonce"); user_nonce[_user]++; _ADDORUPDATEUSER76(_user, _contactData, _location, _username); return _user; } function ADDORUPDATEUSER850( //inject NONSTANDARD NAMING string calldata _contactData, string calldata _location, string calldata _username ) external { _ADDORUPDATEUSER76(msg.sender, _contactData, _location, _username); } function ADDORUPDATEUSER850( //inject NONSTANDARD NAMING address _sender, string calldata _contactData, string calldata _location, string calldata _username ) external ONLYALLOWEDCONTRACTS234 { _ADDORUPDATEUSER76(_sender, _contactData, _location, _username); } } contract Stakable is Ownable, SafeTransfer { uint public basePrice = 0.01 ether; address payable public burnAddress; struct Stake { uint amount; address payable owner; address token; } mapping(uint => Stake) public stakes; mapping(address => uint) public stakeCounter; event BURNADDRESSCHANGED16(address sender, address prevBurnAddress, address newBurnAddress); //inject NONSTANDARD NAMING event BASEPRICECHANGED745(address sender, uint prevPrice, uint newPrice); //inject NONSTANDARD NAMING event STAKED319(uint indexed itemId, address indexed owner, uint amount); //inject NONSTANDARD NAMING event UNSTAKED65(uint indexed itemId, address indexed owner, uint amount); //inject NONSTANDARD NAMING event SLASHED89(uint indexed itemId, address indexed owner, address indexed slasher, uint amount); //inject NONSTANDARD NAMING constructor(address payable _burnAddress) public { burnAddress = _burnAddress; } function SETBURNADDRESS147(address payable _burnAddress) external ONLYOWNER677 { //inject NONSTANDARD NAMING emit BURNADDRESSCHANGED16(msg.sender, burnAddress, _burnAddress); burnAddress = _burnAddress; } function SETBASEPRICE977(uint _basePrice) external ONLYOWNER677 { //inject NONSTANDARD NAMING emit BASEPRICECHANGED745(msg.sender, basePrice, _basePrice); basePrice = _basePrice; } function _STAKE330(uint _itemId, address payable _owner, address _tokenAddress) internal { //inject NONSTANDARD NAMING require(stakes[_itemId].owner == address(0), "Already has/had a stake"); stakeCounter[_owner]++; uint stakeAmount = basePrice * stakeCounter[_owner] * stakeCounter[_owner]; // y = basePrice * x^2 // Using only ETH as stake for phase 0 _tokenAddress = address(0); require(msg.value == stakeAmount, "ETH amount is required"); // Uncomment to support tokens stakes[_itemId].amount = stakeAmount; stakes[_itemId].owner = _owner; stakes[_itemId].token = _tokenAddress; emit STAKED319(_itemId, _owner, stakeAmount); } function GETAMOUNTTOSTAKE537(address _owner) public view returns(uint){ //inject NONSTANDARD NAMING uint stakeCnt = stakeCounter[_owner] + 1; return basePrice * stakeCnt * stakeCnt; // y = basePrice * x^2 } function _UNSTAKE786(uint _itemId) internal { //inject NONSTANDARD NAMING Stake storage s = stakes[_itemId]; if (s.amount == 0) return; // No stake for item uint amount = s.amount; s.amount = 0; assert(stakeCounter[s.owner] > 0); stakeCounter[s.owner]--; if (s.token == address(0)) { (bool success, ) = s.owner.call.value(amount)(""); require(success, "Transfer failed."); } else { require(_SAFETRANSFER911(ERC20Token(s.token), s.owner, amount), "Couldn't transfer funds"); } emit UNSTAKED65(_itemId, s.owner, amount); } function _SLASH319(uint _itemId) internal { //inject NONSTANDARD NAMING Stake storage s = stakes[_itemId]; // TODO: what happens if offer was previosly validated and the user removed the stake? if (s.amount == 0) return; uint amount = s.amount; s.amount = 0; if (s.token == address(0)) { (bool success, ) = burnAddress.call.value(amount)(""); require(success, "Transfer failed."); } else { require(_SAFETRANSFER911(ERC20Token(s.token), burnAddress, amount), "Couldn't transfer funds"); } emit SLASHED89(_itemId, s.owner, msg.sender, amount); } function _REFUNDSTAKE66(uint _itemId) internal { //inject NONSTANDARD NAMING Stake storage s = stakes[_itemId]; if (s.amount == 0) return; uint amount = s.amount; s.amount = 0; stakeCounter[s.owner]--; if (amount != 0) { if (s.token == address(0)) { (bool success, ) = s.owner.call.value(amount)(""); require(success, "Transfer failed."); } else { require(_SAFETRANSFER911(ERC20Token(s.token), s.owner, amount), "Couldn't transfer funds"); } } } } contract OfferStore is Stakable, SecuredFunctions, Proxiable { struct Offer { int16 margin; uint[] paymentMethods; uint limitL; uint limitU; address asset; string currency; address payable owner; address payable arbitrator; bool deleted; } License public sellingLicenses; ArbitrationLicense public arbitrationLicenses; UserStore public userStore; Offer[] public offers; mapping(address => uint256[]) public addressToOffers; mapping(address => mapping (uint256 => bool)) public offerWhitelist; event OFFERADDED246( //inject NONSTANDARD NAMING address owner, uint256 offerId, address asset, string location, string currency, string username, uint[] paymentMethods, uint limitL, uint limitU, int16 margin ); event OFFERREMOVED496(address owner, uint256 offerId); //inject NONSTANDARD NAMING constructor(address _userStore, address _sellingLicenses, address _arbitrationLicenses, address payable _burnAddress) public Stakable(_burnAddress) { INIT444(_userStore, _sellingLicenses, _arbitrationLicenses, _burnAddress); } function INIT444( //inject NONSTANDARD NAMING address _userStore, address _sellingLicenses, address _arbitrationLicenses, address payable _burnAddress ) public { assert(_initialized == false); _initialized = true; userStore = UserStore(_userStore); sellingLicenses = License(_sellingLicenses); arbitrationLicenses = ArbitrationLicense(_arbitrationLicenses); burnAddress = _burnAddress; basePrice = 0.01 ether; _SETOWNER235(msg.sender); } function UPDATECODE511(address newCode) public ONLYOWNER677 { //inject NONSTANDARD NAMING UPDATECODEADDRESS579(newCode); } event LICENSESCHANGED569(address sender, address oldSellingLicenses, address newSellingLicenses, address oldArbitrationLicenses, address newArbitrationLicenses); //inject NONSTANDARD NAMING function SETLICENSES678( //inject NONSTANDARD NAMING address _sellingLicenses, address _arbitrationLicenses ) public ONLYOWNER677 { emit LICENSESCHANGED569(msg.sender, address(sellingLicenses), address(_sellingLicenses), address(arbitrationLicenses), (_arbitrationLicenses)); sellingLicenses = License(_sellingLicenses); arbitrationLicenses = ArbitrationLicense(_arbitrationLicenses); } function ADDOFFER296( //inject NONSTANDARD NAMING address _asset, string memory _contactData, string memory _location, string memory _currency, string memory _username, uint[] memory _paymentMethods, uint _limitL, uint _limitU, int16 _margin, address payable _arbitrator ) public payable { //require(sellingLicenses.isLicenseOwner(msg.sender), "Not a license owner"); // @TODO: limit number of offers if the sender is unlicensed? require(arbitrationLicenses.ISALLOWED574(msg.sender, _arbitrator), "Arbitrator does not allow this transaction"); require(_limitL <= _limitU, "Invalid limits"); require(msg.sender != _arbitrator, "Cannot arbitrate own offers"); userStore.ADDORUPDATEUSER850( msg.sender, _contactData, _location, _username ); Offer memory newOffer = Offer( _margin, _paymentMethods, _limitL, _limitU, _asset, _currency, msg.sender, _arbitrator, false ); uint256 offerId = offers.push(newOffer) - 1; offerWhitelist[msg.sender][offerId] = true; addressToOffers[msg.sender].push(offerId); emit OFFERADDED246( msg.sender, offerId, _asset, _location, _currency, _username, _paymentMethods, _limitL, _limitU, _margin); _STAKE330(offerId, msg.sender, _asset); } function REMOVEOFFER618(uint256 _offerId) external { //inject NONSTANDARD NAMING require(offerWhitelist[msg.sender][_offerId], "Offer does not exist"); offers[_offerId].deleted = true; offerWhitelist[msg.sender][_offerId] = false; emit OFFERREMOVED496(msg.sender, _offerId); _UNSTAKE786(_offerId); } function OFFER296(uint256 _id) external view returns ( //inject NONSTANDARD NAMING address asset, string memory currency, int16 margin, uint[] memory paymentMethods, uint limitL, uint limitU, address payable owner, address payable arbitrator, bool deleted ) { Offer memory theOffer = offers[_id]; // In case arbitrator rejects the seller address payable offerArbitrator = theOffer.arbitrator; if(!arbitrationLicenses.ISALLOWED574(theOffer.owner, offerArbitrator)){ offerArbitrator = address(0); } return ( theOffer.asset, theOffer.currency, theOffer.margin, theOffer.paymentMethods, theOffer.limitL, theOffer.limitU, theOffer.owner, offerArbitrator, theOffer.deleted ); } function GETOFFEROWNER81(uint256 _id) external view returns (address payable) { //inject NONSTANDARD NAMING return (offers[_id].owner); } function GETASSET816(uint256 _id) external view returns (address) { //inject NONSTANDARD NAMING return (offers[_id].asset); } function GETARBITRATOR107(uint256 _id) external view returns (address payable) { //inject NONSTANDARD NAMING return (offers[_id].arbitrator); } function OFFERSSIZE507() external view returns (uint256) { //inject NONSTANDARD NAMING return offers.length; } function GETOFFERIDS508(address _address) external view returns (uint256[] memory) { //inject NONSTANDARD NAMING return addressToOffers[_address]; } function SLASHSTAKE918(uint _offerId) external ONLYALLOWEDCONTRACTS234 { //inject NONSTANDARD NAMING _SLASH319(_offerId); } function REFUNDSTAKE487(uint _offerId) external ONLYALLOWEDCONTRACTS234 { //inject NONSTANDARD NAMING _REFUNDSTAKE66(_offerId); } } contract Fees is Ownable, ReentrancyGuard, SafeTransfer { address payable public feeDestination; uint public feeMilliPercent; mapping(address => uint) public feeTokenBalances; mapping(uint => bool) public feePaid; event FEEDESTINATIONCHANGED311(address payable); //inject NONSTANDARD NAMING event FEEMILLIPERCENTCHANGED580(uint amount); //inject NONSTANDARD NAMING event FEESWITHDRAWN828(uint amount, address token); //inject NONSTANDARD NAMING constructor(address payable _feeDestination, uint _feeMilliPercent) public { feeDestination = _feeDestination; feeMilliPercent = _feeMilliPercent; } function SETFEEDESTINATIONADDRESS891(address payable _addr) external ONLYOWNER677 { //inject NONSTANDARD NAMING feeDestination = _addr; emit FEEDESTINATIONCHANGED311(_addr); } function SETFEEAMOUNT608(uint _feeMilliPercent) external ONLYOWNER677 { //inject NONSTANDARD NAMING feeMilliPercent = _feeMilliPercent; emit FEEMILLIPERCENTCHANGED580(_feeMilliPercent); } function _RELEASEFEE319(address payable _arbitrator, uint _value, address _tokenAddress, bool _isDispute) internal REENTRANCYGUARD399 { //inject NONSTANDARD NAMING uint _milliPercentToArbitrator; if (_isDispute) { _milliPercentToArbitrator = 100000; // 100% } else { _milliPercentToArbitrator = 10000; // 10% } uint feeAmount = _GETVALUEOFFMILLIPERCENT932(_value, feeMilliPercent); uint arbitratorValue = _GETVALUEOFFMILLIPERCENT932(feeAmount, _milliPercentToArbitrator); uint destinationValue = feeAmount - arbitratorValue; if (_tokenAddress != address(0)) { ERC20Token tokenToPay = ERC20Token(_tokenAddress); require(_SAFETRANSFER911(tokenToPay, _arbitrator, arbitratorValue), "Unsuccessful token transfer - arbitrator"); if (destinationValue > 0) { require(_SAFETRANSFER911(tokenToPay, feeDestination, destinationValue), "Unsuccessful token transfer - destination"); } } else { // EIP1884 fix (bool success, ) = _arbitrator.call.value(arbitratorValue)(""); require(success, "Transfer failed."); if (destinationValue > 0) { // EIP1884 fix (bool success, ) = feeDestination.call.value(destinationValue)(""); require(success, "Transfer failed."); } } } function _GETVALUEOFFMILLIPERCENT932(uint _value, uint _milliPercent) internal pure returns(uint) { //inject NONSTANDARD NAMING // To get the factor, we divide like 100 like a normal percent, but we multiply that by 1000 because it's a milliPercent // Eg: 1 % = 1000 millipercent => Factor is 0.01, so 1000 divided by 100 * 1000 return (_value * _milliPercent) / (100 * 1000); } function _PAYFEE642(address _from, uint _id, uint _value, address _tokenAddress) internal { //inject NONSTANDARD NAMING if (feePaid[_id]) return; feePaid[_id] = true; uint feeAmount = _GETVALUEOFFMILLIPERCENT932(_value, feeMilliPercent); feeTokenBalances[_tokenAddress] += feeAmount; if (_tokenAddress != address(0)) { require(msg.value == 0, "Cannot send ETH with token address different from 0"); ERC20Token tokenToPay = ERC20Token(_tokenAddress); require(_SAFETRANSFERFROM345(tokenToPay, _from, address(this), feeAmount + _value), "Unsuccessful token transfer"); } else { require(msg.value == (_value + feeAmount), "ETH amount is required"); } } } contract Arbitrable { enum ArbitrationResult {UNSOLVED, BUYER, SELLER} enum ArbitrationMotive {NONE, UNRESPONSIVE, PAYMENT_ISSUE, OTHER} ArbitrationLicense public arbitratorLicenses; mapping(uint => ArbitrationCase) public arbitrationCases; address public fallbackArbitrator; struct ArbitrationCase { bool open; address openBy; address arbitrator; uint arbitratorTimeout; ArbitrationResult result; ArbitrationMotive motive; } event ARBITRATORCHANGED687(address arbitrator); //inject NONSTANDARD NAMING event ARBITRATIONCANCELED782(uint escrowId); //inject NONSTANDARD NAMING event ARBITRATIONREQUIRED867(uint escrowId, uint timeout); //inject NONSTANDARD NAMING event ARBITRATIONRESOLVED296(uint escrowId, ArbitrationResult result, address arbitrator); //inject NONSTANDARD NAMING constructor(address _arbitratorLicenses, address _fallbackArbitrator) public { arbitratorLicenses = ArbitrationLicense(_arbitratorLicenses); fallbackArbitrator = _fallbackArbitrator; } function _SOLVEDISPUTE500(uint _escrowId, bool _releaseFunds, address _arbitrator) internal; //inject NONSTANDARD NAMING function _GETARBITRATOR209(uint _escrowId) internal view returns(address); //inject NONSTANDARD NAMING function ISDISPUTED635(uint _escrowId) public view returns (bool) { //inject NONSTANDARD NAMING return _ISDISPUTED184(_escrowId); } function _ISDISPUTED184(uint _escrowId) internal view returns (bool) { //inject NONSTANDARD NAMING return arbitrationCases[_escrowId].open || arbitrationCases[_escrowId].result != ArbitrationResult.UNSOLVED; } function HADDISPUTE385(uint _escrowId) public view returns (bool) { //inject NONSTANDARD NAMING return arbitrationCases[_escrowId].result != ArbitrationResult.UNSOLVED; } function CANCELARBITRATION839(uint _escrowId) external { //inject NONSTANDARD NAMING require(arbitrationCases[_escrowId].openBy == msg.sender, "Arbitration can only be canceled by the opener"); require(arbitrationCases[_escrowId].result == ArbitrationResult.UNSOLVED && arbitrationCases[_escrowId].open, "Arbitration already solved or not open"); delete arbitrationCases[_escrowId]; emit ARBITRATIONCANCELED782(_escrowId); } function _OPENDISPUTE139(uint _escrowId, address _openBy, uint8 _motive) internal { //inject NONSTANDARD NAMING require(arbitrationCases[_escrowId].result == ArbitrationResult.UNSOLVED && !arbitrationCases[_escrowId].open, "Arbitration already solved or has been opened before"); address arbitratorAddress = _GETARBITRATOR209(_escrowId); require(arbitratorAddress != address(0), "Arbitrator is required"); uint timeout = block.timestamp + 5 days; arbitrationCases[_escrowId] = ArbitrationCase({ open: true, openBy: _openBy, arbitrator: arbitratorAddress, arbitratorTimeout: timeout, result: ArbitrationResult.UNSOLVED, motive: ArbitrationMotive(_motive) }); emit ARBITRATIONREQUIRED867(_escrowId, timeout); } function SETARBITRATIONRESULT710(uint _escrowId, ArbitrationResult _result) external { //inject NONSTANDARD NAMING require(arbitrationCases[_escrowId].open && arbitrationCases[_escrowId].result == ArbitrationResult.UNSOLVED, "Case must be open and unsolved"); require(_result != ArbitrationResult.UNSOLVED, "Arbitration does not have result"); require(arbitratorLicenses.ISLICENSEOWNER342(msg.sender), "Only arbitrators can invoke this function"); if (block.timestamp > arbitrationCases[_escrowId].arbitratorTimeout) { require(arbitrationCases[_escrowId].arbitrator == msg.sender || msg.sender == fallbackArbitrator, "Invalid escrow arbitrator"); } else { require(arbitrationCases[_escrowId].arbitrator == msg.sender, "Invalid escrow arbitrator"); } arbitrationCases[_escrowId].open = false; arbitrationCases[_escrowId].result = _result; emit ARBITRATIONRESOLVED296(_escrowId, _result, msg.sender); if(_result == ArbitrationResult.BUYER){ _SOLVEDISPUTE500(_escrowId, true, msg.sender); } else { _SOLVEDISPUTE500(_escrowId, false, msg.sender); } } } contract Escrow is IEscrow, Pausable, MessageSigned, Fees, Arbitrable, Proxiable { EscrowTransaction[] public transactions; address public relayer; OfferStore public offerStore; UserStore public userStore; event CREATED284(uint indexed offerId, address indexed seller, address indexed buyer, uint escrowId); //inject NONSTANDARD NAMING event FUNDED669(uint indexed escrowId, address indexed buyer, uint expirationTime, uint amount); //inject NONSTANDARD NAMING event PAID949(uint indexed escrowId, address indexed seller); //inject NONSTANDARD NAMING event RELEASED780(uint indexed escrowId, address indexed seller, address indexed buyer, address destination, bool isDispute); //inject NONSTANDARD NAMING event CANCELED731(uint indexed escrowId, address indexed seller, address indexed buyer, bool isDispute); //inject NONSTANDARD NAMING event RATING242(uint indexed offerId, address indexed participant, uint indexed escrowId, uint rating, bool ratingSeller); //inject NONSTANDARD NAMING constructor( address _relayer, address _fallbackArbitrator, address _arbitratorLicenses, address _offerStore, address _userStore, address payable _feeDestination, uint _feeMilliPercent) Fees(_feeDestination, _feeMilliPercent) Arbitrable(_arbitratorLicenses, _fallbackArbitrator) public { _initialized = true; relayer = _relayer; offerStore = OfferStore(_offerStore); userStore = UserStore(_userStore); } function INIT444( //inject NONSTANDARD NAMING address _fallbackArbitrator, address _relayer, address _arbitratorLicenses, address _offerStore, address _userStore, address payable _feeDestination, uint _feeMilliPercent ) external { assert(_initialized == false); _initialized = true; fallbackArbitrator = _fallbackArbitrator; arbitratorLicenses = ArbitrationLicense(_arbitratorLicenses); offerStore = OfferStore(_offerStore); userStore = UserStore(_userStore); relayer = _relayer; feeDestination = _feeDestination; feeMilliPercent = _feeMilliPercent; paused = false; _SETOWNER235(msg.sender); } function UPDATECODE511(address newCode) public ONLYOWNER677 { //inject NONSTANDARD NAMING UPDATECODEADDRESS579(newCode); } function SETRELAYER20(address _relayer) external ONLYOWNER677 { //inject NONSTANDARD NAMING relayer = _relayer; } function SETFALLBACKARBITRATOR834(address _fallbackArbitrator) external ONLYOWNER677 { //inject NONSTANDARD NAMING fallbackArbitrator = _fallbackArbitrator; } function SETARBITRATORLICENSE102(address _arbitratorLicenses) external ONLYOWNER677 { //inject NONSTANDARD NAMING arbitratorLicenses = ArbitrationLicense(_arbitratorLicenses); } function SETMETADATASTORE408(address _offerStore, address _userStore) external ONLYOWNER677 { //inject NONSTANDARD NAMING offerStore = OfferStore(_offerStore); userStore = UserStore(_userStore); } function _CREATETRANSACTION768( //inject NONSTANDARD NAMING address payable _buyer, address payable _destination, uint _offerId, uint _tokenAmount, uint _fiatAmount ) internal WHENNOTPAUSED504 returns(uint escrowId) { address payable seller; address payable arbitrator; bool deleted; address token; (token, , , , , , seller, arbitrator, deleted) = offerStore.OFFER296(_offerId); require(!deleted, "Offer is not valid"); require(seller != _buyer, "Seller and Buyer must be different"); require(arbitrator != _buyer && arbitrator != address(0), "Cannot buy offers where buyer is arbitrator"); require(_tokenAmount != 0 && _fiatAmount != 0, "Trade amounts cannot be 0"); escrowId = transactions.length++; EscrowTransaction storage trx = transactions[escrowId]; trx.offerId = _offerId; trx.token = token; trx.buyer = _buyer; trx.seller = seller; trx.destination = _destination; trx.arbitrator = arbitrator; trx.tokenAmount = _tokenAmount; trx.fiatAmount = _fiatAmount; emit CREATED284( _offerId, seller, _buyer, escrowId ); } function CREATEESCROW324( //inject NONSTANDARD NAMING uint _offerId, uint _tokenAmount, uint _fiatAmount, address payable _destination, string memory _contactData, string memory _location, string memory _username ) public returns(uint escrowId) { userStore.ADDORUPDATEUSER850(msg.sender, _contactData, _location, _username); escrowId = _CREATETRANSACTION768(msg.sender, _destination, _offerId, _tokenAmount, _fiatAmount); } function CREATEESCROW324( //inject NONSTANDARD NAMING uint _offerId, uint _tokenAmount, uint _fiatAmount, address payable _destination, string memory _contactData, string memory _location, string memory _username, uint _nonce, bytes memory _signature ) public returns(uint escrowId) { address payable _buyer = userStore.ADDORUPDATEUSER850(_signature, _contactData, _location, _username, _nonce); escrowId = _CREATETRANSACTION768(_buyer, _destination, _offerId, _tokenAmount, _fiatAmount); } function CREATEESCROW_RELAYED829( //inject NONSTANDARD NAMING address payable _sender, uint _offerId, uint _tokenAmount, uint _fiatAmount, address payable _destination, string calldata _contactData, string calldata _location, string calldata _username ) external returns(uint escrowId) { assert(msg.sender == relayer); userStore.ADDORUPDATEUSER850(_sender, _contactData, _location, _username); escrowId = _CREATETRANSACTION768(_sender, _destination, _offerId, _tokenAmount, _fiatAmount); } function FUND899(uint _escrowId) external payable WHENNOTPAUSED504 { //inject NONSTANDARD NAMING _FUND192(msg.sender, _escrowId); } function _FUND192(address _from, uint _escrowId) internal WHENNOTPAUSED504 { //inject NONSTANDARD NAMING require(transactions[_escrowId].seller == _from, "Only the seller can invoke this function"); require(transactions[_escrowId].status == EscrowStatus.CREATED, "Invalid escrow status"); transactions[_escrowId].expirationTime = block.timestamp + 5 days; transactions[_escrowId].status = EscrowStatus.FUNDED; uint tokenAmount = transactions[_escrowId].tokenAmount; address token = transactions[_escrowId].token; _PAYFEE642(_from, _escrowId, tokenAmount, token); emit FUNDED669(_escrowId, transactions[_escrowId].buyer, block.timestamp + 5 days, tokenAmount); } function CREATEANDFUND840 ( //inject NONSTANDARD NAMING uint _offerId, uint _tokenAmount, uint _fiatAmount, string memory _bContactData, string memory _bLocation, string memory _bUsername, uint _bNonce, bytes memory _bSignature ) public payable returns(uint escrowId) { address payable _buyer = userStore.ADDORUPDATEUSER850(_bSignature, _bContactData, _bLocation, _bUsername, _bNonce); escrowId = _CREATETRANSACTION768(_buyer, _buyer, _offerId, _tokenAmount, _fiatAmount); _FUND192(msg.sender, escrowId); } function _PAY687(address _sender, uint _escrowId) internal { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; require(trx.status == EscrowStatus.FUNDED, "Transaction is not funded"); require(trx.expirationTime > block.timestamp, "Transaction already expired"); require(trx.buyer == _sender, "Only the buyer can invoke this function"); trx.status = EscrowStatus.PAID; emit PAID949(_escrowId, trx.seller); } function PAY204(uint _escrowId) external { //inject NONSTANDARD NAMING _PAY687(msg.sender, _escrowId); } function PAY_RELAYED312(address _sender, uint _escrowId) external { //inject NONSTANDARD NAMING assert(msg.sender == relayer); _PAY687(_sender, _escrowId); } function PAYSIGNHASH991(uint _escrowId) public view returns(bytes32){ //inject NONSTANDARD NAMING return keccak256( abi.encodePacked( address(this), "pay(uint256)", _escrowId ) ); } function PAY204(uint _escrowId, bytes calldata _signature) external { //inject NONSTANDARD NAMING address sender = _RECOVERADDRESS15(_GETSIGNHASH525(PAYSIGNHASH991(_escrowId)), _signature); _PAY687(sender, _escrowId); } function _RELEASE35(uint _escrowId, EscrowTransaction storage _trx, bool _isDispute) internal { //inject NONSTANDARD NAMING require(_trx.status != EscrowStatus.RELEASED, "Already released"); _trx.status = EscrowStatus.RELEASED; if(!_isDispute){ offerStore.REFUNDSTAKE487(_trx.offerId); } address token = _trx.token; if(token == address(0)){ (bool success, ) = _trx.destination.call.value(_trx.tokenAmount)(""); require(success, "Transfer failed."); } else { require(_SAFETRANSFER911(ERC20Token(token), _trx.buyer, _trx.tokenAmount), "Couldn't transfer funds"); } _RELEASEFEE319(_trx.arbitrator, _trx.tokenAmount, token, _isDispute); emit RELEASED780(_escrowId, _trx.seller, _trx.buyer, _trx.destination, _isDispute); } function RELEASE349(uint _escrowId) external { //inject NONSTANDARD NAMING EscrowStatus mStatus = transactions[_escrowId].status; require(transactions[_escrowId].seller == msg.sender, "Only the seller can invoke this function"); require(mStatus == EscrowStatus.PAID || mStatus == EscrowStatus.FUNDED, "Invalid transaction status"); require(!_ISDISPUTED184(_escrowId), "Can't release a transaction that has an arbitration process"); _RELEASE35(_escrowId, transactions[_escrowId], false); } function CANCEL601(uint _escrowId) external WHENNOTPAUSED504 { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; EscrowStatus mStatus = trx.status; require(mStatus == EscrowStatus.FUNDED || mStatus == EscrowStatus.CREATED, "Only transactions in created or funded state can be canceled"); require(trx.buyer == msg.sender || trx.seller == msg.sender, "Only participants can invoke this function"); if(mStatus == EscrowStatus.FUNDED){ if(msg.sender == trx.seller){ require(trx.expirationTime < block.timestamp, "Can only be canceled after expiration"); } } _CANCEL322(_escrowId, trx, false); } // Same as cancel, but relayed by a contract so we get the sender as param function CANCEL_RELAYED801(address _sender, uint _escrowId) external { //inject NONSTANDARD NAMING assert(msg.sender == relayer); EscrowTransaction storage trx = transactions[_escrowId]; EscrowStatus mStatus = trx.status; require(trx.buyer == _sender, "Only the buyer can invoke this function"); require(mStatus == EscrowStatus.FUNDED || mStatus == EscrowStatus.CREATED, "Only transactions in created or funded state can be canceled"); _CANCEL322(_escrowId, trx, false); } function _CANCEL322(uint _escrowId, EscrowTransaction storage trx, bool isDispute) internal { //inject NONSTANDARD NAMING EscrowStatus origStatus = trx.status; require(trx.status != EscrowStatus.CANCELED, "Already canceled"); trx.status = EscrowStatus.CANCELED; if (origStatus == EscrowStatus.FUNDED) { address token = trx.token; uint amount = trx.tokenAmount; if (!isDispute) { amount += _GETVALUEOFFMILLIPERCENT932(trx.tokenAmount, feeMilliPercent); } if (token == address(0)) { (bool success, ) = trx.seller.call.value(amount)(""); require(success, "Transfer failed."); } else { ERC20Token erc20token = ERC20Token(token); require(_SAFETRANSFER911(erc20token, trx.seller, amount), "Transfer failed"); } } trx.status = EscrowStatus.CANCELED; emit CANCELED731(_escrowId, trx.seller, trx.buyer, isDispute); } function _RATETRANSACTION102(address _sender, uint _escrowId, uint _rate) internal { //inject NONSTANDARD NAMING require(_rate >= 1, "Rating needs to be at least 1"); require(_rate <= 5, "Rating needs to be at less than or equal to 5"); EscrowTransaction storage trx = transactions[_escrowId]; require(trx.status == EscrowStatus.RELEASED || HADDISPUTE385(_escrowId), "Transaction not completed yet"); if (trx.buyer == _sender) { require(trx.sellerRating == 0, "Transaction already rated"); emit RATING242(trx.offerId, trx.seller, _escrowId, _rate, true); trx.sellerRating = _rate; } else if (trx.seller == _sender) { require(trx.buyerRating == 0, "Transaction already rated"); emit RATING242(trx.offerId, trx.buyer, _escrowId, _rate, false); trx.buyerRating = _rate; } else { revert("Only participants can invoke this function"); } } function RATETRANSACTION74(uint _escrowId, uint _rate) external { //inject NONSTANDARD NAMING _RATETRANSACTION102(msg.sender, _escrowId, _rate); } // Same as rateTransaction, but relayed by a contract so we get the sender as param function RATETRANSACTION_RELAYED289(address _sender, uint _escrowId, uint _rate) external { //inject NONSTANDARD NAMING assert(msg.sender == relayer); _RATETRANSACTION102(_sender, _escrowId, _rate); } function GETBASICTRADEDATA166(uint _escrowId) //inject NONSTANDARD NAMING external view returns(address payable buyer, address payable seller, address token, uint tokenAmount) { buyer = transactions[_escrowId].buyer; seller = transactions[_escrowId].seller; tokenAmount = transactions[_escrowId].tokenAmount; token = transactions[_escrowId].token; return (buyer, seller, token, tokenAmount); } function OPENCASE508(uint _escrowId, uint8 _motive) external { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; require(!ISDISPUTED635(_escrowId), "Case already exist"); require(trx.buyer == msg.sender || trx.seller == msg.sender, "Only participants can invoke this function"); require(trx.status == EscrowStatus.PAID, "Cases can only be open for paid transactions"); _OPENDISPUTE139(_escrowId, msg.sender, _motive); } function OPENCASE_RELAYED502(address _sender, uint256 _escrowId, uint8 _motive) external { //inject NONSTANDARD NAMING assert(msg.sender == relayer); EscrowTransaction storage trx = transactions[_escrowId]; require(!ISDISPUTED635(_escrowId), "Case already exist"); require(trx.buyer == _sender, "Only the buyer can invoke this function"); require(trx.status == EscrowStatus.PAID, "Cases can only be open for paid transactions"); _OPENDISPUTE139(_escrowId, _sender, _motive); } function OPENCASE508(uint _escrowId, uint8 _motive, bytes calldata _signature) external { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; require(!ISDISPUTED635(_escrowId), "Case already exist"); require(trx.status == EscrowStatus.PAID, "Cases can only be open for paid transactions"); address senderAddress = _RECOVERADDRESS15(_GETSIGNHASH525(OPENCASESIGNHASH754(_escrowId, _motive)), _signature); require(trx.buyer == senderAddress || trx.seller == senderAddress, "Only participants can invoke this function"); _OPENDISPUTE139(_escrowId, msg.sender, _motive); } function _SOLVEDISPUTE500(uint _escrowId, bool _releaseFunds, address _arbitrator) internal { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; require(trx.buyer != _arbitrator && trx.seller != _arbitrator, "Arbitrator cannot be part of transaction"); if (_releaseFunds) { _RELEASE35(_escrowId, trx, true); offerStore.SLASHSTAKE918(trx.offerId); } else { _CANCEL322(_escrowId, trx, true); _RELEASEFEE319(trx.arbitrator, trx.tokenAmount, trx.token, true); } } function _GETARBITRATOR209(uint _escrowId) internal view returns(address) { //inject NONSTANDARD NAMING return transactions[_escrowId].arbitrator; } function OPENCASESIGNHASH754(uint _escrowId, uint8 _motive) public view returns(bytes32){ //inject NONSTANDARD NAMING return keccak256( abi.encodePacked( address(this), "openCase(uint256)", _escrowId, _motive ) ); } function RECEIVEAPPROVAL139(address _from, uint256 _amount, address _token, bytes memory _data) public { //inject NONSTANDARD NAMING require(_token == address(msg.sender), "Wrong call"); require(_data.length == 36, "Wrong data length"); bytes4 sig; uint256 escrowId; (sig, escrowId) = _ABIDECODEFUNDCALL446(_data); if (sig == bytes4(0xca1d209d)){ // fund(uint256) uint tokenAmount = transactions[escrowId].tokenAmount; require(_amount == tokenAmount + _GETVALUEOFFMILLIPERCENT932(tokenAmount, feeMilliPercent), "Invalid amount"); _FUND192(_from, escrowId); } else { revert("Wrong method selector"); } } function _ABIDECODEFUNDCALL446(bytes memory _data) internal pure returns (bytes4 sig, uint256 escrowId) { //inject NONSTANDARD NAMING assembly { sig := mload(add(_data, add(0x20, 0))) escrowId := mload(add(_data, 36)) } } function WITHDRAW_EMERGENCY162(uint _escrowId) external WHENPAUSED494 { //inject NONSTANDARD NAMING EscrowTransaction storage trx = transactions[_escrowId]; require(trx.status == EscrowStatus.FUNDED, "Cannot withdraw from escrow in a stage different from FUNDED. Open a case"); _CANCEL322(_escrowId, trx, false); } }
inject NONSTANDARD NAMING
function RELEASE349(uint _escrowId) external {
12,593,964
[ 1, 4625, 348, 7953, 560, 30, 4590, 18708, 882, 18264, 423, 2192, 1360, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 2438, 22357, 5026, 29, 12, 11890, 389, 742, 492, 548, 13, 3903, 288, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// Sources flattened with hardhat v2.8.3 https://hardhat.org // File @openzeppelin/contracts/utils/[email protected] // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File @openzeppelin/contracts/token/ERC20/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File @openzeppelin/contracts/token/ERC20/extensions/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File @openzeppelin/contracts/token/ERC20/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-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 virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File @openzeppelin/contracts/utils/math/[email protected] // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // File @uniswap/v2-core/contracts/interfaces/[email protected] pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // File @uniswap/v2-core/contracts/interfaces/[email protected] pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File @uniswap/v2-periphery/contracts/interfaces/[email protected] pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // File @uniswap/v2-periphery/contracts/interfaces/[email protected] pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // File contracts/BLUME.sol pragma solidity ^0.8.0; /** * @title SafeMathUint * @dev Math operations with safety checks that revert on error */ library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } library SafeMathInt { function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library IterableMapping { // Iterable mapping from address to uint; struct Map { address[] keys; mapping(address => uint) values; mapping(address => uint) indexOf; mapping(address => bool) inserted; } function get(Map storage map, address key) public view returns (uint) { return map.values[key]; } function getIndexOfKey(Map storage map, address key) public view returns (int) { if(!map.inserted[key]) { return -1; } return int(map.indexOf[key]); } function getKeyAtIndex(Map storage map, uint index) public view returns (address) { return map.keys[index]; } function size(Map storage map) public view returns (uint) { return map.keys.length; } function set(Map storage map, address key, uint val) public { if (map.inserted[key]) { map.values[key] = val; } else { map.inserted[key] = true; map.values[key] = val; map.indexOf[key] = map.keys.length; map.keys.push(key); } } function remove(Map storage map, address key) public { if (!map.inserted[key]) { return; } delete map.inserted[key]; delete map.values[key]; uint index = map.indexOf[key]; uint lastIndex = map.keys.length - 1; address lastKey = map.keys[lastIndex]; map.indexOf[lastKey] = index; delete map.indexOf[key]; map.keys[index] = lastKey; map.keys.pop(); } } /// @title Dividend-Paying Token Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev An interface for a dividend-paying token contract. interface DividendPayingTokenInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) external view returns (uint256); /// @dev This event MUST emit when ether is distributed to token holders. /// @param from The address which sends ether to this contract. /// @param weiAmount The amount of distributed ether in wei. event DividendsDistributed(address indexed from, uint256 weiAmount); /// @dev This event MUST emit when an address withdraws their dividend. /// @param to The address which withdraws ether from this contract. /// @param weiAmount The amount of withdrawn ether in wei. event DividendWithdrawn(address indexed to, uint256 weiAmount); } /// @title Dividend-Paying Token Optional Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev OPTIONAL functions for a dividend-paying token contract. interface DividendPayingTokenOptionalInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) external view returns (uint256); /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) external view returns (uint256); /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) external view returns (uint256); } /// @title Dividend-Paying Token /// @author Roger Wu (https://github.com/roger-wu) /// @dev A mintable ERC20 token that allows anyone to pay and distribute ether /// to token holders as dividends and allows token holders to withdraw their dividends. /// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code contract DividendPayingToken is Context, ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(_msgSender(), msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); (bool success,) = user.call{value: _withdrawableDividend, gas: 3000}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return (magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() + magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] - (magnifiedDividendPerShare.mul(value)).toInt256Safe(); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] + (magnifiedDividendPerShare.mul(value)).toInt256Safe(); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } } contract ERC20DividendToken is Context, ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; TokenDividendTracker public dividendTracker; uint256 public minTokensBeforeSwap; mapping(address => bool) public isBlacklisted; uint256 public rewardsFee; uint256 public liquidityFee; uint256 public treasuryFee; uint256 public totalFees; address public treasuryAddress; bool public tradingEnabled; // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; uint256 public maxTxAmount; uint256 public maxWalletAmount; mapping (address => bool) public isExcludedFromLimits; event DeployedDividendTracker( address indexed newAddress ); event UpdateUniswapV2Router( address indexed newAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SendDividends(uint256 tokensSwapped, uint256 amount); event SendDividendsToTreasury(uint256 tokensSwapped, uint256 amount); constructor(string memory name_, string memory symbol_, uint256 totalSupply_, address routerV2_, address treasuryAddress_) ERC20(name_, symbol_) { rewardsFee = 3; liquidityFee = 2; treasuryFee = 10; totalFees = rewardsFee.add(liquidityFee).add(treasuryFee); require(totalFees <= 100, "Total fee is over 100%"); treasuryAddress = treasuryAddress_; minTokensBeforeSwap = 1_000 * (10**18); maxTxAmount = totalSupply_ * 3 * (10**16); // 3% maxWalletAmount = totalSupply_ * (10**17); // 10% deployDividendTracker(routerV2_); _updateUniswapV2Router(routerV2_); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(treasuryAddress, true); excludeFromLimits(owner(), true); excludeFromLimits(address(this), true); excludeFromLimits(treasuryAddress, true); excludeFromLimits(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(owner(), totalSupply_ * (10**18)); } receive() external payable {} function excludeFromLimits(address account, bool excluded) public onlyOwner { isExcludedFromLimits[account] = excluded; } function changeMaxTxAmount(uint256 amount) public onlyOwner { maxTxAmount = amount; } function changeMaxWalletAmount(uint256 amount) public onlyOwner { maxWalletAmount = amount; } function setMinTokensBeforeSwap(uint256 amount) external onlyOwner { minTokensBeforeSwap = amount; } function enableTrading(bool enabled) external onlyOwner { tradingEnabled = enabled; } function deployDividendTracker(address _uniswapV2Router) internal { dividendTracker = new TokenDividendTracker(); // exclude from receiving dividends dividendTracker.excludeFromDividends(address(dividendTracker)); dividendTracker.excludeFromDividends(address(this)); dividendTracker.excludeFromDividends(owner()); dividendTracker.excludeFromDividends(address(0xdead)); dividendTracker.excludeFromDividends(address(_uniswapV2Router)); emit DeployedDividendTracker(address(dividendTracker)); } function _updateUniswapV2Router(address newAddress) internal { uniswapV2Router = IUniswapV2Router02(newAddress); address _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), uniswapV2Router.WETH()); excludeFromLimits(newAddress, true); uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); emit UpdateUniswapV2Router(newAddress); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function excludeMultipleAccountsFromFees( address[] calldata accounts, bool excluded ) public onlyOwner { for (uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFees[accounts[i]] = excluded; } emit ExcludeMultipleAccountsFromFees(accounts, excluded); } function setTreasuryWallet(address wallet) external onlyOwner { treasuryAddress = wallet; } function setRewardsFee(uint256 value) external onlyOwner { rewardsFee = value; totalFees = rewardsFee.add(liquidityFee).add(treasuryFee); } function setLiquidityFee(uint256 value) external onlyOwner { liquidityFee = value; totalFees = rewardsFee.add(liquidityFee).add(treasuryFee); } function setTreasuryFee(uint256 value) external onlyOwner { treasuryFee = value; totalFees = rewardsFee.add(liquidityFee).add(treasuryFee); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "ERC20DividendToken: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function blacklistAddress(address account, bool value) external onlyOwner { isBlacklisted[account] = value; } function _setAutomatedMarketMakerPair(address pair, bool value) private { require( automatedMarketMakerPairs[pair] != value, "ERC20DividendToken: Automated market maker pair is already set to that value" ); automatedMarketMakerPairs[pair] = value; if (value) { excludeFromLimits(pair, true); dividendTracker.excludeFromDividends(pair); } emit SetAutomatedMarketMakerPair(pair, value); } function getTotalDividendsDistributed() external view returns (uint256) { return dividendTracker.totalDividendsDistributed(); } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } function withdrawableDividendOf(address account) public view returns (uint256) { return dividendTracker.withdrawableDividendOf(account); } function dividendTokenBalanceOf(address account) public view returns (uint256) { return dividendTracker.balanceOf(account); } function excludeFromDividends(address account) external onlyOwner { dividendTracker.excludeFromDividends(account); } function includeInDividends(address account) external onlyOwner { dividendTracker.includeInDividends(account, balanceOf(account)); } function getAccountDividendsInfo(address account) external view returns ( address, int256, uint256, uint256 ) { return dividendTracker.getAccount(account); } function getAccountDividendsInfoAtIndex(uint256 index) external view returns ( address, int256, uint256, uint256 ) { return dividendTracker.getAccountAtIndex(index); } function claim() external { dividendTracker.processAccount(_msgSender()); } function getNumberOfDividendTokenHolders() external view returns (uint256) { return dividendTracker.getNumberOfTokenHolders(); } function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(balanceOf(from) >= amount, "ERC20: transfer amount exceeds balance"); require(!isBlacklisted[from] && !isBlacklisted[to], "Blacklisted address"); if ((automatedMarketMakerPairs[from] || automatedMarketMakerPairs[to]) && (from != owner() && to != owner())) { require(tradingEnabled, "Trading is not enabled"); } if (!isExcludedFromLimits[from] || (automatedMarketMakerPairs[from] && !isExcludedFromLimits[to])) { require(amount <= maxTxAmount, "Anti-whale: Transfer amount exceeds max limit"); } if (!isExcludedFromLimits[to]) { require(balanceOf(to) + amount <= maxWalletAmount, "Anti-whale: Wallet amount exceeds max limit"); } if (amount == 0) { super._transfer(from, to, 0); return; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= minTokensBeforeSwap; if ( canSwap && !swapping && !automatedMarketMakerPairs[from] && from != owner() && to != owner() ) { swapping = true; if (treasuryFee > 0) { uint256 treasuryTokens = contractTokenBalance.mul(treasuryFee).div(totalFees); swapAndSendDividendsToTreasury(treasuryTokens); } if (liquidityFee > 0) { uint256 swapTokens = contractTokenBalance.mul(liquidityFee).div(totalFees); swapAndLiquify(swapTokens); } if (rewardsFee > 0) { uint256 rewardTokens = balanceOf(address(this)); swapAndSendDividends(rewardTokens); } swapping = false; } bool takeFee = !swapping && (automatedMarketMakerPairs[from] || automatedMarketMakerPairs[to]); // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } if (takeFee) { uint256 fees = amount.mul(totalFees).div(100); amount = amount.sub(fees); super._transfer(from, address(this), fees); } super._transfer(from, to, amount); try dividendTracker.setBalance(from, balanceOf(from)) {} catch {} try dividendTracker.setBalance(to, balanceOf(to)) {} catch {} } function swapAndLiquify(uint256 tokens) private { // split the contract balance into halves uint256 half = tokens.div(2); uint256 otherHalf = tokens.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable address(0xdead), block.timestamp ); } function swapAndSendDividends(uint256 tokens) private { swapTokensForEth(tokens); uint256 dividends = address(this).balance; (bool success,) = payable(address(dividendTracker)).call{value: dividends}(""); if(success) { emit SendDividends(tokens, dividends); } } function swapAndSendDividendsToTreasury(uint256 tokens) private { uint256 initialBalance = address(this).balance; swapTokensForEth(tokens); uint256 dividends = address(this).balance.sub(initialBalance); (bool success,) = payable(treasuryAddress).call{value: dividends}(""); if(success) { emit SendDividendsToTreasury(tokens, dividends); } } } contract TokenDividendTracker is Ownable, DividendPayingToken { using SafeMath for uint256; using IterableMapping for IterableMapping.Map; IterableMapping.Map private tokenHoldersMap; mapping(address => bool) public isExcludedFromDividends; uint256 public minimumTokenBalanceForDividends; event ExcludeFromDividends(address indexed account); event IncludeInDividends(address indexed account); event Claim( address indexed account, uint256 amount ); constructor() DividendPayingToken("Dividend_Tracker", "Dividend_Tracker") { minimumTokenBalanceForDividends = 1 * (10**18); } function excludeFromDividends(address account) external onlyOwner { require(!isExcludedFromDividends[account]); isExcludedFromDividends[account] = true; _setBalance(account, 0); tokenHoldersMap.remove(account); emit ExcludeFromDividends(account); } function includeInDividends(address account, uint256 balance) external onlyOwner { require(isExcludedFromDividends[account]); isExcludedFromDividends[account] = false; _setBalance(account, balance); tokenHoldersMap.set(account, balance); emit IncludeInDividends(account); } function getNumberOfTokenHolders() external view returns (uint256) { return tokenHoldersMap.keys.length; } function getAccount(address _account) public view returns ( address account, int256 index, uint256 withdrawableDividends, uint256 totalDividends ) { account = _account; index = tokenHoldersMap.getIndexOfKey(account); withdrawableDividends = withdrawableDividendOf(account); totalDividends = accumulativeDividendOf(account); } function getAccountAtIndex(uint256 index) public view returns ( address, int256, uint256, uint256 ) { if (index >= tokenHoldersMap.size()) { return (address(0), -1, 0, 0); } address account = tokenHoldersMap.getKeyAtIndex(index); return getAccount(account); } function setBalance(address account, uint256 newBalance) external onlyOwner { if (isExcludedFromDividends[account]) { return; } if (newBalance >= minimumTokenBalanceForDividends) { _setBalance(account, newBalance); tokenHoldersMap.set(account, newBalance); } else { _setBalance(account, 0); tokenHoldersMap.remove(account); } } function processAccount(address account) public onlyOwner returns (bool) { uint256 amount = _withdrawDividendOfUser(payable(account)); if (amount > 0) { emit Claim(account, amount); return true; } return false; } } contract BLUME is ERC20DividendToken { uint256 private _tokenSupply = 10_000_000; /** * @dev Choose proper router address according to your network: * Ethereum mainnet: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D (Uniswap) * BSC mainnet: 0x10ED43C718714eb63d5aA57B78B54704E256024E (PancakeSwap) * BSC testnet: 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 */ address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor (address _treasuryAddress) ERC20DividendToken("Blume Capital", "BLUME", _tokenSupply, _routerAddress, _treasuryAddress) { // Fees to be set in parent constructor } }
@title Dividend-Paying Token Optional Interface @author Roger Wu (https://github.com/roger-wu) @dev OPTIONAL functions for a dividend-paying token contract.
interface DividendPayingTokenOptionalInterface { function withdrawableDividendOf(address _owner) external view returns (uint256); function withdrawnDividendOf(address _owner) external view returns (uint256); function accumulativeDividendOf(address _owner) external view returns (uint256); } }
437,298
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 2649, 21411, 26746, 17, 9148, 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9148, 310, 1345, 6542, 1358, 288, 203, 565, 445, 598, 9446, 429, 7244, 26746, 951, 12, 2867, 389, 8443, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 598, 9446, 82, 7244, 26746, 951, 12, 2867, 389, 8443, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 8822, 1535, 7244, 26746, 951, 12, 2867, 389, 8443, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 1769, 203, 97, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x5D8d9F5b96f4438195BE9b99eee6118Ed4304286/sources/contracts/Blacksmith.sol
update bonus token rewards if exist for pool
BonusToken storage bonusToken = bonusTokens[_lpToken];
2,907,497
[ 1, 4625, 348, 7953, 560, 30, 225, 1089, 324, 22889, 1147, 283, 6397, 309, 1005, 364, 2845, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 605, 22889, 1345, 2502, 324, 22889, 1345, 273, 324, 22889, 5157, 63, 67, 9953, 1345, 15533, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/97/0xfD77CC4b5f5A745481747e93167C9B114dA5d539/sources/project_/contracts/ForzaPresale.sol
* @dev Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow./
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; }
3,284,189
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 326, 720, 25693, 434, 2795, 9088, 12321, 16, 15226, 310, 603, 9391, 261, 13723, 326, 563, 353, 6092, 2934, 9354, 2680, 358, 348, 7953, 560, 1807, 1375, 17, 68, 3726, 18, 29076, 30, 300, 2592, 25693, 2780, 9391, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 377, 445, 720, 12, 11890, 5034, 279, 16, 2254, 5034, 324, 13, 2713, 16618, 1135, 261, 11890, 5034, 13, 288, 203, 540, 327, 279, 300, 324, 31, 203, 377, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/80001/0x31b35eb97EDf5001B543143c41F6Ffc8b88De2d3/sources/project_/contracts/ThriveCoinRewardSeasonGasRefundable.sol
* @dev Beside storing rewards it refunds the gas cost to transaction origin. See {ThriveCoinRewardSeason-addRewardBatch} for more details./
function addRewardBatch( UserRewardRequest[] calldata entries ) public virtual override(ThriveCoinRewardSeason) onlyWriter refundGasCost { super.addRewardBatch(entries); }
9,517,130
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 605, 281, 831, 15729, 283, 6397, 518, 16255, 87, 326, 16189, 6991, 358, 2492, 4026, 18, 2164, 288, 1315, 86, 688, 27055, 17631, 1060, 1761, 2753, 17, 1289, 17631, 1060, 4497, 97, 364, 1898, 3189, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 527, 17631, 1060, 4497, 12, 203, 565, 2177, 17631, 1060, 691, 8526, 745, 892, 3222, 203, 225, 262, 1071, 5024, 3849, 12, 1315, 86, 688, 27055, 17631, 1060, 1761, 2753, 13, 1338, 2289, 16255, 27998, 8018, 288, 203, 565, 2240, 18, 1289, 17631, 1060, 4497, 12, 8219, 1769, 203, 225, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0x079BC05ebF765c3678Bec03A598561f0414f6227/sources/project:/contracts/PropertyNFT.sol
* @title PropertyNFT @dev An NFT representation of a property. This contract allows for minting property NFTs, updating their attributes, and querying based on certain attributes like launchpadID. It also provides role-based access control for various operations./
contract PropertyNFT is ERC721, ERC721Enumerable, ERC721URIStorage { pragma solidity ^0.8.0; struct Property { } address public minter; address public redeemer; address public operator; address public admin; modifier onlyAdmin() { require(msg.sender == admin, "Caller is not an admin"); _; } modifier onlyMinter() { require(msg.sender == minter, "Caller is not a minter"); _; } modifier onlyRedeemer() { require(msg.sender == redeemer, "Caller is not a redeemer"); _; } modifier onlyOperator() { require(msg.sender == operator, "Caller is not an operator"); _; } uint256 tokenId, string propertyName, uint apr, uint totalPropertyRaised, uint propertyParticipation, uint launchpadID, uint redeemFees, uint sellFees, uint totalEarned ); event PropertyMinted( constructor() ERC721("PropertyNFT", "PNFT") { } function setNewAdmin(address _newAdmin) public onlyAdmin { admin = _newAdmin; } function setMinter(address _minter) public onlyAdmin { minter = _minter; } function setRedeemer(address _redeemer) public onlyAdmin { redeemer = _redeemer; } function setOperator(address _operator) public onlyAdmin { operator = _operator; } function mintProperty( address to, string memory propertyName, uint apr, uint totalPropertyRaised, uint propertyParticipation, uint launchpadID, uint redeemFees, uint sellFees, uint totalEarned ) external onlyMinter { uint256 newTokenId = totalSupply() + 1; _safeMint(to, newTokenId); Property memory newProperty = Property({ propertyName: propertyName, apr: apr, totalPropertyRaised: totalPropertyRaised, propertyParticipation: propertyParticipation, launchpadID: launchpadID, redeemFees: redeemFees, sellFees: sellFees, totalEarned: totalEarned }); properties[newTokenId] = newProperty; launchpadIDToTokenIds[launchpadID].push(newTokenId); emit PropertyMinted( newTokenId, propertyName, apr, totalPropertyRaised, propertyParticipation, launchpadID, redeemFees, sellFees, totalEarned ); } function mintProperty( address to, string memory propertyName, uint apr, uint totalPropertyRaised, uint propertyParticipation, uint launchpadID, uint redeemFees, uint sellFees, uint totalEarned ) external onlyMinter { uint256 newTokenId = totalSupply() + 1; _safeMint(to, newTokenId); Property memory newProperty = Property({ propertyName: propertyName, apr: apr, totalPropertyRaised: totalPropertyRaised, propertyParticipation: propertyParticipation, launchpadID: launchpadID, redeemFees: redeemFees, sellFees: sellFees, totalEarned: totalEarned }); properties[newTokenId] = newProperty; launchpadIDToTokenIds[launchpadID].push(newTokenId); emit PropertyMinted( newTokenId, propertyName, apr, totalPropertyRaised, propertyParticipation, launchpadID, redeemFees, sellFees, totalEarned ); } function burnTokenWithApproval(uint256 tokenId) external onlyRedeemer { require(ownerOf(tokenId) == msg.sender || isApprovedForAll(ownerOf(tokenId), msg.sender), "Not approved to burn"); _burn(tokenId); } function updateSellFees(uint256 tokenId, uint _sellFees) external onlyOperator { require(_exists(tokenId), "NFT does not exist"); properties[tokenId].sellFees = _sellFees; } function updateRedeemFees(uint256 tokenId, uint _redeemFees) external onlyOperator { require(_exists(tokenId), "NFT does not exist"); properties[tokenId].redeemFees = _redeemFees; } function updateTotalEarned(uint256 tokenId, uint _totalEarned) external onlyOperator { require(_exists(tokenId), "NFT does not exist"); properties[tokenId].totalEarned = _totalEarned; } function updateBulkSellFees(uint256[] memory tokenIds, uint _sellFees) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].sellFees = _sellFees; } } function updateBulkSellFees(uint256[] memory tokenIds, uint _sellFees) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].sellFees = _sellFees; } } function updateBulkRedeemFees(uint256[] memory tokenIds, uint _redeemFees) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].redeemFees = _redeemFees; } } function updateBulkRedeemFees(uint256[] memory tokenIds, uint _redeemFees) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].redeemFees = _redeemFees; } } function updateBulkTotalEarned(uint256[] memory tokenIds, uint _totalEarned) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].totalEarned = _totalEarned; } } function updateBulkTotalEarned(uint256[] memory tokenIds, uint _totalEarned) external onlyOperator { for (uint i = 0; i < tokenIds.length; i++) { require(_exists(tokenIds[i]), "NFT does not exist"); properties[tokenIds[i]].totalEarned = _totalEarned; } } function getTokensByLaunchpadID(uint _launchpadID) external view returns (uint256[] memory) { return launchpadIDToTokenIds[_launchpadID]; } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function setTokenURI(uint256 tokenId, string memory _tokenURI) external onlyOperator { _setTokenURI(tokenId, _tokenURI); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function getProperty(uint256 tokenId) external view returns (Property memory) { return properties[tokenId]; } function balanceOf(address owner) public view virtual override(ERC721, IERC721) returns (uint256) { return super.balanceOf(owner); } function ownerOf(uint256 tokenId) public view virtual override(ERC721, IERC721) returns (address) { return super.ownerOf(tokenId); } function approve(address to, uint256 tokenId) public virtual override(ERC721, IERC721) { super.approve(to, tokenId); } function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, IERC721) { super.transferFrom(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, IERC721) { super.safeTransferFrom(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override(ERC721, IERC721) { super.safeTransferFrom(from, to, tokenId, _data); } function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable, ERC721URIStorage) returns (bool) { return super.supportsInterface(interfaceId); } }
1,864,608
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 4276, 50, 4464, 632, 5206, 1922, 423, 4464, 4335, 434, 279, 1272, 18, 1220, 6835, 5360, 364, 312, 474, 310, 1272, 423, 4464, 87, 16, 9702, 3675, 1677, 16, 471, 23936, 2511, 603, 8626, 1677, 3007, 8037, 6982, 734, 18, 2597, 2546, 8121, 2478, 17, 12261, 2006, 3325, 364, 11191, 5295, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 4276, 50, 4464, 353, 4232, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3572, 25121, 16, 4232, 39, 27, 5340, 3098, 3245, 288, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 565, 1958, 4276, 288, 203, 565, 289, 203, 203, 203, 565, 1758, 1071, 1131, 387, 31, 203, 565, 1758, 1071, 283, 24903, 264, 31, 203, 565, 1758, 1071, 3726, 31, 203, 203, 565, 1758, 1071, 3981, 31, 203, 565, 9606, 1338, 4446, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 3981, 16, 315, 11095, 353, 486, 392, 3981, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 9606, 1338, 49, 2761, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 1131, 387, 16, 315, 11095, 353, 486, 279, 1131, 387, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 9606, 1338, 426, 24903, 264, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 283, 24903, 264, 16, 315, 11095, 353, 486, 279, 283, 24903, 264, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 9606, 1338, 5592, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 3726, 16, 315, 11095, 353, 486, 392, 3726, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 3639, 2254, 5034, 1147, 548, 16, 203, 3639, 533, 5470, 16, 203, 3639, 2254, 513, 86, 16, 203, 3639, 2254, 2078, 1396, 12649, 5918, 16, 203, 3639, 2254, 1272, 1988, 24629, 367, 16, 203, 3639, 2254, 8037, 6982, 734, 16, 203, 3639, 2254, 283, 24903, 2954, 281, 16, 203, 3639, 2254, 357, 80, 2954, 281, 16, 203, 3639, 2254, 2078, 41, 1303, 329, 203, 565, 11272, 203, 203, 565, 871, 4276, 49, 474, 329, 12, 203, 565, 3885, 1435, 4232, 39, 27, 5340, 2932, 1396, 50, 4464, 3113, 315, 15124, 4464, 7923, 288, 203, 565, 289, 203, 203, 203, 565, 445, 19469, 4446, 12, 2867, 389, 2704, 4446, 13, 1071, 1338, 4446, 288, 203, 3639, 3981, 273, 389, 2704, 4446, 31, 203, 565, 289, 203, 203, 565, 445, 15430, 2761, 12, 2867, 389, 1154, 387, 13, 1071, 1338, 4446, 288, 203, 3639, 1131, 387, 273, 389, 1154, 387, 31, 203, 565, 289, 203, 203, 565, 445, 444, 426, 24903, 264, 12, 2867, 389, 266, 24903, 264, 13, 1071, 1338, 4446, 288, 203, 3639, 283, 24903, 264, 273, 389, 266, 24903, 264, 31, 203, 565, 289, 203, 203, 565, 445, 444, 5592, 12, 2867, 389, 9497, 13, 1071, 1338, 4446, 288, 203, 3639, 3726, 273, 389, 9497, 31, 203, 565, 289, 203, 203, 565, 445, 312, 474, 1396, 12, 203, 3639, 1758, 358, 16, 203, 3639, 533, 3778, 5470, 16, 203, 3639, 2254, 513, 86, 16, 203, 3639, 2254, 2078, 1396, 12649, 5918, 16, 203, 3639, 2254, 1272, 1988, 24629, 367, 16, 203, 3639, 2254, 8037, 6982, 734, 16, 203, 3639, 2254, 283, 24903, 2954, 281, 16, 203, 3639, 2254, 357, 80, 2954, 281, 16, 203, 3639, 2254, 2078, 41, 1303, 329, 203, 565, 262, 3903, 1338, 49, 2761, 288, 203, 3639, 2254, 5034, 394, 1345, 548, 273, 2078, 3088, 1283, 1435, 397, 404, 31, 203, 3639, 389, 4626, 49, 474, 12, 869, 16, 394, 1345, 548, 1769, 203, 203, 3639, 4276, 3778, 394, 1396, 273, 4276, 12590, 203, 5411, 5470, 30, 5470, 16, 203, 5411, 513, 86, 30, 513, 86, 16, 203, 5411, 2078, 1396, 12649, 5918, 30, 2078, 1396, 12649, 5918, 16, 203, 5411, 1272, 1988, 24629, 367, 30, 1272, 1988, 24629, 367, 16, 203, 5411, 8037, 6982, 734, 30, 8037, 6982, 734, 16, 203, 5411, 283, 24903, 2954, 281, 30, 283, 24903, 2954, 281, 16, 203, 5411, 357, 80, 2954, 281, 30, 357, 80, 2954, 281, 16, 203, 5411, 2078, 41, 1303, 329, 30, 2078, 41, 1303, 329, 203, 3639, 15549, 203, 203, 3639, 1790, 63, 2704, 1345, 548, 65, 273, 394, 1396, 31, 203, 3639, 8037, 6982, 734, 774, 1345, 2673, 63, 20738, 6982, 734, 8009, 6206, 12, 2704, 1345, 548, 1769, 203, 203, 3639, 3626, 4276, 49, 474, 329, 12, 203, 5411, 394, 1345, 548, 16, 203, 5411, 5470, 16, 203, 5411, 513, 86, 16, 203, 5411, 2078, 1396, 12649, 5918, 16, 203, 5411, 1272, 1988, 24629, 367, 16, 203, 5411, 8037, 6982, 734, 16, 203, 5411, 283, 24903, 2954, 281, 16, 203, 5411, 357, 80, 2954, 281, 16, 203, 5411, 2078, 41, 1303, 329, 203, 3639, 11272, 203, 565, 289, 203, 203, 565, 445, 312, 474, 1396, 12, 203, 3639, 1758, 358, 16, 203, 3639, 533, 3778, 5470, 16, 203, 3639, 2254, 513, 86, 16, 203, 3639, 2254, 2078, 1396, 12649, 5918, 16, 203, 3639, 2254, 1272, 1988, 24629, 367, 16, 203, 3639, 2254, 8037, 6982, 734, 16, 203, 3639, 2254, 283, 24903, 2954, 281, 16, 203, 3639, 2254, 357, 80, 2954, 281, 16, 203, 3639, 2254, 2078, 41, 1303, 329, 203, 565, 262, 3903, 1338, 49, 2761, 288, 203, 3639, 2254, 5034, 394, 1345, 548, 273, 2078, 3088, 1283, 1435, 397, 404, 31, 203, 3639, 389, 4626, 49, 474, 12, 869, 16, 394, 1345, 548, 1769, 203, 203, 3639, 4276, 3778, 394, 1396, 273, 4276, 12590, 203, 5411, 5470, 30, 5470, 16, 203, 5411, 513, 86, 30, 513, 86, 16, 203, 5411, 2078, 1396, 12649, 5918, 30, 2078, 1396, 12649, 5918, 16, 203, 5411, 1272, 1988, 24629, 367, 30, 1272, 1988, 24629, 367, 16, 203, 5411, 8037, 6982, 734, 30, 8037, 6982, 734, 16, 203, 5411, 283, 24903, 2954, 281, 30, 283, 24903, 2954, 281, 16, 203, 5411, 357, 80, 2954, 281, 30, 357, 80, 2954, 281, 16, 203, 5411, 2078, 41, 1303, 329, 30, 2078, 41, 1303, 329, 203, 3639, 15549, 203, 203, 3639, 1790, 63, 2704, 1345, 548, 65, 273, 394, 1396, 31, 203, 3639, 8037, 6982, 734, 774, 1345, 2673, 63, 20738, 6982, 734, 8009, 6206, 12, 2704, 1345, 548, 1769, 203, 203, 3639, 3626, 4276, 49, 474, 329, 12, 203, 5411, 394, 1345, 548, 16, 203, 5411, 5470, 16, 203, 5411, 513, 86, 16, 203, 5411, 2078, 1396, 12649, 5918, 16, 203, 5411, 1272, 1988, 24629, 367, 16, 203, 5411, 8037, 6982, 734, 16, 203, 5411, 283, 24903, 2954, 281, 16, 203, 5411, 357, 80, 2954, 281, 16, 203, 2 ]
pragma solidity ^0.4.24; // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } // File: contracts/controller/Reputation.sol /** * @title Reputation system * @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust . * A reputation is use to assign influence measure to a DAO'S peers. * Reputation is similar to regular tokens but with one crucial difference: It is non-transferable. * The Reputation contract maintain a map of address to reputation value. * It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address. */ contract Reputation is Ownable { using SafeMath for uint; mapping (address => uint256) public balances; uint256 public totalSupply; uint public decimals = 18; // Event indicating minting of reputation to an address. event Mint(address indexed _to, uint256 _amount); // Event indicating burning of reputation for an address. event Burn(address indexed _from, uint256 _amount); /** * @dev return the reputation amount of a given owner * @param _owner an address of the owner which we want to get his reputation */ function reputationOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev Generates `_amount` of reputation that are assigned to `_to` * @param _to The address that will be assigned the new reputation * @param _amount The quantity of reputation to be generated * @return True if the reputation are generated correctly */ function mint(address _to, uint _amount) public onlyOwner returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); return true; } /** * @dev Burns `_amount` of reputation from `_from` * if _amount tokens to burn > balances[_from] the balance of _from will turn to zero. * @param _from The address that will lose the reputation * @param _amount The quantity of reputation to burn * @return True if the reputation are burned correctly */ function burn(address _from, uint _amount) public onlyOwner returns (bool) { uint amountMinted = _amount; if (balances[_from] < _amount) { amountMinted = balances[_from]; } totalSupply = totalSupply.sub(amountMinted); balances[_from] = balances[_from].sub(amountMinted); emit Burn(_from, amountMinted); return true; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } // File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } // File: openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } // File: contracts/token/ERC827/ERC827.sol /** * @title ERC827 interface, an extension of ERC20 token standard * * @dev Interface of a ERC827 token, following the ERC20 standard with extra * methods to transfer value and data and execute calls in transfers and * approvals. */ contract ERC827 is ERC20 { function approveAndCall(address _spender,uint256 _value,bytes _data) public payable returns(bool); function transferAndCall(address _to,uint256 _value,bytes _data) public payable returns(bool); function transferFromAndCall(address _from,address _to,uint256 _value,bytes _data) public payable returns(bool); } // File: contracts/token/ERC827/ERC827Token.sol /* solium-disable security/no-low-level-calls */ pragma solidity ^0.4.24; /** * @title ERC827, an extension of ERC20 token standard * * @dev Implementation the ERC827, following the ERC20 standard with extra * methods to transfer value and data and execute calls in transfers and * approvals. Uses OpenZeppelin StandardToken. */ contract ERC827Token is ERC827, StandardToken { /** * @dev Addition to ERC20 token methods. It allows to * approve the transfer of value and execute a call with the sent data. * Beware that changing an allowance with this method brings the risk that * someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race condition * is to first reduce the spender's allowance to 0 and set the desired value * afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address that will spend the funds. * @param _value The amount of tokens to be spent. * @param _data ABI-encoded contract call to call `_spender` address. * @return true if the call function was executed successfully */ function approveAndCall( address _spender, uint256 _value, bytes _data ) public payable returns (bool) { require(_spender != address(this)); super.approve(_spender, _value); // solium-disable-next-line security/no-call-value require(_spender.call.value(msg.value)(_data)); return true; } /** * @dev Addition to ERC20 token methods. Transfer tokens to a specified * address and execute a call with the sent data on the same transaction * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered * @param _data ABI-encoded contract call to call `_to` address. * @return true if the call function was executed successfully */ function transferAndCall( address _to, uint256 _value, bytes _data ) public payable returns (bool) { require(_to != address(this)); super.transfer(_to, _value); // solium-disable-next-line security/no-call-value require(_to.call.value(msg.value)(_data)); return true; } /** * @dev Addition to ERC20 token methods. Transfer tokens from one address to * another and make a contract call on the same transaction * @param _from The address which you want to send tokens from * @param _to The address which you want to transfer to * @param _value The amout of tokens to be transferred * @param _data ABI-encoded contract call to call `_to` address. * @return true if the call function was executed successfully */ function transferFromAndCall( address _from, address _to, uint256 _value, bytes _data ) public payable returns (bool) { require(_to != address(this)); super.transferFrom(_from, _to, _value); // solium-disable-next-line security/no-call-value require(_to.call.value(msg.value)(_data)); return true; } /** * @dev Addition to StandardToken methods. Increase the amount of tokens that * an owner allowed to a spender and execute a call with the sent data. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. * @param _data ABI-encoded contract call to call `_spender` address. */ function increaseApprovalAndCall( address _spender, uint _addedValue, bytes _data ) public payable returns (bool) { require(_spender != address(this)); super.increaseApproval(_spender, _addedValue); // solium-disable-next-line security/no-call-value require(_spender.call.value(msg.value)(_data)); return true; } /** * @dev Addition to StandardToken methods. Decrease the amount of tokens that * an owner allowed to a spender and execute a call with the sent data. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. * @param _data ABI-encoded contract call to call `_spender` address. */ function decreaseApprovalAndCall( address _spender, uint _subtractedValue, bytes _data ) public payable returns (bool) { require(_spender != address(this)); super.decreaseApproval(_spender, _subtractedValue); // solium-disable-next-line security/no-call-value require(_spender.call.value(msg.value)(_data)); return true; } } // File: contracts/controller/DAOToken.sol /** * @title DAOToken, base on zeppelin contract. * @dev ERC20 compatible token. It is a mintable, destructible, burnable token. */ contract DAOToken is ERC827Token,MintableToken,BurnableToken { string public name; string public symbol; // solium-disable-next-line uppercase uint8 public constant decimals = 18; uint public cap; /** * @dev Constructor * @param _name - token name * @param _symbol - token symbol * @param _cap - token cap - 0 value means no cap */ constructor(string _name, string _symbol,uint _cap) public { name = _name; symbol = _symbol; cap = _cap; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) public onlyOwner canMint returns (bool) { if (cap > 0) require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } // File: contracts/controller/Avatar.sol /** * @title An Avatar holds tokens, reputation and ether for a controller */ contract Avatar is Ownable { bytes32 public orgName; DAOToken public nativeToken; Reputation public nativeReputation; event GenericAction(address indexed _action, bytes32[] _params); event SendEther(uint _amountInWei, address indexed _to); event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint _value); event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint _value); event ExternalTokenIncreaseApproval(StandardToken indexed _externalToken, address _spender, uint _addedValue); event ExternalTokenDecreaseApproval(StandardToken indexed _externalToken, address _spender, uint _subtractedValue); event ReceiveEther(address indexed _sender, uint _value); /** * @dev the constructor takes organization name, native token and reputation system and creates an avatar for a controller */ constructor(bytes32 _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public { orgName = _orgName; nativeToken = _nativeToken; nativeReputation = _nativeReputation; } /** * @dev enables an avatar to receive ethers */ function() public payable { emit ReceiveEther(msg.sender, msg.value); } /** * @dev perform a generic call to an arbitrary contract * @param _contract the contract's address to call * @param _data ABI-encoded contract call to call `_contract` address. * @return the return bytes of the called contract's function. */ function genericCall(address _contract,bytes _data) public onlyOwner { // solium-disable-next-line security/no-low-level-calls bool result = _contract.call(_data); // solium-disable-next-line security/no-inline-assembly assembly { // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // call returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev send ethers from the avatar's wallet * @param _amountInWei amount to send in Wei units * @param _to send the ethers to this address * @return bool which represents success */ function sendEther(uint _amountInWei, address _to) public onlyOwner returns(bool) { _to.transfer(_amountInWei); emit SendEther(_amountInWei, _to); return true; } /** * @dev external token transfer * @param _externalToken the token contract * @param _to the destination address * @param _value the amount of tokens to transfer * @return bool which represents success */ function externalTokenTransfer(StandardToken _externalToken, address _to, uint _value) public onlyOwner returns(bool) { _externalToken.transfer(_to, _value); emit ExternalTokenTransfer(_externalToken, _to, _value); return true; } /** * @dev external token transfer from a specific account * @param _externalToken the token contract * @param _from the account to spend token from * @param _to the destination address * @param _value the amount of tokens to transfer * @return bool which represents success */ function externalTokenTransferFrom( StandardToken _externalToken, address _from, address _to, uint _value ) public onlyOwner returns(bool) { _externalToken.transferFrom(_from, _to, _value); emit ExternalTokenTransferFrom(_externalToken, _from, _to, _value); return true; } /** * @dev increase approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _addedValue the amount of ether (in Wei) which the approval is referring to. * @return bool which represents a success */ function externalTokenIncreaseApproval(StandardToken _externalToken, address _spender, uint _addedValue) public onlyOwner returns(bool) { _externalToken.increaseApproval(_spender, _addedValue); emit ExternalTokenIncreaseApproval(_externalToken, _spender, _addedValue); return true; } /** * @dev decrease approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _subtractedValue the amount of ether (in Wei) which the approval is referring to. * @return bool which represents a success */ function externalTokenDecreaseApproval(StandardToken _externalToken, address _spender, uint _subtractedValue ) public onlyOwner returns(bool) { _externalToken.decreaseApproval(_spender, _subtractedValue); emit ExternalTokenDecreaseApproval(_externalToken,_spender, _subtractedValue); return true; } } // File: contracts/globalConstraints/GlobalConstraintInterface.sol contract GlobalConstraintInterface { enum CallPhase { Pre, Post,PreAndPost } function pre( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool); function post( address _scheme, bytes32 _params, bytes32 _method ) public returns(bool); /** * @dev when return if this globalConstraints is pre, post or both. * @return CallPhase enum indication Pre, Post or PreAndPost. */ function when() public returns(CallPhase); } // File: contracts/controller/ControllerInterface.sol /** * @title Controller contract * @dev A controller controls the organizations tokens ,reputation and avatar. * It is subject to a set of schemes and constraints that determine its behavior. * Each scheme has it own parameters and operation permissions. */ interface ControllerInterface { /** * @dev Mint `_amount` of reputation that are assigned to `_to` . * @param _amount amount of reputation to mint * @param _to beneficiary address * @return bool which represents a success */ function mintReputation(uint256 _amount, address _to,address _avatar) external returns(bool); /** * @dev Burns `_amount` of reputation from `_from` * @param _amount amount of reputation to burn * @param _from The address that will lose the reputation * @return bool which represents a success */ function burnReputation(uint256 _amount, address _from,address _avatar) external returns(bool); /** * @dev mint tokens . * @param _amount amount of token to mint * @param _beneficiary beneficiary address * @param _avatar address * @return bool which represents a success */ function mintTokens(uint256 _amount, address _beneficiary,address _avatar) external returns(bool); /** * @dev register or update a scheme * @param _scheme the address of the scheme * @param _paramsHash a hashed configuration of the usage of the scheme * @param _permissions the permissions the new scheme will have * @param _avatar address * @return bool which represents a success */ function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions,address _avatar) external returns(bool); /** * @dev unregister a scheme * @param _avatar address * @param _scheme the address of the scheme * @return bool which represents a success */ function unregisterScheme(address _scheme,address _avatar) external returns(bool); /** * @dev unregister the caller's scheme * @param _avatar address * @return bool which represents a success */ function unregisterSelf(address _avatar) external returns(bool); function isSchemeRegistered( address _scheme,address _avatar) external view returns(bool); function getSchemeParameters(address _scheme,address _avatar) external view returns(bytes32); function getGlobalConstraintParameters(address _globalConstraint,address _avatar) external view returns(bytes32); function getSchemePermissions(address _scheme,address _avatar) external view returns(bytes4); /** * @dev globalConstraintsCount return the global constraint pre and post count * @return uint globalConstraintsPre count. * @return uint globalConstraintsPost count. */ function globalConstraintsCount(address _avatar) external view returns(uint,uint); function isGlobalConstraintRegistered(address _globalConstraint,address _avatar) external view returns(bool); /** * @dev add or update Global Constraint * @param _globalConstraint the address of the global constraint to be added. * @param _params the constraint parameters hash. * @param _avatar the avatar of the organization * @return bool which represents a success */ function addGlobalConstraint(address _globalConstraint, bytes32 _params,address _avatar) external returns(bool); /** * @dev remove Global Constraint * @param _globalConstraint the address of the global constraint to be remove. * @param _avatar the organization avatar. * @return bool which represents a success */ function removeGlobalConstraint (address _globalConstraint,address _avatar) external returns(bool); /** * @dev upgrade the Controller * The function will trigger an event 'UpgradeController'. * @param _newController the address of the new controller. * @param _avatar address * @return bool which represents a success */ function upgradeController(address _newController,address _avatar) external returns(bool); /** * @dev perform a generic call to an arbitrary contract * @param _contract the contract's address to call * @param _data ABI-encoded contract call to call `_contract` address. * @param _avatar the controller's avatar address * @return bytes32 - the return value of the called _contract's function. */ function genericCall(address _contract,bytes _data,address _avatar) external returns(bytes32); /** * @dev send some ether * @param _amountInWei the amount of ether (in Wei) to send * @param _to address of the beneficiary * @param _avatar address * @return bool which represents a success */ function sendEther(uint _amountInWei, address _to,address _avatar) external returns(bool); /** * @dev send some amount of arbitrary ERC20 Tokens * @param _externalToken the address of the Token Contract * @param _to address of the beneficiary * @param _value the amount of ether (in Wei) to send * @param _avatar address * @return bool which represents a success */ function externalTokenTransfer(StandardToken _externalToken, address _to, uint _value,address _avatar) external returns(bool); /** * @dev transfer token "from" address "to" address * One must to approve the amount of tokens which can be spend from the * "from" account.This can be done using externalTokenApprove. * @param _externalToken the address of the Token Contract * @param _from address of the account to send from * @param _to address of the beneficiary * @param _value the amount of ether (in Wei) to send * @param _avatar address * @return bool which represents a success */ function externalTokenTransferFrom(StandardToken _externalToken, address _from, address _to, uint _value,address _avatar) external returns(bool); /** * @dev increase approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _addedValue the amount of ether (in Wei) which the approval is referring to. * @param _avatar address * @return bool which represents a success */ function externalTokenIncreaseApproval(StandardToken _externalToken, address _spender, uint _addedValue,address _avatar) external returns(bool); /** * @dev decrease approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _subtractedValue the amount of ether (in Wei) which the approval is referring to. * @param _avatar address * @return bool which represents a success */ function externalTokenDecreaseApproval(StandardToken _externalToken, address _spender, uint _subtractedValue,address _avatar) external returns(bool); /** * @dev getNativeReputation * @param _avatar the organization avatar. * @return organization native reputation */ function getNativeReputation(address _avatar) external view returns(address); } // File: contracts/controller/Controller.sol /** * @title Controller contract * @dev A controller controls the organizations tokens,reputation and avatar. * It is subject to a set of schemes and constraints that determine its behavior. * Each scheme has it own parameters and operation permissions. */ contract Controller is ControllerInterface { struct Scheme { bytes32 paramsHash; // a hash "configuration" of the scheme bytes4 permissions; // A bitwise flags of permissions, // All 0: Not registered, // 1st bit: Flag if the scheme is registered, // 2nd bit: Scheme can register other schemes // 3rd bit: Scheme can add/remove global constraints // 4th bit: Scheme can upgrade the controller // 5th bit: Scheme can call genericCall on behalf of // the organization avatar } struct GlobalConstraint { address gcAddress; bytes32 params; } struct GlobalConstraintRegister { bool isRegistered; //is registered uint index; //index at globalConstraints } mapping(address=>Scheme) public schemes; Avatar public avatar; DAOToken public nativeToken; Reputation public nativeReputation; // newController will point to the new controller after the present controller is upgraded address public newController; // globalConstraintsPre that determine pre conditions for all actions on the controller GlobalConstraint[] public globalConstraintsPre; // globalConstraintsPost that determine post conditions for all actions on the controller GlobalConstraint[] public globalConstraintsPost; // globalConstraintsRegisterPre indicate if a globalConstraints is registered as a pre global constraint mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPre; // globalConstraintsRegisterPost indicate if a globalConstraints is registered as a post global constraint mapping(address=>GlobalConstraintRegister) public globalConstraintsRegisterPost; event MintReputation (address indexed _sender, address indexed _to, uint256 _amount); event BurnReputation (address indexed _sender, address indexed _from, uint256 _amount); event MintTokens (address indexed _sender, address indexed _beneficiary, uint256 _amount); event RegisterScheme (address indexed _sender, address indexed _scheme); event UnregisterScheme (address indexed _sender, address indexed _scheme); event GenericAction (address indexed _sender, bytes32[] _params); event SendEther (address indexed _sender, uint _amountInWei, address indexed _to); event ExternalTokenTransfer (address indexed _sender, address indexed _externalToken, address indexed _to, uint _value); event ExternalTokenTransferFrom (address indexed _sender, address indexed _externalToken, address _from, address _to, uint _value); event ExternalTokenIncreaseApproval (address indexed _sender, StandardToken indexed _externalToken, address _spender, uint _value); event ExternalTokenDecreaseApproval (address indexed _sender, StandardToken indexed _externalToken, address _spender, uint _value); event UpgradeController(address indexed _oldController,address _newController); event AddGlobalConstraint(address indexed _globalConstraint, bytes32 _params,GlobalConstraintInterface.CallPhase _when); event RemoveGlobalConstraint(address indexed _globalConstraint ,uint256 _index,bool _isPre); event GenericCall(address indexed _contract,bytes _data); constructor( Avatar _avatar) public { avatar = _avatar; nativeToken = avatar.nativeToken(); nativeReputation = avatar.nativeReputation(); schemes[msg.sender] = Scheme({paramsHash: bytes32(0),permissions: bytes4(0x1F)}); } // Do not allow mistaken calls: function() external { revert(); } // Modifiers: modifier onlyRegisteredScheme() { require(schemes[msg.sender].permissions&bytes4(1) == bytes4(1)); _; } modifier onlyRegisteringSchemes() { require(schemes[msg.sender].permissions&bytes4(2) == bytes4(2)); _; } modifier onlyGlobalConstraintsScheme() { require(schemes[msg.sender].permissions&bytes4(4) == bytes4(4)); _; } modifier onlyUpgradingScheme() { require(schemes[msg.sender].permissions&bytes4(8) == bytes4(8)); _; } modifier onlyGenericCallScheme() { require(schemes[msg.sender].permissions&bytes4(16) == bytes4(16)); _; } modifier onlySubjectToConstraint(bytes32 func) { uint idx; for (idx = 0;idx<globalConstraintsPre.length;idx++) { require((GlobalConstraintInterface(globalConstraintsPre[idx].gcAddress)).pre(msg.sender,globalConstraintsPre[idx].params,func)); } _; for (idx = 0;idx<globalConstraintsPost.length;idx++) { require((GlobalConstraintInterface(globalConstraintsPost[idx].gcAddress)).post(msg.sender,globalConstraintsPost[idx].params,func)); } } modifier isAvatarValid(address _avatar) { require(_avatar == address(avatar)); _; } /** * @dev Mint `_amount` of reputation that are assigned to `_to` . * @param _amount amount of reputation to mint * @param _to beneficiary address * @return bool which represents a success */ function mintReputation(uint256 _amount, address _to,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("mintReputation") isAvatarValid(_avatar) returns(bool) { emit MintReputation(msg.sender, _to, _amount); return nativeReputation.mint(_to, _amount); } /** * @dev Burns `_amount` of reputation from `_from` * @param _amount amount of reputation to burn * @param _from The address that will lose the reputation * @return bool which represents a success */ function burnReputation(uint256 _amount, address _from,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("burnReputation") isAvatarValid(_avatar) returns(bool) { emit BurnReputation(msg.sender, _from, _amount); return nativeReputation.burn(_from, _amount); } /** * @dev mint tokens . * @param _amount amount of token to mint * @param _beneficiary beneficiary address * @return bool which represents a success */ function mintTokens(uint256 _amount, address _beneficiary,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("mintTokens") isAvatarValid(_avatar) returns(bool) { emit MintTokens(msg.sender, _beneficiary, _amount); return nativeToken.mint(_beneficiary, _amount); } /** * @dev register a scheme * @param _scheme the address of the scheme * @param _paramsHash a hashed configuration of the usage of the scheme * @param _permissions the permissions the new scheme will have * @return bool which represents a success */ function registerScheme(address _scheme, bytes32 _paramsHash, bytes4 _permissions,address _avatar) external onlyRegisteringSchemes onlySubjectToConstraint("registerScheme") isAvatarValid(_avatar) returns(bool) { Scheme memory scheme = schemes[_scheme]; // Check scheme has at least the permissions it is changing, and at least the current permissions: // Implementation is a bit messy. One must recall logic-circuits ^^ // produces non-zero if sender does not have all of the perms that are changing between old and new require(bytes4(0x1F)&(_permissions^scheme.permissions)&(~schemes[msg.sender].permissions) == bytes4(0)); // produces non-zero if sender does not have all of the perms in the old scheme require(bytes4(0x1F)&(scheme.permissions&(~schemes[msg.sender].permissions)) == bytes4(0)); // Add or change the scheme: schemes[_scheme].paramsHash = _paramsHash; schemes[_scheme].permissions = _permissions|bytes4(1); emit RegisterScheme(msg.sender, _scheme); return true; } /** * @dev unregister a scheme * @param _scheme the address of the scheme * @return bool which represents a success */ function unregisterScheme( address _scheme,address _avatar) external onlyRegisteringSchemes onlySubjectToConstraint("unregisterScheme") isAvatarValid(_avatar) returns(bool) { //check if the scheme is registered if (schemes[_scheme].permissions&bytes4(1) == bytes4(0)) { return false; } // Check the unregistering scheme has enough permissions: require(bytes4(0x1F)&(schemes[_scheme].permissions&(~schemes[msg.sender].permissions)) == bytes4(0)); // Unregister: emit UnregisterScheme(msg.sender, _scheme); delete schemes[_scheme]; return true; } /** * @dev unregister the caller's scheme * @return bool which represents a success */ function unregisterSelf(address _avatar) external isAvatarValid(_avatar) returns(bool) { if (_isSchemeRegistered(msg.sender,_avatar) == false) { return false; } delete schemes[msg.sender]; emit UnregisterScheme(msg.sender, msg.sender); return true; } function isSchemeRegistered(address _scheme,address _avatar) external isAvatarValid(_avatar) view returns(bool) { return _isSchemeRegistered(_scheme,_avatar); } function getSchemeParameters(address _scheme,address _avatar) external isAvatarValid(_avatar) view returns(bytes32) { return schemes[_scheme].paramsHash; } function getSchemePermissions(address _scheme,address _avatar) external isAvatarValid(_avatar) view returns(bytes4) { return schemes[_scheme].permissions; } function getGlobalConstraintParameters(address _globalConstraint,address) external view returns(bytes32) { GlobalConstraintRegister memory register = globalConstraintsRegisterPre[_globalConstraint]; if (register.isRegistered) { return globalConstraintsPre[register.index].params; } register = globalConstraintsRegisterPost[_globalConstraint]; if (register.isRegistered) { return globalConstraintsPost[register.index].params; } } /** * @dev globalConstraintsCount return the global constraint pre and post count * @return uint globalConstraintsPre count. * @return uint globalConstraintsPost count. */ function globalConstraintsCount(address _avatar) external isAvatarValid(_avatar) view returns(uint,uint) { return (globalConstraintsPre.length,globalConstraintsPost.length); } function isGlobalConstraintRegistered(address _globalConstraint,address _avatar) external isAvatarValid(_avatar) view returns(bool) { return (globalConstraintsRegisterPre[_globalConstraint].isRegistered || globalConstraintsRegisterPost[_globalConstraint].isRegistered); } /** * @dev add or update Global Constraint * @param _globalConstraint the address of the global constraint to be added. * @param _params the constraint parameters hash. * @return bool which represents a success */ function addGlobalConstraint(address _globalConstraint, bytes32 _params,address _avatar) external onlyGlobalConstraintsScheme isAvatarValid(_avatar) returns(bool) { GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when(); if ((when == GlobalConstraintInterface.CallPhase.Pre)||(when == GlobalConstraintInterface.CallPhase.PreAndPost)) { if (!globalConstraintsRegisterPre[_globalConstraint].isRegistered) { globalConstraintsPre.push(GlobalConstraint(_globalConstraint,_params)); globalConstraintsRegisterPre[_globalConstraint] = GlobalConstraintRegister(true,globalConstraintsPre.length-1); }else { globalConstraintsPre[globalConstraintsRegisterPre[_globalConstraint].index].params = _params; } } if ((when == GlobalConstraintInterface.CallPhase.Post)||(when == GlobalConstraintInterface.CallPhase.PreAndPost)) { if (!globalConstraintsRegisterPost[_globalConstraint].isRegistered) { globalConstraintsPost.push(GlobalConstraint(_globalConstraint,_params)); globalConstraintsRegisterPost[_globalConstraint] = GlobalConstraintRegister(true,globalConstraintsPost.length-1); }else { globalConstraintsPost[globalConstraintsRegisterPost[_globalConstraint].index].params = _params; } } emit AddGlobalConstraint(_globalConstraint, _params,when); return true; } /** * @dev remove Global Constraint * @param _globalConstraint the address of the global constraint to be remove. * @return bool which represents a success */ function removeGlobalConstraint (address _globalConstraint,address _avatar) external onlyGlobalConstraintsScheme isAvatarValid(_avatar) returns(bool) { GlobalConstraintRegister memory globalConstraintRegister; GlobalConstraint memory globalConstraint; GlobalConstraintInterface.CallPhase when = GlobalConstraintInterface(_globalConstraint).when(); bool retVal = false; if ((when == GlobalConstraintInterface.CallPhase.Pre)||(when == GlobalConstraintInterface.CallPhase.PreAndPost)) { globalConstraintRegister = globalConstraintsRegisterPre[_globalConstraint]; if (globalConstraintRegister.isRegistered) { if (globalConstraintRegister.index < globalConstraintsPre.length-1) { globalConstraint = globalConstraintsPre[globalConstraintsPre.length-1]; globalConstraintsPre[globalConstraintRegister.index] = globalConstraint; globalConstraintsRegisterPre[globalConstraint.gcAddress].index = globalConstraintRegister.index; } globalConstraintsPre.length--; delete globalConstraintsRegisterPre[_globalConstraint]; retVal = true; } } if ((when == GlobalConstraintInterface.CallPhase.Post)||(when == GlobalConstraintInterface.CallPhase.PreAndPost)) { globalConstraintRegister = globalConstraintsRegisterPost[_globalConstraint]; if (globalConstraintRegister.isRegistered) { if (globalConstraintRegister.index < globalConstraintsPost.length-1) { globalConstraint = globalConstraintsPost[globalConstraintsPost.length-1]; globalConstraintsPost[globalConstraintRegister.index] = globalConstraint; globalConstraintsRegisterPost[globalConstraint.gcAddress].index = globalConstraintRegister.index; } globalConstraintsPost.length--; delete globalConstraintsRegisterPost[_globalConstraint]; retVal = true; } } if (retVal) { emit RemoveGlobalConstraint(_globalConstraint,globalConstraintRegister.index,when == GlobalConstraintInterface.CallPhase.Pre); } return retVal; } /** * @dev upgrade the Controller * The function will trigger an event 'UpgradeController'. * @param _newController the address of the new controller. * @return bool which represents a success */ function upgradeController(address _newController,address _avatar) external onlyUpgradingScheme isAvatarValid(_avatar) returns(bool) { require(newController == address(0)); // so the upgrade could be done once for a contract. require(_newController != address(0)); newController = _newController; avatar.transferOwnership(_newController); require(avatar.owner()==_newController); if (nativeToken.owner() == address(this)) { nativeToken.transferOwnership(_newController); require(nativeToken.owner()==_newController); } if (nativeReputation.owner() == address(this)) { nativeReputation.transferOwnership(_newController); require(nativeReputation.owner()==_newController); } emit UpgradeController(this,newController); return true; } /** * @dev perform a generic call to an arbitrary contract * @param _contract the contract's address to call * @param _data ABI-encoded contract call to call `_contract` address. * @param _avatar the controller's avatar address * @return bytes32 - the return value of the called _contract's function. */ function genericCall(address _contract,bytes _data,address _avatar) external onlyGenericCallScheme onlySubjectToConstraint("genericCall") isAvatarValid(_avatar) returns (bytes32) { emit GenericCall(_contract, _data); avatar.genericCall(_contract, _data); // solium-disable-next-line security/no-inline-assembly assembly { // Copy the returned data. returndatacopy(0, 0, returndatasize) return(0, returndatasize) } } /** * @dev send some ether * @param _amountInWei the amount of ether (in Wei) to send * @param _to address of the beneficiary * @return bool which represents a success */ function sendEther(uint _amountInWei, address _to,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("sendEther") isAvatarValid(_avatar) returns(bool) { emit SendEther(msg.sender, _amountInWei, _to); return avatar.sendEther(_amountInWei, _to); } /** * @dev send some amount of arbitrary ERC20 Tokens * @param _externalToken the address of the Token Contract * @param _to address of the beneficiary * @param _value the amount of ether (in Wei) to send * @return bool which represents a success */ function externalTokenTransfer(StandardToken _externalToken, address _to, uint _value,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("externalTokenTransfer") isAvatarValid(_avatar) returns(bool) { emit ExternalTokenTransfer(msg.sender, _externalToken, _to, _value); return avatar.externalTokenTransfer(_externalToken, _to, _value); } /** * @dev transfer token "from" address "to" address * One must to approve the amount of tokens which can be spend from the * "from" account.This can be done using externalTokenApprove. * @param _externalToken the address of the Token Contract * @param _from address of the account to send from * @param _to address of the beneficiary * @param _value the amount of ether (in Wei) to send * @return bool which represents a success */ function externalTokenTransferFrom(StandardToken _externalToken, address _from, address _to, uint _value,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("externalTokenTransferFrom") isAvatarValid(_avatar) returns(bool) { emit ExternalTokenTransferFrom(msg.sender, _externalToken, _from, _to, _value); return avatar.externalTokenTransferFrom(_externalToken, _from, _to, _value); } /** * @dev increase approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _addedValue the amount of ether (in Wei) which the approval is referring to. * @return bool which represents a success */ function externalTokenIncreaseApproval(StandardToken _externalToken, address _spender, uint _addedValue,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("externalTokenIncreaseApproval") isAvatarValid(_avatar) returns(bool) { emit ExternalTokenIncreaseApproval(msg.sender,_externalToken,_spender,_addedValue); return avatar.externalTokenIncreaseApproval(_externalToken, _spender, _addedValue); } /** * @dev decrease approval for the spender address to spend a specified amount of tokens * on behalf of msg.sender. * @param _externalToken the address of the Token Contract * @param _spender address * @param _subtractedValue the amount of ether (in Wei) which the approval is referring to. * @return bool which represents a success */ function externalTokenDecreaseApproval(StandardToken _externalToken, address _spender, uint _subtractedValue,address _avatar) external onlyRegisteredScheme onlySubjectToConstraint("externalTokenDecreaseApproval") isAvatarValid(_avatar) returns(bool) { emit ExternalTokenDecreaseApproval(msg.sender,_externalToken,_spender,_subtractedValue); return avatar.externalTokenDecreaseApproval(_externalToken, _spender, _subtractedValue); } /** * @dev getNativeReputation * @param _avatar the organization avatar. * @return organization native reputation */ function getNativeReputation(address _avatar) external isAvatarValid(_avatar) view returns(address) { return address(nativeReputation); } function _isSchemeRegistered(address _scheme,address _avatar) private isAvatarValid(_avatar) view returns(bool) { return (schemes[_scheme].permissions&bytes4(1) != bytes4(0)); } } // File: contracts/universalSchemes/ExecutableInterface.sol contract ExecutableInterface { function execute(bytes32 _proposalId, address _avatar, int _param) public returns(bool); } // File: contracts/VotingMachines/IntVoteInterface.sol interface IntVoteInterface { //When implementing this interface please do not only override function and modifier, //but also to keep the modifiers on the overridden functions. modifier onlyProposalOwner(bytes32 _proposalId) {revert(); _;} modifier votable(bytes32 _proposalId) {revert(); _;} event NewProposal(bytes32 indexed _proposalId, address indexed _avatar, uint _numOfChoices, address _proposer, bytes32 _paramsHash); event ExecuteProposal(bytes32 indexed _proposalId, address indexed _avatar, uint _decision, uint _totalReputation); event VoteProposal(bytes32 indexed _proposalId, address indexed _avatar, address indexed _voter, uint _vote, uint _reputation); event CancelProposal(bytes32 indexed _proposalId, address indexed _avatar ); event CancelVoting(bytes32 indexed _proposalId, address indexed _avatar, address indexed _voter); /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _proposalParameters defines the parameters of the voting machine used for this proposal * @param _avatar an address to be sent as the payload to the _executable contract. * @param _executable This contract will be executed when vote is over. * @param _proposer address * @return proposal's id. */ function propose( uint _numOfChoices, bytes32 _proposalParameters, address _avatar, ExecutableInterface _executable, address _proposer ) external returns(bytes32); // Only owned proposals and only the owner: function cancelProposal(bytes32 _proposalId) external returns(bool); // Only owned proposals and only the owner: function ownerVote(bytes32 _proposalId, uint _vote, address _voter) external returns(bool); function vote(bytes32 _proposalId, uint _vote) external returns(bool); function voteWithSpecifiedAmounts( bytes32 _proposalId, uint _vote, uint _rep, uint _token) external returns(bool); function cancelVote(bytes32 _proposalId) external; //@dev execute check if the proposal has been decided, and if so, execute the proposal //@param _proposalId the id of the proposal //@return bool true - the proposal has been executed // false - otherwise. function execute(bytes32 _proposalId) external returns(bool); function getNumberOfChoices(bytes32 _proposalId) external view returns(uint); function isVotable(bytes32 _proposalId) external view returns(bool); /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId,uint _choice) external view returns(uint); /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns(bool); /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns(uint min,uint max); } // File: contracts/universalSchemes/UniversalSchemeInterface.sol contract UniversalSchemeInterface { function updateParameters(bytes32 _hashedParameters) public; function getParametersFromController(Avatar _avatar) internal view returns(bytes32); } // File: contracts/universalSchemes/UniversalScheme.sol contract UniversalScheme is Ownable, UniversalSchemeInterface { bytes32 public hashedParameters; // For other parameters. function updateParameters( bytes32 _hashedParameters ) public onlyOwner { hashedParameters = _hashedParameters; } /** * @dev get the parameters for the current scheme from the controller */ function getParametersFromController(Avatar _avatar) internal view returns(bytes32) { return ControllerInterface(_avatar.owner()).getSchemeParameters(this,address(_avatar)); } } // File: contracts/libs/RealMath.sol /** * RealMath: fixed-point math library, based on fractional and integer parts. * Using int256 as real216x40, which isn't in Solidity yet. * 40 fractional bits gets us down to 1E-12 precision, while still letting us * go up to galaxy scale counting in meters. * Internally uses the wider int256 for some math. * * Note that for addition, subtraction, and mod (%), you should just use the * built-in Solidity operators. Functions for these operations are not provided. * * Note that the fancy functions like sqrt, atan2, etc. aren't as accurate as * they should be. They are (hopefully) Good Enough for doing orbital mechanics * on block timescales in a game context, but they may not be good enough for * other applications. */ library RealMath { /** * How many total bits are there? */ int256 constant REAL_BITS = 256; /** * How many fractional bits are there? */ int256 constant REAL_FBITS = 40; /** * How many integer bits are there? */ int256 constant REAL_IBITS = REAL_BITS - REAL_FBITS; /** * What's the first non-fractional bit */ int256 constant REAL_ONE = int256(1) << REAL_FBITS; /** * What's the last fractional bit? */ int256 constant REAL_HALF = REAL_ONE >> 1; /** * What's two? Two is pretty useful. */ int256 constant REAL_TWO = REAL_ONE << 1; /** * And our logarithms are based on ln(2). */ int256 constant REAL_LN_TWO = 762123384786; /** * It is also useful to have Pi around. */ int256 constant REAL_PI = 3454217652358; /** * And half Pi, to save on divides. * TODO: That might not be how the compiler handles constants. */ int256 constant REAL_HALF_PI = 1727108826179; /** * And two pi, which happens to be odd in its most accurate representation. */ int256 constant REAL_TWO_PI = 6908435304715; /** * What's the sign bit? */ int256 constant SIGN_MASK = int256(1) << 255; /** * Convert an integer to a real. Preserves sign. */ function toReal(int216 ipart) internal pure returns (int256) { return int256(ipart) * REAL_ONE; } /** * Convert a real to an integer. Preserves sign. */ function fromReal(int256 realValue) internal pure returns (int216) { return int216(realValue / REAL_ONE); } /** * Round a real to the nearest integral real value. */ function round(int256 realValue) internal pure returns (int256) { // First, truncate. int216 ipart = fromReal(realValue); if ((fractionalBits(realValue) & (uint40(1) << (REAL_FBITS - 1))) > 0) { // High fractional bit is set. Round up. if (realValue < int256(0)) { // Rounding up for a negative number is rounding down. ipart -= 1; } else { ipart += 1; } } return toReal(ipart); } /** * Get the absolute value of a real. Just the same as abs on a normal int256. */ function abs(int256 realValue) internal pure returns (int256) { if (realValue > 0) { return realValue; } else { return -realValue; } } /** * Returns the fractional bits of a real. Ignores the sign of the real. */ function fractionalBits(int256 realValue) internal pure returns (uint40) { return uint40(abs(realValue) % REAL_ONE); } /** * Get the fractional part of a real, as a real. Ignores sign (so fpart(-0.5) is 0.5). */ function fpart(int256 realValue) internal pure returns (int256) { // This gets the fractional part but strips the sign return abs(realValue) % REAL_ONE; } /** * Get the fractional part of a real, as a real. Respects sign (so fpartSigned(-0.5) is -0.5). */ function fpartSigned(int256 realValue) internal pure returns (int256) { // This gets the fractional part but strips the sign int256 fractional = fpart(realValue); if (realValue < 0) { // Add the negative sign back in. return -fractional; } else { return fractional; } } /** * Get the integer part of a fixed point value. */ function ipart(int256 realValue) internal pure returns (int256) { // Subtract out the fractional part to get the real part. return realValue - fpartSigned(realValue); } /** * Multiply one real by another. Truncates overflows. */ function mul(int256 realA, int256 realB) internal pure returns (int256) { // When multiplying fixed point in x.y and z.w formats we get (x+z).(y+w) format. // So we just have to clip off the extra REAL_FBITS fractional bits. return int256((int256(realA) * int256(realB)) >> REAL_FBITS); } /** * Divide one real by another real. Truncates overflows. */ function div(int256 realNumerator, int256 realDenominator) internal pure returns (int256) { // We use the reverse of the multiplication trick: convert numerator from // x.y to (x+z).(y+w) fixed point, then divide by denom in z.w fixed point. return int256((int256(realNumerator) * REAL_ONE) / int256(realDenominator)); } /** * Create a real from a rational fraction. */ function fraction(int216 numerator, int216 denominator) internal pure returns (int256) { return div(toReal(numerator), toReal(denominator)); } // Now we have some fancy math things (like pow and trig stuff). This isn't // in the RealMath that was deployed with the original Macroverse // deployment, so it needs to be linked into your contract statically. /** * Raise a number to a positive integer power in O(log power) time. * See <https://stackoverflow.com/a/101613> */ function ipow(int256 realBase, int216 exponent) internal pure returns (int256) { if (exponent < 0) { // Negative powers are not allowed here. revert(); } int256 tempRealBase = realBase; int256 tempExponent = exponent; // Start with the 0th power int256 realResult = REAL_ONE; while (tempExponent != 0) { // While there are still bits set if ((tempExponent & 0x1) == 0x1) { // If the low bit is set, multiply in the (many-times-squared) base realResult = mul(realResult, tempRealBase); } // Shift off the low bit tempExponent = tempExponent >> 1; // Do the squaring tempRealBase = mul(tempRealBase, tempRealBase); } // Return the final result. return realResult; } /** * Zero all but the highest set bit of a number. * See <https://stackoverflow.com/a/53184> */ function hibit(uint256 _val) internal pure returns (uint256) { // Set all the bits below the highest set bit uint256 val = _val; val |= (val >> 1); val |= (val >> 2); val |= (val >> 4); val |= (val >> 8); val |= (val >> 16); val |= (val >> 32); val |= (val >> 64); val |= (val >> 128); return val ^ (val >> 1); } /** * Given a number with one bit set, finds the index of that bit. */ function findbit(uint256 val) internal pure returns (uint8 index) { index = 0; // We and the value with alternating bit patters of various pitches to find it. if (val & 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA != 0) { // Picth 1 index |= 1; } if (val & 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC != 0) { // Pitch 2 index |= 2; } if (val & 0xF0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0 != 0) { // Pitch 4 index |= 4; } if (val & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 != 0) { // Pitch 8 index |= 8; } if (val & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 != 0) { // Pitch 16 index |= 16; } if (val & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000 != 0) { // Pitch 32 index |= 32; } if (val & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000 != 0) { // Pitch 64 index |= 64; } if (val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 != 0) { // Pitch 128 index |= 128; } } /** * Shift realArg left or right until it is between 1 and 2. Return the * rescaled value, and the number of bits of right shift applied. Shift may be negative. * * Expresses realArg as realScaled * 2^shift, setting shift to put realArg between [1 and 2). * * Rejects 0 or negative arguments. */ function rescale(int256 realArg) internal pure returns (int256 realScaled, int216 shift) { if (realArg <= 0) { // Not in domain! revert(); } // Find the high bit int216 highBit = findbit(hibit(uint256(realArg))); // We'll shift so the high bit is the lowest non-fractional bit. shift = highBit - int216(REAL_FBITS); if (shift < 0) { // Shift left realScaled = realArg << -shift; } else if (shift >= 0) { // Shift right realScaled = realArg >> shift; } } /** * Calculate the natural log of a number. Rescales the input value and uses * the algorithm outlined at <https://math.stackexchange.com/a/977836> and * the ipow implementation. * * Lets you artificially limit the number of iterations. * * Note that it is potentially possible to get an un-converged value; lack * of convergence does not throw. */ function lnLimited(int256 realArg, int maxIterations) internal pure returns (int256) { if (realArg <= 0) { // Outside of acceptable domain revert(); } if (realArg == REAL_ONE) { // Handle this case specially because people will want exactly 0 and // not ~2^-39 ish. return 0; } // We know it's positive, so rescale it to be between [1 and 2) int256 realRescaled; int216 shift; (realRescaled, shift) = rescale(realArg); // Compute the argument to iterate on int256 realSeriesArg = div(realRescaled - REAL_ONE, realRescaled + REAL_ONE); // We will accumulate the result here int256 realSeriesResult = 0; for (int216 n = 0; n < maxIterations; n++) { // Compute term n of the series int256 realTerm = div(ipow(realSeriesArg, 2 * n + 1), toReal(2 * n + 1)); // And add it in realSeriesResult += realTerm; if (realTerm == 0) { // We must have converged. Next term is too small to represent. break; } // If we somehow never converge I guess we will run out of gas } // Double it to account for the factor of 2 outside the sum realSeriesResult = mul(realSeriesResult, REAL_TWO); // Now compute and return the overall result return mul(toReal(shift), REAL_LN_TWO) + realSeriesResult; } /** * Calculate a natural logarithm with a sensible maximum iteration count to * wait until convergence. Note that it is potentially possible to get an * un-converged value; lack of convergence does not throw. */ function ln(int256 realArg) internal pure returns (int256) { return lnLimited(realArg, 100); } /** * Calculate e^x. Uses the series given at * <http://pages.mtu.edu/~shene/COURSES/cs201/NOTES/chap04/exp.html>. * * Lets you artificially limit the number of iterations. * * Note that it is potentially possible to get an un-converged value; lack * of convergence does not throw. */ function expLimited(int256 realArg, int maxIterations) internal pure returns (int256) { // We will accumulate the result here int256 realResult = 0; // We use this to save work computing terms int256 realTerm = REAL_ONE; for (int216 n = 0; n < maxIterations; n++) { // Add in the term realResult += realTerm; // Compute the next term realTerm = mul(realTerm, div(realArg, toReal(n + 1))); if (realTerm == 0) { // We must have converged. Next term is too small to represent. break; } // If we somehow never converge I guess we will run out of gas } // Return the result return realResult; } /** * Calculate e^x with a sensible maximum iteration count to wait until * convergence. Note that it is potentially possible to get an un-converged * value; lack of convergence does not throw. */ function exp(int256 realArg) internal pure returns (int256) { return expLimited(realArg, 100); } /** * Raise any number to any power, except for negative bases to fractional powers. */ function pow(int256 realBase, int256 realExponent) internal pure returns (int256) { if (realExponent == 0) { // Anything to the 0 is 1 return REAL_ONE; } if (realBase == 0) { if (realExponent < 0) { // Outside of domain! revert(); } // Otherwise it's 0 return 0; } if (fpart(realExponent) == 0) { // Anything (even a negative base) is super easy to do to an integer power. if (realExponent > 0) { // Positive integer power is easy return ipow(realBase, fromReal(realExponent)); } else { // Negative integer power is harder return div(REAL_ONE, ipow(realBase, fromReal(-realExponent))); } } if (realBase < 0) { // It's a negative base to a non-integer power. // In general pow(-x^y) is undefined, unless y is an int or some // weird rational-number-based relationship holds. revert(); } // If it's not a special case, actually do it. return exp(mul(realExponent, ln(realBase))); } /** * Compute the square root of a number. */ function sqrt(int256 realArg) internal pure returns (int256) { return pow(realArg, REAL_HALF); } /** * Compute the sin of a number to a certain number of Taylor series terms. */ function sinLimited(int256 _realArg, int216 maxIterations) internal pure returns (int256) { // First bring the number into 0 to 2 pi // TODO: This will introduce an error for very large numbers, because the error in our Pi will compound. // But for actual reasonable angle values we should be fine. int256 realArg = _realArg; realArg = realArg % REAL_TWO_PI; int256 accumulator = REAL_ONE; // We sum from large to small iteration so that we can have higher powers in later terms for (int216 iteration = maxIterations - 1; iteration >= 0; iteration--) { accumulator = REAL_ONE - mul(div(mul(realArg, realArg), toReal((2 * iteration + 2) * (2 * iteration + 3))), accumulator); // We can't stop early; we need to make it to the first term. } return mul(realArg, accumulator); } /** * Calculate sin(x) with a sensible maximum iteration count to wait until * convergence. */ function sin(int256 realArg) internal pure returns (int256) { return sinLimited(realArg, 15); } /** * Calculate cos(x). */ function cos(int256 realArg) internal pure returns (int256) { return sin(realArg + REAL_HALF_PI); } /** * Calculate tan(x). May overflow for large results. May throw if tan(x) * would be infinite, or return an approximation, or overflow. */ function tan(int256 realArg) internal pure returns (int256) { return div(sin(realArg), cos(realArg)); } } // File: openzeppelin-solidity/contracts/ECRecovery.sol /** * @title Eliptic curve signature operations * * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d * * TODO Remove this library once solidity supports passing a signature to ecrecover. * See https://github.com/ethereum/solidity/issues/864 * */ library ECRecovery { /** * @dev Recover signer address from a message by using their signature * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param sig bytes signature, the signature is generated using web3.eth.sign() */ function recover(bytes32 hash, bytes sig) internal pure returns (address) { bytes32 r; bytes32 s; uint8 v; // Check the signature length if (sig.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solium-disable-next-line security/no-inline-assembly assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions if (v < 27) { v += 27; } // If the version is correct return the signer address if (v != 27 && v != 28) { return (address(0)); } else { // solium-disable-next-line arg-overflow return ecrecover(hash, v, r, s); } } /** * toEthSignedMessageHash * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * @dev and hash the result */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256( "\x19Ethereum Signed Message:\n32", hash ); } } // File: contracts/libs/OrderStatisticTree.sol library OrderStatisticTree { struct Node { mapping (bool => uint) children; // a mapping of left(false) child and right(true) child nodes uint parent; // parent node bool side; // side of the node on the tree (left or right) uint height; //Height of this node uint count; //Number of tree nodes below this node (including this one) uint dupes; //Number of duplicates values for this node } struct Tree { // a mapping between node value(uint) to Node // the tree's root is always at node 0 ,which points to the "real" tree // as its right child.this is done to eliminate the need to update the tree // root in the case of rotation.(saving gas). mapping(uint => Node) nodes; } /** * @dev rank - find the rank of a value in the tree, * i.e. its index in the sorted list of elements of the tree * @param _tree the tree * @param _value the input value to find its rank. * @return smaller - the number of elements in the tree which their value is * less than the input value. */ function rank(Tree storage _tree,uint _value) internal view returns (uint smaller) { if (_value != 0) { smaller = _tree.nodes[0].dupes; uint cur = _tree.nodes[0].children[true]; Node storage currentNode = _tree.nodes[cur]; while (true) { if (cur <= _value) { if (cur<_value) { smaller = smaller + 1+currentNode.dupes; } uint leftChild = currentNode.children[false]; if (leftChild!=0) { smaller = smaller + _tree.nodes[leftChild].count; } } if (cur == _value) { break; } cur = currentNode.children[cur<_value]; if (cur == 0) { break; } currentNode = _tree.nodes[cur]; } } } function count(Tree storage _tree) internal view returns (uint) { Node storage root = _tree.nodes[0]; Node memory child = _tree.nodes[root.children[true]]; return root.dupes+child.count; } function updateCount(Tree storage _tree,uint _value) private { Node storage n = _tree.nodes[_value]; n.count = 1+_tree.nodes[n.children[false]].count+_tree.nodes[n.children[true]].count+n.dupes; } function updateCounts(Tree storage _tree,uint _value) private { uint parent = _tree.nodes[_value].parent; while (parent!=0) { updateCount(_tree,parent); parent = _tree.nodes[parent].parent; } } function updateHeight(Tree storage _tree,uint _value) private { Node storage n = _tree.nodes[_value]; uint heightLeft = _tree.nodes[n.children[false]].height; uint heightRight = _tree.nodes[n.children[true]].height; if (heightLeft > heightRight) n.height = heightLeft+1; else n.height = heightRight+1; } function balanceFactor(Tree storage _tree,uint _value) private view returns (int bf) { Node storage n = _tree.nodes[_value]; return int(_tree.nodes[n.children[false]].height)-int(_tree.nodes[n.children[true]].height); } function rotate(Tree storage _tree,uint _value,bool dir) private { bool otherDir = !dir; Node storage n = _tree.nodes[_value]; bool side = n.side; uint parent = n.parent; uint valueNew = n.children[otherDir]; Node storage nNew = _tree.nodes[valueNew]; uint orphan = nNew.children[dir]; Node storage p = _tree.nodes[parent]; Node storage o = _tree.nodes[orphan]; p.children[side] = valueNew; nNew.side = side; nNew.parent = parent; nNew.children[dir] = _value; n.parent = valueNew; n.side = dir; n.children[otherDir] = orphan; o.parent = _value; o.side = otherDir; updateHeight(_tree,_value); updateHeight(_tree,valueNew); updateCount(_tree,_value); updateCount(_tree,valueNew); } function rebalanceInsert(Tree storage _tree,uint _nValue) private { updateHeight(_tree,_nValue); Node storage n = _tree.nodes[_nValue]; uint pValue = n.parent; if (pValue!=0) { int pBf = balanceFactor(_tree,pValue); bool side = n.side; int sign; if (side) sign = -1; else sign = 1; if (pBf == sign*2) { if (balanceFactor(_tree,_nValue) == (-1 * sign)) { rotate(_tree,_nValue,side); } rotate(_tree,pValue,!side); } else if (pBf != 0) { rebalanceInsert(_tree,pValue); } } } function rebalanceDelete(Tree storage _tree,uint _pValue,bool side) private { if (_pValue!=0) { updateHeight(_tree,_pValue); int pBf = balanceFactor(_tree,_pValue); int sign; if (side) sign = 1; else sign = -1; int bf = balanceFactor(_tree,_pValue); if (bf==(2*sign)) { Node storage p = _tree.nodes[_pValue]; uint sValue = p.children[!side]; int sBf = balanceFactor(_tree,sValue); if (sBf == (-1 * sign)) { rotate(_tree,sValue,!side); } rotate(_tree,_pValue,side); if (sBf!=0) { p = _tree.nodes[_pValue]; rebalanceDelete(_tree,p.parent,p.side); } } else if (pBf != sign) { p = _tree.nodes[_pValue]; rebalanceDelete(_tree,p.parent,p.side); } } } function fixParents(Tree storage _tree,uint parent,bool side) private { if (parent!=0) { updateCount(_tree,parent); updateCounts(_tree,parent); rebalanceDelete(_tree,parent,side); } } function insertHelper(Tree storage _tree,uint _pValue,bool _side,uint _value) private { Node storage root = _tree.nodes[_pValue]; uint cValue = root.children[_side]; if (cValue==0) { root.children[_side] = _value; Node storage child = _tree.nodes[_value]; child.parent = _pValue; child.side = _side; child.height = 1; child.count = 1; updateCounts(_tree,_value); rebalanceInsert(_tree,_value); } else if (cValue==_value) { _tree.nodes[cValue].dupes++; updateCount(_tree,_value); updateCounts(_tree,_value); } else { insertHelper(_tree,cValue,(_value >= cValue),_value); } } function insert(Tree storage _tree,uint _value) internal { if (_value==0) { _tree.nodes[_value].dupes++; } else { insertHelper(_tree,0,true,_value); } } function rightmostLeaf(Tree storage _tree,uint _value) private view returns (uint leaf) { uint child = _tree.nodes[_value].children[true]; if (child!=0) { return rightmostLeaf(_tree,child); } else { return _value; } } function zeroOut(Tree storage _tree,uint _value) private { Node storage n = _tree.nodes[_value]; n.parent = 0; n.side = false; n.children[false] = 0; n.children[true] = 0; n.count = 0; n.height = 0; n.dupes = 0; } function removeBranch(Tree storage _tree,uint _value,uint _left) private { uint ipn = rightmostLeaf(_tree,_left); Node storage i = _tree.nodes[ipn]; uint dupes = i.dupes; removeHelper(_tree,ipn); Node storage n = _tree.nodes[_value]; uint parent = n.parent; Node storage p = _tree.nodes[parent]; uint height = n.height; bool side = n.side; uint ncount = n.count; uint right = n.children[true]; uint left = n.children[false]; p.children[side] = ipn; i.parent = parent; i.side = side; i.count = ncount+dupes-n.dupes; i.height = height; i.dupes = dupes; if (left!=0) { i.children[false] = left; _tree.nodes[left].parent = ipn; } if (right!=0) { i.children[true] = right; _tree.nodes[right].parent = ipn; } zeroOut(_tree,_value); updateCounts(_tree,ipn); } function removeHelper(Tree storage _tree,uint _value) private { Node storage n = _tree.nodes[_value]; uint parent = n.parent; bool side = n.side; Node storage p = _tree.nodes[parent]; uint left = n.children[false]; uint right = n.children[true]; if ((left == 0) && (right == 0)) { p.children[side] = 0; zeroOut(_tree,_value); fixParents(_tree,parent,side); } else if ((left != 0) && (right != 0)) { removeBranch(_tree,_value,left); } else { uint child = left+right; Node storage c = _tree.nodes[child]; p.children[side] = child; c.parent = parent; c.side = side; zeroOut(_tree,_value); fixParents(_tree,parent,side); } } function remove(Tree storage _tree,uint _value) internal { Node storage n = _tree.nodes[_value]; if (_value==0) { if (n.dupes==0) { return; } } else { if (n.count==0) { return; } } if (n.dupes>0) { n.dupes--; if (_value!=0) { n.count--; } fixParents(_tree,n.parent,n.side); } else { removeHelper(_tree,_value); } } } // File: contracts/VotingMachines/GenesisProtocol.sol /** * @title GenesisProtocol implementation -an organization's voting machine scheme. */ contract GenesisProtocol is IntVoteInterface,UniversalScheme { using SafeMath for uint; using RealMath for int216; using RealMath for int256; using ECRecovery for bytes32; using OrderStatisticTree for OrderStatisticTree.Tree; enum ProposalState { None ,Closed, Executed, PreBoosted,Boosted,QuietEndingPeriod } enum ExecutionState { None, PreBoostedTimeOut, PreBoostedBarCrossed, BoostedTimeOut,BoostedBarCrossed } //Organization's parameters struct Parameters { uint preBoostedVoteRequiredPercentage; // the absolute vote percentages bar. uint preBoostedVotePeriodLimit; //the time limit for a proposal to be in an absolute voting mode. uint boostedVotePeriodLimit; //the time limit for a proposal to be in an relative voting mode. uint thresholdConstA;//constant A for threshold calculation . threshold =A * (e ** (numberOfBoostedProposals/B)) uint thresholdConstB;//constant B for threshold calculation . threshold =A * (e ** (numberOfBoostedProposals/B)) uint minimumStakingFee; //minimum staking fee allowed. uint quietEndingPeriod; //quite ending period uint proposingRepRewardConstA;//constant A for calculate proposer reward. proposerReward =(A*(RTotal) +B*(R+ - R-))/1000 uint proposingRepRewardConstB;//constant B for calculate proposing reward.proposerReward =(A*(RTotal) +B*(R+ - R-))/1000 uint stakerFeeRatioForVoters; // The “ratio of stake” to be paid to voters. // All stakers pay a portion of their stake to all voters, stakerFeeRatioForVoters * (s+ + s-). //All voters (pre and during boosting period) divide this portion in proportion to their reputation. uint votersReputationLossRatio;//Unsuccessful pre booster voters lose votersReputationLossRatio% of their reputation. uint votersGainRepRatioFromLostRep; //the percentages of the lost reputation which is divided by the successful pre boosted voters, //in proportion to their reputation. //The rest (100-votersGainRepRatioFromLostRep)% of lost reputation is divided between the successful wagers, //in proportion to their stake. uint daoBountyConst;//The DAO adds up a bounty for successful staker. //The bounty formula is: s * daoBountyConst, where s+ is the wager staked for the proposal, //and daoBountyConst is a constant factor that is configurable and changeable by the DAO given. // daoBountyConst should be greater than stakerFeeRatioForVoters and less than 2 * stakerFeeRatioForVoters. uint daoBountyLimit;//The daoBounty cannot be greater than daoBountyLimit. } struct Voter { uint vote; // YES(1) ,NO(2) uint reputation; // amount of voter's reputation bool preBoosted; } struct Staker { uint vote; // YES(1) ,NO(2) uint amount; // amount of staker's stake uint amountForBounty; // amount of staker's stake which will be use for bounty calculation } struct Proposal { address avatar; // the organization's avatar the proposal is target to. uint numOfChoices; ExecutableInterface executable; // will be executed if the proposal will pass uint votersStakes; uint submittedTime; uint boostedPhaseTime; //the time the proposal shift to relative mode. ProposalState state; uint winningVote; //the winning vote. address proposer; uint currentBoostedVotePeriodLimit; bytes32 paramsHash; uint daoBountyRemain; uint[2] totalStakes;// totalStakes[0] - (amount staked minus fee) - Total number of tokens staked which can be redeemable by stakers. // totalStakes[1] - (amount staked) - Total number of redeemable tokens. // vote reputation mapping(uint => uint ) votes; // vote reputation mapping(uint => uint ) preBoostedVotes; // address voter mapping(address => Voter ) voters; // vote stakes mapping(uint => uint ) stakes; // address staker mapping(address => Staker ) stakers; } event GPExecuteProposal(bytes32 indexed _proposalId, ExecutionState _executionState); event Stake(bytes32 indexed _proposalId, address indexed _avatar, address indexed _staker,uint _vote,uint _amount); event Redeem(bytes32 indexed _proposalId, address indexed _avatar, address indexed _beneficiary,uint _amount); event RedeemDaoBounty(bytes32 indexed _proposalId, address indexed _avatar, address indexed _beneficiary,uint _amount); event RedeemReputation(bytes32 indexed _proposalId, address indexed _avatar, address indexed _beneficiary,uint _amount); mapping(bytes32=>Parameters) public parameters; // A mapping from hashes to parameters mapping(bytes32=>Proposal) public proposals; // Mapping from the ID of the proposal to the proposal itself. mapping(bytes=>bool) stakeSignatures; //stake signatures uint constant public NUM_OF_CHOICES = 2; uint constant public NO = 2; uint constant public YES = 1; uint public proposalsCnt; // Total number of proposals mapping(address=>uint) orgBoostedProposalsCnt; StandardToken public stakingToken; mapping(address=>OrderStatisticTree.Tree) proposalsExpiredTimes; //proposals expired times /** * @dev Constructor */ constructor(StandardToken _stakingToken) public { stakingToken = _stakingToken; } /** * @dev Check that the proposal is votable (open and not executed yet) */ modifier votable(bytes32 _proposalId) { require(_isVotable(_proposalId)); _; } /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _avatar an address to be sent as the payload to the _executable contract. * @param _executable This contract will be executed when vote is over. * @param _proposer address * @return proposal's id. */ function propose(uint _numOfChoices, bytes32 , address _avatar, ExecutableInterface _executable,address _proposer) external returns(bytes32) { // Check valid params and number of choices: require(_numOfChoices == NUM_OF_CHOICES); require(ExecutableInterface(_executable) != address(0)); //Check parameters existence. bytes32 paramsHash = getParametersFromController(Avatar(_avatar)); require(parameters[paramsHash].preBoostedVoteRequiredPercentage > 0); // Generate a unique ID: bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt)); proposalsCnt++; // Open proposal: Proposal memory proposal; proposal.numOfChoices = _numOfChoices; proposal.avatar = _avatar; proposal.executable = _executable; proposal.state = ProposalState.PreBoosted; // solium-disable-next-line security/no-block-members proposal.submittedTime = now; proposal.currentBoostedVotePeriodLimit = parameters[paramsHash].boostedVotePeriodLimit; proposal.proposer = _proposer; proposal.winningVote = NO; proposal.paramsHash = paramsHash; proposals[proposalId] = proposal; emit NewProposal(proposalId, _avatar, _numOfChoices, _proposer, paramsHash); return proposalId; } /** * @dev Cancel a proposal, only the owner can call this function and only if allowOwner flag is true. */ function cancelProposal(bytes32 ) external returns(bool) { //This is not allowed. return false; } /** * @dev staking function * @param _proposalId id of the proposal * @param _vote NO(2) or YES(1). * @param _amount the betting amount * @return bool true - the proposal has been executed * false - otherwise. */ function stake(bytes32 _proposalId, uint _vote, uint _amount) external returns(bool) { return _stake(_proposalId,_vote,_amount,msg.sender); } // Digest describing the data the user signs according EIP 712. // Needs to match what is passed to Metamask. bytes32 public constant DELEGATION_HASH_EIP712 = keccak256(abi.encodePacked("address GenesisProtocolAddress","bytes32 ProposalId", "uint Vote","uint AmountToStake","uint Nonce")); // web3.eth.sign prefix string public constant ETH_SIGN_PREFIX= "\x19Ethereum Signed Message:\n32"; /** * @dev stakeWithSignature function * @param _proposalId id of the proposal * @param _vote NO(2) or YES(1). * @param _amount the betting amount * @param _nonce nonce value ,it is part of the signature to ensure that a signature can be received only once. * @param _signatureType signature type 1 - for web3.eth.sign 2 - for eth_signTypedData according to EIP #712. * @param _signature - signed data by the staker * @return bool true - the proposal has been executed * false - otherwise. */ function stakeWithSignature( bytes32 _proposalId, uint _vote, uint _amount, uint _nonce, uint _signatureType, bytes _signature ) external returns(bool) { require(stakeSignatures[_signature] == false); // Recreate the digest the user signed bytes32 delegationDigest; if (_signatureType == 2) { delegationDigest = keccak256( abi.encodePacked( DELEGATION_HASH_EIP712, keccak256( abi.encodePacked( address(this), _proposalId, _vote, _amount, _nonce))) ); } else { delegationDigest = keccak256( abi.encodePacked( ETH_SIGN_PREFIX, keccak256( abi.encodePacked( address(this), _proposalId, _vote, _amount, _nonce))) ); } address staker = delegationDigest.recover(_signature); //a garbage staker address due to wrong signature will revert due to lack of approval and funds. require(staker!=address(0)); stakeSignatures[_signature] = true; return _stake(_proposalId,_vote,_amount,staker); } /** * @dev voting function * @param _proposalId id of the proposal * @param _vote NO(2) or YES(1). * @return bool true - the proposal has been executed * false - otherwise. */ function vote(bytes32 _proposalId, uint _vote) external votable(_proposalId) returns(bool) { return internalVote(_proposalId, msg.sender, _vote, 0); } /** * @dev voting function with owner functionality (can vote on behalf of someone else) * @return bool true - the proposal has been executed * false - otherwise. */ function ownerVote(bytes32 , uint , address ) external returns(bool) { //This is not allowed. return false; } function voteWithSpecifiedAmounts(bytes32 _proposalId,uint _vote,uint _rep,uint) external votable(_proposalId) returns(bool) { return internalVote(_proposalId,msg.sender,_vote,_rep); } /** * @dev Cancel the vote of the msg.sender. * cancel vote is not allow in genesisProtocol so this function doing nothing. * This function is here in order to comply to the IntVoteInterface . */ function cancelVote(bytes32 _proposalId) external votable(_proposalId) { //this is not allowed return; } /** * @dev getNumberOfChoices returns the number of choices possible in this proposal * @param _proposalId the ID of the proposals * @return uint that contains number of choices */ function getNumberOfChoices(bytes32 _proposalId) external view returns(uint) { return proposals[_proposalId].numOfChoices; } /** * @dev voteInfo returns the vote and the amount of reputation of the user committed to this proposal * @param _proposalId the ID of the proposal * @param _voter the address of the voter * @return uint vote - the voters vote * uint reputation - amount of reputation committed by _voter to _proposalId */ function voteInfo(bytes32 _proposalId, address _voter) external view returns(uint, uint) { Voter memory voter = proposals[_proposalId].voters[_voter]; return (voter.vote, voter.reputation); } /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId,uint _choice) external view returns(uint) { return proposals[_proposalId].votes[_choice]; } /** * @dev isVotable check if the proposal is votable * @param _proposalId the ID of the proposal * @return bool true or false */ function isVotable(bytes32 _proposalId) external view returns(bool) { return _isVotable(_proposalId); } /** * @dev proposalStatus return the total votes and stakes for a given proposal * @param _proposalId the ID of the proposal * @return uint preBoostedVotes YES * @return uint preBoostedVotes NO * @return uint stakersStakes * @return uint totalRedeemableStakes * @return uint total stakes YES * @return uint total stakes NO */ function proposalStatus(bytes32 _proposalId) external view returns(uint, uint, uint ,uint, uint ,uint) { return ( proposals[_proposalId].preBoostedVotes[YES], proposals[_proposalId].preBoostedVotes[NO], proposals[_proposalId].totalStakes[0], proposals[_proposalId].totalStakes[1], proposals[_proposalId].stakes[YES], proposals[_proposalId].stakes[NO] ); } /** * @dev proposalAvatar return the avatar for a given proposal * @param _proposalId the ID of the proposal * @return uint total reputation supply */ function proposalAvatar(bytes32 _proposalId) external view returns(address) { return (proposals[_proposalId].avatar); } /** * @dev scoreThresholdParams return the score threshold params for a given * organization. * @param _avatar the organization's avatar * @return uint thresholdConstA * @return uint thresholdConstB */ function scoreThresholdParams(address _avatar) external view returns(uint,uint) { bytes32 paramsHash = getParametersFromController(Avatar(_avatar)); Parameters memory params = parameters[paramsHash]; return (params.thresholdConstA,params.thresholdConstB); } /** * @dev getStaker return the vote and stake amount for a given proposal and staker * @param _proposalId the ID of the proposal * @param _staker staker address * @return uint vote * @return uint amount */ function getStaker(bytes32 _proposalId,address _staker) external view returns(uint,uint) { return (proposals[_proposalId].stakers[_staker].vote,proposals[_proposalId].stakers[_staker].amount); } /** * @dev state return the state for a given proposal * @param _proposalId the ID of the proposal * @return ProposalState proposal state */ function state(bytes32 _proposalId) external view returns(ProposalState) { return proposals[_proposalId].state; } /** * @dev winningVote return the winningVote for a given proposal * @param _proposalId the ID of the proposal * @return uint winningVote */ function winningVote(bytes32 _proposalId) external view returns(uint) { return proposals[_proposalId].winningVote; } /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns(bool) { return false; } /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns(uint min,uint max) { return (NUM_OF_CHOICES,NUM_OF_CHOICES); } /** * @dev execute check if the proposal has been decided, and if so, execute the proposal * @param _proposalId the id of the proposal * @return bool true - the proposal has been executed * false - otherwise. */ function execute(bytes32 _proposalId) external votable(_proposalId) returns(bool) { return _execute(_proposalId); } /** * @dev redeem a reward for a successful stake, vote or proposing. * The function use a beneficiary address as a parameter (and not msg.sender) to enable * users to redeem on behalf of someone else. * @param _proposalId the ID of the proposal * @param _beneficiary - the beneficiary address * @return rewards - * rewards[0] - stakerTokenAmount * rewards[1] - stakerReputationAmount * rewards[2] - voterTokenAmount * rewards[3] - voterReputationAmount * rewards[4] - proposerReputationAmount * @return reputation - redeem reputation */ function redeem(bytes32 _proposalId,address _beneficiary) public returns (uint[5] rewards) { Proposal storage proposal = proposals[_proposalId]; require((proposal.state == ProposalState.Executed) || (proposal.state == ProposalState.Closed),"wrong proposal state"); Parameters memory params = parameters[proposal.paramsHash]; uint amount; uint reputation; uint lostReputation; if (proposal.winningVote == YES) { lostReputation = proposal.preBoostedVotes[NO]; } else { lostReputation = proposal.preBoostedVotes[YES]; } lostReputation = (lostReputation * params.votersReputationLossRatio)/100; //as staker Staker storage staker = proposal.stakers[_beneficiary]; if ((staker.amount>0) && (staker.vote == proposal.winningVote)) { uint totalWinningStakes = proposal.stakes[proposal.winningVote]; if (totalWinningStakes != 0) { rewards[0] = (staker.amount * proposal.totalStakes[0]) / totalWinningStakes; } if (proposal.state != ProposalState.Closed) { rewards[1] = (staker.amount * ( lostReputation - ((lostReputation * params.votersGainRepRatioFromLostRep)/100)))/proposal.stakes[proposal.winningVote]; } staker.amount = 0; } //as voter Voter storage voter = proposal.voters[_beneficiary]; if ((voter.reputation != 0 ) && (voter.preBoosted)) { uint preBoostedVotes = proposal.preBoostedVotes[YES] + proposal.preBoostedVotes[NO]; if (preBoostedVotes>0) { rewards[2] = ((proposal.votersStakes * voter.reputation) / preBoostedVotes); } if (proposal.state == ProposalState.Closed) { //give back reputation for the voter rewards[3] = ((voter.reputation * params.votersReputationLossRatio)/100); } else if (proposal.winningVote == voter.vote ) { rewards[3] = (((voter.reputation * params.votersReputationLossRatio)/100) + (((voter.reputation * lostReputation * params.votersGainRepRatioFromLostRep)/100)/preBoostedVotes)); } voter.reputation = 0; } //as proposer if ((proposal.proposer == _beneficiary)&&(proposal.winningVote == YES)&&(proposal.proposer != address(0))) { rewards[4] = (params.proposingRepRewardConstA.mul(proposal.votes[YES]+proposal.votes[NO]) + params.proposingRepRewardConstB.mul(proposal.votes[YES]-proposal.votes[NO]))/1000; proposal.proposer = 0; } amount = rewards[0] + rewards[2]; reputation = rewards[1] + rewards[3] + rewards[4]; if (amount != 0) { proposal.totalStakes[1] = proposal.totalStakes[1].sub(amount); require(stakingToken.transfer(_beneficiary, amount)); emit Redeem(_proposalId,proposal.avatar,_beneficiary,amount); } if (reputation != 0 ) { ControllerInterface(Avatar(proposal.avatar).owner()).mintReputation(reputation,_beneficiary,proposal.avatar); emit RedeemReputation(_proposalId,proposal.avatar,_beneficiary,reputation); } } /** * @dev redeemDaoBounty a reward for a successful stake, vote or proposing. * The function use a beneficiary address as a parameter (and not msg.sender) to enable * users to redeem on behalf of someone else. * @param _proposalId the ID of the proposal * @param _beneficiary - the beneficiary address * @return redeemedAmount - redeem token amount * @return potentialAmount - potential redeem token amount(if there is enough tokens bounty at the avatar ) */ function redeemDaoBounty(bytes32 _proposalId,address _beneficiary) public returns(uint redeemedAmount,uint potentialAmount) { Proposal storage proposal = proposals[_proposalId]; require((proposal.state == ProposalState.Executed) || (proposal.state == ProposalState.Closed)); uint totalWinningStakes = proposal.stakes[proposal.winningVote]; if ( // solium-disable-next-line operator-whitespace (proposal.stakers[_beneficiary].amountForBounty>0)&& (proposal.stakers[_beneficiary].vote == proposal.winningVote)&& (proposal.winningVote == YES)&& (totalWinningStakes != 0)) { //as staker Parameters memory params = parameters[proposal.paramsHash]; uint beneficiaryLimit = (proposal.stakers[_beneficiary].amountForBounty.mul(params.daoBountyLimit)) / totalWinningStakes; potentialAmount = (params.daoBountyConst.mul(proposal.stakers[_beneficiary].amountForBounty))/100; if (potentialAmount > beneficiaryLimit) { potentialAmount = beneficiaryLimit; } } if ((potentialAmount != 0)&&(stakingToken.balanceOf(proposal.avatar) >= potentialAmount)) { proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount); require(ControllerInterface(Avatar(proposal.avatar).owner()).externalTokenTransfer(stakingToken,_beneficiary,potentialAmount,proposal.avatar)); proposal.stakers[_beneficiary].amountForBounty = 0; redeemedAmount = potentialAmount; emit RedeemDaoBounty(_proposalId,proposal.avatar,_beneficiary,redeemedAmount); } } /** * @dev shouldBoost check if a proposal should be shifted to boosted phase. * @param _proposalId the ID of the proposal * @return bool true or false. */ function shouldBoost(bytes32 _proposalId) public view returns(bool) { Proposal memory proposal = proposals[_proposalId]; return (_score(_proposalId) >= threshold(proposal.paramsHash,proposal.avatar)); } /** * @dev score return the proposal score * @param _proposalId the ID of the proposal * @return uint proposal score. */ function score(bytes32 _proposalId) public view returns(int) { return _score(_proposalId); } /** * @dev getBoostedProposalsCount return the number of boosted proposal for an organization * @param _avatar the organization avatar * @return uint number of boosted proposals */ function getBoostedProposalsCount(address _avatar) public view returns(uint) { uint expiredProposals; if (proposalsExpiredTimes[_avatar].count() != 0) { // solium-disable-next-line security/no-block-members expiredProposals = proposalsExpiredTimes[_avatar].rank(now); } return orgBoostedProposalsCnt[_avatar].sub(expiredProposals); } /** * @dev threshold return the organization's score threshold which required by * a proposal to shift to boosted state. * This threshold is dynamically set and it depend on the number of boosted proposal. * @param _avatar the organization avatar * @param _paramsHash the organization parameters hash * @return int organization's score threshold. */ function threshold(bytes32 _paramsHash,address _avatar) public view returns(int) { uint boostedProposals = getBoostedProposalsCount(_avatar); int216 e = 2; Parameters memory params = parameters[_paramsHash]; require(params.thresholdConstB > 0,"should be a valid parameter hash"); int256 power = int216(boostedProposals).toReal().div(int216(params.thresholdConstB).toReal()); if (power.fromReal() > 100 ) { power = int216(100).toReal(); } int256 res = int216(params.thresholdConstA).toReal().mul(e.toReal().pow(power)); return res.fromReal(); } /** * @dev hash the parameters, save them if necessary, and return the hash value * @param _params a parameters array * _params[0] - _preBoostedVoteRequiredPercentage, * _params[1] - _preBoostedVotePeriodLimit, //the time limit for a proposal to be in an absolute voting mode. * _params[2] -_boostedVotePeriodLimit, //the time limit for a proposal to be in an relative voting mode. * _params[3] -_thresholdConstA * _params[4] -_thresholdConstB * _params[5] -_minimumStakingFee * _params[6] -_quietEndingPeriod * _params[7] -_proposingRepRewardConstA * _params[8] -_proposingRepRewardConstB * _params[9] -_stakerFeeRatioForVoters * _params[10] -_votersReputationLossRatio * _params[11] -_votersGainRepRatioFromLostRep * _params[12] - _daoBountyConst * _params[13] - _daoBountyLimit */ function setParameters( uint[14] _params //use array here due to stack too deep issue. ) public returns(bytes32) { require(_params[0] <= 100 && _params[0] > 0,"0 < preBoostedVoteRequiredPercentage <= 100"); require(_params[4] > 0 && _params[4] <= 100000000,"0 < thresholdConstB < 100000000 "); require(_params[3] <= 100000000 ether,"thresholdConstA <= 100000000 wei"); require(_params[9] <= 100,"stakerFeeRatioForVoters <= 100"); require(_params[10] <= 100,"votersReputationLossRatio <= 100"); require(_params[11] <= 100,"votersGainRepRatioFromLostRep <= 100"); require(_params[2] >= _params[6],"boostedVotePeriodLimit >= quietEndingPeriod"); require(_params[7] <= 100000000,"proposingRepRewardConstA <= 100000000"); require(_params[8] <= 100000000,"proposingRepRewardConstB <= 100000000"); require(_params[12] <= (2 * _params[9]),"daoBountyConst <= 2 * stakerFeeRatioForVoters"); require(_params[12] >= _params[9],"daoBountyConst >= stakerFeeRatioForVoters"); bytes32 paramsHash = getParametersHash(_params); parameters[paramsHash] = Parameters({ preBoostedVoteRequiredPercentage: _params[0], preBoostedVotePeriodLimit: _params[1], boostedVotePeriodLimit: _params[2], thresholdConstA:_params[3], thresholdConstB:_params[4], minimumStakingFee: _params[5], quietEndingPeriod: _params[6], proposingRepRewardConstA: _params[7], proposingRepRewardConstB:_params[8], stakerFeeRatioForVoters:_params[9], votersReputationLossRatio:_params[10], votersGainRepRatioFromLostRep:_params[11], daoBountyConst:_params[12], daoBountyLimit:_params[13] }); return paramsHash; } /** * @dev hashParameters returns a hash of the given parameters */ function getParametersHash( uint[14] _params) //use array here due to stack too deep issue. public pure returns(bytes32) { return keccak256( abi.encodePacked( _params[0], _params[1], _params[2], _params[3], _params[4], _params[5], _params[6], _params[7], _params[8], _params[9], _params[10], _params[11], _params[12], _params[13])); } /** * @dev execute check if the proposal has been decided, and if so, execute the proposal * @param _proposalId the id of the proposal * @return bool true - the proposal has been executed * false - otherwise. */ function _execute(bytes32 _proposalId) internal votable(_proposalId) returns(bool) { Proposal storage proposal = proposals[_proposalId]; Parameters memory params = parameters[proposal.paramsHash]; Proposal memory tmpProposal = proposal; uint totalReputation = Avatar(proposal.avatar).nativeReputation().totalSupply(); uint executionBar = totalReputation * params.preBoostedVoteRequiredPercentage/100; ExecutionState executionState = ExecutionState.None; if (proposal.state == ProposalState.PreBoosted) { // solium-disable-next-line security/no-block-members if ((now - proposal.submittedTime) >= params.preBoostedVotePeriodLimit) { proposal.state = ProposalState.Closed; proposal.winningVote = NO; executionState = ExecutionState.PreBoostedTimeOut; } else if (proposal.votes[proposal.winningVote] > executionBar) { // someone crossed the absolute vote execution bar. proposal.state = ProposalState.Executed; executionState = ExecutionState.PreBoostedBarCrossed; } else if ( shouldBoost(_proposalId)) { //change proposal mode to boosted mode. proposal.state = ProposalState.Boosted; // solium-disable-next-line security/no-block-members proposal.boostedPhaseTime = now; proposalsExpiredTimes[proposal.avatar].insert(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit); orgBoostedProposalsCnt[proposal.avatar]++; } } if ((proposal.state == ProposalState.Boosted) || (proposal.state == ProposalState.QuietEndingPeriod)) { // solium-disable-next-line security/no-block-members if ((now - proposal.boostedPhaseTime) >= proposal.currentBoostedVotePeriodLimit) { proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit); orgBoostedProposalsCnt[tmpProposal.avatar] = orgBoostedProposalsCnt[tmpProposal.avatar].sub(1); proposal.state = ProposalState.Executed; executionState = ExecutionState.BoostedTimeOut; } else if (proposal.votes[proposal.winningVote] > executionBar) { // someone crossed the absolute vote execution bar. orgBoostedProposalsCnt[tmpProposal.avatar] = orgBoostedProposalsCnt[tmpProposal.avatar].sub(1); proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit); proposal.state = ProposalState.Executed; executionState = ExecutionState.BoostedBarCrossed; } } if (executionState != ExecutionState.None) { if (proposal.winningVote == YES) { uint daoBountyRemain = (params.daoBountyConst.mul(proposal.stakes[proposal.winningVote]))/100; if (daoBountyRemain > params.daoBountyLimit) { daoBountyRemain = params.daoBountyLimit; } proposal.daoBountyRemain = daoBountyRemain; } emit ExecuteProposal(_proposalId, proposal.avatar, proposal.winningVote, totalReputation); emit GPExecuteProposal(_proposalId, executionState); (tmpProposal.executable).execute(_proposalId, tmpProposal.avatar, int(proposal.winningVote)); } return (executionState != ExecutionState.None); } /** * @dev staking function * @param _proposalId id of the proposal * @param _vote NO(2) or YES(1). * @param _amount the betting amount * @param _staker the staker address * @return bool true - the proposal has been executed * false - otherwise. */ function _stake(bytes32 _proposalId, uint _vote, uint _amount,address _staker) internal returns(bool) { // 0 is not a valid vote. require(_vote <= NUM_OF_CHOICES && _vote > 0); require(_amount > 0); if (_execute(_proposalId)) { return true; } Proposal storage proposal = proposals[_proposalId]; if (proposal.state != ProposalState.PreBoosted) { return false; } // enable to increase stake only on the previous stake vote Staker storage staker = proposal.stakers[_staker]; if ((staker.amount > 0) && (staker.vote != _vote)) { return false; } uint amount = _amount; Parameters memory params = parameters[proposal.paramsHash]; require(amount >= params.minimumStakingFee); require(stakingToken.transferFrom(_staker, address(this), amount)); proposal.totalStakes[1] = proposal.totalStakes[1].add(amount); //update totalRedeemableStakes staker.amount += amount; staker.amountForBounty = staker.amount; staker.vote = _vote; proposal.votersStakes += (params.stakerFeeRatioForVoters * amount)/100; proposal.stakes[_vote] = amount.add(proposal.stakes[_vote]); amount = amount - ((params.stakerFeeRatioForVoters*amount)/100); proposal.totalStakes[0] = amount.add(proposal.totalStakes[0]); // Event: emit Stake(_proposalId, proposal.avatar, _staker, _vote, _amount); // execute the proposal if this vote was decisive: return _execute(_proposalId); } /** * @dev Vote for a proposal, if the voter already voted, cancel the last vote and set a new one instead * @param _proposalId id of the proposal * @param _voter used in case the vote is cast for someone else * @param _vote a value between 0 to and the proposal's number of choices. * @param _rep how many reputation the voter would like to stake for this vote. * if _rep==0 so the voter full reputation will be use. * @return true in case of proposal execution otherwise false * throws if proposal is not open or if it has been executed * NB: executes the proposal if a decision has been reached */ function internalVote(bytes32 _proposalId, address _voter, uint _vote, uint _rep) internal returns(bool) { // 0 is not a valid vote. require(_vote <= NUM_OF_CHOICES && _vote > 0,"0 < _vote <= 2"); if (_execute(_proposalId)) { return true; } Parameters memory params = parameters[proposals[_proposalId].paramsHash]; Proposal storage proposal = proposals[_proposalId]; // Check voter has enough reputation: uint reputation = Avatar(proposal.avatar).nativeReputation().reputationOf(_voter); require(reputation >= _rep); uint rep = _rep; if (rep == 0) { rep = reputation; } // If this voter has already voted, return false. if (proposal.voters[_voter].reputation != 0) { return false; } // The voting itself: proposal.votes[_vote] = rep.add(proposal.votes[_vote]); //check if the current winningVote changed or there is a tie. //for the case there is a tie the current winningVote set to NO. if ((proposal.votes[_vote] > proposal.votes[proposal.winningVote]) || ((proposal.votes[NO] == proposal.votes[proposal.winningVote]) && proposal.winningVote == YES)) { // solium-disable-next-line security/no-block-members uint _now = now; if ((proposal.state == ProposalState.QuietEndingPeriod) || ((proposal.state == ProposalState.Boosted) && ((_now - proposal.boostedPhaseTime) >= (params.boostedVotePeriodLimit - params.quietEndingPeriod)))) { //quietEndingPeriod proposalsExpiredTimes[proposal.avatar].remove(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit); if (proposal.state != ProposalState.QuietEndingPeriod) { proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod; proposal.state = ProposalState.QuietEndingPeriod; } proposal.boostedPhaseTime = _now; proposalsExpiredTimes[proposal.avatar].insert(proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit); } proposal.winningVote = _vote; } proposal.voters[_voter] = Voter({ reputation: rep, vote: _vote, preBoosted:(proposal.state == ProposalState.PreBoosted) }); if (proposal.state == ProposalState.PreBoosted) { proposal.preBoostedVotes[_vote] = rep.add(proposal.preBoostedVotes[_vote]); uint reputationDeposit = (params.votersReputationLossRatio * rep)/100; ControllerInterface(Avatar(proposal.avatar).owner()).burnReputation(reputationDeposit,_voter,proposal.avatar); } // Event: emit VoteProposal(_proposalId, proposal.avatar, _voter, _vote, rep); // execute the proposal if this vote was decisive: return _execute(_proposalId); } /** * @dev _score return the proposal score * For dual choice proposal S = (S+) - (S-) * @param _proposalId the ID of the proposal * @return int proposal score. */ function _score(bytes32 _proposalId) private view returns(int) { Proposal storage proposal = proposals[_proposalId]; return int(proposal.stakes[YES]) - int(proposal.stakes[NO]); } /** * @dev _isVotable check if the proposal is votable * @param _proposalId the ID of the proposal * @return bool true or false */ function _isVotable(bytes32 _proposalId) private view returns(bool) { ProposalState pState = proposals[_proposalId].state; return ((pState == ProposalState.PreBoosted)||(pState == ProposalState.Boosted)||(pState == ProposalState.QuietEndingPeriod)); } }
a garbage staker address due to wrong signature will revert due to lack of approval and funds.
require(staker!=address(0));
1,299,274
[ 1, 4625, 348, 7953, 560, 30, 279, 15340, 384, 6388, 1758, 6541, 358, 7194, 3372, 903, 15226, 6541, 358, 30679, 434, 23556, 471, 284, 19156, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 2583, 12, 334, 6388, 5, 33, 2867, 12, 20, 10019, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity 0.4.23; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns(uint256) { assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { function totalSupply()public view returns(uint total_Supply); function balanceOf(address who)public view returns(uint256); function allowance(address owner, address spender)public view returns(uint); function transferFrom(address from, address to, uint value)public returns(bool ok); function approve(address spender, uint value)public returns(bool ok); function transfer(address to, uint value)public returns(bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract YettaToken is ERC20 { using SafeMath for uint256; uint256 constant public TOKEN_DECIMALS = 10 ** 8; uint256 constant public ETH_DECIMALS = 10 ** 18; uint256 public TotalCrowdsaleSupply = 25000000; //25 Million uint256 public TotalOwnerSupply = 60000000; //60 Million uint256 public BonusPoolSupply = 15000000; //15 Million // Name of the token string public constant name = "Yetta Token"; // Symbol of token string public constant symbol = "YET"; uint8 public constant decimals = 8; // 100 Million total supply // muliplies dues to decimal precision uint public TotalTokenSupply = 100000000 * TOKEN_DECIMALS; //100 Million // Owner of this contract address public owner; address public bonusPool = 0xf6148aD4C8b2138B9029301310074F391ea4529D; address public YettaCrowdSale; bool public mintedCrowdsale; bool public lockstatus; uint public Currenttask; string public Currentproposal; mapping(address => mapping(address => uint)) allowed; mapping(uint =>mapping(address => bool)) Task; mapping(uint =>bool) public acceptProp; mapping(uint =>uint256) public agreed; mapping(uint =>uint256) public disagreed; mapping(address => uint) balances; enum VotingStages { VOTING_NOTSTARTED, VOTING_OPEN, VOTING_CLOSED } VotingStages public votingstage; modifier atStage(VotingStages _stage) { require(votingstage == _stage); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; lockstatus = true; votingstage = VotingStages.VOTING_NOTSTARTED; balances[owner] = TotalOwnerSupply.mul(TOKEN_DECIMALS); balances[bonusPool] = BonusPoolSupply.mul(TOKEN_DECIMALS); emit Transfer(0, owner, balances[owner]); emit Transfer(0, bonusPool, balances[bonusPool]); } function Bonus_PoolTransfer(address receiver, uint256 tokenQuantity) external onlyOwner { require( receiver != 0x0); require(balances[bonusPool] >= tokenQuantity && tokenQuantity >= 0); balances[bonusPool] = (balances[bonusPool]).sub(tokenQuantity); balances[receiver] = balances[receiver].add(tokenQuantity); emit Transfer(0, receiver, tokenQuantity); } function mint_Crowdsale(address _YettaCrowdSale) public onlyOwner{ require(!mintedCrowdsale); YettaCrowdSale = _YettaCrowdSale; balances[YettaCrowdSale] = balances[YettaCrowdSale].add(TotalCrowdsaleSupply.mul(TOKEN_DECIMALS)); mintedCrowdsale = true; emit Transfer(0,YettaCrowdSale, balances[YettaCrowdSale]); } function startVoting(uint newtask, string _currentproposal) external onlyOwner { votingstage = VotingStages.VOTING_OPEN; Currenttask = newtask; Currentproposal = _currentproposal; } // Function to check that if Investor already voted for a particular task or not, //if voted: true, else: false function VotedForProposal(uint _task, address spender) public constant returns(bool) { require(spender != 0x0); return Task[_task][spender]; } function submitVote(uint _task, bool proposal) public atStage(VotingStages.VOTING_OPEN){ require(Currenttask == _task); require(balanceOf(msg.sender)>0); require(Task[_task][msg.sender] ==false); // Checks if already voted for a particular task if(proposal == true){ agreed[_task] = agreed[_task].add(balanceOf(msg.sender)); Task[_task][msg.sender] = true; } else{ disagreed[_task] = disagreed[_task].add(balanceOf(msg.sender)); Task[_task][msg.sender] = true; } } function finaliseVoting(uint _currenttask) external onlyOwner atStage(VotingStages.VOTING_OPEN){ require(Currenttask == _currenttask); if(agreed[_currenttask] < disagreed[_currenttask]){ acceptProp[_currenttask]=false; } else{ acceptProp[_currenttask]=true; } votingstage = VotingStages.VOTING_CLOSED; } /* YET tokens will be unlocked after completion of the Yetta Blockchain ICO so users could upgrade to the new platform to continue participation in governance of the Yetta Blockchain project. */ function removeLocking(bool RunningStatusLock) external onlyOwner { lockstatus = RunningStatusLock; } // what is the total supply YET token function totalSupply() public view returns(uint256 total_Supply) { total_Supply = TotalTokenSupply; } // What is the balance of a particular account? function balanceOf(address token_Owner)public constant returns(uint256 balance) { return balances[token_Owner]; } // Send _value amount of tokens from address _from to address _to // The transferFrom method is used for a withdraw workflow, allowing contracts to send // tokens on your behalf, for example to "deposit" to a contract address and/or to charge // fees in sub-currencies; the command should fail unless the _from account has // deliberately authorized the sender of the message via some mechanism; we propose // these standardized APIs for approval: function transferFrom(address from_address, address to_address, uint256 tokens)public returns(bool success) { require(to_address != 0x0); require(balances[from_address] >= tokens && allowed[from_address][msg.sender] >= tokens && tokens >= 0); balances[from_address] = (balances[from_address]).sub(tokens); allowed[from_address][msg.sender] = (allowed[from_address][msg.sender]).sub(tokens); balances[to_address] = (balances[to_address]).add(tokens); emit Transfer(from_address, to_address, tokens); return true; } // Allow _spender to withdraw from your account, multiple times, up to the _value amount. // If this function is called again it overwrites the current allowance with _value. function approve(address spender, uint256 tokens)public returns(bool success) { require(spender != 0x0); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function allowance(address token_Owner, address spender) public constant returns(uint256 remaining) { require(token_Owner != 0x0 && spender != 0x0); return allowed[token_Owner][spender]; } // Transfer the balance from owner&#39;s account to another account function transfer(address to_address, uint256 tokens)public returns(bool success) { if ( msg.sender == owner) { require( to_address != 0x0); require(balances[owner] >= tokens && tokens >= 0); balances[owner] = balances[owner].sub(tokens); balances[to_address] = (balances[to_address]).add(tokens); emit Transfer(msg.sender, to_address, tokens); return true; } else if (!lockstatus && msg.sender != owner) { require( to_address != 0x0); require(balances[msg.sender] >= tokens && tokens >= 0); balances[msg.sender] = (balances[msg.sender]).sub(tokens); balances[to_address] = (balances[to_address]).add(tokens); emit Transfer(msg.sender, to_address, tokens); return true; } else{ revert(); } } function transferby(address _to,uint256 _amount) external onlyOwner returns(bool success) { require( _to != 0x0); require( balances[YettaCrowdSale] >= _amount && _amount > 0); balances[YettaCrowdSale] = ( balances[YettaCrowdSale]).sub(_amount); balances[_to] = (balances[_to]).add(_amount); emit Transfer(address(this), _to, _amount); return true; } }
Function to check that if Investor already voted for a particular task or not,if voted: true, else: false
function VotedForProposal(uint _task, address spender) public constant returns(bool) { require(spender != 0x0); return Task[_task][spender]; }
10,709,324
[ 1, 4625, 348, 7953, 560, 30, 225, 4284, 358, 866, 716, 309, 5454, 395, 280, 1818, 331, 16474, 364, 279, 6826, 1562, 578, 486, 16, 430, 331, 16474, 30, 225, 638, 16, 469, 30, 629, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 377, 445, 776, 16474, 1290, 14592, 12, 11890, 389, 4146, 16, 1758, 17571, 264, 13, 1071, 5381, 1135, 12, 6430, 13, 203, 565, 288, 203, 3639, 2583, 12, 87, 1302, 264, 480, 374, 92, 20, 1769, 203, 3639, 327, 3837, 63, 67, 4146, 6362, 87, 1302, 264, 15533, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.24; // //////////////////////////////////////////////////////////////////////////////////////////////////// // ___ ___ ___ __ // ___ / /\ / /\ / /\ | |\ // /__/\ / /::\ / /::\ / /::| | |:| // \ \:\ / /:/\:\ / /:/\:\ / /:|:| | |:| // \__\:\ / /::\ \:\ / /::\ \:\ / /:/|:|__ |__|:|__ // / /::\ /__/:/\:\ \:\ /__/:/\:\_\:\ /__/:/_|::::\ ____/__/::::\ // / /:/\:\ \ \:\ \:\_\/ \__\/ \:\/:/ \__\/ /~~/:/ \__\::::/~~~~ // / /:/__\/ \ \:\ \:\ \__\::/ / /:/ |~~|:| // /__/:/ \ \:\_\/ / /:/ / /:/ | |:| // \__\/ \ \:\ /__/:/ /__/:/ |__|:| // \__\/ \__\/ \__\/ \__\| // ______ ______ ______ _____ _ _ ______ ______ _____ // | | | \ | | | \ / | | \ | | \ \ | | | | | | | | | | \ \ // | |__|_/ | |__| | | | | | | | | | | | | | | | | |---- | | | | // |_| |_| \_\ \_|__|_/ |_|_/_/ \_|__|_| |_|____ |_|____ |_|_/_/ // // TEAM X All Rights Received. http://teamx.club // This product is protected under license. Any unauthorized copy, modification, or use without // express written consent from the creators is prohibited. // v 0.1.3 // Any cooperation Please email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed9e889f9b848e88ad99888c8095c38e81988f">[email&#160;protected]</a> // Follow these step to become a site owner: // 1. fork git repository: https://github.com/teamx-club/escape-mmm // 2. modify file: js/config.js // 3. replace siteOwner with your address // 4. search for how to use github pages and bind your domain, setup the forked repository // 5. having fun, you will earn 5% every privode from your site page // //////////////////////////////////////////////////////////////////////////////////////////////////// //=========================================================... // (~ _ _ _|_ _ . // (_\/(/_| | | _\ . Events //========================================================= contract EscapeMmmEvents { event onOffered ( address indexed playerAddress, uint256 offerAmount, address affiliateAddress, address siteOwner, uint256 timestamp ); event onAccepted ( address indexed playerAddress, uint256 acceptAmount ); event onWithdraw ( address indexed playerAddress, uint256 withdrawAmount ); event onAirDrop ( address indexed playerAddress, uint256 airdropAmount, uint256 offerAmount ); } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } //=========================================================... // |\/| _ . _ /~` _ _ _|_ _ _ __|_ . // | |(_||| | \_,(_)| | | | (_|(_ | . Main Contract //========================================================= contract EFMAPlatform is EscapeMmmEvents, Ownable { using SafeMath for *; //=========================================================... // _ _ _ |`. _ _ _ . // (_(_)| |~|~|(_||_|| (/_ . system settings //==============_|========================================= string constant public name = "Escape Financial Mutual Aid Platform"; string constant public symbol = "EFMAP"; address private xTokenAddress = 0xfe8b40a35ff222c8475385f74e77d33954531b41; uint8 public feePercent_ = 1; // 1% for fee uint8 public affPercent_ = 5; // 5% for affiliate uint8 public sitePercent_ = 5; // 5% for site owner uint8 public airDropPercent_ = 10; // 10% for air drop uint8 public xTokenPercent_ = 3; // 3% for x token uint256 constant public interestPeriod_ = 1 hours; uint256 constant public maxInterestTime_ = 7 days; //=========================================================... // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ ||_||_) . data setup //=========================|=============================== uint256 public airDropPool_; uint256 public airDropTracker_ = 0; // +1 every (0.001 ether) time triggered; if 0.002 eth, trigger twice //=========================================================... // _ | _ _|_|` _ _ _ _ _| _ _|_ _ . // |_)|(_| |~|~(_)| | | | (_|(_| | (_| . platform data //=|======================================================= mapping (address => FMAPDatasets.Player) public players_; mapping (address => mapping (uint256 => FMAPDatasets.OfferInfo)) public playerOfferOrders_; // player => player offer count => offerInfo. mapping (address => mapping (uint256 => uint256)) public playerAcceptOrders_; // player => count => orderId. player orders to accept; uint256 private restOfferAmount_ = 0; // offered amount that not been accepted; FMAPDatasets.AcceptOrder private currentOrder_; // unmatched current order; mapping (uint256 => FMAPDatasets.AcceptOrder) public acceptOrders_; // accept orders; address private teamXWallet; uint256 public _totalFee; uint256 public _totalXT; //=========================================================... // _ _ _ __|_ _ __|_ _ _ // (_(_)| |_\ | ||_|(_ | (_)| //========================================================= constructor() public { teamXWallet = msg.sender; // setting something ? FMAPDatasets.AcceptOrder memory ao; ao.nextOrder = 1; ao.playerAddress = msg.sender; ao.acceptAmount = 1 finney; acceptOrders_[0] = ao; currentOrder_ = ao; } function transFee() public onlyOwner { teamXWallet.transfer(_totalFee); } function setTeamWallet(address wallet) public onlyOwner { teamXWallet = wallet; } function setXToken(address xToken) public onlyOwner { xTokenAddress = xToken; } //=========================================================... // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . modifiers //========================================================= modifier isHuman() { require(AddressUtils.isContract(msg.sender) == false, "sorry, only human allowed"); _; } //=========================================================... // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . public functions //=|======================================================= /** * offer help directly */ function() isHuman() public payable { FMAPDatasets.OfferInfo memory offerInfo = packageOfferInfo(address(0), msg.value); offerCore(offerInfo, false); } function offerHelp(address siteOwner, address affiliate) isHuman() public payable { FMAPDatasets.OfferInfo memory offerInfo = packageOfferInfo(siteOwner, msg.value); bool updateAff = false; if(affiliate != address(0) && affiliate != offerInfo.affiliateAddress) { offerInfo.affiliateAddress = affiliate; updateAff = true; } offerCore(offerInfo, updateAff); emit onOffered(offerInfo.playerAddress, offerInfo.offerAmount, offerInfo.affiliateAddress, offerInfo.siteOwner, offerInfo.timestamp); } function offerHelpUsingBalance(address siteOwner, address affiliate, uint256 ethAmount) isHuman() public { require(ethAmount <= players_[msg.sender].balance, "sorry, you don&#39;t have enough balance"); FMAPDatasets.OfferInfo memory offerInfo = packageOfferInfo(siteOwner, ethAmount); bool updateAff = false; if(affiliate != address(0) && affiliate != offerInfo.affiliateAddress) { offerInfo.affiliateAddress = affiliate; updateAff = true; } players_[msg.sender].balance = players_[msg.sender].balance.sub(ethAmount); offerCore(offerInfo, updateAff); emit onOffered(offerInfo.playerAddress, offerInfo.offerAmount, offerInfo.affiliateAddress, offerInfo.siteOwner, offerInfo.timestamp); } function acceptHelp(uint256 amount) isHuman() public returns (uint256 canAcceptLeft) { (canAcceptLeft, ) = calcCanAcceptAmount(msg.sender, true, 0); require(amount <= canAcceptLeft, "sorry, you don&#39;t have enough acceptable amount"); uint256 _nextOrderId = currentOrder_.nextOrder; FMAPDatasets.AcceptOrder memory acceptOrder; acceptOrder.playerAddress = msg.sender; acceptOrder.acceptAmount = amount; acceptOrder.acceptedAmount = 0; acceptOrder.nextOrder = _nextOrderId + 1; acceptOrders_[_nextOrderId] = acceptOrder; // see if currentOrder_ is finished if (currentOrder_.orderId == _nextOrderId || currentOrder_.acceptAmount == currentOrder_.acceptedAmount) { currentOrder_ = acceptOrder; } players_[acceptOrder.playerAddress].totalAccepted = amount.add(players_[acceptOrder.playerAddress].totalAccepted); players_[acceptOrder.playerAddress].acceptOrderCount++; if (restOfferAmount_ > 0) { matching(); } calcAndSetPlayerTotalCanAccept(acceptOrder.playerAddress, amount); emit onAccepted(acceptOrder.playerAddress, acceptOrder.acceptAmount); return (canAcceptLeft); } function withdraw() isHuman() public { require(players_[msg.sender].balance >= 1 finney, "sorry, withdraw at least 1 finney"); uint256 _balance = players_[msg.sender].balance; players_[msg.sender].balance = 0; msg.sender.transfer(_balance); emit onWithdraw(msg.sender, _balance); } //=========================================================... // . _ |` _ __|_. _ _ _ . // \/|(/_VV ~|~|_|| |(_ | |(_)| |_\ . view functions //========================================================= function getCanAcceptAmount(address playerAddr) public view returns (uint256 canAccept, uint256 earliest) { (canAccept, earliest) = calcCanAcceptAmount(playerAddr, true, 0); return (canAccept, earliest); } function getBalance(address playerAddr) public view returns (uint256) { uint256 balance = players_[playerAddr].balance; return (balance); } function getPlayerInfo(address playerAddr) public view returns (uint256 totalAssets, uint256 nextPeriodAssets, uint256 balance, uint256 canAccept, uint256 airdrop, uint256 offered, uint256 accepted, uint256 affiliateEarned, uint256 siteEarned, uint256 nextUpdateTime) { FMAPDatasets.Player memory _player = players_[playerAddr]; uint256 _calculatedCanAccept; (_calculatedCanAccept, ) = calcCanAcceptAmount(playerAddr, false, 0); totalAssets = _player.balance.add(_calculatedCanAccept); (_calculatedCanAccept, ) = calcCanAcceptAmount(playerAddr, false, interestPeriod_); nextPeriodAssets = _player.balance.add(_calculatedCanAccept); (canAccept, nextUpdateTime) = calcCanAcceptAmount(playerAddr, true, 0); return (totalAssets, nextPeriodAssets, _player.balance, canAccept, _player.airDroped, _player.totalOffered, _player.totalAccepted, _player.affiliateEarned, _player.siteEarned, nextUpdateTime); } //=========================================================... // _ _. _ _|_ _ |` _ __|_. _ _ _ . // |_)| |\/(_| | (/_ ~|~|_|| |(_ | |(_)| |_\ . private functions //=|======================================================= function packageOfferInfo(address siteOwner, uint256 amount) private view returns (FMAPDatasets.OfferInfo) { FMAPDatasets.OfferInfo memory offerInfo; offerInfo.playerAddress = msg.sender; offerInfo.offerAmount = amount; offerInfo.affiliateAddress = players_[msg.sender].lastAffiliate; offerInfo.siteOwner = siteOwner; offerInfo.timestamp = block.timestamp; offerInfo.interesting = true; return (offerInfo); } //=========================================================... // _ _ _ _ |` _ __|_. _ _ _ . // (_(_)| (/_ ~|~|_|| |(_ | |(_)| |_\ . core functions //========================================================= function offerCore(FMAPDatasets.OfferInfo memory offerInfo, bool updateAff) private { uint256 _fee = (offerInfo.offerAmount).mul(feePercent_).div(100); // 1% for fee uint256 _aff = (offerInfo.offerAmount).mul(affPercent_).div(100); // 5% for affiliate uint256 _sit = (offerInfo.offerAmount).mul(sitePercent_).div(100); // 5% for site owner uint256 _air = (offerInfo.offerAmount).mul(airDropPercent_).div(100); // 10% for air drop uint256 _xt = (offerInfo.offerAmount).mul(xTokenPercent_).div(100); // 3% for x token uint256 _leftAmount = offerInfo.offerAmount; if (offerInfo.affiliateAddress == offerInfo.siteOwner) { // site owner is forbid to be affiliater offerInfo.affiliateAddress = address(0); } // fee players_[offerInfo.playerAddress].totalOffered = (offerInfo.offerAmount).add(players_[offerInfo.playerAddress].totalOffered); if (offerInfo.affiliateAddress == address(0) || offerInfo.affiliateAddress == offerInfo.playerAddress) { _fee = _fee.add(_aff); _aff = 0; } if (offerInfo.siteOwner == address(0) || offerInfo.siteOwner == offerInfo.playerAddress) { _fee = _fee.add(_sit); _sit = 0; } _totalFee = _totalFee.add(_fee); _totalXT = _totalXT.add(_xt); if (_totalXT > 1 finney) { xTokenAddress.transfer(_totalXT); } _leftAmount = _leftAmount.sub(_fee); // affiliate if (_aff > 0) { players_[offerInfo.affiliateAddress].balance = _aff.add(players_[offerInfo.affiliateAddress].balance); players_[offerInfo.affiliateAddress].affiliateEarned = _aff.add(players_[offerInfo.affiliateAddress].affiliateEarned); _leftAmount = _leftAmount.sub(_aff); } // site if (_sit > 0) { players_[offerInfo.siteOwner].balance = _sit.add(players_[offerInfo.siteOwner].balance); players_[offerInfo.siteOwner].siteEarned = _sit.add(players_[offerInfo.siteOwner].siteEarned); _leftAmount = _leftAmount.sub(_sit); } // air drop if (offerInfo.offerAmount >= 1 finney) { airDropTracker_ = airDropTracker_ + FMAPMath.calcTrackerCount(offerInfo.offerAmount); if (airdrop() == true) { uint256 _airdrop = FMAPMath.calcAirDropAmount(offerInfo.offerAmount); players_[offerInfo.playerAddress].balance = _airdrop.add(players_[offerInfo.playerAddress].balance); players_[offerInfo.playerAddress].airDroped = _airdrop.add(players_[offerInfo.playerAddress].airDroped); emit onAirDrop(offerInfo.playerAddress, _airdrop, offerInfo.offerAmount); } } airDropPool_ = airDropPool_.add(_air); _leftAmount = _leftAmount.sub(_air); if (updateAff) { players_[offerInfo.playerAddress].lastAffiliate = offerInfo.affiliateAddress; } restOfferAmount_ = restOfferAmount_.add(_leftAmount); if (currentOrder_.acceptAmount > currentOrder_.acceptedAmount) { matching(); } playerOfferOrders_[offerInfo.playerAddress][players_[offerInfo.playerAddress].offeredCount] = offerInfo; players_[offerInfo.playerAddress].offeredCount = (players_[offerInfo.playerAddress].offeredCount).add(1); if (players_[offerInfo.playerAddress].playerAddress == address(0)) { players_[offerInfo.playerAddress].playerAddress = offerInfo.playerAddress; } } function matching() private { while (restOfferAmount_ > 0 && currentOrder_.acceptAmount > currentOrder_.acceptedAmount) { uint256 needAcceptAmount = (currentOrder_.acceptAmount).sub(currentOrder_.acceptedAmount); if (needAcceptAmount <= restOfferAmount_) { // currentOrder finished restOfferAmount_ = restOfferAmount_.sub(needAcceptAmount); players_[currentOrder_.playerAddress].balance = needAcceptAmount.add(players_[currentOrder_.playerAddress].balance); currentOrder_.acceptedAmount = (currentOrder_.acceptedAmount).add(needAcceptAmount); currentOrder_ = acceptOrders_[currentOrder_.nextOrder]; } else { // offer end currentOrder_.acceptedAmount = (currentOrder_.acceptedAmount).add(restOfferAmount_); players_[currentOrder_.playerAddress].balance = (players_[currentOrder_.playerAddress].balance).add(restOfferAmount_); restOfferAmount_ = 0; } } } function calcAndSetPlayerTotalCanAccept(address pAddr, uint256 acceptAmount) private { uint256 _now = block.timestamp; uint256 _latestCalced = players_[pAddr].lastCalcOfferNo; uint256 _acceptedAmount = acceptAmount; while(_latestCalced < players_[pAddr].offeredCount) { FMAPDatasets.OfferInfo storage oi = playerOfferOrders_[pAddr][_latestCalced]; uint256 _ts = _now.sub(oi.timestamp); if (oi.interesting == true) { if (_ts >= maxInterestTime_) { // stop interesting... uint256 interest1 = oi.offerAmount.sub(oi.acceptAmount).mul(1).div(1000).mul(maxInterestTime_ / interestPeriod_); // 24 * 7 players_[pAddr].canAccept = (players_[pAddr].canAccept).add(oi.offerAmount).add(interest1); oi.interesting = false; // set accept if (oi.offerAmount.sub(oi.acceptAmount) > _acceptedAmount) { _acceptedAmount = 0; oi.acceptAmount = oi.acceptAmount.add(_acceptedAmount); } else { _acceptedAmount = _acceptedAmount.sub(oi.offerAmount.sub(oi.acceptAmount)); oi.acceptAmount = oi.offerAmount; } } else if (_acceptedAmount > 0) { if (_acceptedAmount < oi.offerAmount.sub(oi.acceptAmount)) { oi.acceptAmount = oi.acceptAmount.add(_acceptedAmount); _acceptedAmount = 0; } else { uint256 interest0 = oi.offerAmount.sub(oi.acceptAmount).mul(1).div(1000).mul(_ts / interestPeriod_); players_[pAddr].canAccept = (players_[pAddr].canAccept).add(oi.offerAmount).add(interest0); oi.interesting = false; _acceptedAmount = _acceptedAmount.sub(oi.offerAmount.sub(oi.acceptAmount)); oi.acceptAmount = oi.offerAmount; } } } else if (oi.offerAmount > oi.acceptAmount && _acceptedAmount > 0) { // set accept if (oi.offerAmount.sub(oi.acceptAmount) > _acceptedAmount) { _acceptedAmount = 0; oi.acceptAmount = oi.acceptAmount.add(_acceptedAmount); } else { _acceptedAmount = _acceptedAmount.sub(oi.offerAmount.sub(oi.acceptAmount)); oi.acceptAmount = oi.offerAmount; } } if (_acceptedAmount == 0) { break; } _latestCalced = _latestCalced + 1; } players_[pAddr].lastCalcOfferNo = _latestCalced; } function airdrop() private view returns (bool) { uint256 seed = uint256(keccak256(abi.encodePacked(block.timestamp, block.number, block.timestamp, block.difficulty, block.gaslimit, airDropTracker_, block.coinbase, msg.sender))); if(seed - (seed / 10000).mul(10000) < airDropTracker_) { return (true); } return (false); } function calcCanAcceptAmount(address pAddr, bool isLimit, uint256 offsetTime) private view returns (uint256, uint256 nextUpdateTime) { uint256 _totalCanAccepted = players_[pAddr].canAccept; uint256 i = players_[pAddr].offeredCount; uint256 _now = block.timestamp.add(offsetTime); uint256 _nextUpdateTime = _now.add(interestPeriod_); for(;i > 0; i--) { FMAPDatasets.OfferInfo memory oi = playerOfferOrders_[pAddr][i - 1]; if (oi.interesting == true) { uint256 timepassed = _now.sub(oi.timestamp); if (!isLimit || (timepassed >= interestPeriod_)) { // at least 1 period uint256 interest; if (timepassed < maxInterestTime_) { interest = oi.offerAmount.sub(oi.acceptAmount).mul(1).div(1000).mul(timepassed / interestPeriod_); uint256 oiNextUpdateTime = (timepassed / interestPeriod_).add(1).mul(interestPeriod_).add(oi.timestamp); if (_nextUpdateTime > oiNextUpdateTime) { _nextUpdateTime = oiNextUpdateTime; } } else { interest = oi.offerAmount.sub(oi.acceptAmount).mul(1).div(1000).mul(maxInterestTime_ / interestPeriod_); } _totalCanAccepted = _totalCanAccepted.add(oi.offerAmount).add(interest); } } else if (oi.timestamp == 0) { continue; } else { break; } } return (_totalCanAccepted.sub(players_[pAddr].totalAccepted), _nextUpdateTime); } } //=========================================================... // _ _ _ _|_|_ |.|_ _ _ _ . // | | |(_| | | | |||_)| (_||\/ . math library //============================/============================ library FMAPMath { using SafeMath for uint256; function calcTrackerCount(uint256 ethAmount) internal pure returns (uint256) { if (ethAmount >= 1 finney && ethAmount < 10 finney) { return (1); } else if (ethAmount < 50 finney) { return (2); } else if (ethAmount < 200 finney) { return (3); } else if (ethAmount < 500 finney) { return (4); } else if (ethAmount < 1 ether) { return (5); } else if (ethAmount >= 1 ether) { return ethAmount.div(1 ether).add(5); } return (0); } function calcAirDropAmount(uint256 ethAmount) internal pure returns (uint256) { if (ethAmount >= 1 finney && ethAmount < 10 finney) { return (5); } else if (ethAmount < 50 finney) { return (10); } else if (ethAmount < 200 finney) { return (15); } else if (ethAmount < 500 finney) { return (20); } else if (ethAmount < 1 ether) { return (25); } else if (ethAmount >= 1 ether) { uint256 a = ethAmount.div(1 ether).add(5).mul(5); return (a > 75 ? 75 : a); } return (0); } } //=========================================================... // __|_ _ __|_ . // _\ | ||_|(_ | . //========================================================= library FMAPDatasets { struct OfferInfo { address playerAddress; uint256 offerAmount; uint256 acceptAmount; // 不再计算利息 address affiliateAddress; address siteOwner; uint256 timestamp; bool interesting; } struct AcceptOrder { uint256 orderId; address playerAddress; uint256 acceptAmount; uint256 acceptedAmount; uint256 nextOrder; } struct Player { address playerAddress; address lastAffiliate; uint256 totalOffered; uint256 totalAccepted; uint256 airDroped; uint256 balance; // can withdraw uint256 offeredCount; uint256 acceptOrderCount; uint256 canAccept; uint256 lastCalcOfferNo; uint256 affiliateEarned; uint256 siteEarned; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting &#39;a&#39; not being zero, but the // benefit is lost if &#39;b&#39; is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * Utility library of inline functions on addresses */ library AddressUtils { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address to check * @return whether the target address is a contract */ function isContract(address addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(addr) } return size > 0; } }
+1 every (0.001 ether) time triggered; if 0.002 eth, trigger twice
uint256 public airDropTracker_ = 0;
10,905,512
[ 1, 4625, 348, 7953, 560, 30, 225, 397, 21, 3614, 261, 20, 18, 11664, 225, 2437, 13, 813, 10861, 31, 309, 374, 18, 24908, 13750, 16, 3080, 13605, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 23350, 7544, 8135, 67, 273, 374, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.5.0; /** * @title Screen Selling Platform * @notice This contract abstracts the screen selling * marketplace and provides functions to perform * transactions * @author Team Block-Daggers * */ contract Auction { /** * This enum defines status of screen (item) present in the * marketplace * */ enum ITEM_STATUS { LOCKED, /// Item is being processed, hence is not listed in marketplace OPEN, /// Item is being sold at marketplace BUYING, /// Buyer has paid for the item, but hasn't received it yet BOUGHT /// Buyer received the item } enum AUCTION_STATUS { ONGOING, VERIFICATION, REVEALED } enum AUCTION_TYPE { FIRST_PRICE, SECOND_PRICE, AVG_PRICE, FIXED } /** * This struct defines the blueprint of each screen (item) * present in the marketplace * */ struct Listing { address payable seller; ITEM_STATUS status; string item_name; string item_desc; string secret_string; uint256 asking_price; uint256 final_price; mapping(bytes32 => bool) hashedBids; uint256 biddersCount; mapping(address => bool) bidders; mapping(address => bool) isVerified; Bidder[] verifiedBids; Bidder bidWinner; AUCTION_STATUS auctionStatus; AUCTION_TYPE auctionType; } struct Bidder { address payable buyer; uint256 price; string public_key; } uint256 private itemsCount; mapping(uint256 => Listing) private itemsList; /** * Initialising smart contract to the scenario when no item * is present in the marketplace * */ constructor() public { itemsCount = 0; } /** * Allows only seller of item to access the function * * @param index unique id of item */ modifier onlyItemSeller(uint256 index) { require(index <= itemsCount && index > 0, "Item not present in list"); require( msg.sender == itemsList[index].seller, "You are not seller of item" ); _; } /** * Allows only buyer or seller to access the function * * @param index unique id of item */ modifier onlyItemOwnerOrSeller(uint256 index) { require(index <= itemsCount && index > 0, "Item not present in list"); require( msg.sender == itemsList[index].seller || (msg.sender == itemsList[index].bidWinner.buyer && itemsList[index].status == ITEM_STATUS.BOUGHT), "You are not owner or seller of item" ); _; } /** * Checks empty string * * @param str string */ modifier nonEmpty(string memory str){ require(bytes(str).length > 0, "String should be non empty"); _; } /** * Checks empty array * * @param item_id id of the item */ modifier nonEmptyBidders(uint256 item_id){ require(true, "No bidders found"); _; } /** * Adds an item in the marketplace * Used by: Seller * * @param _item_name name of item * @param _item_desc description of item * @param _asking_price asking price of item */ function addItem( string memory _item_name, string memory _item_desc, uint256 _asking_price, uint256 _auction_type ) public nonEmpty(_item_name) nonEmpty(_item_desc) returns (uint256) { itemsCount++; itemsList[itemsCount].status = ITEM_STATUS.LOCKED; itemsList[itemsCount].item_desc = _item_desc; itemsList[itemsCount].seller = msg.sender; itemsList[itemsCount].item_name = _item_name; itemsList[itemsCount].asking_price = _asking_price; itemsList[itemsCount].status = ITEM_STATUS.OPEN; itemsList[itemsCount].auctionStatus = AUCTION_STATUS.ONGOING; if (_auction_type == 0) { itemsList[itemsCount].auctionType = AUCTION_TYPE.FIRST_PRICE; } else if (_auction_type == 1) { itemsList[itemsCount].auctionType = AUCTION_TYPE.SECOND_PRICE; } else if (_auction_type == 2) { itemsList[itemsCount].auctionType = AUCTION_TYPE.AVG_PRICE; } else { itemsList[itemsCount].auctionStatus = AUCTION_STATUS.VERIFICATION; itemsList[itemsCount].auctionType = AUCTION_TYPE.FIXED; } return itemsCount; } function bidItem(uint256 item_id, bytes32 hashString) public { require( item_id <= itemsCount && item_id > 0, "Item not present in list" ); require( itemsList[item_id].auctionStatus == AUCTION_STATUS.ONGOING, "Auction not ongoing" ); require( itemsList[item_id].bidders[msg.sender] == false, "Already bidded" ); itemsList[item_id].hashedBids[hashString] = true; itemsList[item_id].biddersCount += 1; itemsList[item_id].bidders[msg.sender] = true; } function closeBid(uint256 item_id) public nonEmptyBidders(item_id) { require( msg.sender == itemsList[item_id].seller || msg.sender == address(this), 'Access denied' ); require( item_id <= itemsCount && item_id > 0, "Item not present in list" ); require( itemsList[item_id].auctionStatus == AUCTION_STATUS.ONGOING, "Auction not ongoing" ); require( itemsList[item_id].biddersCount != 0, "No Bidder" ); if(itemsList[item_id].auctionType == AUCTION_TYPE.SECOND_PRICE) { require( itemsList[item_id].biddersCount >= 2, "Atleast two people should bid for vickery auction" ); } itemsList[item_id].auctionStatus = AUCTION_STATUS.VERIFICATION; } function verifyBid( uint256 item_id, string memory password, string memory public_key ) public payable { require( item_id <= itemsCount && item_id > 0, "Item not present in list" ); require( itemsList[item_id].auctionStatus == AUCTION_STATUS.VERIFICATION, "Bid verification not in progress" ); if(itemsList[item_id].auctionType == AUCTION_TYPE.FIXED){ if(msg.value == itemsList[item_id].asking_price){ itemsList[item_id].final_price = msg.value; itemsList[item_id].bidWinner = Bidder(msg.sender, msg.value, public_key); itemsList[item_id].status = ITEM_STATUS.BUYING; itemsList[item_id].auctionStatus = AUCTION_STATUS.REVEALED; // everything is done } else{ revert("Invalid Price"); } } else{ bytes32 hashValue = keccak256( abi.encodePacked(password, uintToStr(msg.value)) ); if(itemsList[item_id].hashedBids[hashValue] != true){ revert("Invalid details"); } itemsList[item_id].verifiedBids.push( Bidder(msg.sender, msg.value, public_key) ); itemsList[item_id].isVerified[msg.sender] = true; } } function abs(uint256 a, uint256 b) private pure returns (uint256) { if (a >= b) { return a - b; } else { return b - a; } } function revealBid(uint256 item_id) public payable onlyItemSeller(item_id){ require( item_id <= itemsCount && item_id > 0, "Item not present in list" ); require( itemsList[item_id].auctionStatus == AUCTION_STATUS.VERIFICATION, "Bid verification not in progress" ); require( itemsList[item_id].verifiedBids.length > 0, "No one verified bid" ); if(itemsList[item_id].auctionType == AUCTION_TYPE.SECOND_PRICE) { require( itemsList[item_id].verifiedBids.length >= 2, "Atleast two people should verify for vickery auction" ); } uint256 maxBid = 0; Bidder memory maxBidder; uint256 secondMaxBid = 0; uint256 totalBid = 0; for (uint256 i = 0; i < itemsList[item_id].verifiedBids.length; i++) { uint256 currentBidPrice = itemsList[item_id].verifiedBids[i].price; totalBid += currentBidPrice; if (currentBidPrice > maxBid) { secondMaxBid = maxBid; maxBid = currentBidPrice; maxBidder = itemsList[item_id].verifiedBids[i]; } else if (currentBidPrice > secondMaxBid) { secondMaxBid = currentBidPrice; } } if (itemsList[item_id].auctionType == AUCTION_TYPE.FIRST_PRICE) { itemsList[item_id].bidWinner = maxBidder; itemsList[item_id].final_price = maxBid; } else if ( itemsList[item_id].auctionType == AUCTION_TYPE.SECOND_PRICE ) { itemsList[item_id].bidWinner = maxBidder; itemsList[item_id].final_price = secondMaxBid; } else if(itemsList[item_id].auctionType == AUCTION_TYPE.AVG_PRICE) { uint256 minDiff = uint256(-1); Bidder memory avgBidder; uint256 n = itemsList[item_id].verifiedBids.length; for (uint256 i = 0; i < n; i++) { uint256 currentBidPrice = itemsList[item_id] .verifiedBids[i] .price * n; if (abs(currentBidPrice, totalBid) < minDiff) { avgBidder = itemsList[item_id].verifiedBids[i]; minDiff = abs(currentBidPrice, totalBid); } itemsList[item_id].bidWinner = avgBidder; itemsList[item_id].final_price = avgBidder.price; } } else{ // normal purchase, do nothing } itemsList[item_id].status = ITEM_STATUS.BUYING; itemsList[item_id].auctionStatus = AUCTION_STATUS.REVEALED; returnNonWinnerMoney(item_id); } /** * Gets public key of the buyer from the item being bought * Used by: Seller * * @param item_id unique id of item */ function getKey(uint256 item_id) public view onlyItemSeller(item_id) returns (string memory) { require( itemsList[item_id].status == ITEM_STATUS.BUYING, "KEY NOT AVAILABLE" ); return itemsList[item_id].bidWinner.public_key; } /** * Assigns encrypted password to the item which can be only decrypted * by the buyer * Thus, it simulates delivery of the screen (item) from the seller * Item is marked as BOUGHT * Used by: Seller * * @param item_id unique id of item * @param secret_string Encrypted password of the screen (i.e. * item) along with the public key of the buyer */ function giveAccess(uint256 item_id, string memory secret_string) public payable onlyItemSeller(item_id) { require( itemsList[item_id].status == ITEM_STATUS.BUYING, "Item not purchased yet" ); itemsList[item_id].secret_string = secret_string; itemsList[item_id].status = ITEM_STATUS.BOUGHT; itemsList[item_id].seller.transfer(itemsList[item_id].final_price); // return pending money of bid winner like in case of auction type 2 returnWinnerPendingMoney(item_id); } function returnWinnerPendingMoney(uint256 item_id) private { uint256 pendingMoney = itemsList[item_id].bidWinner.price - itemsList[item_id].final_price; itemsList[item_id].bidWinner.buyer.transfer(pendingMoney); } function returnNonWinnerMoney(uint256 item_id) private { for (uint256 i = 0; i < itemsList[item_id].verifiedBids.length; i++) { if ( itemsList[item_id].verifiedBids[i].buyer == itemsList[item_id].bidWinner.buyer ) { continue; } uint256 returnPrice = itemsList[item_id].verifiedBids[i].price; itemsList[item_id].verifiedBids[i].buyer.transfer(returnPrice); } } /** * @dev View pending balance in escrow account * Used by: Developer * */ function getBalance() public view returns (uint256) { return address(this).balance; } /** * Returns encrypted password of the delivered item * Used by: Buyer, (optional) Seller * * @param item_id unique id of item */ function accessItem(uint256 item_id) public view onlyItemOwnerOrSeller(item_id) returns (string memory) { return itemsList[item_id].secret_string; } /** * Updates the name of the item listed in the marketplace * Used by: Seller * * @param item_id unique id of item * @param item_name name of item */ function changeName(uint256 item_id, string memory item_name) public onlyItemSeller(item_id) { require( itemsList[item_id].status == ITEM_STATUS.OPEN, "Item is already sold" ); itemsList[item_id].status = ITEM_STATUS.LOCKED; itemsList[item_id].item_name = item_name; itemsList[item_id].status = ITEM_STATUS.OPEN; } /** * Updates the price of the item listed in the marketplace * Used by: seller * * @param item_id unique id of item * @param price item price */ function changePrice(uint256 item_id, uint256 price) public onlyItemSeller(item_id) { require( itemsList[item_id].status == ITEM_STATUS.OPEN, "Item is already sold" ); itemsList[item_id].status = ITEM_STATUS.LOCKED; itemsList[item_id].asking_price = price; itemsList[item_id].status = ITEM_STATUS.OPEN; } /** * Converts an unsigned integer to its equivalent string * * @param _i number */ function uintToStr(uint256 _i) private pure returns (string memory _uintAsString) { uint256 number = _i; if (number == 0) { return "0"; } uint256 j = number; uint256 len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint256 k = len - 1; while (number != 0) { bstr[k--] = bytes1(uint8(48 + (number % 10))); number /= 10; } return string(bstr); } /** * Converts address to string * Source: https://ethereum.stackexchange.com/a/58341 * * @param account address of account */ function toString(address account) private pure returns (string memory) { return toString(abi.encodePacked(account)); } function toString(bytes memory data) private pure returns (string memory) { bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(2 + data.length * 2); str[0] = "0"; str[1] = "x"; for (uint256 i = 0; i < data.length; i++) { str[2 + i * 2] = alphabet[uint256(uint8(data[i] >> 4))]; str[3 + i * 2] = alphabet[uint256(uint8(data[i] & 0x0f))]; } return string(str); } function printHelper(uint i, bool firstItem) public view returns (string memory) { string memory str = ""; uint at = 0; if(itemsList[i].auctionType == AUCTION_TYPE.SECOND_PRICE){ at=1; } else if(itemsList[i].auctionType == AUCTION_TYPE.AVG_PRICE){ at = 2; } else if(itemsList[i].auctionType == AUCTION_TYPE.FIXED){ at = 3; } uint ast = 0; if(itemsList[i].auctionStatus == AUCTION_STATUS.VERIFICATION){ ast = 1; } else if(itemsList[i].auctionStatus == AUCTION_STATUS.REVEALED) { ast = 2; } uint ist = 0; if(itemsList[i].status == ITEM_STATUS.OPEN){ ist = 1; } else if(itemsList[i].status == ITEM_STATUS.BUYING){ ist = 2; } else if(itemsList[i].status == ITEM_STATUS.BOUGHT){ ist = 3; } if(!firstItem){ str = string(abi.encodePacked(str, ',')); } str = string(abi.encodePacked(str, '{"itemId":')); str = string(abi.encodePacked(str, uintToStr(i))); str = string(abi.encodePacked(str, ',"itemName":"')); str = string(abi.encodePacked(str, itemsList[i].item_name)); str = string(abi.encodePacked(str, '","itemDescription": "')); str = string(abi.encodePacked(str, itemsList[i].item_desc)); str = string(abi.encodePacked(str, '","itemStatus":')); str = string(abi.encodePacked(str, uintToStr(ist))); str = string(abi.encodePacked(str, ',"askingPrice":')); str = string(abi.encodePacked(str, uintToStr(itemsList[i].asking_price))); str = string(abi.encodePacked(str, ',"auctionType":')); str = string(abi.encodePacked(str, uintToStr(at))); str = string(abi.encodePacked(str, ',"auctionStatus":')); str = string(abi.encodePacked(str, uintToStr(ast))); str = string(abi.encodePacked(str, ',"sellerId": "')); str = string(abi.encodePacked(str,toString(abi.encodePacked(itemsList[i].seller)))); str = string(abi.encodePacked(str, '","alreadyBid": "')); str = string(abi.encodePacked(str,toString(abi.encodePacked(itemsList[i].bidders[msg.sender])))); str = string(abi.encodePacked(str, '","bidWinner": "')); str = string(abi.encodePacked(str,toString(abi.encodePacked(itemsList[i].bidWinner.buyer)))); str = string(abi.encodePacked(str, '","isVerified": "')); str = string(abi.encodePacked(str,toString(abi.encodePacked(itemsList[i].isVerified[msg.sender])))); str = string(abi.encodePacked(str, '"}')); return str; } /** * Returns the items present in the marketplace, which are * ready to be sold * Used by: public * */ function viewActiveListings(bool allItems) public view returns (string memory) { string memory str = "["; bool firstItem = true; for (uint256 i = 1; i <= itemsCount; i++) { if (allItems || itemsList[i].auctionStatus == AUCTION_STATUS.ONGOING || (itemsList[i].auctionStatus == AUCTION_STATUS.VERIFICATION && itemsList[i].auctionType == AUCTION_TYPE.FIXED)) { str = string(abi.encodePacked(str, printHelper(i, firstItem))); firstItem = false; } } str = string(abi.encodePacked(str, "]")); return str; } function viewSellerListings(address seller_id) public view returns (string memory) { string memory str = "["; bool firstItem = true; for (uint256 i = 1; i <= itemsCount; i++) { if (itemsList[i].seller == seller_id) { str = string(abi.encodePacked(str, printHelper(i, firstItem))); firstItem = false; } } str = string(abi.encodePacked(str, "]")); return str; } }
* Checks empty string @param str string/
modifier nonEmpty(string memory str){ require(bytes(str).length > 0, "String should be non empty"); _; }
12,878,048
[ 1, 4625, 348, 7953, 560, 30, 380, 13074, 1008, 533, 632, 891, 609, 533, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 9606, 1661, 1921, 12, 1080, 3778, 609, 15329, 203, 3639, 2583, 12, 3890, 12, 701, 2934, 2469, 405, 374, 16, 315, 780, 1410, 506, 1661, 1008, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x329F5a8d24503fC00B31b229835b6452A6723ae4/sources/home/arman/dev/dvf-contracts/amm-core/contracts/PairWithL2Overlay.sol
We can also use the universal state transition check here, however that would open us to partial settlement of L1 orders
require(balance0 >= token0ExpectedBalance && balance1 >= token1ExpectedBalance, 'DVF: INVALID_TOKEN_AMOUNTS');
9,718,022
[ 1, 4625, 348, 7953, 560, 30, 225, 1660, 848, 2546, 999, 326, 26182, 919, 6007, 866, 2674, 16, 14025, 716, 4102, 1696, 584, 358, 4702, 26319, 806, 434, 511, 21, 11077, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 1377, 2583, 12, 12296, 20, 1545, 1147, 20, 6861, 13937, 597, 11013, 21, 1545, 1147, 21, 6861, 13937, 16, 296, 30199, 42, 30, 10071, 67, 8412, 67, 2192, 51, 5321, 55, 8284, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// ----------------------------------------------------------------------------- // File RUS_NOUNS_PARADIGMAS.SOL // // (c) Koziev Elijah // SOLARIX Intellectronix Project http://www.solarix.ru // // Лексикон - определения таблиц формообразования (парадигм) для существительных. // // Русские существительные http://www.solarix.ru/for_developers/api/russian-noun-declension.shtml // Особенности описания существительных http://www.solarix.ru/russian_grammar_dictionary/russian-noun-declension.shtml // Словарные статьи http://www.solarix.ru/for_developers/docs/entries.shtml#words // // // 18.12.2009 - для парадигм мужского рода проставлены признаки одушевленности, // чтобы избежать появления (и поправить имеющиеся) ошибок в // винительном падеже. // 19.03.2010 - полная переделка концепции автопарадигм, теперь они не выделяются // особым ключевым словом auto и могут иметь имя для ссылок из // прикладного кода через API. // 02.01.2012 - убраны некоторые малочисленные парадигмы // ----------------------------------------------------------------------------- // // CD->30.12.2000 // LC->01.08.2018 // -------------- #include "sg_defs.h" automat sg { paradigm /*ОПЕРАТОР*/ Сущ_1002 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // КАРП ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // КАРПА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // КАРПОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%+А" } // КАРПА ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // КАРПУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // КАРПЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+Ы" } :: flexer "pl" // КАРПЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // КАРПОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // КАРПАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // КАРПЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // КАРПАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // КАРПАХ } paradigm Сущ_1003 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ФАЙЛ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // ФАЙЛА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // ФАЙЛОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ФАЙЛ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // ФАЙЛУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // ФАЙЛЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+Ы" } :: flexer "pl" // ФАЙЛЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // ФАЙЛОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // ФАЙЛАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+Ы" } :: flexer "pl" // ФАЙЛЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // ФАЙЛАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // ФАЙЛАХ } paradigm Бахчисарай, Сущ_1005 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Й" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ГНОЙ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // ГНОЯ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // ГНОЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ГНОЙ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // ГНОЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ГНОЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ГНОИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕВ" } :: flexer "pl" // ГНОЕВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // ГНОЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ГНОИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // ГНОЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // ГНОЯХ } paradigm /*ДУШ*/ Сущ_1006 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ДУШ ДУШИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // ДУША ДУШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЕМ" "%+АМИ" } // ДУШЕМ ДУШАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // ДУШ ДУШИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ДУШУ ДУШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ДУШЕ ДУШАХ } paradigm /*СИДОРОВ*/ Сущ_1007 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // ИВАНОВ ИВАНОВЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЫХ" } // ИВАНОВА ИВАНОВЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЫМ" "%+ЫМИ" } // ИВАНОВЫМ ИВАНОВЫМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЫХ" } // ИВАНОВА ИВАНОВЫХ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+ЫМ" } // ИВАНОВУ ИВАНОВЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+ЫХ" } // ИВАНОВЕ ИВАНОВЫХ } paradigm ЭТАЖ, Сущ_1068 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЖЧШЩ]" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЭТАЖ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // ЭТАЖА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // ЭТАЖОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ЭТАЖ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // ЭТАЖУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // ЭТАЖЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+И" } :: flexer "pl" // ЭТАЖИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ЕЙ" } :: flexer "pl" // ЭТАЖЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // ЭТАЖАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+И" } :: flexer "pl" // ЭТАЖИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // ЭТАЖАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // ЭТАЖАХ } paradigm /*ЛАРЬ*/ Сущ_1010 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЛАРЬ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // ЛАРЯ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // ЛАРЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ЛАРЬ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // ЛАРЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ЛАРЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ЛАРИ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+Я" } :: flexer "x" // ЛАГЕРЯ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕЙ" } :: flexer "pl" // ЛАРЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // ЛАРЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ЛАРИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // ЛАРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // ЛАРЯХ } paradigm ЦАРЬ, Сущ_1011 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Ь" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ЦАРЬ ЦАРИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // ЦАРЯ ЦАРЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЁМ" "%-1%+ЯМИ" } // ЦАРЁМ ЦАРЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // ЦАРЯ ЦАРЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // ЦАРЮ ЦАРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // ЦАРЕ ЦАРЯХ } paradigm КНЯЗЬ, Сущ_1012 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Ь" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Я" } // КНЯЗЬ КНЯЗЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // КНЯЗЯ КНЯЗЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%+ЯМИ" } // КНЯЗЕМ КНЯЗЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // КНЯЗЯ КНЯЗЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%+ЯМ" } // КНЯЗЮ КНЯЗЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+ЯХ" } // КНЯЗЕ КНЯЗЬЯХ } paradigm /*ЛЕС*/ Сущ_1013 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+А" } // ЛЕС ЛЕСА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ЛЕСА ЛЕСОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ЛЕСОМ ЛЕСАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+А" } // ЛЕС ЛЕСА ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ЛЕСУ ЛЕСАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ЛЕСЕ ЛЕСАХ ПАДЕЖ:(МЕСТ) ЧИСЛО:ЕД { "%+У" } // ЛЕСУ } paradigm ГЕРОЙ, Сущ_1015_одуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Й" { РОД:МУЖ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ГЕРОЙ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // ГЕРОЯ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // ГЕРОЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Я" } // ГЕРОЯ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // ГЕРОЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ГЕРОЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ГЕРОИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕВ" } :: flexer "pl" // ГЕРОЕВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // ГЕРОЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+ЕВ" } :: flexer "pl" // ГЕРОЕВ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // ГЕРОЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // ГЕРОЯХ } paradigm Сергий : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ИЙ" { РОД:МУЖ ОДУШ:ОДУШ ПЕРЕЧИСЛИМОСТЬ:НЕТ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // Сергий ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // Сергия ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // Сергием ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Я" } // Сергия ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // Сергию ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // Сергии } paradigm бобслей, Сущ_1015_неодуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Й" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // бобслей ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // бобслея ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // бобслеем ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // бобслей ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // бобслею ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // бобслее ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // бобслеи ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕВ" } :: flexer "pl" // бобслеев ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // бобслеями ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // бобслеи ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // бобслеям ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // бобслеях } paradigm лепрозорий : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ИЙ" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // лепрозорий ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // лепрозория ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // лепрозорием ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // лепрозорий ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // лепрозорию ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // лепрозории ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // лепрозории ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕВ" } :: flexer "pl" // лепрозориев ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // лепрозориями ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // лепрозории ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // лепрозориям ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // лепрозориях } paradigm МЕДВЕЖОНОК, Сущ_1016 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)НОК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-4%+АТА" } // МЕДВЕЖОНОК МЕДВЕЖАТА ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+КА" "%-4%+АТ" } // МЕДВЕЖОНКА МЕДВЕЖАТ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+КОМ" "%-4%+АТАМИ" } // МЕДВЕЖОНКОМ МЕДВЕЖАТАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+КА" "%-4%+АТ" } // МЕДВЕЖОНКА МЕДВЕЖАТ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+КУ" "%-4%+АТАМ" } // МЕДВЕЖОНКУ МЕДВЕЖАТАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+КЕ" "%-4%+АТАХ" } // МЕДВЕЖОНКЕ МЕДВЕЖАТАХ } paradigm ПОРОСЁНОК, Сущ_1017 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЕЁ]НОК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-4%+ЯТА" } // ПОРОСЁНОК ПОРОСЯТА ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+КА" "%-4%+ЯТ" } // ПОРОСЁНКА ПОРОСЯТ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+КОМ" "%-4%+ЯТАМИ" } // ПОРОСЁНКОМ ПОРОСЯТАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+КА" "%-4%+ЯТ" } // ПОРОСЁНКА ПОРОСЯТ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+КУ" "%-4%+ЯТАМ" } // ПОРОСЁНКУ ПОРОСЯТАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+КЕ" "%-4%+ЯТАХ" } // ПОРОСЁНКЕ ПОРОСЯТАХ } paradigm ДВОРЯНИН, Сущ_1018 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)НИН" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+Е" } // ДВОРЯНИН ДВОРЯНЕ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-2" } // ДВОРЯНИНА ДВОРЯН ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-2%+АМИ" } // ДВОРЯНИНОМ ДВОРЯНАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-2" } // ДВОРЯНИНА ДВОРЯН ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-2%+АМ" } // ДВОРЯНИНУ ДВОРЯНАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-2%+АХ" } // ДВОРЯНИНЕ ДВОРЯНАХ } paradigm /*ХОЗЯИН*/ Сущ_1019 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЕВА" } // ХОЗЯИН ХОЗЯЕВА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-2%+ЕВ" } // ХОЗЯИНА ХОЗЯЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-2%+ЕВАМИ" } // ХОЗЯИНОМ ХОЗЯЕВАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-2%+ЕВ" } // ХОЗЯИНА ХОЗЯЕВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-2%+ЕВАМ" } // ХОЗЯИНУ ХОЗЯЕВАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-2%+ЕВАХ" } // ХОЗЯИНЕ ХОЗЯЕВАХ } paradigm /*ТАТАРИН*/ Сущ_1020 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+Ы" } // ТАТАРИН ТАТАРЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-2" } // ТАТАРИНА ТАТАР ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-2%+АМИ" } // ТАТАРИНОМ ТАТАРАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-2" } // ТАТАРИНА ТАТАР ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-2%+АМ" } // ТАТАРИНУ ТАТАРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-2%+АХ" } // ТАТАРИНЕ ТАТАРАХ } paradigm ЦВЕТОК, Сущ_1021 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ОК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+И" } // ЦВЕТОК ЦВЕТКИ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ЦВЕТКА ЦВЕТКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // ЦВЕТКОМ ЦВЕТКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%c1%+И" } // ЦВЕТОК ЦВЕТКИ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // ЦВЕТКУ ЦВЕТКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // ЦВЕТКЕ ЦВЕТКАХ } paradigm /*КОФЕ*/ Сущ_1025 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // КОФЕ --- ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } // КОФЕ --- ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "" } // КОФЕ --- ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // КОФЕ --- ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "" } // КОФЕ --- ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "" } // КОФЕ --- } paradigm КЕНГУРУ, Сущ_1026 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)У" { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "" } // КЕНГУРУ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ ПАДЕЖ:(РОД) ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ ПАДЕЖ:ТВОР ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ ПАДЕЖ:ДАТ ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "" } :: flexer "pl" // КЕНГУРУ } paradigm ИЗБРАННИК, Сущ_1027 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ИК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ИЗБРАННИК ИЗБРАННИКИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ИЗБРАННИКА ИЗБРАННИКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ИЗБРАННИКОМ ИЗБРАННИКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ОВ" } // ИЗБРАННИКА ИЗБРАННИКОВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ИЗБРАННИКУ ИЗБРАННИКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ИЗБРАННИКЕ ИЗБРАННИКАХ } paradigm БУЛЬДОГ, Сущ_1042a : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Г" { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДОГ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // ДОГА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // ДОГОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%+А" } // ДОГА ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // ДОГУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // ДОГЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+И" } :: flexer "pl" // ДОГИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // ДОГОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // ДОГАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // ДОГОВ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // ДОГАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // ДОГАХ } paradigm ПРОЛОГ, Сущ_1042 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Г" { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ПРОЛОГ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // ПРОЛОГА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // ПРОЛОГОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ПРОЛОГА ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // ПРОЛОГУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // ПРОЛОГЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+И" } :: flexer "pl" // ПРОЛОГИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // ПРОЛОГОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // ПРОЛОГАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+И" } :: flexer "pl" // ПРОЛОГИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // ПРОЛОГАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // ПРОЛОГАХ } paradigm БУДЕНЬ, Сущ_1029 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)НЬ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+НИ" } // БУДЕНЬ БУДНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-3%+НЯ" "%-3%+НЕЙ" } // БУДНЯ БУДНЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-3%+НЕМ" "%-3%+НЯМИ" } // БУДНЕМ БУДНЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-3%+НИ" } // БУДЕНЬ БУДНИ ПАДЕЖ:ДАТ ЧИСЛО { "%-3%+НЮ" "%-3%+НЯМ" } // БУДНЮ БУДНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-3%+НЕ" "%-3%+НЯХ" } // БУДНЕ БУДНЯХ } paradigm /*ПАРЕНЬ*/ Сущ_1030 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+НИ" } // ПАРЕНЬ ПАРНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-3%+НЯ" "%-3%+НЕЙ" } // ПАРНЯ ПАРНЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-3%+НЕМ" "%-3%+НЯМИ" } // ПАРНЕМ ПАРНЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-3%+НЯ" "%-3%+НЕЙ" } // ПАРНЯ ПАРНЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-3%+НЮ" "%-3%+НЯМ" } // ПАРНЮ ПАРНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-3%+НЕ" "%-3%+НЯХ" } // ПАРНЕ ПАРНЯХ } paradigm КАМЕШЕК, Сущ_1032_неодуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШ]ЕК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+И" } // КАМЕШЕК КАМЕШКИ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // КАМЕШКА КАМЕШКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // КАМЕШКОМ КАМЕШКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%c1%+И" } // КАМЕШЕК КАМЕШКИ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // КАМЕШКУ КАМЕШКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // КАМЕШКЕ КАМЕШКАХ } paradigm ПОРОСЁНОЧЕК, Сущ_1032_одуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШ]ЕК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+И" } // ПОРОСЁНОЧЕК ПОРОСЁНОЧКИ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ПОРОСЁНОЧКА ПОРОСЁНОЧКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // ПОРОСЁНОЧКОМ ПОРОСЁНОЧКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ПОРОСЁНОЧКА ПОРОСЁНОЧКОВ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // ПОРОСЁНОЧКУ ПОРОСЁНОЧКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // ПОРОСЁНОЧКЕ ПОРОСЁНОЧКАХ } paradigm /*ГОСПОДИН*/ Сущ_1033 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+А" } // ГОСПОДИН ГОСПОДА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-2" } // ГОСПОДИНА ГОСПОД ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-2%+АМИ" } // ГОСПОДИНОМ ГОСПОДАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-2" } // ГОСПОДИНА ГОСПОД ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-2%+АМ" } // ГОСПОДИНУ ГОСПОДАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-2%+АХ" } // ГОСПОДИНЕ ГОСПОДАХ } paradigm /*МАСТЕР*/ Сущ_1035 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+А" } // МАСТЕР МАСТЕРА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // МАСТЕРА МАСТЕРОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // МАСТЕРОМ МАСТЕРАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ОВ" } // МАСТЕРА МАСТЕРОВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // МАСТЕРУ МАСТЕРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // МАСТЕРЕ МАСТЕРАХ } paradigm /*ГОРОД*/ Сущ_1036 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+А" } // ГОРОД ГОРОДА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ГОРОДА ГОРОДОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ГОРОДОМ ГОРОДАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+А" } // ГОРОД ГОРОДА ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ГОРОДУ ГОРОДАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ГОРОДЕ ГОРОДАХ } paradigm ВРАЧ, Сущ_1037 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Ч" { РОД:МУЖ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ВРАЧ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // ВРАЧА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // ВРАЧОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%+А" } // ВРАЧА ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // ВРАЧУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // ВРАЧЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+И" } :: flexer "pl" // ВРАЧИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ЕЙ" } :: flexer "pl" // ВРАЧЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // ВРАЧАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+ЕЙ" } :: flexer "pl" // ВРАЧЕЙ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // ВРАЧАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // ВРАЧАХ } paradigm /*ДРУГ*/ Сущ_1038 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+ЗЬЯ" } // ДРУГ ДРУЗЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-1%+ЗЕЙ" } // ДРУГА ДРУЗЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-1%+ЗЬЯМИ" } // ДРУГОМ ДРУЗЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-1%+ЗЕЙ" } // ДРУГА ДРУЗЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-1%+ЗЬЯМ" } // ДРУГУ ДРУЗЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-1%+ЗЬЯХ" } // ДРУГЕ ДРУЗЬЯХ } paradigm ТОВАРИЩ, Сущ_1039 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШЩ]" { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ТОВАРИЩ ТОВАРИЩИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // ТОВАРИЩА ТОВАРИЩЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЕМ" "%+АМИ" } // ТОВАРИЩЕМ ТОВАРИЩАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЕЙ" } // ТОВАРИЩА ТОВАРИЩЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ТОВАРИЩУ ТОВАРИЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ТОВАРИЩЕ ТОВАРИЩАХ } paradigm /*РОТ*/ Сущ_1041 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+Ы" } // РОТ РТЫ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // РТА РТОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // РТОМ РТАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%c1%+Ы" } // РОТ РТЫ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // РТУ РТАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // РТЕ РТАХ } paradigm /*КОГОТЬ*/ Сущ_1043 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c2%-1%+И" } // КОГОТЬ КОГТИ ПАДЕЖ:(РОД) ЧИСЛО { "%c2%-1%+Я" "%c2%-1%+ЕЙ" } // КОГТЯ КОГТЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%c2%-1%+ЁМ" "%c2%-1%+ЯМИ" } // КОГТЁМ КОГТЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%c2%-1%+И" } // КОГОТЬ КОГТИ ПАДЕЖ:ДАТ ЧИСЛО { "%c2%-1%+Ю" "%c2%-1%+ЯМ" } // КОГТЮ КОГТЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c2%-1%+Е" "%c2%-1%+ЯХ" } // КОГТЕ КОГТЯХ } paradigm КОНЬЯК, Сущ_1044 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[КГХШЩ]" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // КОНЬЯК ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // КОНЬЯКА ПАДЕЖ:(ПАРТ) ЧИСЛО:ЕД { "%+У" } :: flexer "partitiv" // КОНЬЯКУ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // КОНЬЯКОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // КОНЬЯК ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // КОНЬЯКУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // КОНЬЯКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+И" } :: flexer "pl" // КОНЬЯКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%+ОВ" } :: flexer "pl" // КОНЬЯКОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+АМИ" } :: flexer "pl" // КОНЬЯКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+И" } :: flexer "pl" // КОНЬЯКИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+АМ" } :: flexer "pl" // КОНЬЯКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+АХ" } :: flexer "pl" // КОНЬЯКАХ } paradigm /*ПАЛЕЦ*/ Сущ_1045 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬЦЫ" } // ПАЛЕЦ ПАЛЬЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬЦА" "%-2%+ЬЦЕВ" } // ПАЛЬЦА ПАЛЬЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬЦЕМ" "%-2%+ЬЦАМИ" } // ПАЛЬЦЕМ ПАЛЬЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-2%+ЬЦЫ" } // ПАЛЕЦ ПАЛЬЦЫ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬЦУ" "%-2%+ЬЦАМ" } // ПАЛЬЦУ ПАЛЬЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬЦЕ" "%-2%+ЬЦАХ" } // ПАЛЬЦЕ ПАЛЬЦАХ } paradigm СЛЕДОВАТЕЛЬ, Сущ_1046 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЕЛЬ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СЛЕДОВАТЕЛЬ СЛЕДОВАТЕЛИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // СЛЕДОВАТЕЛЯ СЛЕДОВАТЕЛЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // СЛЕДОВАТЕЛЕМ СЛЕДОВАТЕЛЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // СЛЕДОВАТЕЛЯ СЛЕДОВАТЕЛЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // СЛЕДОВАТЕЛЮ СЛЕДОВАТЕЛЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // СЛЕДОВАТЕЛЕ СЛЕДОВАТЕЛЯХ } paradigm /*ЧЕЛОВЕЧЕК*/ Сущ_1047 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+И" } // ЧЕЛОВЕЧЕК ЧЕЛОВЕЧКИ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ЧЕЛОВЕЧКА ЧЕЛОВЕЧКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // ЧЕЛОВЕЧКОМ ЧЕЛОВЕЧКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ЧЕЛОВЕЧКА ЧЕЛОВЕЧКОВ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // ЧЕЛОВЕЧКУ ЧЕЛОВЕЧКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // ЧЕЛОВЕЧКЕ ЧЕЛОВЕЧКАХ } paradigm /*КАФЕТЕРИЙ*/ Сущ_1048 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // КАФЕТЕРИЙ КАФЕТЕРИИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕВ" } // КАФЕТЕРИЯ КАФЕТЕРИЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // КАФЕТЕРИЕМ КАФЕТЕРИЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // КАФЕТЕРИЙ КАФЕТЕРИИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // КАФЕТЕРИЮ КАФЕТЕРИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+И" "%-1%+ЯХ" } // КАФЕТЕРИИ КАФЕТЕРИЯХ } paradigm /*ГРОМИЛА*/ Сущ_1049 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ГРОМИЛА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // ГРОМИЛЫ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ГРОМИЛОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ГРОМИЛОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ГРОМИЛУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ГРОМИЛЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ГРОМИЛЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // ГРОМИЛЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // ГРОМИЛ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ГРОМИЛАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1" } :: flexer "pl" // ГРОМИЛ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ГРОМИЛАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ГРОМИЛАХ } paradigm /*ПАПАША*/ Сущ_1050 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ПАПАША ПАПАШИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1" } // ПАПАШИ ПАПАШ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+АМИ" } // ПАПАШЕЙ ПАПАШАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // ПАПАШУ ПАПАШ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ПАПАШЕ ПАПАШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ПАПАШЕ ПАПАШАХ } paradigm /*ЮНОША*/ Сущ_1051 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ЮНОША ЮНОШИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+ЕЙ" } // ЮНЮШИ ЮНОШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+АМИ" } // ЮНОШЕЙ ЮНОШАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+ЕЙ" } // ЮНОШУ ЮНОШЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ЮНОШЕ ЮНОШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ЮНОШЕ ЮНОШАХ } paradigm /*ЕГЕРЬ*/ Сущ_1052 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Я" } // ЕГЕРЬ ЕГЕРЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // ЕГЕРЯ ЕГЕРЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // ЕГЕРЕМ ЕГЕРЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // ЕГЕРЯ ЕГЕРЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // ЕГЕРЮ ЕГЕРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // ЕГЕРЕ ЕГЕРЯХ } paradigm /*МУРАВЕЙ*/ Сущ_1054 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬИ" } // МУРАВЕЙ МУРАВЬИ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬЯ" "%-2%+ЬЁВ" } // МУРАВЬЯ МУРАВЬЁВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬЁМ" "%-2%+ЬЯМИ" } // МУРАВЬЁМ МУРАВЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЬЯ" "%-2%+ЬЁВ" } // МУРАВЬЯ МУРАВЬЁВ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬЮ" "%-2%+ЬЯМ" } // МУРАВЬЮ МУРАВЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬЕ" "%-2%+ЬЯХ" } // МУРАВЬЕ МУРАВЬЯХ } paradigm /*КУЛЁК*/ Сущ_1055 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬКИ" } // КУЛЁК КУЛЬКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // КУЛЬКА КУЛЬКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬКОМ" "%-2%+ЬКАМИ" } // КУЛЬКОМ КУЛЬКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-2%+ЬКИ" } // КУЛЁК КУЛЬКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬКУ" "%-2%+ЬКАМ" } // КУЛЬКУ КУЛЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬКЕ" "%-2%+ЬКАХ" } // КУЛЬКЕ КУЛЬКАХ } paradigm /*ПАРЕНЁК*/ Сущ_1056 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬКИ" } // ПАРЕНЁК ПАРЕНЬКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // ПАРЕНЬКА ПАРЕНЬКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬКОМ" "%-2%+ЬКАМИ" } // ПАРЕНЬКОМ ПАРЕНЬКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // ПАРЕНЬКА ПАРЕНЬКОВ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬКУ" "%-2%+ЬКАМ" } // ПАРЕНЬКУ ПАРЕНЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬКЕ" "%-2%+ЬКАХ" } // ПАРЕНЬКЕ ПАРЕНЬКАХ } paradigm /*ПЛАТЁЖ*/ Сущ_1057 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ПЛАТЁЖ ПЛАТЕЖИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // ПЛАТЕЖА ПЛАТЕЖЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ПЛАТЕЖОМ ПЛАТЕЖАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // ПЛАТЁЖ ПЛАТЕЖИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ПЛАТЕЖУ ПЛАТЕЖАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ПЛАТЕЖЕ ПЛАТЕЖАХ } paradigm /*САРАЙ*/ Сущ_1058 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // САРАЙ САРАИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕВ" } // САРАЯ САРАЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // САРАЕМ САРАЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // САРАЙ САРАИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // САРАЮ САРАЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // САРАЕ САРАЯХ } paradigm /*БУКА*/ Сущ_1059 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // БУКА БУКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1" } // БУКИ БУК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // БУКОЙ БУКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // БУКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // БУКУ БУК ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // БУКЕ БУКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // БУКЕ БУКАХ } paradigm /*ДЕДУШКА*/ Сущ_1060 : СУЩЕСТВИТЕЛЬНОЕ { ОДУШ:ОДУШ РОД:МУЖ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДЕДУШКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ДЕДУШКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ДЕДУШКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ДЕДУШКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ДЕДУШКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ДЕДУШКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ДЕДУШКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ДЕДУШКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-2%+ЕК" } :: flexer "pl" // ДЕДУШЕК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ДЕДУШКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-2%+ЕК" } :: flexer "pl" // ДЕДУШЕК ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ДЕДУШКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ДЕДУШКАХ } paradigm ДЯДЕНЬКА, Сущ_1061 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЬКА" { РОД:МУЖ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДЯДЕНЬКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ДЯДЕНЬКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ДЯДЕНЬКОЙ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ДЯДЕНЬКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ДЯДЕНЬКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ДЯДЕНЬКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ДЯДЕНЬКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-3%+ЕК" } :: flexer "pl" // ДЯДЕНЕК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ДЯДЕНЬКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-3%+ЕК" } :: flexer "pl" // ДЯДЕНЕК ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ДЯДЕНЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ДЯДЕНЬКАХ } paradigm /*ОРЁЛ*/ Сущ_1062 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+Ы" } // ОРЁЛ ОРЛЫ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ОРЛА ОРЛОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // ОРЛОМ ОРЛАМИ ПАДЕЖ:ВИН ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // ОРЛА ОРЛОВ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // ОРЛУ ОРЛАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // ОРЛЕ ОРЛАХ } paradigm /*ПЛАЩ*/ Сущ_1064 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ПЛАЩ ПЛАЩИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // ПЛАЩА ПЛАЩЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЁМ" "%+АМИ" } // ПЛАЩЁМ ПЛАЩАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // ПЛАЩ ПЛАЩИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ПЛАЩУ ПЛАЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ПЛАЩЕ ПЛАЩАХ } paradigm /*МЕСЯЦ*/ Сущ_1065 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // МЕСЯЦ МЕСЯЦЫ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%+А" } // --- МЕСЯЦА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕВ" } // МЕСЯЦА МЕСЯЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЕМ" "%+АМИ" } // МЕСЯЦЕМ МЕСЯЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+Ы" } // МЕСЯЦ МЕСЯЦЫ ПАДЕЖ:ВИН ЧИСЛО:МН { "%+А" } // --- МЕСЯЦА ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // МЕСЯЦУ МЕСЯЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // МЕСЯЦЕ МЕСЯЦАХ } paradigm КРИК, Сущ_1067 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@аК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // КРИК КРИКИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // КРИКА КРИКОВ ПАДЕЖ:(ПАРТ) ЧИСЛО:ЕД { "%+У" } // КРИКУ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // КРИКОМ КРИКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // КРИК КРИКИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // КРИКУ КРИКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // КРИКЕ КРИКАХ } paradigm /*ШОФЁР*/ Сущ_1069 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЕРА" } // ШОФЁР ШОФЕРА ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%-2%+ЕРОВ" } // ШОФЁРА ШОФЕРОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%-2%+ЕРАМИ" } // ШОФЁРОМ ШОФЕРАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%-2%+ЕРОВ" } // ШОФЁРА ШОФЕРОВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%-2%+ЕРАМ" } // ШОФЁРУ ШОФЕРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%-2%+ЕРАХ" } // ШОФЁРЕ ШОФЕРАХ } paradigm /*ВЕРХ*/ Сущ_1070 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // ВЕРХ ВЕРХИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ВЕРХА ВЕРХОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ВЕРХОМ ВЕРХАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // ВЕРХ ВЕРХИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ВЕРХУ ВЕРХАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ВЕРХЕ ВЕРХАХ } paradigm /*УЖАС*/ Сущ_1071 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // УЖАС УЖАСЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // УЖАСА УЖАСОВ ПАДЕЖ:(ПАРТ) ЧИСЛО:ЕД { "%+У" } // УЖАСУ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // УЖАСОМ УЖАСАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+Ы" } // УЖАС УЖАСЫ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // УЖАСУ УЖАСАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // УЖАСЕ УЖАСАХ } paradigm /*СТРАЖ*/ Сущ_1072_одуш : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // СТРАЖ СТРАЖИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // СТРАЖА СТРАЖЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЕМ" "%+АМИ" } // СТРАЖЕМ СТРАЖАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЕЙ" } // СТРАЖА СТРАЖЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // СТРАЖУ СТРАЖАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // СТРАЖЕ СТРАЖАХ } paradigm /*КУКИШ*/ Сущ_1072_неодуш : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // КУКИШ КУКИШИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // КУКИША КУКИШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЕМ" "%+АМИ" } // КУКИШЕМ КУКИШАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+И" } // КУКИШ КУКИШИ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // КУКИШУ КУКИШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // КУКИШЕ КУКИШАХ } paradigm /*РОСТ*/ Сущ_1073 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // РОСТ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%+А" } // РОСТА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+ОМ" } // РОСТОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // РОСТ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%+У" } // РОСТУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%+Е" } // РОСТЕ } paradigm /*БРАТ*/ Сущ_1076 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+ЬЯ" } // БРАТ БРАТЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЬЕВ" } // БРАТА БРАТЬЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+ЬЯМИ" } // БРАТОМ БРАТЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЬЕВ" } // БРАТА БРАТЬЕВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+ЬЯМ" } // БРАТУ БРАТЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+ЬЯХ" } // БРАТЕ БРАТЬЯХ } paradigm ПРИШЕЛЕЦ, Сущ_1078 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЕЦ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬЦЫ" } // ПРИШЕЛЕЦ ПРИШЕЛЬЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬЦА" "%-2%+ЬЦЕВ" } // ПРИШЕЛЬЦА ПРИШЕЛЬЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬЦЕМ" "%-2%+ЬЦАМИ" } // ПРИШЕЛЬЦЕМ ПРИШЕЛЬЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЬЦА" "%-2%+ЬЦЕВ" } // ПРИШЕЛЬЦА ПРИШЕЛЬЦЕВ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬЦУ" "%-2%+ЬЦАМ" } // ПРИШЕЛЬЦУ ПРИШЕЛЬЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬЦЕ" "%-2%+ЬЦАХ" } // ПРИШЕЛЬЦЕ ПРИШЕЛЬЦАХ } paradigm /*СТУЛ*/ Сущ_1079 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+ЬЯ" } // СТУЛ СТУЛЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЬЕВ" } // СТУЛА СТУЛЬЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+ЬЯМИ" } // СТУЛОМ СТУЛЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+ЬЯ" } // СТУЛ СТУЛЬЯ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+ЬЯМ" } // СТУЛУ СТУЛЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+ЬЯХ" } // СТУЛЕ СТУЛЬЯХ } paradigm /*СОСЕД*/ Сущ_1080 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // СОСЕД СОСЕДИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // СОСЕДА СОСЕДЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+ЯМИ" } // СОСЕДОМ СОСЕДЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЕЙ" } // СОСЕДА СОСЕДЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+ЯМ" } // СОСЕДУ СОСЕДЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+ЯХ" } // СОСЕДЕ СОСЕДЯХ } paradigm ДИМКА, Сущ_1081 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бКА" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ЧИСЛО:ЕД |{ ПАДЕЖ:(ИМ) { "" } // ДИМКА ПАДЕЖ:(РОД) { "%-1%+И" } // ДИМКИ ПАДЕЖ:ТВОР { "%-1%+ОЙ" } // ДИМКОЙ ПАДЕЖ:ВИН { "%-1%+У" } // ДИМКУ ПАДЕЖ:ДАТ { "%-1%+Е" } // ДИМКЕ ПАДЕЖ:(ПРЕДЛ) { "%-1%+Е" } // ДИМКЕ } } paradigm /*УЧЁНЫЙ*/ Сущ_1083 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Е" } // УЧЁНЫЙ УЧЁНЫЕ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ОГО" "%-1%+Х" } // УЧЁНОГО УЧЁНЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+М" "%-1%+МИ" } // УЧЁНЫМ УЧЁНЫМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ОГО" "%-1%+Х" } // УЧЁНОГО УЧЁНЫХ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ОМУ" "%-1%+М" } // УЧЁНОМУ УЧЁНЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ОМ" "%-1%+Х" } // УЧЁНОМ УЧЁНЫХ } paradigm /*МАЛЫШ*/ Сущ_1084 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+И" } // МАЛЫШ МАЛЫШИ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЕЙ" } // МАЛЫША МАЛЫШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // МАЛЫШОМ МАЛЫШАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЕЙ" } // МАЛЫША МАЛЫШЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // МАЛЫШУ МАЛЫШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // МАЛЫШЕ МАЛЫШАХ } paradigm /*СЛУГА*/ Сущ_1086 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СЛУГА СЛУГИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1" } // СЛУГИ СЛУГ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // СЛУГОЙ СЛУГАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // СЛУГУ СЛУГ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // СЛУГЕ СЛУГАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // СЛУГЕ СЛУГАХ } paradigm ОГОНЁК, Сущ_1087_неодуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бЕК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬКИ" } // ОГОНЁК ОГОНЬКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // ОГОНЬКА ОГОНЬКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬКОМ" "%-2%+ЬКАМИ" } // ОГОНЬКОМ ОГОНЬКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-2%+ЬКИ" } // ОГОНЁК ОГОНЬКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬКУ" "%-2%+ЬКАМ" } // ОГОНЬКУ ОГОНЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬКЕ" "%-2%+ЬКАХ" } // ОГОНЬКЕ ОГОНЬКАХ } paradigm ИГОРЁК, Сущ_1087_одуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бЕК" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЬКИ" } // ИГОРЁК ИГОРЬКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // ИГОРЬКА ИГОРЬКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЬКОМ" "%-2%+ЬКАМИ" } // ИГОРЬКОМ ИГОРЬКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЬКА" "%-2%+ЬКОВ" } // ИГОРЬКА ИГОРЬКОВ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЬКУ" "%-2%+ЬКАМ" } // ИГОРЬКУ ИГОРЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЬКЕ" "%-2%+ЬКАХ" } // ИГОРЬКЕ ИГОРЬКАХ } paradigm УБИЙЦА, Сущ_1088 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЙЦА" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Ы" } // УБИЙЦА УБИЙЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Ы" "%-1" } // УБИЙЦЫ УБИЙЦ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+АМИ" } // УБИЙЦЕЙ УБИЙЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // УБИЙЦУ УБИЙЦ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // УБИЙЦЕ УБИЙЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // УБИЙЦЕ УБИЙЦАХ } paradigm ДОМИШКА, Сущ_1091 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШЩ]КА" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ДОМИШКА ДОМИШКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ЕК" } // ДОМИШКИ ДОМИШЕК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // ДОМИШКОЙ ДОМИШКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // ДОМИШКА ДОМИШКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ДОМИШКЕ ДОМИШКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ДОМИШКЕ ДОМИШКАХ } paradigm ОЛИМПИЕЦ, Сущ_1092 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ИЕЦ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЙЦЫ" } // ОЛИМПИЕЦ ОЛИМПИЙЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЙЦА" "%-2%+ЙЦЕВ" } // ОЛИМПИЙЦА ОЛИМПИЙЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЙЦЕМ" "%-2%+ЙЦАМИ" } // ОЛИМПИЙЦЕМ ОЛИМПИЙЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЙЦА" "%-2%+ЙЦЕВ" } // ОЛИМПИЙЦА ОЛИМПИЙЦЕВ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЙЦУ" "%-2%+ЙЦАМ" } // ОЛИМПИЙЦУ ОЛИМПИЙЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЙЦЕ" "%-2%+ЙЦАХ" } // ОЛИМПИЙЦЕ ОЛИМПИЙЦАХ } paradigm /*ТАНЕЦ*/ Сущ_1093 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+Ы" } // ТАНЕЦ ТАНЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ЕВ" } // ТАНЦА ТАНЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ЕМ" "%c1%+АМИ" } // ТАНЦЕМ ТАНЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%c1%+Ы" } // ТАНЕЦ ТАНЦЫ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // ТАНЦУ ТАНЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // ТАНЦЕ ТАНЦАХ } paradigm МЕРЗАВЕЦ, Сущ_1094 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЕЦ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+Ы" } // МЕРЗАВЕЦ МЕРЗАВЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ЕВ" } // МЕРЗАВЦА МЕРЗАВЦЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ЕМ" "%c1%+АМИ" } // МЕРЗАВЦЕМ МЕРЗАВЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "%c1%+А" "%c1%+ЕВ" } // МЕРЗАВЦА МЕРЗАВЦЕВ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // МЕРЗАВЦУ МЕРЗАВЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // МЕРЗАВЦЕ МЕРЗАВЦАХ } paradigm ДВОРЕЦ, Сущ_1095 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЕЦ" { РОД:МУЖ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДВОРЕЦ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%c1%+А" } // ДВОРЦА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%c1%+ОМ" } // ДВОРЦОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ДВОРЕЦ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%c1%+У" } // ДВОРЦУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%c1%+Е" } // ДВОРЦЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%c1%+Ы" } :: flexer "pl" // ДВОРЦЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%c1%+ОВ" } :: flexer "pl" // ДВОРЦОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%c1%+АМИ" } :: flexer "pl" // ДВОРЦАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%c1%+Ы" } :: flexer "pl" // ДВОРЦЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%c1%+АМ" } :: flexer "pl" // ДВОРЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%c1%+АХ" } :: flexer "pl" // ДВОРЦАХ } paradigm САМЕЦ, Сущ_1096 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЕЦ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%c1%+Ы" } // САМЕЦ САМЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // САМЦА САМЦОВ ПАДЕЖ:ТВОР ЧИСЛО { "%c1%+ОМ" "%c1%+АМИ" } // САМЦОМ САМЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "%c1%+А" "%c1%+ОВ" } // САМЦА САМЦОВ ПАДЕЖ:ДАТ ЧИСЛО { "%c1%+У" "%c1%+АМ" } // САМЦУ САМЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%c1%+Е" "%c1%+АХ" } // САМЦЕ САМЦАХ } paradigm /*КОМАНДУЮЩИЙ*/ Сущ_1097 : СУЩЕСТВИТЕЛЬНОЕ { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Е" } // КОМАНДУЮЩИЙ КОМАНДУЮЩИЕ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЕГО" "%-1%+Х" } // КОМАНДУЮЩЕГО КОМАНДУЮЩИХ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+М" "%-1%+МИ" } // КОМАНДУЮЩИМ КОМАНДУЮЩИМ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+ЕГО" "%-1%+Х" } // КОМАНДУЮЩЕГО КОМАНДУЮЩИХ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЕМУ" "%-1%+М" } // КОМАНДУЮЩЕМУ КОМАНДУЮЩИМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЕМ" "%-1%+Х" } // КОМАНДУЮЩЕМ КОМАНДУЮЩИХ } paradigm ДОСТОЕВСКИЙ, Сущ_1098 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)СКИЙ" { ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ РОД:МУЖ ЧИСЛО:ЕД |{ ПАДЕЖ:(ИМ) { "" } // Достоевский ПАДЕЖ:(РОД) { "%-2%+ОГО" } // Достоевского ПАДЕЖ:ТВОР { "%-2%+ИМ" } // достоевским ПАДЕЖ:ВИН { "%-2%+ОГО" } // Достоевского ПАДЕЖ:ДАТ { "%-2%+ОМУ" } // Достоевскому ПАДЕЖ:(ПРЕДЛ) { "%-2%+ОМ" } // Достоевском } } paradigm ДЫМИЩЕ, Сущ_1099 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЩЕ" { РОД:МУЖ ОДУШ:НЕОДУШ ПЕРЕЧИСЛИМОСТЬ:ДА ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДЫМИЩЕ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // ДЫМИЩА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // ДЫМИЩЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ДЫМИЩЕ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+У" } // ДЫМИЩУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ДЫМИЩЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } // ДЫМИЩИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } // ДЫМИЩ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // ДЫМИЩАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+А" } // ДЫМИЩА ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // ДЫМИЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // ДЫМИЩАХ } paradigm ОКУНИЩЕ, Сущ_1100 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЩЕ" { РОД:МУЖ ОДУШ:ОДУШ ПЕРЕЧИСЛИМОСТЬ:ДА ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ОКУНИЩЕ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // ОКУНИЩА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕМ" } // ОКУНИЩЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+А" } // ОКУНИЩА ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+У" } // ОКУНИЩУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ОКУНИЩЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } // ОКУНИЩИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+А" } // ОКУНИЩА ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // ОКУНИЩ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1" } // ОКУНИЩ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // ОКУНИЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // ОКУНИЩАХ } // ======================================================================= paradigm /*МАТЬ*/ Сущ_2001 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+ЕРИ" } // МАТЬ МАТЕРИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+ЕРИ" "%-1%+ЕРЕЙ" } // МАТЕРИ МАТЕРЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕРЬЮ" "%-1%+ЕРЯМИ" } // МАТЕРЬЮ МАТЕРЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+ЕРЕЙ" } // МАТЬ МАТЕРЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+ЕРИ" "%-1%+ЕРЯМ" } // МАТЕРИ МАТЕРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+ЕРИ" "%-1%+ЕРЯХ" } // МАТЕРИ МАТЕРЯХ } paradigm /*ТЬМА*/ Сущ_2002 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Ы" } // ТЬМА ТЬМЫ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // ТЬМЫ - ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // ТЬМОЙ ТЬМАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ТЬМОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+Ы" } // ТЬМУ ТЬМЫ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ТЬМЕ ТЬМАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ТЬМЕ ТЬМАХ } paradigm БЛОНДИНКА, Сущ_2003 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бКА" { РОД:ЖЕН ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // БЛОНДИНКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // БЛОНДИНКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // БЛОНДИНКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // БЛОНДИНКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // БЛОНДИНКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // БЛОНДИНКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // БЛОНДИНКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // БЛОНДИНКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-2%+ОК" } :: flexer "pl" // БЛОНДИНОК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // БЛОНДИНКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-2%+ОК" } :: flexer "pl" // БЛОНДИНОК ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // БЛОНДИНКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // БЛОНДИНКАХ } paradigm /*ВОШЬ*/ Сущ_2004 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ШИ" } // ВОШЬ ВШИ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "%-3%+ША" } // ВША ПАДЕЖ:(РОД) ЧИСЛО { "%-3%+ШИ" "%-3%+ШЕЙ" } // ВШИ ВШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+Ю" "%-3%+ШАМИ" } // ВОШЬЮ ВШАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-3%+ШОЙ" } // ВШОЙ ПАДЕЖ:ВИН ЧИСЛО { "" "%-3%+ШЕЙ" } // ВОШЬ ВШЕЙ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-3%+ШУ" } // ВШУ ПАДЕЖ:ДАТ ЧИСЛО { "%-3%+ШЕ" "%-3%+ШАМ" } // ВШЕ ВШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-3%+ШЕ" "%-3%+ШАХ" } // ВШЕ ВШАХ } paradigm МАМА, Сущ_2006 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)А" { РОД:ЖЕН ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // МАМА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // МАМЫ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // МАМОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // МАМОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // МАМУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // МАМЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // МАМЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // МАМЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // МАМ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // МАМАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1" } :: flexer "pl" // МАМ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // МАМАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // МАМАХ } paradigm ЦВЕТАЕВА, Сущ_2006_Фамилия : СУЩЕСТВИТЕЛЬНОЕ for "(.+)А" { РОД:ЖЕН ОДУШ:ОДУШ ПЕРЕЧИСЛИМОСТЬ:НЕТ CharCasing:FirstCapitalized ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЦВЕТАЕВА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+ОЙ" } // ЦВЕТАЕВОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ЦВЕТАЕВОЙ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ЦВЕТАЕВУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+ОЙ" } // ЦВЕТАЕВОЙ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+ОЙ" } // ЦВЕТАЕВОЙ } paradigm РОЗА, Сущ_2007 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)А" { РОД:ЖЕН ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // РОЗА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // РОЗЫ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // РОЗОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // РОЗОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // РОЗУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // РОЗЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // РОЗЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // РОЗЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // РОЗ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // РОЗАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // РОЗЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // РОЗАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // РОЗАХ } paradigm СУХОСТЬ, Сущ_2008 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ОСТЬ" { РОД:ЖЕН ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // СУХОСТЬ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // СУХОСТИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+Ю" } // СУХОСТЬЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // СУХОСТЬ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+И" } // СУХОСТИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // СУХОСТИ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // СУХОСТИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕЙ" } :: flexer "pl" // СУХОСТЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // СУХОСТЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // СУХОСТИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // СУХОСТЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // СУХОСТЯХ } paradigm ХАРЯ, Сущ_2009 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бЯ" { РОД:ЖЕН ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ХАРЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ХАРИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ХАРЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ХАРЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // ХАРЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ХАРЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ХАРЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ХАРИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+Ь" } :: flexer "pl" // ХАРЬ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } :: flexer "pl" // ХАРЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ХАРИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } :: flexer "pl" // ХАРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } :: flexer "pl" // ХАРЯХ } paradigm ГУСЫНЯ, Сущ_2009_одуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бЯ" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ГУСЫНЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ГУСЫНИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ГУСЫНЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ГУСЫНЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // ГУСЫНЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ГУСЫНЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ГУСЫНЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } // ГУСЫНИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+Ь" } // ГУСЫНЬ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } // ГУСЫНЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+Ь" } // ГУСЫНЬ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } // ГУСЫНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } // ГУСЫНЯХ } paradigm ОЛЯ, Сущ_2009_имя : СУЩЕСТВИТЕЛЬНОЕ for "(.+)Я" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ CharCasing:FirstCapitalized ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // Оля ПАДЕЖ:ЗВАТ ЧИСЛО:ЕД { "%-1%+Ь" } :: flexer "vocative" // Оль ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // Оли ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // Олей ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // Олю ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // Оле ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // Оле } paradigm ЭМИССИЯ, Сущ_2010 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ИЬ]Я" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЭМИССИЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ЭМИССИИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ЭМИССИЕЙ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // ЭМИССИЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+И" } // ЭМИССИИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // ЭМИССИИ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ЭМИССИИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+Й" } :: flexer "pl" // ЭМИССИЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // ЭМИССИЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ЭМИССИИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // ЭМИССИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // ЭМИССИЯХ } // с дополнительной формой творительного падежа paradigm ИСТОРИЯ, Сущ_2010_2 : СУЩЕСТВИТЕЛЬНОЕ { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ИСТОРИЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ИСТОРИИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ИСТОРИЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ИСТОРИЕЙ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // ИСТОРИЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+И" } // ИСТОРИИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // ИСТОРИИ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ИСТОРИИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+Й" } :: flexer "pl" // ИСТОРИЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // ИСТОРИЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ИСТОРИИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // ИСТОРИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // ИСТОРИЯХ } paradigm /*МЫШЬ*/ Сущ_2011_одуш : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // МЫШЬ МЫШИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+ЕЙ" } // МЫШИ МЫШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+Ю" "%-1%+АМИ" } // МЫШЬЮ МЫШАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+ЕЙ" } // МЫШЬ МЫШЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+И" "%-1%+АМ" } // МЫШИ МЫШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+И" "%-1%+АХ" } // МЫШИ МЫШАХ } paradigm /*НОЧЬ*/ Сущ_2011_неодуш : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // НОЧЬ НОЧИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+ЕЙ" } // НОЧИ НОЧЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+Ю" "%-1%+АМИ" } // НОЧЬЮ НОЧАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // НОЧЬ НОЧЕЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+И" "%-1%+АМ" } // НОЧИ НОЧАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+И" "%-1%+АХ" } // НОЧИ НОЧАХ } paradigm ДЕВУШКА, Сущ_2013 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШЩ]КА" { РОД:ЖЕН ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ДЕВУШКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ДЕВУШКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ДЕВУШКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ДЕВУШКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ДЕВУШКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ДЕВУШКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ДЕВУШКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ДЕВУШКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-2%+ЕК" } :: flexer "pl" // ДЕВУШЕК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ДЕВУШКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-2%+ЕК" } :: flexer "pl" // ДЕВУШЕК ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ДЕВУШКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ДЕВУШКАХ } paradigm ДВУШКА, Сущ_2014 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бКА" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ДВУШКА ДВУШКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ЕК" } // ДВУШКИ ДВУШЕК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // ДВУШКОЙ ДВУШКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ДВУШКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // ДВУШКУ ДВУШКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ДВУШКЕ ДВУШКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ДВУШКЕ ДВУШКАХ } paradigm РУКА, Сущ_2015 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[КХ]А" { РОД:ЖЕН ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // РУКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // РУКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // РУКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // РУКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // РУКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // РУКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // РУКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // РУКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // РУК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // РУКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // РУКИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // РУКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // РУКАХ } paradigm СНОХА, Сущ_2015a : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[КХ]А" { РОД:ЖЕН ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // СНОХА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // СНОХИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // СНОХОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // СНОХОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // СНОХУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // СНОХЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // СНОХЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // СНОХИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // СНОХ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // СНОХАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1" } :: flexer "pl" // СНОХ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // СНОХАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // СНОХАХ } paradigm /*ДЕНЬГА*/ Сущ_2016 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ДЕНЬГА ДЕНЬГИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЕГ" } // ДЕНЬГИ ДЕНЕГ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%+МИ" } // ДЕНЬГОЙ ДЕНЬГАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ДЕНЬГОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // ДЕНЬГУ ДЕНЬГИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // ДЕНЬГЕ ДЕНЬГАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // ДЕНЬГЕ ДЕНЬГАХ } paradigm /*ЖЕНА*/ Сущ_2017 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ЁНЫ" } // ЖЕНА ЖЁНЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Ы" "%-3%+ЁН" } // ЖЕНЫ ЖЁН ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-3%+ЁНАМИ" } // ЖЕНОЙ ЖЁНАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ЖЕНОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-3%+ЁН" } // ЖЕНУ ЖЁН ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-3%+ЁНАМ" } // ЖЕНЕ ЖЁНАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-3%+ЁНАХ" } // ЖЕНЕ ЖЁНАХ } paradigm УЛИЦА, Сущ_2018 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЦА" { ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // УЛИЦА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // УЛИЦЫ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // УЛИЦЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // УЛИЦЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // УЛИЦУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // УЛИЦЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // УЛИЦЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // УЛИЦЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // УЛИЦ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // УЛИЦАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+Ы" } :: flexer "pl" // УЛИЦЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // УЛИЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // УЛИЦАХ } paradigm /*ПТИЦА*/ Сущ_2018a : СУЩЕСТВИТЕЛЬНОЕ { ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Ы" } // ПТИЦА ПТИЦЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Ы" "%-1" } // ПТИЦЫ ПТИЦ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%+МИ" } // ПТИЦЕЙ ПТИЦАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ПТИЦЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // ПТИЦУ ПТИЦ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // ПТИЦЕ ПТИЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // ПТИЦЕ ПТИЦАХ } paradigm /*НАТАША*/ Сущ_2018_2a : СУЩЕСТВИТЕЛЬНОЕ { ОДУШ:ОДУШ РОД:ЖЕН ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // НАТАША ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // НАТАШИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // НАТАШЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // НАТАШЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // НАТАШУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // НАТАШЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // НАТАШЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // БАНКИРШИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // БАНКИРШ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // БАНКИРШАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1" } :: flexer "pl" // БАНКИРШ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // БАНКИРШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // БАНКИРШАХ } paradigm /*КУХНЯ*/ Сущ_2019 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // КУХНЯ КУХНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ОНЬ" } // КУХНИ КУХОНЬ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+ЯМИ" } // КУХНЕЙ КУХНЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // КУХНЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // КУХНЮ КУХНИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+ЯМ" } // КУХНЕ КУХНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // КУХНЕ КУХНЯХ } paradigm ТРУБКА, Сущ_2020 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бКА" { РОД:ЖЕН ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ТРУБКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ТРУБКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // ТРУБКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ТРУБКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ТРУБКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ТРУБКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ТРУБКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ТРУБКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-2%+ОК" } :: flexer "pl" // ТРУБОК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // ТРУБКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ТРУБКИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ТРУБКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ТРУБКАХ } paradigm /*ПРИРОДА*/ Сущ_2021 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ПРИРОДА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Ы" } // ПРИРОДЫ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ"} // ПРИРОДОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ"} // ПРИРОДОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ПРИРОДУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ПРИРОДЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ПРИРОДЕ } paradigm /*ЧУШЬ*/ Сущ_2022 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЧУШЬ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ЧУШИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+Ю" } // ЧУШЬЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ЧУШЬ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+И" } // ЧУШИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+И" } // ЧУШИ } paradigm /*ВАННАЯ*/ Сущ_2023 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЫЕ" } // ВАННАЯ ВАННЫЕ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ОЙ" "%-2%+ЫХ" } // ВАННОЙ ВАННЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ОЙ" "%-2%+ЫМИ" } // ВАННОЙ ВАННЫМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-2%+ОЮ" } // ВАННОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+УЮ" "%-2%+ЫЕ" } // ВАННУЮ ВАННЫЕ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ОЙ" "%-2%+ЫМ" } // ВАННОЙ ВАННЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ОЙ" "%-2%+ЫХ" } // ВАННОЙ ВАННЫХ } paradigm /*ПРИХОЖАЯ*/ Сущ_2024 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ИЕ" } // ПРИХОЖАЯ ПРИХОЖИЕ ПАДЕЖ:(РОД) ЧИСЛО { "%-2%+ЕЙ" "%-2%+ИХ" } // ПРИХОЖЕЙ ПРИХОЖИХ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЕЙ" "%-2%+ИМИ" } // ПРИХОЖЕЙ ПРИХОЖИМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-2%+ЕЮ" } // ПРИХОЖЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-2%+УЮ" "%-2%+ИЕ" } // ПРИХОЖУЮ ПРИХОЖИЕ ПАДЕЖ:ДАТ ЧИСЛО { "%-2%+ЕЙ" "%-2%+ИМ" } // ПРИХОЖЕЙ ПРИХОЖИМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-2%+ЕЙ" "%-2%+ИХ" } // ПРИХОЖЕЙ ПРИХОЖЫХ } paradigm НЯНЬКА, Сущ_2025 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЬКА" { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // НЯНЬКА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // НЯНЬКИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ" } // НЯНЬКОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // НЯНЬКОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // НЯНЬКУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // НЯНЬКЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // НЯНЬКЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // НЯНЬКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-3%+ЕК" } :: flexer "pl" // НЯНЕК ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } :: flexer "pl" // НЯНЬКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-3%+ЕК" } :: flexer "pl" // НЯНЕК ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } :: flexer "pl" // НЯНЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } :: flexer "pl" // НЯНЬКАХ } paradigm /*ЛЕДИ*/ Сущ_2026 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "" } // ЛЕДИ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ ПАДЕЖ:ТВОР ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "" } :: flexer "pl" // ЛЕДИ } paradigm /*ЗЕМЛЯ*/ Сущ_2027 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ЗЕМЛЯ ЗЕМЛИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ЕЛЬ" } // ЗЕМЛИ ЗЕМЕЛЬ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЁЙ" "%-1%+ЯМИ" } // ЗЕМЛЁЙ ЗЕМЛЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЁЮ" } // ЗЕМЛЁЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // ЗЕМЛЮ ЗЕМЛИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+ЯМ" } // ЗЕМЛЕ ЗЕМЛЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // ЗЕМЛЕ ЗЕМЛЯХ } paradigm /*ШЕЯ*/ Сущ_2028 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ШЕЯ ШЕИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+Й" } // ШЕИ ШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%+МИ" } // ШЕЕЙ ШЕЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // ШЕЮ ШЕИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // ШЕЕ ШЕЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // ШЕЕ ШЕЯХ } paradigm ТЫСЯЧА, Сущ_2030 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[ЧШЩ]А" { ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ТЫСЯЧА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ТЫСЯЧИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ТЫСЯЧЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ТЫСЯЧЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ТЫСЯЧУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ТЫСЯЧЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ТЫСЯЧЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ТЫСЯЧИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // ТЫСЯЧ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ТЫСЯЧАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+И" } :: flexer "pl" // ТЫСЯЧИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ТЫСЯЧАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ТЫСЯЧАХ } paradigm /*СОБАКА*/ Сущ_2031 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СОБАКА СОБАКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1" } // СОБАКИ СОБАК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%+МИ" } // СОБАКОЙ СОБАКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // СОБАКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1" } // СОБАКУ СОБАК ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // СОБАКЕ СОБАКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // СОБАКЕ СОБАКАХ } paradigm /*СПАЛЬНЯ*/ Сущ_2032 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СПАЛЬНЯ СПАЛЬНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЕН" } // СПАЛЬНИ СПАЛЕН ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+ЯМИ" } // СПАЛЬНЕЙ СПАЛЬНЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // СПАЛЬНЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // СПАЛЬНЮ СПАЛЬНИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+ЯМ" } // СПАЛЬНЕ СПАЛЬНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // СПАЛЬНЕ СПАЛЬНЯХ } paradigm СКАМЕЙКА, Сущ_2035 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЙКА" { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СКАМЕЙКА СКАМЕЙКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЕК" } // СКАМЕЙКИ СКАМЕЕК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // СКАМЕЙКОЙ СКАМЕЙКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // СКАМЕЙКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // СКАМЕЙКУ СКАМЕЙКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // СКАМЕЙКЕ СКАМЕЙКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // СКАМЕЙКЕ СКАМЕЙКАХ } paradigm КАНАРЕЙКА, Сущ_2035_одуш : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЙКА" { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // КАНАРЕЙКА КАНАРЕЙКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЕК" } // КАНАРЕЙКИ КАНАРЕЕК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // КАНАРЕЙКОЙ КАНАРЕЙКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // КАНАРЕЙКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-3%+ЕК" } // КАНАРЕЙКУ КАНАРЕЕК ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // КАНАРЕЙКЕ КАНАРЕЙКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // КАНАРЕЙКЕ КАНАРЕЙКАХ } paradigm /*ЩЕКА*/ Сущ_2036 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ЁКИ" } // ЩЕКА ЩЁКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЁК" } // ЩЕКИ ЩЁК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-3%+ЁКАМИ" } // ЩЕКОЙ ЩЁКАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ЩЕКОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-3%+ЁКИ" } // ЩЕКУ ЩЁКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-3%+ЁКАМ" } // ЩЕКЕ ЩЁКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-3%+ЁКАХ" } // ЩЕКЕ ЩЁКАХ } paradigm /*СУДЬБА*/ Сущ_2037 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Ы" } // СУДЬБА СУДЬБЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Ы" "%-3%+ЕБ" } // СУДЬБЫ СУДЕБ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%+МИ" } // СУДЬБОЙ СУДЬБАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // СУДЬБОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+Ы" } // СУДЬБУ СУДЬБЫ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // СУДЬБЕ СУДЬБАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // СУДЬБЕ СУДЬБАХ } paradigm СВЕЧА, Сущ_2038 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЧА" { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СВЕЧ СВЕЧИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+ЕЙ" } // СВЕЧИ СВЕЧЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // СВЕЧОЙ СВЕЧАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // СВЕЧОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // СВЕЧУ СВЕЧИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // СВЕЧЕ СВЕЧАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // СВЕЧЕ СВЕЧАХ } paradigm /*ЧЕПУХА*/ Сущ_2039 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЧЕПУХА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ЧЕПУХИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЙ"} // ЧЕПУХОЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ"} // ЧЕПУХОЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ЧЕПУХУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ЧЕПУХЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ЧЕПУХЕ } paradigm /*ВОЛЯ*/ Сущ_2040 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ВОЛЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ВОЛИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ"} // ВОЛЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ"} // ВОЛЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // ВОЛЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ВОЛЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ВОЛЕ } paradigm /*ЗМЕЯ*/ Сущ_2041 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ЗМЕЯ ЗМЕИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+Й" } // ЗМЕИ ЗМЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЁЙ" "%+МИ" } // ЗМЕЁЙ ЗМЕЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЁЮ" } // ЗМЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // ЗМЕЮ ЗМЕИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // ЗМЕЕ ЗМЕЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // ЗМЕЕ ЗМЕЯХ } // несклоняемые paradigm /*СОЛЯРИС*/ Сущ_2042 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "" } ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "" } ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "" } ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } :: flexer "pl" ПАДЕЖ:(РОД) ЧИСЛО:МН { "" } :: flexer "pl" ПАДЕЖ:ТВОР ЧИСЛО:МН { "" } :: flexer "pl" ПАДЕЖ:ВИН ЧИСЛО:МН { "" } :: flexer "pl" ПАДЕЖ:ДАТ ЧИСЛО:МН { "" } :: flexer "pl" ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "" } :: flexer "pl" } paradigm /*КАПЛЯ*/ Сущ_2044 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // КАПЛЯ КАПЛИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ЕЛЬ" } // КАПЛИ КАПЕЛЬ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+ЯМИ" } // КАПЛЕЙ КАПЛЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // КАПЛЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // КАПЛЮ КАПЛИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+ЯМ" } // КАПЛЕ КАПЛЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // КАПЛЕ КАПЛЯХ } paradigm /*ДЕРЕВНЯ*/ Сущ_2045 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ДЕРЕВНЯ ДЕРЕВНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ЕНЬ" } // ДЕРЕВНИ ДЕРЕВЕНЬ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%-1%+ЯМИ" } // ДЕРЕВНЕЙ ДЕРЕВНЯМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ДЕРЕВНЕЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // ДЕРЕВНЮ ДЕРЕВНИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+ЯМ" } // ДЕРЕВНЕ ДЕРЕВНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // ДЕРЕВНЕ ДЕРЕВНЯХ } paradigm /*ДУША*/ Сущ_2048 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ДУША ДУШИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1" } // ДУШИ ДУШ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+АМИ" } // ДУШОЙ ДУШАМИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ОЮ" } // ДУШОЮ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // ДУШУ ДУШИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%-1%+АМ" } // ДУШЕ ДУШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ДУШЕ ДУШАХ } paradigm /*ПИЩА*/ Сущ_2049 : СУЩЕСТВИТЕЛЬНОЕ { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ПИЩА ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // ПИЩИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЙ" } // ПИЩЕЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЕЮ" } // ПИЩЕЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+У" } // ПИЩУ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // ПИЩЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ПИЩЕ } paradigm СТУПЕНЬКА, Сущ_2050 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ЬКА" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // СТУПЕНЬКА СТУПЕНЬКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-3%+ЕК" } // СТУПЕНЬКИ СТУПЕНЕК ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%+МИ" } // СТУПЕНЬКОЙ СТУПЕНЬКАМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+И" } // СТУПЕНЬКУ СТУПЕНЬКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // СТУПЕНЬКЕ СТУПЕНЬКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // СТУПЕНЬКЕ СТУПЕНЬКАХ } paradigm /*СТРЯПНЯ*/ Сущ_2051 : СУЩЕСТВИТЕЛЬНОЕ { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // СТРЯПНЯ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+И" } // СТРЯПНИ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЁЙ" } // СТРЯПНЁЙ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЁЮ" } // СТРЯПНЁЮ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "%-1%+Ю" } // СТРЯПНЮ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Е" } // СТРЯПНЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // СТРЯПНЕ } paradigm Анастасия, Сущ_2052 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бИЯ" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // АНАСТАСИЯ АНАСТАСИИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+Й" } // АНАСТАСИИ АНАСТАСИЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%+МИ" } // АНАСТАСИЕЙ АНАСТАСИЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+Й" } // АНАСТАСИЮ АНАСТАСИЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+И" "%+М" } // АНАСТАСИИ АНАСТАСИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+И" "%+Х" } // АНАСТАСИИ АНАСТАСИЯХ } paradigm Авдотья, Сущ_2053 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бЬЯ" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // АВДОТЬЯ АВДОТЬИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-2%+ИЙ" } // АВДОТЬИ АВДОТИЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%+МИ" } // АВДОТЬЕЙ АВДОТЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-2%+ИЙ" } // АВДОТЬЮ АВДОТИЙ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // АВДОТЬЕ АВДОТЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // АВДОТЬЕ АВДОТЬЯХ } paradigm /*ПАШНЯ*/ Сущ_2054: СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+и" } // пашня пашни ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+и" "%-2%+ен" } // пашни пашен ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+еЙ" "%+МИ" } // пашней пашнями ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ею" } // пашнею ПАДЕЖ:ВИН ЧИСЛО { "%-1%+ю" "%-1%+и" } // пашню пашни ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+е" "%+м" } // пашне пашням ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+е" "%+х" } // пашне пашнях } paradigm /*петля*/ Сущ_2055: СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+и" } // петля петли ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+и" "%-2%+ель" } // петли петель ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+еЙ" "%+МИ" } // петлей петлями ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ею" } // петлею ПАДЕЖ:ВИН ЧИСЛО { "%-1%+ю" "%-1%+и" } // петлю петли ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+е" "%+м" } // петле петлям ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+е" "%+х" } // петле петлях } paradigm /*пеня*/ Сущ_2056: СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+и" } // пеня пени ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+и" } // пени ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+еЙ" "%+МИ" } // пеней пенями ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ею" } // пенею ПАДЕЖ:ВИН ЧИСЛО { "%-1%+ю" "%-1%+и" } // пеню пени ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+е" "%+м" } // пене пеням ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+е" "%+х" } // пене пенях } // Отличие от 2010 - в дательном падеже единственного числа paradigm /*ГАЛЕРЕЯ*/ Сущ_2057 : СУЩЕСТВИТЕЛЬНОЕ { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ГАЛЕРЕЯ ГАЛЕРЕИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+И" "%-1%+Й" } // ГАЛЕРЕИ ГАЛЕРЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕЙ" "%+МИ" } // ГАЛЕРЕЕЙ ГАЛЕРЕЯМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+Ю" "%-1%+И" } // ГАЛЕРЕЮ ГАЛЕРЕИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Е" "%+М" } // ГАЛЕРЕЕ ГАЛЕРЕЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%+Х" } // ГАЛЕРЕЕ ГАЛЕРЕЯХ } paradigm /*МОРЕ*/ Сущ_3001 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Я" } // МОРЕ МОРЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-1%+ЕЙ" } // МОРЯ МОРЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+ЯМИ" } // МОРЕМ МОРЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+Я" } // МОРЕ МОРЯ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // МОРЮ МОРЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // МОРЕ МОРЯХ } paradigm ПРЕДУПРЕЖДЕНИЕ, Сущ_3003 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ИЕ" { РОД:СР ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:Ед { "" } // предупреждение ПАДЕЖ:(РОД) ЧИСЛО:Ед { "%-1%+Я" } // ПРЕДУПРЕЖДЕНИЯ ПАДЕЖ:ТВОР ЧИСЛО:Ед { "%-1%+ЕМ" } // ПРЕДУПРЕЖДЕНИЕМ ПАДЕЖ:ВИН ЧИСЛО:Ед { "" } // ПРЕДУПРЕЖДЕНИЕ ПАДЕЖ:ДАТ ЧИСЛО:Ед { "%-1%+Ю" } // ПРЕДУПРЕЖДЕНИЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Ед { "%-1%+И" } // ПРЕДУПРЕЖДЕНИИ ПАДЕЖ:(ИМ) ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯ ПАДЕЖ:(РОД) ЧИСЛО:Мн { "%-1%+Й" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЙ ПАДЕЖ:ТВОР ЧИСЛО:Мн { "%-1%+ЯМИ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯМИ ПАДЕЖ:ВИН ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯ ПАДЕЖ:ДАТ ЧИСЛО:Мн { "%-1%+ЯМ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Мн { "%-1%+ЯХ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯХ ПАДЕЖ:(ИМ) ЧИСЛО:Ед { "" } // предупрежденье ПАДЕЖ:(РОД) ЧИСЛО:Ед { "%-1%+Я" } // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ТВОР ЧИСЛО:Ед { "%-1%+ЕМ" } // ПРЕДУПРЕЖДЕНЬЕМ ПАДЕЖ:ВИН ЧИСЛО:Ед { "" } // ПРЕДУПРЕЖДЕНЬЕ ПАДЕЖ:ДАТ ЧИСЛО:Ед { "%-1%+Ю" } // ПРЕДУПРЕЖДЕНЬЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Ед { "%-1%+И" } // ПРЕДУПРЕЖДЕНЬИ ПАДЕЖ:(ИМ) ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ТВОР ЧИСЛО:Мн { "%-1%+ЯМИ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯМИ ПАДЕЖ:ВИН ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ДАТ ЧИСЛО:Мн { "%-1%+ЯМ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Мн { "%-1%+ЯХ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯХ } // существительные типа ПРЕДУПРЕЖДЕНИЕ, имеющие альтернативных набор форм на -ЬЕ paradigm /*ПРЕДУПРЕЖДЕНИЕ*/ Сущ_3003_2 : СУЩЕСТВИТЕЛЬНОЕ { РОД:СР ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:Ед { "%-2%+ИЕ" } // предупреждение ПАДЕЖ:(РОД) ЧИСЛО:Ед { "%-2%+ИЯ" } // ПРЕДУПРЕЖДЕНиЯ ПАДЕЖ:ТВОР ЧИСЛО:Ед { "%-2%+ИЕМ" } // ПРЕДУПРЕЖДЕНиЕМ ПАДЕЖ:ВИН ЧИСЛО:Ед { "%-2%+ИЕ" } // ПРЕДУПРЕЖДЕНиЕ ПАДЕЖ:ДАТ ЧИСЛО:Ед { "%-2%+ИЮ" } // ПРЕДУПРЕЖДЕНиЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Ед { "%-2%+ИИ" } // ПРЕДУПРЕЖДЕНиИ ПАДЕЖ:(ИМ) ЧИСЛО:Мн { "%-2%+ИЯ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯ ПАДЕЖ:(РОД) ЧИСЛО:Мн { "%-2%+ИЙ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЙ ПАДЕЖ:ТВОР ЧИСЛО:Мн { "%-2%+ИЯМИ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯМИ ПАДЕЖ:ВИН ЧИСЛО:Мн { "%-2%+ИЯ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯ ПАДЕЖ:ДАТ ЧИСЛО:Мн { "%-2%+ИЯМ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Мн { "%-2%+ИЯХ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНИЯХ ПАДЕЖ:(ИМ) ЧИСЛО:Ед { "%-2%+ЬЕ" } // предупрежденье ПАДЕЖ:(РОД) ЧИСЛО:Ед { "%-2%+ЬЯ" } // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ТВОР ЧИСЛО:Ед { "%-2%+ЬЕМ" } // ПРЕДУПРЕЖДЕНЬЕМ ПАДЕЖ:ВИН ЧИСЛО:Ед { "%-2%+ЬЕ" } // ПРЕДУПРЕЖДЕНЬЕ ПАДЕЖ:ДАТ ЧИСЛО:Ед { "%-2%+ЬЮ" } // ПРЕДУПРЕЖДЕНЬЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Ед { "%-2%+ЬЕ" } // ПРЕДУПРЕЖДЕНЬЕ ПАДЕЖ:(ИМ) ЧИСЛО:Мн { "%-2%+ЬЯ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ТВОР ЧИСЛО:Мн { "%-2%+ЬЯМИ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯМИ ПАДЕЖ:ВИН ЧИСЛО:Мн { "%-2%+ЬЯ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯ ПАДЕЖ:ДАТ ЧИСЛО:Мн { "%-2%+ЬЯМ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Мн { "%-2%+ЬЯХ" } :: flexer "pl" // ПРЕДУПРЕЖДЕНЬЯХ } paradigm /*КУШАНЬЕ*/ Сущ_3006 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:Ед { "" } // КУШАНЬЕ ПАДЕЖ:(РОД) ЧИСЛО:Ед { "%-1%+Я" } // КУШАНЬЯ ПАДЕЖ:ТВОР ЧИСЛО:Ед { "%-1%+ЕМ" } // КУШАНЬЕМ ПАДЕЖ:ВИН ЧИСЛО:Ед { "" } // КУШАНЬЕ ПАДЕЖ:ДАТ ЧИСЛО:Ед { "%-1%+Ю" } // КУШАНЬЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Ед { "%-1%+Е" } // КУШАНЬЕ ПАДЕЖ:(ИМ) ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // КУШАНЬЯ ПАДЕЖ:(РОД) ЧИСЛО:Мн { "%-2%+ИЙ" } :: flexer "pl" // КУШАНИЙ ПАДЕЖ:ТВОР ЧИСЛО:Мн { "%-1%+ЯМИ" } :: flexer "pl" // КУШАНЬЯМИ ПАДЕЖ:ВИН ЧИСЛО:Мн { "%-1%+Я" } :: flexer "pl" // КУШАНЬЯ ПАДЕЖ:ДАТ ЧИСЛО:Мн { "%-1%+ЯМ" } :: flexer "pl" // КУШАНЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:Мн { "%-1%+ЯХ" } :: flexer "pl" // КУШАНЬЯХ } paradigm /*ДЕРЕВО*/ Сущ_3007 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+ЬЯ" } // ДЕРЕВО ДЕРЕВЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1%+ЬЕВ" } // ДЕРЕВА ДЕРЕВЬЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-1%+ЬЯМИ" } // ДЕРЕВОМ ДЕРЕВЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+ЬЯ" } // ДЕРЕВО ДЕРЕВЬЯ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+ЬЯМ" } // ДЕРЕВУ ДЕРЕВЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЬЯХ" } // ДЕРЕВЕ ДЕРЕВЬЯХ } paradigm /*УХО*/ Сущ_3008 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ШИ" } // УХО УШИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-2%+ШЕЙ" } // УХА УШЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-2%+ШАМИ" } // УХОМ УШАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-2%+ШИ" } // УХО УШИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-2%+ШАМ" } // УХУ УШАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-2%+ШАХ" } // УХЕ УШАХ } paradigm ВАРЕВО, Сущ_3009 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)\\@бО" { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ВАРЕВО ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // ВАРЕВА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+М" } // ВАРЕВОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ВАРЕВО ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+У" } // ВАРЕВУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ВАРЕВЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "%-1%+А" } :: flexer "pl" // ВАРЕВА ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } :: flexer "pl" // ВАРЕВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } :: flexer "pl" // ВАРЕВАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+А" } :: flexer "pl" // ВАРЕВА ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } :: flexer "pl" // ВАРЕВАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } :: flexer "pl" // ВАРЕВАХ } paradigm ИВАНОВО, Сущ_3010 : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ВО" { РОД:СР ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ CharCasing:FirstCapitalized ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ИВАНОВО ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // ИВАНОВА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+ЫМ" } // ИВАНОВЫМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ИВАНОВО ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+У" } // ИВАНОВУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ИВАНОВЕ } paradigm /*КУПЕ*/ Сущ_3012 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "" } // КУПЕ ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ ПАДЕЖ:(РОД) ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ ПАДЕЖ:ТВОР ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ ПАДЕЖ:ДАТ ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "" } :: flexer "pl" // КУПЕ } paradigm /*СЕРДЦЕ*/ Сущ_3013 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // СЕРДЦЕ СЕРДЦА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-2%+ЕЦ" } // СЕРДЦА СЕРДЕЦ ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // СЕРДЦЕМ СЕРДЦЕМ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // СЕРДЦЕ СЕРДЦА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // СЕРДЦУ СЕРДЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // СЕРДЦЕ СЕРДЦАХ } paradigm /*СТЕКЛО*/ Сущ_3014 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ЁКЛА" } // СТЕКЛО СТЁКЛА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-3%+ЁКЛ" } // СТЕКЛА СТЁКОЛ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-3%+ЁКЛАМИ" } // СТЕКЛОМ СТЁКЛАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-3%+ЁКЛА" } // СТЕКЛО СТЁКЛА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-3%+ЁКЛАМ" } // СТЕКЛУ СТЁКЛАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-3%+ЁКЛАХ" } // СТЕКЛЕ СТЁКЛАХ } paradigm /*ЯЙЦО*/ Сущ_3015 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // ЯЙЦО ЯЙЦА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-3%+ИЦ" } // ЯЙЦА ЯИЦ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-1%+АМИ" } // ЯЙЦОМ ЯЙЦАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // ЯЙЦО ЯЙЦА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ЯЙЦУ ЯЙЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ЯЙЦЕ ЯЙЦАХ } paradigm /*УТРО*/ Сущ_3016 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // УТРО ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // УТРА ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-1%+АМИ" } // УТРОМ УТРАМИ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // УТРО ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // УТРУ УТРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // УТРЕ УТРАХ } paradigm /*БЕЛЬЁ*/ Сущ_3017 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // БЕЛЬЁ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // БЕЛЬЯ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+М" } // БЕЛЬЁМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // БЕЛЬЁ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // БЕЛЬЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Ё" } // БЕЛЬЁ } paradigm /*КОЛЕНО*/ Сущ_3018 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // КОЛЕНО КОЛЕНИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1%+ЕЙ" } // КОЛЕНА КОЛЕНЕЙ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } // КОЛЕН ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-1%+ЯМИ" } // КОЛЕНОМ КОЛЕНЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // КОЛЕНО КОЛЕНИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+ЯМ" } // КОЛЕНУ КОЛЕНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // КОЛЕНЕ КОЛЕНЯХ } paradigm /*ПЛЕЧО*/ Сущ_3019 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ПЛЕЧО ПЛЕЧИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1%+ЕЙ" } // ПЛЕЧА ПЛЕЧЕЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-1%+АМИ" } // ПЛЕЧОМ ПЛЕЧАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // ПЛЕЧО ПЛЕЧИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ПЛЕЧУ ПЛЕЧАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ПЛЕЧЕ ПЛЕЧАХ } paradigm /*ГОРЕ*/ Сущ_3021 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ГОРЕ ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+Я" } // ГОРЯ ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%-1%+Е" } // ГОРЕМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ГОРЕ ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+Ю" } // ГОРЮ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ГОРЕ } paradigm /*ЧЕЛО*/ Сущ_3022 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // ЧЕЛО ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "%-1%+А" } // ЧЕЛА ПАДЕЖ:ТВОР ЧИСЛО:ЕД { "%+М" } // ЧЕЛОМ ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // ЧЕЛО ПАДЕЖ:ДАТ ЧИСЛО:ЕД { "%-1%+У" } // ЧЕЛУ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:ЕД { "%-1%+Е" } // ЧЕЛЕ } paradigm /*ПЛАТЬЕ*/ Сущ_3023 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Я" } // ПЛАТЬЕ ПЛАТЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%+В" } // ПЛАТЬЯ ПЛАТЬЕВ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // ПЛАТЬЕМ ПЛАТЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+Я" } // ПЛАТЬЕ ПЛАТЬЯ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Я" "%-1%+ЯМ" } // ПЛАТЬЯ ПЛАТЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "" "%-1%+ЯХ" } // ПЛАТЬЕ ПЛАТЬЯХ } paradigm /*ВЕКО*/ Сущ_3024 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // ВЕКО ВЕКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1" } // ВЕКА ВЕК ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // ВЕКОМ ВЕКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // ВЕКО ВЕКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ВЕКУ ВЕКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ВЕКЕ ВЕКАХ } paradigm /*ПЯТНО*/ Сущ_3025 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // ПЯТНО ПЯТНА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-2%+ЕН" } // ПЯТНА ПЯТЕН ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // ПЯТНОМ ПЯТНАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // ПЯТНО ПЯТНА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ПЯТНУ ПЯТНАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ПЯТНЕ ПЯТНАХ } paradigm /*НЕБО*/ Сущ_3027 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+ЕСА" } // НЕБО НЕБЕСА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1%+ЕС" } // НЕБА НЕБЕС ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+ЕСАМИ" } // НЕБОМ НЕБЕСАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+ЕСА" } // НЕБО НЕБЕСА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+ЕСАМ" } // НЕБУ НЕБЕСАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЕСАХ" } // НЕБЕ НЕБЕСАХ } paradigm /*КОПЬЁ*/ Сущ_3029 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Я" } // КОПЬЁ КОПЬЯ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+Я" "%-2%+ИЙ" } // КОПЬЯ КОПИЙ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+ЯМИ" } // КОПЬЁМ КОПЬЯМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+Я" } // КОПЬЁ КОПЬЯ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+Ю" "%-1%+ЯМ" } // КОПЬЮ КОПЬЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+ЯХ" } // КОПЬЕ КОПЬЯХ } paradigm /*ЖИВОТНОЕ*/ Сущ_3030 : СУЩЕСТВИТЕЛЬНОЕ { РОД:СР ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-2%+ЫЕ" } // ЖИВОТНОЕ ЖИВОТНЫЕ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+ГО" "%-2%+ЫХ" } // ЖИВОТНОГО ЖИВОТНЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%-2%+ЫМ" "%-2%+ЫМИ" } // ЖИВОТНЫМ ЖИВОТНЫМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-2%+ЫХ" } // ЖИВОТНОЕ ЖИВОТНЫХ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+МУ" "%-2%+ЫМ" } // ЖИВОТНОМУ ЖИВОТНЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+М" "%-2%+ЫХ" } // ЖИВОТНОМ ЖИВОТНЫХ } paradigm /*ОБЛАКО*/ Сущ_3031 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // ОБЛАКО ОБЛАКА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1%+ОВ" } // ОБЛАКА ОБЛАКОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // ОБЛАКОМ ОБЛАКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // ОБЛАКО ОБЛАКА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ОБЛАКУ ОБЛАКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ОБЛАКЕ ОБЛАКАХ } paradigm /*ОЗЕРО*/ Сущ_3033 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ЁРА" } // ОЗЕРО ОЗЁРА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-3%+ЁР" } // ОЗЕРА ОЗЁР ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-3%+ЁРАМИ" } // ОЗЕРОМ ОЗЁРАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-3%+ЁРА" } // ОЗЕРО ОЗЁРА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-3%+ЁРАМ" } // ОЗЕРУ ОЗЁРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-3%+ЁРАХ" } // ОЗЕРЕ ОЗЁРАХ } paradigm /*КОЛЕСО*/ Сущ_3034 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-3%+ЁСА" } // КОЛЕСО КОЛЁСА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-3%+ЁС" } // КОЛЕСА КОЛЁС ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОМ" "%-3%+ЁСАМИ" } // КОЛЕСОМ КОЛЁСАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-3%+ЁСА" } // КОЛЕСО КОЛЁСА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-3%+ЁСАМ" } // КОЛЕСУ КОЛЁСАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-3%+ЁСАХ" } // КОЛЕСЕ КОЛЁСАХ } paradigm /*КЛАДБИЩЕ*/ Сущ_3035 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // КЛАДБИЩЕ КЛАДБИЩА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-1" } // КЛАДБИЩА КЛАДБИЩ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ЕМ" "%-1%+АМИ" } // КЛАДБИЩЕМ КЛАДБИЩАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // КЛАДБИЩЕ КЛАДБИЩА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // КЛАДБИЩУ КЛАДБИЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // КЛАДБИЩЕ КЛАДБИЩАХ } paradigm /*ГНЕЗДО*/ Сущ_3036 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-4%+ЁЗДА" } // ГНЕЗДО ГНЁЗДА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-4%+ЁЗД" } // ГНЕЗДА ГНЁЗД ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-4%+ЁЗДАМИ" } // ГНЕЗДОМ ГНЁЗДАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-4%+ЁЗДА" } // ГНЕЗДО ГНЁЗДА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-4%+ЁЗДАМ" } // ГНЕЗДУ ГНЁЗДАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-4%+ЁЗДАХ" } // ГНЕЗДЕ ГНЁЗДАХ } paradigm /*МЕСТЕЧКО*/ Сущ_3037 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+И" } // МЕСТЕЧКО МЕСТЕЧКИ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-2%+ЕК" } // МЕСТЕЧКА МЕСТЕЧЕК ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // МЕСТЕЧКОМ МЕСТЕЧКАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+И" } // МЕСТЕЧКО МЕСТЕЧКИ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // МЕСТЕЧКУ МЕСТЕЧКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // МЕСТЕЧКЕ МЕСТЕЧКАХ } paradigm /*ЯДРО*/ Сущ_3038 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+А" } // ЯДРО ЯДРА ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+А" "%-2%+ЕР" } // ЯДРА ЯДЕР ПАДЕЖ:ТВОР ЧИСЛО { "%+М" "%-1%+АМИ" } // ЯДРОМ ЯДРАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%-1%+А" } // ЯДРО ЯДРА ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" } // ЯДРУ ЯДРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+Е" "%-1%+АХ" } // ЯДРЕ ЯДРАХ } paradigm /*САНИ*/ Сущ_4001 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // САНИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕЙ" } // САНЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+ЯМИ" } // САНЯМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } // САНИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+ЯМ" } // САНЯМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+ЯХ" } // САНЯХ } paradigm /*ЦВЕТЫ*/ Сущ_4003 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // --- ЦВЕТЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ОВ" } // --- ЦВЕТОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // --- ЦВЕТАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "%-1%+Ы" } // --- ЦВЕТЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // --- ЦВЕТАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // --- ЦВЕТАХ } paradigm /*НОЖНИЦЫ*/ Сущ_4004 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // НОЖНИЦЫ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } // НОЖНИЦ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // НОЖНИЦАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } // НОЖНИЦЫ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // НОЖНИЦАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // НОЖНИЦАХ } paradigm /*ОЧКИ*/ Сущ_4005 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // ОЧКИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ОВ" } // ОЧКОВ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // ОЧКАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } // ОЧКИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // ОЧКАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // ОЧКАХ } paradigm /*ВОРОТА*/ Сущ_4006 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // ВОРОТА ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1" } // ВОРОТ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%+МИ" } // ВОРОТАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } // ВОРОТА ПАДЕЖ:ДАТ ЧИСЛО:МН { "%+М" } // ВОРОТАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%+Х" } // ВОРОТАХ } paradigm /*ГРАФФИТИ*/ Сущ_4007 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } ПАДЕЖ:(РОД) ЧИСЛО:МН { "" } ПАДЕЖ:ТВОР ЧИСЛО:МН { "" } ПАДЕЖ:ВИН ЧИСЛО:МН { "" } ПАДЕЖ:ДАТ ЧИСЛО:МН { "" } ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "" } } paradigm /*МОЩИ*/ Сущ_4008 : СУЩЕСТВИТЕЛЬНОЕ { ПАДЕЖ:(ИМ) ЧИСЛО:МН { "" } // МОЩИ ПАДЕЖ:(РОД) ЧИСЛО:МН { "%-1%+ЕЙ" } // МОЩЕЙ ПАДЕЖ:ТВОР ЧИСЛО:МН { "%-1%+АМИ" } // МОЩАМИ ПАДЕЖ:ВИН ЧИСЛО:МН { "" } // МОЩИ ПАДЕЖ:ДАТ ЧИСЛО:МН { "%-1%+АМ" } // МОЩАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО:МН { "%-1%+АХ" } // МОЩАХ } // слова без парадигмы paradigm /**/ Сущ_4010 : СУЩЕСТВИТЕЛЬНОЕ { РОД:СР ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // } paradigm Полрюмки, Сущ_4011 : СУЩЕСТВИТЕЛЬНОЕ { ОДУШ:НЕОДУШ ПЕРЕЧИСЛИМОСТЬ:ДА РОД:СР ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } // полрюмки ПАДЕЖ:(РОД) ЧИСЛО:ЕД { "" } // полрюмки ПАДЕЖ:ВИН ЧИСЛО:ЕД { "" } // полрюмки } // ****************************************************** // Далее идут автоматические парадигмы для стеммера // ****************************************************** paradigm МЕХАНОШВИЛИ : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ШВИЛИ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { ""} } paradigm ЮЩЕНКО : СУЩЕСТВИТЕЛЬНОЕ for "(.+)НКО" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { ""} } paradigm ИВАНОВА /*(женская фамилия)*/ : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ОВА" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%-1%+Ы" } // ИВАНОВА ИВАНОВЫ ПАДЕЖ:(РОД) ЧИСЛО { "%-1%+ОЙ" "%-1%+ЫХ" } // ИВАНОВОЙ ИВАНОВЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%-1%+ОЙ" "%-1%+ЫМИ" } // ИВАНОВОЙ ИВАНОВЫМИ ПАДЕЖ:ВИН ЧИСЛО { "%-1%+У" "%-1%+ЫХ" } // ИВАНОВУ ИВАНОВЫХ ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+ОЙ" "%-1%+ЫМ" } // ИВАНОВОЙ ИВАНОВЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%-1%+ОЙ" "%-1%+ЫХ" } // ИВАНОВОЙ ИВАНОВЫХ } paradigm ПАПАНЕСКУ : СУЩЕСТВИТЕЛЬНОЕ for "(.+)СКУ" { РОД:ЖЕН ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО:ЕД { "" } } paradigm ИВАНОВ /*(мужская фамилия)*/ : СУЩЕСТВИТЕЛЬНОЕ for "(.+)ОВ" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:НЕТ ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // ИВАНОВ ИВАНОВЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ЫХ" } // ИВАНОВА ИВАНОВЫХ ПАДЕЖ:ТВОР ЧИСЛО { "%+ЫМ" "%+ЫМИ" } // ИВАНОВЫМ ИВАНОВЫМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ЫХ" } // ИВАНОВА ИВАНОВЫХ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+ЫМ" } // ИВАНОВУ ИВАНОВЫМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+ЫХ" } // ИВАНОВЕ ИВАНОВЫХ } // Последняя в списке - парадигма для самого частого склонения paradigm ФАЙЛ : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[БВДЗЛМНПРСТФЦ]" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:НЕОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // ФАЙЛ ФАЙЛЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ФАЙЛА ФАЙЛОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ФАЙЛОМ ФАЙЛАМИ ПАДЕЖ:ВИН ЧИСЛО { "" "%+Ы" } // ФАЙЛ ФАЙЛЫ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ФАЙЛУ ФАЙЛАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ФАЙЛЕ ФАЙЛАХ } // Вариант самого частого склонения - для одушевленных существительных paradigm ТАНЦОР : СУЩЕСТВИТЕЛЬНОЕ for "(.+)[БВДЗЛМНПРСТФЦ]" { РОД:МУЖ ПЕРЕЧИСЛИМОСТЬ:ДА ОДУШ:ОДУШ ПАДЕЖ:(ИМ) ЧИСЛО { "" "%+Ы" } // ОПЕРАТОР ОПЕРАТОРЫ ПАДЕЖ:(РОД) ЧИСЛО { "%+А" "%+ОВ" } // ОПЕРАТОРА ОПЕРАТОРОВ ПАДЕЖ:ТВОР ЧИСЛО { "%+ОМ" "%+АМИ" } // ОПЕРАТОРОМ ОПЕРАТОРАМИ ПАДЕЖ:ВИН ЧИСЛО { "%+А" "%+ОВ" } // ОПЕРАТОРА ОПЕРАТОРОВ ПАДЕЖ:ДАТ ЧИСЛО { "%+У" "%+АМ" } // ОПЕРАТОРУ ОПЕРАТОРАМ ПАДЕЖ:(ПРЕДЛ) ЧИСЛО { "%+Е" "%+АХ" } // ОПЕРАТОРЕ ОПЕРАТОРАХ } }
КЛАДБИЩУ КЛАДБИЩАМ
ПАДЕЖ:ДАТ ЧИСЛО { "%-1%+У" "%-1%+АМ" }
5,384,210
[ 1, 4625, 348, 7953, 560, 30, 225, 225, 145, 253, 145, 254, 145, 243, 145, 247, 145, 244, 145, 251, 145, 107, 145, 101, 282, 225, 145, 253, 145, 254, 145, 243, 145, 247, 145, 244, 145, 251, 145, 107, 145, 243, 145, 255, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 225, 145, 258, 145, 243, 145, 247, 145, 248, 145, 249, 30, 145, 247, 145, 243, 145, 100, 377, 225, 145, 105, 145, 251, 145, 99, 145, 254, 145, 257, 288, 2213, 17, 21, 9, 15, 145, 101, 6, 225, 2213, 17, 21, 9, 15, 145, 243, 145, 255, 6, 225, 289, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x35c068B00Bd9204Ca47970272D18E9B8775C5b63/sources/src/MultiOwnable.sol
@notice Update the royaltyOwner @dev Can also be used to revoke this power by setting to 0x0
function setRoyaltyOwner(address _royaltyOwner) external onlyRoyaltyOwner { royaltyOwner = _royaltyOwner; }
3,715,487
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 2315, 326, 721, 93, 15006, 5541, 632, 5206, 4480, 2546, 506, 1399, 358, 18007, 333, 7212, 635, 3637, 358, 374, 92, 20, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 444, 54, 13372, 15006, 5541, 12, 2867, 389, 3800, 15006, 5541, 13, 3903, 1338, 54, 13372, 15006, 5541, 288, 203, 3639, 721, 93, 15006, 5541, 273, 389, 3800, 15006, 5541, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0xD00Fd4f3b37ED6852c7eA2AfFc1100C12eFe3706/sources/erc20.sol
ERC 20 token */ metadata
contract erc20 is Token, SafeMath { string public name; string public symbol; uint256 public decimals; uint256 public totalSupply; function erc20(string _name, string _symbol, uint256 _totalSupply, uint256 _decimals){ name = _name; symbol = _symbol; decimals = _decimals; totalSupply = formatDecimals(_totalSupply); balances[msg.sender] = totalSupply; } function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0 && balances[_to] +_value > balances[_to] ) { balances[msg.sender] = SafeMath.safeSub(balances[msg.sender], _value); balances[_to] = SafeMath.safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; return false; } } function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0 && balances[_to] +_value > balances[_to] ) { balances[msg.sender] = SafeMath.safeSub(balances[msg.sender], _value); balances[_to] = SafeMath.safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; return false; } } } else { function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0 && balances[_to] +_value > balances[_to]) { balances[_from] = SafeMath.safeSub(balances[_from], _value); balances[_to] = SafeMath.safeAdd(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.safeSub(allowed[_from][msg.sender], _value); return true; return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0 && balances[_to] +_value > balances[_to]) { balances[_from] = SafeMath.safeSub(balances[_from], _value); balances[_to] = SafeMath.safeAdd(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.safeSub(allowed[_from][msg.sender], _value); return true; return false; } } } else { function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; }
9,388,100
[ 1, 4625, 348, 7953, 560, 30, 282, 4232, 39, 4200, 1147, 1195, 1982, 2, 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10477, 288, 203, 203, 565, 533, 225, 1071, 225, 508, 31, 203, 565, 533, 225, 1071, 225, 3273, 31, 203, 565, 2254, 5034, 1071, 225, 15105, 31, 203, 565, 2254, 5034, 1071, 2078, 3088, 1283, 31, 203, 377, 203, 565, 445, 6445, 71, 3462, 12, 1080, 389, 529, 16, 533, 389, 7175, 16, 2254, 5034, 389, 4963, 3088, 1283, 16, 2254, 5034, 389, 31734, 15329, 203, 3639, 508, 273, 389, 529, 31, 203, 3639, 3273, 273, 389, 7175, 31, 203, 3639, 15105, 273, 389, 31734, 31, 203, 3639, 2078, 3088, 1283, 273, 740, 31809, 24899, 4963, 3088, 1283, 1769, 203, 3639, 324, 26488, 63, 3576, 18, 15330, 65, 273, 2078, 3088, 1283, 31, 203, 565, 289, 203, 377, 203, 377, 203, 565, 445, 740, 31809, 12, 11890, 5034, 389, 1132, 13, 2713, 1135, 261, 11890, 5034, 262, 288, 203, 3639, 327, 389, 1132, 380, 1728, 2826, 15105, 31, 203, 565, 289, 203, 203, 377, 203, 565, 445, 7412, 12, 2867, 389, 869, 16, 2254, 5034, 389, 1132, 13, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 309, 261, 70, 26488, 63, 3576, 18, 15330, 65, 1545, 389, 1132, 597, 389, 1132, 405, 374, 597, 324, 26488, 63, 67, 869, 65, 397, 67, 1132, 405, 324, 26488, 63, 67, 869, 65, 262, 288, 203, 5411, 324, 26488, 63, 3576, 18, 15330, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 70, 26488, 63, 3576, 18, 15330, 6487, 389, 1132, 1769, 8227, 203, 5411, 324, 26488, 63, 67, 869, 65, 273, 14060, 10477, 18, 4626, 986, 12, 70, 26488, 63, 67, 869, 6487, 389, 1132, 1769, 7010, 5411, 12279, 12, 3576, 18, 15330, 16, 389, 869, 16, 389, 1132, 1769, 203, 5411, 327, 638, 31, 203, 5411, 327, 629, 31, 203, 3639, 289, 203, 565, 289, 203, 7010, 565, 445, 7412, 12, 2867, 389, 869, 16, 2254, 5034, 389, 1132, 13, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 309, 261, 70, 26488, 63, 3576, 18, 15330, 65, 1545, 389, 1132, 597, 389, 1132, 405, 374, 597, 324, 26488, 63, 67, 869, 65, 397, 67, 1132, 405, 324, 26488, 63, 67, 869, 65, 262, 288, 203, 5411, 324, 26488, 63, 3576, 18, 15330, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 70, 26488, 63, 3576, 18, 15330, 6487, 389, 1132, 1769, 8227, 203, 5411, 324, 26488, 63, 67, 869, 65, 273, 14060, 10477, 18, 4626, 986, 12, 70, 26488, 63, 67, 869, 6487, 389, 1132, 1769, 7010, 5411, 12279, 12, 3576, 18, 15330, 16, 389, 869, 16, 389, 1132, 1769, 203, 5411, 327, 638, 31, 203, 5411, 327, 629, 31, 203, 3639, 289, 203, 565, 289, 203, 7010, 3639, 289, 469, 288, 203, 565, 445, 7412, 1265, 12, 2867, 389, 2080, 16, 1758, 389, 869, 16, 2254, 5034, 389, 1132, 13, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 309, 261, 70, 26488, 63, 67, 2080, 65, 1545, 389, 1132, 597, 2935, 63, 67, 2080, 6362, 3576, 18, 15330, 65, 1545, 389, 1132, 597, 389, 1132, 405, 374, 597, 324, 26488, 63, 67, 869, 65, 397, 67, 1132, 405, 324, 26488, 63, 67, 869, 5717, 288, 203, 5411, 324, 26488, 63, 67, 2080, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 70, 26488, 63, 67, 2080, 6487, 389, 1132, 1769, 21821, 203, 5411, 324, 26488, 63, 67, 869, 65, 273, 14060, 10477, 18, 4626, 986, 12, 70, 26488, 63, 67, 869, 6487, 389, 1132, 1769, 11794, 203, 5411, 2935, 63, 67, 2080, 6362, 3576, 18, 15330, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 8151, 63, 67, 2080, 6362, 3576, 18, 15330, 6487, 389, 1132, 1769, 203, 203, 5411, 327, 638, 31, 203, 5411, 327, 629, 31, 203, 3639, 289, 203, 565, 289, 203, 7010, 565, 445, 7412, 1265, 12, 2867, 389, 2080, 16, 1758, 389, 869, 16, 2254, 5034, 389, 1132, 13, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 309, 261, 70, 26488, 63, 67, 2080, 65, 1545, 389, 1132, 597, 2935, 63, 67, 2080, 6362, 3576, 18, 15330, 65, 1545, 389, 1132, 597, 389, 1132, 405, 374, 597, 324, 26488, 63, 67, 869, 65, 397, 67, 1132, 405, 324, 26488, 63, 67, 869, 5717, 288, 203, 5411, 324, 26488, 63, 67, 2080, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 70, 26488, 63, 67, 2080, 6487, 389, 1132, 1769, 21821, 203, 5411, 324, 26488, 63, 67, 869, 65, 273, 14060, 10477, 18, 4626, 986, 12, 70, 26488, 63, 67, 869, 6487, 389, 1132, 1769, 11794, 203, 5411, 2935, 63, 67, 2080, 6362, 3576, 18, 15330, 65, 273, 14060, 10477, 18, 4626, 1676, 12, 8151, 63, 67, 2080, 6362, 3576, 18, 15330, 6487, 389, 1132, 1769, 203, 203, 5411, 327, 638, 31, 203, 5411, 327, 629, 31, 203, 3639, 289, 203, 565, 289, 203, 7010, 3639, 289, 469, 288, 203, 565, 445, 11013, 951, 12, 2867, 389, 8443, 13, 5381, 1135, 261, 11890, 5034, 11013, 13, 288, 203, 3639, 327, 324, 26488, 63, 67, 8443, 15533, 203, 565, 289, 203, 7010, 565, 445, 6617, 537, 12, 2867, 389, 87, 1302, 264, 16, 2254, 5034, 389, 1132, 13, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 2935, 63, 3576, 18, 15330, 6362, 67, 87, 1302, 264, 65, 273, 389, 1132, 31, 203, 3639, 1716, 685, 1125, 12, 3576, 18, 15330, 16, 389, 87, 1302, 264, 16, 389, 1132, 1769, 203, 3639, 327, 638, 31, 203, 565, 289, 203, 7010, 565, 445, 1699, 1359, 12, 2867, 389, 8443, 16, 1758, 389, 87, 1302, 264, 13, 5381, 1135, 261, 11890, 5034, 4463, 13, 288, 203, 3639, 327, 2935, 63, 67, 8443, 6362, 67, 87, 1302, 264, 15533, 203, 565, 289, 203, 7010, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 324, 26488, 31, 203, 565, 2874, 261, 2867, 516, 2874, 261, 2867, 516, 2254, 5034, 3719, 2935, 31, 203, 97, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]