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
./full_match/4/0xe153650f20B339D35e45bc40A0ca18D4A28F3d97/sources/contracts/Arena.sol
Check Monster killTime
function calcKillTime(uint256 _tokenID) public view returns (uint256) { Stats memory stats = rock.tokenStats(_tokenID); Enemy memory enemyStats = getCurrentTarget(_tokenID); uint256 emaxHit = (((enemyStats.strength + 11) * 64 + 320) / 640); uint256 eattackRoll = (enemyStats.attack + 11) * 64; uint256 edefenseRoll = (stats.defense + 9) * 64; uint256 eKdps = 0; if(eattackRoll > edefenseRoll) { eKdps = eattackRoll * 1000 / (2 * (edefenseRoll + 1)); } uint256 ekillTime = (stats.health * 1000) / eKdps + 1; uint256 attackRoll = (stats.attack + 11) * 64; uint256 defenseRoll = (enemyStats.defense + 9) * 64; uint256 Kdps = 0; if(attackRoll > defenseRoll) { Kdps = attackRoll * 1000 / (2 * (defenseRoll + 1)); } uint256 killTime = (enemyStats.health * 1000) / Kdps + 1; if(ekillTime < killTime){ return 999999999999999; } return killTime; }
655,437
[ 1, 1564, 9041, 8190, 8673, 950, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7029, 19045, 950, 12, 11890, 5034, 389, 2316, 734, 13, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 11486, 3778, 3177, 273, 23486, 18, 2316, 4195, 24899, 2316, 734, 1769, 203, 3639, 1374, 351, 93, 3778, 570, 351, 93, 4195, 273, 5175, 2326, 24899, 2316, 734, 1769, 203, 3639, 2254, 5034, 801, 651, 13616, 273, 261, 12443, 275, 351, 93, 4195, 18, 334, 13038, 397, 4648, 13, 380, 5178, 397, 890, 3462, 13, 342, 5178, 20, 1769, 203, 3639, 2254, 5034, 425, 4558, 484, 24194, 273, 261, 275, 351, 93, 4195, 18, 4558, 484, 397, 4648, 13, 380, 5178, 31, 203, 3639, 2254, 5034, 425, 536, 3558, 24194, 273, 261, 5296, 18, 536, 3558, 397, 2468, 13, 380, 5178, 31, 203, 3639, 2254, 5034, 425, 47, 72, 1121, 273, 374, 31, 203, 3639, 309, 12, 73, 4558, 484, 24194, 405, 425, 536, 3558, 24194, 13, 288, 203, 5411, 425, 47, 72, 1121, 273, 425, 4558, 484, 24194, 380, 4336, 342, 261, 22, 380, 261, 73, 536, 3558, 24194, 397, 404, 10019, 203, 3639, 289, 203, 3639, 2254, 5034, 425, 16418, 950, 273, 261, 5296, 18, 13267, 380, 4336, 13, 342, 425, 47, 72, 1121, 397, 404, 31, 203, 203, 3639, 2254, 5034, 13843, 24194, 273, 261, 5296, 18, 4558, 484, 397, 4648, 13, 380, 5178, 31, 203, 3639, 2254, 5034, 1652, 3558, 24194, 273, 261, 275, 351, 93, 4195, 18, 536, 3558, 397, 2468, 13, 380, 5178, 31, 203, 3639, 2254, 5034, 1475, 72, 1121, 273, 374, 31, 203, 3639, 2 ]
./full_match/1/0x184e48FA8B332D3D3FB08eDa535Fd7591e340Bb2/sources/contracts/NFT/NFTByMetadrop.sol
* ____________________________________________________________________________________________________________________ -->GETTER @dev (function) metadropCustom Returns if this contract is a custom NFT (true) or is a standard metadrop ERC721M (false) --------------------------------------------------------------------------------------------------------------------- @return isMetadropCustom_ The total minted supply of this collection --------------------------------------------------------------------------------------------------------------------- _____________________________________________________________________________________________________________________/
function metadropCustom() external pure returns (bool isMetadropCustom_) { return (false); }
4,935,065
[ 1, 21157, 21157, 21157, 21157, 21157, 21157, 21157, 7198, 28524, 4766, 2398, 15431, 7113, 11976, 225, 261, 915, 13, 312, 1167, 1764, 3802, 225, 2860, 309, 333, 6835, 353, 279, 1679, 423, 4464, 261, 3767, 13, 578, 353, 279, 4529, 312, 1167, 1764, 4766, 4232, 39, 27, 5340, 49, 261, 5743, 13, 8879, 9634, 553, 327, 15707, 1167, 1764, 3802, 67, 282, 1021, 2078, 312, 474, 329, 14467, 434, 333, 1849, 8879, 9634, 553, 389, 21157, 21157, 21157, 21157, 21157, 21157, 21157, 7198, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 312, 1167, 1764, 3802, 1435, 3903, 16618, 1135, 261, 6430, 15707, 1167, 1764, 3802, 67, 13, 288, 203, 565, 327, 261, 5743, 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 ]
./partial_match/3/0x5C90d5EF81617C0928c28DB999Ab5eF8361bF383/sources/Bizzcoin.sol
* Token information/ Token distribution Total token supply: 1M Public tokens: 67% Founders: 10% Advisors: 1% Team: 2% Partners, Bounties Reserves: 20% (belongs to token owner)/ Token unlock datetime: 1. Founder, Advisor and Team Thursday, 31 December 2020 12:00:00 GMT 2. All other Users Thursday, 31 December 2020 12:00:00 GMT/
constructor() public { totalSupply_ = INITIAL_SUPPLY; }
5,163,438
[ 1, 1345, 1779, 19, 3155, 7006, 10710, 1147, 14467, 30, 404, 49, 7224, 2430, 30, 21017, 9, 10750, 414, 30, 1728, 9, 4052, 3516, 1383, 30, 404, 9, 10434, 30, 576, 9, 6393, 9646, 16, 605, 592, 606, 1124, 264, 3324, 30, 4200, 9, 261, 13285, 7260, 358, 1147, 3410, 13176, 3155, 7186, 3314, 30, 404, 18, 478, 465, 765, 16, 4052, 10227, 471, 10434, 935, 25152, 2881, 16, 8231, 1505, 311, 81, 744, 26599, 20, 2593, 30, 713, 30, 713, 21706, 576, 18, 4826, 1308, 12109, 935, 25152, 2881, 16, 8231, 1505, 311, 81, 744, 26599, 20, 2593, 30, 713, 30, 713, 21706, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1435, 1071, 288, 203, 3639, 2078, 3088, 1283, 67, 273, 28226, 67, 13272, 23893, 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 ]
./full_match/1/0x9259746Be26f8Bd66D12D13671Dddc3561AD970d/sources/contracts/Solid.sol
Extract price from the first 80 bits Extract billingPeriod from the following 48 bits Extract timestamp from the next 48 bits Extract discount from the last 16 bits
function _getPlan(address _vendor, uint256 _planId) internal view returns(uint256, uint256, uint256, uint256) { uint256 _planUint = plan[_getPlanKey(_vendor, _planId)]; uint256 price = uint256(uint80(_planUint)); uint256 billingPeriod = uint256(uint48(_planUint>>128)); uint256 timestamp = uint256(uint48(_planUint>>176)); uint256 discount = uint256(uint16(_planUint>>224)); return (price, billingPeriod, timestamp, discount); }
2,972,123
[ 1, 4976, 6205, 628, 326, 1122, 8958, 4125, 8152, 10709, 5027, 628, 326, 3751, 9934, 4125, 8152, 2858, 628, 326, 1024, 9934, 4125, 8152, 12137, 628, 326, 1142, 2872, 4125, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 588, 5365, 12, 2867, 389, 10645, 16, 2254, 5034, 389, 7088, 548, 13, 2713, 1476, 1135, 12, 11890, 5034, 16, 2254, 5034, 16, 2254, 5034, 16, 2254, 5034, 13, 288, 203, 565, 2254, 5034, 389, 7088, 5487, 273, 4995, 63, 67, 588, 5365, 653, 24899, 10645, 16, 389, 7088, 548, 13, 15533, 203, 565, 2254, 5034, 6205, 273, 2254, 5034, 12, 11890, 3672, 24899, 7088, 5487, 10019, 203, 565, 2254, 5034, 10709, 5027, 273, 2254, 5034, 12, 11890, 8875, 24899, 7088, 5487, 9778, 10392, 10019, 203, 565, 2254, 5034, 2858, 273, 2254, 5034, 12, 11890, 8875, 24899, 7088, 5487, 9778, 28493, 10019, 203, 565, 2254, 5034, 12137, 273, 2254, 5034, 12, 11890, 2313, 24899, 7088, 5487, 9778, 23622, 10019, 203, 377, 203, 565, 327, 261, 8694, 16, 10709, 5027, 16, 2858, 16, 12137, 1769, 203, 225, 289, 203, 21281, 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 ]
// File: @openzeppelin/contracts/math/Math.sol pragma solidity ^0.6.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); } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.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: contracts/interfaces/IVat.sol pragma solidity ^0.6.10; /// @dev Interface to interact with the vat contract from MakerDAO /// Taken from https://github.com/makerdao/developerguides/blob/master/devtools/working-with-dsproxy/working-with-dsproxy.md interface IVat { // function can(address, address) external view returns (uint); function hope(address) external; function nope(address) external; function live() external view returns (uint); function ilks(bytes32) external view returns (uint, uint, uint, uint, uint); function urns(bytes32, address) external view returns (uint, uint); function gem(bytes32, address) external view returns (uint); // function dai(address) external view returns (uint); function frob(bytes32, address, address, address, int, int) external; function fork(bytes32, address, address, int, int) external; function move(address, address, uint) external; function flux(bytes32, address, address, uint) external; } // File: contracts/interfaces/IDaiJoin.sol pragma solidity ^0.6.10; /// @dev Interface to interact with the `Join.sol` contract from MakerDAO using Dai interface IDaiJoin { function rely(address usr) external; function deny(address usr) external; function cage() external; function join(address usr, uint WAD) external; function exit(address usr, uint WAD) external; } // File: contracts/interfaces/IGemJoin.sol pragma solidity ^0.6.10; /// @dev Interface to interact with the `Join.sol` contract from MakerDAO using ERC20 interface IGemJoin { function rely(address usr) external; function deny(address usr) external; function cage() external; function join(address usr, uint WAD) external; function exit(address usr, uint WAD) external; } // File: contracts/interfaces/IPot.sol pragma solidity ^0.6.10; /// @dev interface for the pot contract from MakerDao /// Taken from https://github.com/makerdao/developerguides/blob/master/dai/dsr-integration-guide/dsr.sol interface IPot { function chi() external view returns (uint256); function pie(address) external view returns (uint256); // Not a function, but a public variable. function rho() external returns (uint256); function drip() external returns (uint256); function join(uint256) external; function exit(uint256) external; } // File: contracts/interfaces/IChai.sol pragma solidity ^0.6.10; /// @dev interface for the chai contract /// Taken from https://github.com/makerdao/developerguides/blob/master/dai/dsr-integration-guide/dsr.sol interface IChai { function balanceOf(address account) external view returns (uint256); function transfer(address dst, uint wad) external returns (bool); function move(address src, address dst, uint wad) external returns (bool); function transferFrom(address src, address dst, uint wad) external returns (bool); function approve(address usr, uint wad) external returns (bool); function dai(address usr) external returns (uint wad); function join(address dst, uint wad) external; function exit(address src, uint wad) external; function draw(address src, uint wad) external; function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external; function nonces(address account) external view returns (uint256); } // File: contracts/interfaces/IWeth.sol pragma solidity ^0.6.10; interface IWeth { function deposit() external payable; function withdraw(uint) external; function approve(address, uint) external returns (bool) ; function transfer(address, uint) external returns (bool); function transferFrom(address, address, uint) external returns (bool); } // File: contracts/interfaces/ITreasury.sol pragma solidity ^0.6.10; interface ITreasury { function debt() external view returns(uint256); function savings() external view returns(uint256); function pushDai(address user, uint256 dai) external; function pullDai(address user, uint256 dai) external; function pushChai(address user, uint256 chai) external; function pullChai(address user, uint256 chai) external; function pushWeth(address to, uint256 weth) external; function pullWeth(address to, uint256 weth) external; function shutdown() external; function live() external view returns(bool); function vat() external view returns (IVat); function weth() external view returns (IWeth); function dai() external view returns (IERC20); function daiJoin() external view returns (IDaiJoin); function wethJoin() external view returns (IGemJoin); function pot() external view returns (IPot); function chai() external view returns (IChai); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.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. */ 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. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 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; } } // File: contracts/helpers/DecimalMath.sol pragma solidity ^0.6.10; /// @dev Implements simple fixed point math mul and div operations for 27 decimals. contract DecimalMath { using SafeMath for uint256; uint256 constant public UNIT = 1e27; /// @dev Multiplies x and y, assuming they are both fixed point with 27 digits. function muld(uint256 x, uint256 y) internal pure returns (uint256) { return x.mul(y).div(UNIT); } /// @dev Divides x between y, assuming they are both fixed point with 27 digits. function divd(uint256 x, uint256 y) internal pure returns (uint256) { return x.mul(UNIT).div(y); } /// @dev Multiplies x and y, rounding up to the closest representable number. /// Assumes x and y are both fixed point with `decimals` digits. function muldrup(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x.mul(y); return z.mod(UNIT) == 0 ? z.div(UNIT) : z.div(UNIT).add(1); } /// @dev Divides x between y, rounding up to the closest representable number. /// Assumes x and y are both fixed point with `decimals` digits. function divdrup(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x.mul(UNIT); return z.mod(y) == 0 ? z.div(y) : z.div(y).add(1); } } // File: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.6.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; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.6.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. */ 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; } } // File: contracts/helpers/Orchestrated.sol pragma solidity ^0.6.10; /** * @dev Orchestrated allows to define static access control between multiple contracts. * This contract would be used as a parent contract of any contract that needs to restrict access to some methods, * which would be marked with the `onlyOrchestrated` modifier. * During deployment, the contract deployer (`owner`) can register any contracts that have privileged access by calling `orchestrate`. * Once deployment is completed, `owner` should call `transferOwnership(address(0))` to avoid any more contracts ever gaining privileged access. */ contract Orchestrated is Ownable { event GrantedAccess(address access, bytes4 signature); mapping(address => mapping (bytes4 => bool)) public orchestration; constructor () public Ownable() {} /// @dev Restrict usage to authorized users /// @param err The error to display if the validation fails modifier onlyOrchestrated(string memory err) { require(orchestration[msg.sender][msg.sig], err); _; } /// @dev Add orchestration /// @param user Address of user or contract having access to this contract. /// @param signature bytes4 signature of the function we are giving orchestrated access to. /// It seems to me a bad idea to give access to humans, and would use this only for predictable smart contracts. function orchestrate(address user, bytes4 signature) public onlyOwner { orchestration[user][signature] = true; emit GrantedAccess(user, signature); } /// @dev Adds orchestration for the provided function signatures function batchOrchestrate(address user, bytes4[] memory signatures) public onlyOwner { for (uint256 i = 0; i < signatures.length; i++) { orchestrate(user, signatures[i]); } } } // File: contracts/Treasury.sol pragma solidity ^0.6.10; /** * @dev Treasury manages asset transfers between all contracts in the Yield Protocol and other external contracts such as Chai and MakerDAO. * Treasury doesn't have any transactional functions available for regular users. * All transactional methods are to be available only for orchestrated contracts. * Treasury will ensure that all Weth is always stored as collateral in MAkerDAO. * Treasury will use all Dai to pay off system debt in MakerDAO first, and if there is no system debt the surplus Dai will be wrapped as Chai. * Treasury will use any Chai it holds when requested to provide Dai. If there isn't enough Chai, it will borrow Dai from MakerDAO. */ contract Treasury is ITreasury, Orchestrated(), DecimalMath { bytes32 constant WETH = "ETH-A"; IVat public override vat; IWeth public override weth; IERC20 public override dai; IDaiJoin public override daiJoin; IGemJoin public override wethJoin; IPot public override pot; IChai public override chai; address public unwind; bool public override live = true; /// @dev As part of the constructor: /// Treasury allows the `chai` and `wethJoin` contracts to take as many tokens as wanted. /// Treasury approves the `daiJoin` and `wethJoin` contracts to move assets in MakerDAO. constructor ( address vat_, address weth_, address dai_, address wethJoin_, address daiJoin_, address pot_, address chai_ ) public { // These could be hardcoded for mainnet deployment. dai = IERC20(dai_); chai = IChai(chai_); pot = IPot(pot_); weth = IWeth(weth_); daiJoin = IDaiJoin(daiJoin_); wethJoin = IGemJoin(wethJoin_); vat = IVat(vat_); vat.hope(wethJoin_); vat.hope(daiJoin_); dai.approve(address(chai), uint256(-1)); // Chai will never cheat on us dai.approve(address(daiJoin), uint256(-1)); // DaiJoin will never cheat on us weth.approve(address(wethJoin), uint256(-1)); // WethJoin will never cheat on us } /// @dev Only while the Treasury is not unwinding due to a MakerDAO shutdown. modifier onlyLive() { require(live == true, "Treasury: Not available during unwind"); _; } /// @dev Safe casting from uint256 to int256 function toInt(uint256 x) internal pure returns(int256) { require( x <= uint256(type(int256).max), "Treasury: Cast overflow" ); return int256(x); } /// @dev Disables pulling and pushing. Can only be called if MakerDAO shuts down. function shutdown() public override { require( vat.live() == 0, "Treasury: MakerDAO is live" ); live = false; } /// @dev Returns the Treasury debt towards MakerDAO, in Dai. /// We have borrowed (rate * art) /// Borrowing limit (rate * art) <= (ink * spot) function debt() public view override returns(uint256) { (, uint256 rate,,,) = vat.ilks(WETH); // Retrieve the MakerDAO stability fee for Weth (, uint256 art) = vat.urns(WETH, address(this)); // Retrieve the Treasury debt in MakerDAO return muld(art, rate); } /// @dev Returns the amount of chai in this contract, converted to Dai. function savings() public view override returns(uint256){ return muld(chai.balanceOf(address(this)), pot.chi()); } /// @dev Takes dai from user and pays as much system debt as possible, saving the rest as chai. /// User needs to have approved Treasury to take the Dai. /// This function can only be called by other Yield contracts, not users directly. /// @param from Wallet to take Dai from. /// @param daiAmount Dai quantity to take. function pushDai(address from, uint256 daiAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { require(dai.transferFrom(from, address(this), daiAmount)); // Take dai from user to Treasury // Due to the DSR being mostly lower than the SF, it is better for us to // immediately pay back as much as possible from the current debt to // minimize our future stability fee liabilities. If we didn't do this, // the treasury would simultaneously owe DAI (and need to pay the SF) and // hold Chai, which is inefficient. uint256 toRepay = Math.min(debt(), daiAmount); if (toRepay > 0) { daiJoin.join(address(this), toRepay); // Remove debt from vault using frob (, uint256 rate,,,) = vat.ilks(WETH); // Retrieve the MakerDAO stability fee vat.frob( WETH, address(this), address(this), address(this), 0, // Weth collateral to add -toInt(divd(toRepay, rate)) // Dai debt to remove ); } uint256 toSave = daiAmount - toRepay; // toRepay can't be greater than dai if (toSave > 0) { chai.join(address(this), toSave); // Give dai to Chai, take chai back } } /// @dev Takes Chai from user and pays as much system debt as possible, saving the rest as chai. /// User needs to have approved Treasury to take the Chai. /// This function can only be called by other Yield contracts, not users directly. /// @param from Wallet to take Chai from. /// @param chaiAmount Chai quantity to take. function pushChai(address from, uint256 chaiAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { require(chai.transferFrom(from, address(this), chaiAmount)); uint256 daiAmount = chai.dai(address(this)); uint256 toRepay = Math.min(debt(), daiAmount); if (toRepay > 0) { chai.draw(address(this), toRepay); // Grab dai from Chai, converted from chai daiJoin.join(address(this), toRepay); // Remove debt from vault using frob (, uint256 rate,,,) = vat.ilks(WETH); // Retrieve the MakerDAO stability fee vat.frob( WETH, address(this), address(this), address(this), 0, // Weth collateral to add -toInt(divd(toRepay, rate)) // Dai debt to remove ); } // Anything that is left from repaying, is chai savings } /// @dev Takes Weth collateral from user into the Treasury Maker vault /// User needs to have approved Treasury to take the Weth. /// This function can only be called by other Yield contracts, not users directly. /// @param from Wallet to take Weth from. /// @param wethAmount Weth quantity to take. function pushWeth(address from, uint256 wethAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { require(weth.transferFrom(from, address(this), wethAmount)); wethJoin.join(address(this), wethAmount); // GemJoin reverts if anything goes wrong. // All added collateral should be locked into the vault using frob vat.frob( WETH, address(this), address(this), address(this), toInt(wethAmount), // Collateral to add - WAD 0 // Normalized Dai to receive - WAD ); } /// @dev Returns dai using chai savings as much as possible, and borrowing the rest. /// This function can only be called by other Yield contracts, not users directly. /// @param to Wallet to send Dai to. /// @param daiAmount Dai quantity to send. function pullDai(address to, uint256 daiAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { uint256 toRelease = Math.min(savings(), daiAmount); if (toRelease > 0) { chai.draw(address(this), toRelease); // Grab dai from Chai, converted from chai } uint256 toBorrow = daiAmount - toRelease; // toRelease can't be greater than dai if (toBorrow > 0) { (, uint256 rate,,,) = vat.ilks(WETH); // Retrieve the MakerDAO stability fee // Increase the dai debt by the dai to receive divided by the stability fee // `frob` deals with "normalized debt", instead of DAI. // "normalized debt" is used to account for the fact that debt grows // by the stability fee. The stability fee is accumulated by the "rate" // variable, so if you store Dai balances in "normalized dai" you can // deal with the stability fee accumulation with just a multiplication. // This means that the `frob` call needs to be divided by the `rate` // while the `GemJoin.exit` call can be done with the raw `toBorrow` // number. vat.frob( WETH, address(this), address(this), address(this), 0, toInt(divdrup(toBorrow, rate)) // We need to round up, otherwise we won't exit toBorrow ); daiJoin.exit(address(this), toBorrow); // `daiJoin` reverts on failures } require(dai.transfer(to, daiAmount)); // Give dai to user } /// @dev Returns chai using chai savings as much as possible, and borrowing the rest. /// This function can only be called by other Yield contracts, not users directly. /// @param to Wallet to send Chai to. /// @param chaiAmount Chai quantity to send. function pullChai(address to, uint256 chaiAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { uint256 chi = pot.chi(); uint256 daiAmount = muldrup(chaiAmount, chi); // dai = price * chai, we round up, otherwise we won't borrow enough dai uint256 toRelease = Math.min(savings(), daiAmount); // As much chai as the Treasury has, can be used, we borrow dai and convert it to chai for the rest uint256 toBorrow = daiAmount - toRelease; // toRelease can't be greater than daiAmount if (toBorrow > 0) { (, uint256 rate,,,) = vat.ilks(WETH); // Retrieve the MakerDAO stability fee // Increase the dai debt by the dai to receive divided by the stability fee vat.frob( WETH, address(this), address(this), address(this), 0, toInt(divdrup(toBorrow, rate)) // We need to round up, otherwise we won't exit toBorrow ); // `vat.frob` reverts on failure daiJoin.exit(address(this), toBorrow); // `daiJoin` reverts on failures chai.join(address(this), toBorrow); // Grab chai from Chai, converted from dai } require(chai.transfer(to, chaiAmount)); // Give dai to user } /// @dev Moves Weth collateral from Treasury controlled Maker Eth vault to `to` address. /// This function can only be called by other Yield contracts, not users directly. /// @param to Wallet to send Weth to. /// @param wethAmount Weth quantity to send. function pullWeth(address to, uint256 wethAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { // Remove collateral from vault using frob vat.frob( WETH, address(this), address(this), address(this), -toInt(wethAmount), // Weth collateral to remove - WAD 0 // Dai debt to add - WAD ); wethJoin.exit(to, wethAmount); // `GemJoin` reverts on failures } /// @dev Registers the one contract that will take assets from the Treasury if MakerDAO shuts down. /// This function can only be called by the contract owner, which should only be possible during deployment. /// This function allows Unwind to take all the Chai savings and operate with the Treasury MakerDAO vault. /// @param unwind_ The address of the Unwild.sol contract. function registerUnwind(address unwind_) public onlyOwner { require( unwind == address(0), "Treasury: Unwind already set" ); unwind = unwind_; chai.approve(address(unwind), uint256(-1)); // Unwind will never cheat on us vat.hope(address(unwind)); // Unwind will never cheat on us } }
@dev Takes Weth collateral from user into the Treasury Maker vault User needs to have approved Treasury to take the Weth. This function can only be called by other Yield contracts, not users directly. @param from Wallet to take Weth from. @param wethAmount Weth quantity to take. All added collateral should be locked into the vault using frob
function pushWeth(address from, uint256 wethAmount) public override onlyOrchestrated("Treasury: Not Authorized") onlyLive { require(weth.transferFrom(from, address(this), wethAmount)); vat.frob( WETH, address(this), address(this), address(this), ); }
1,532,542
[ 1, 11524, 678, 546, 4508, 2045, 287, 628, 729, 1368, 326, 399, 266, 345, 22498, 490, 6388, 9229, 2177, 4260, 358, 1240, 20412, 399, 266, 345, 22498, 358, 4862, 326, 678, 546, 18, 1220, 445, 848, 1338, 506, 2566, 635, 1308, 31666, 20092, 16, 486, 3677, 5122, 18, 225, 628, 20126, 358, 4862, 678, 546, 628, 18, 225, 341, 546, 6275, 678, 546, 10457, 358, 4862, 18, 4826, 3096, 4508, 2045, 287, 1410, 506, 8586, 1368, 326, 9229, 1450, 284, 303, 70, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1817, 59, 546, 12, 2867, 628, 16, 2254, 5034, 341, 546, 6275, 13, 203, 3639, 1071, 3849, 203, 3639, 1338, 1162, 23386, 690, 2932, 56, 266, 345, 22498, 30, 2288, 6712, 1235, 7923, 203, 3639, 1338, 12328, 203, 565, 288, 203, 3639, 2583, 12, 91, 546, 18, 13866, 1265, 12, 2080, 16, 1758, 12, 2211, 3631, 341, 546, 6275, 10019, 203, 203, 3639, 17359, 18, 74, 303, 70, 12, 203, 5411, 678, 1584, 44, 16, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 1758, 12, 2211, 3631, 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 ]
./partial_match/1/0x874B936cc69A68D4cb6f5f24aB90ba60eb376AD6/sources/BitmassExchangeToken.sol
CHANGE THIS. Update the contract name.
contract BitmassExchangeToken is StandardToken {
3,979,375
[ 1, 14473, 20676, 18, 2315, 326, 6835, 508, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6539, 10424, 11688, 1345, 353, 8263, 1345, 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 ]
./partial_match/1/0xa94310AeeD50687f7c39ACdAA5FCd311AEDB25f8/sources/contracts/erc721/interfaces/IERC721EditionsDFS.sol
* @notice Core creation interface @author [email protected]/
interface IERC721EditionsDFS { function createEdition( string memory _editionUri, uint256 _editionSize, address _editionTokenManager, IRoyaltyManager.Royalty memory editionRoyalty ) external returns (uint256); function getEditionStartIds() external view returns (uint256[] memory); pragma solidity 0.8.10; }
3,645,494
[ 1, 4670, 6710, 1560, 225, 353, 25842, 36, 15978, 18, 17177, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 467, 654, 39, 27, 5340, 41, 1460, 87, 31999, 288, 203, 565, 445, 25184, 1460, 12, 203, 3639, 533, 3778, 389, 329, 608, 3006, 16, 203, 3639, 2254, 5034, 389, 329, 608, 1225, 16, 203, 3639, 1758, 389, 329, 608, 1345, 1318, 16, 203, 3639, 15908, 13372, 15006, 1318, 18, 54, 13372, 15006, 3778, 28432, 54, 13372, 15006, 203, 565, 262, 3903, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 4774, 1460, 1685, 2673, 1435, 3903, 1476, 1135, 261, 11890, 5034, 8526, 3778, 1769, 203, 683, 9454, 18035, 560, 374, 18, 28, 18, 2163, 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 ]
pragma solidity >=0.6.0; import '@openzeppelin/contracts/math/SafeMath.sol'; import '@openzeppelin/contracts/ownership/Ownable.sol'; import "@openzeppelin/contracts/drafts/Counters.sol"; /** * @author LordOfTheBees * @notice Workplace with Market */ contract MarketPool is Ownable { using SafeMath for uint256; using Counters for Counters.Counter; event MarketCreated(uint256 indexed marketId, address indexed owner); event MarketOwnershipTransferred(uint256 indexed marketId, address indexed previousOwner, address indexed newOwner); struct Market { string name; } //Список созданных маркетов Market[] public markets; // ID магазина и их владельцы mapping (uint256 => address) marketToOwner; mapping (address => Counters.Counter) addressToMarketCount; receive() external payable { } fallback() external payable { } function withdraw() external onlyOwner { address payable _owner = payable(owner()); _owner.transfer(address(this).balance); } /** * @notice Create new Market for sender. * @param name The name of marketplace * @return id of the created market */ function createMarket(string memory name) public returns (uint256) { markets.push(Market(name)); uint256 id = markets.length.sub(1); marketToOwner[id] = msg.sender; addressToMarketCount[msg.sender].increment(); emit MarketCreated(id, msg.sender); return id; } /** * @notice Return all data of market by its id */ function getMarketData(uint256 marketId) public view onlyMarketExists(marketId) returns (string memory name) { Market storage marketData = markets[marketId]; return (marketData.name); } /** * @notice Renouncing ownership will leave the contract without an market owner, thereby removing any functionality that is only available to the market owner (e.g. creating new Item Types). */ function renounceMarketOwnership(uint256 marketId) public onlyMarketOwner(marketId) { emit MarketOwnershipTransferred(marketId, marketToOwner[marketId], address(0)); addressToMarketCount[msg.sender].decrement(); marketToOwner[marketId] = address(0); } /** * @notice Transfers ownership of the ('marketId') to a new account (`newOwner`). */ function transferMarketOwnership(uint256 marketId, address newOwner) public onlyMarketOwner(marketId) notZeroAddress(newOwner) { emit MarketOwnershipTransferred(marketId, marketToOwner[marketId], newOwner); marketToOwner[marketId] = newOwner; addressToMarketCount[msg.sender].decrement(); addressToMarketCount[newOwner].increment(); } /** * @notice Return addres of market owner */ function getMarketOwner(uint256 marketId) public view onlyMarketExists(marketId) returns (address) { return marketToOwner[marketId]; } function getMarketCounts(address owner) public view returns (uint256) { return addressToMarketCount[owner].current(); } /** * @notice Chech if it is market owner */ function isMarketOwner(uint256 marketId) public view onlyMarketExists(marketId) returns (bool) { return marketToOwner[marketId] == msg.sender; } /** * @notice Check if market exist */ function marketExist(uint256 marketId) public view returns (bool) { return markets.length > marketId; } modifier notZeroAddress(address checkAddress) { require(checkAddress != address(0), "CheckAddress is the zero address"); _; } modifier onlyMarketExists(uint256 marketId) { require(marketExist(marketId), "MarketPool: Market does not exist"); _; } modifier onlyMarketOwner(uint256 marketId) { require(marketExist(marketId), "Market does not exist"); require(marketToOwner[marketId] == msg.sender, "Caller is not the owner"); _; } }
* @notice Renouncing ownership will leave the contract without an market owner, thereby removing any functionality that is only available to the market owner (e.g. creating new Item Types)./
function renounceMarketOwnership(uint256 marketId) public onlyMarketOwner(marketId) { emit MarketOwnershipTransferred(marketId, marketToOwner[marketId], address(0)); addressToMarketCount[msg.sender].decrement(); marketToOwner[marketId] = address(0); }
1,045,711
[ 1, 16290, 465, 2822, 23178, 903, 8851, 326, 6835, 2887, 392, 13667, 3410, 16, 1915, 1637, 9427, 1281, 14176, 716, 353, 1338, 2319, 358, 326, 13667, 3410, 261, 73, 18, 75, 18, 4979, 394, 4342, 7658, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1654, 8386, 3882, 278, 5460, 12565, 12, 11890, 5034, 13667, 548, 13, 1071, 1338, 3882, 278, 5541, 12, 27151, 548, 13, 288, 203, 3639, 3626, 6622, 278, 5460, 12565, 1429, 4193, 12, 27151, 548, 16, 13667, 774, 5541, 63, 27151, 548, 6487, 1758, 12, 20, 10019, 203, 3639, 1758, 774, 3882, 278, 1380, 63, 3576, 18, 15330, 8009, 323, 3702, 5621, 203, 3639, 13667, 774, 5541, 63, 27151, 548, 65, 273, 1758, 12, 20, 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 ]
// full contract sources : https://github.com/DigixGlobal/dao-contracts pragma solidity 0.4.25; // File: @digix/solidity-collections/contracts/abstract/AddressIteratorInteractive.sol /** @title Address Iterator Interactive @author DigixGlobal Pte Ltd */ contract AddressIteratorInteractive { /** @notice Lists a Address collection from start or end @param _count Total number of Address items to return @param _function_first Function that returns the First Address item in the list @param _function_last Function that returns the last Address item in the list @param _function_next Function that returns the Next Address item in the list @param _function_previous Function that returns previous Address item in the list @param _from_start whether to read from start (or end) of the list @return {"_address_items" : "Collection of reversed Address list"} */ function list_addresses(uint256 _count, function () external constant returns (address) _function_first, function () external constant returns (address) _function_last, function (address) external constant returns (address) _function_next, function (address) external constant returns (address) _function_previous, bool _from_start) internal constant returns (address[] _address_items) { if (_from_start) { _address_items = private_list_addresses_from_address(_function_first(), _count, true, _function_last, _function_next); } else { _address_items = private_list_addresses_from_address(_function_last(), _count, true, _function_first, _function_previous); } } /** @notice Lists a Address collection from some `_current_item`, going forwards or backwards depending on `_from_start` @param _current_item The current Item @param _count Total number of Address items to return @param _function_first Function that returns the First Address item in the list @param _function_last Function that returns the last Address item in the list @param _function_next Function that returns the Next Address item in the list @param _function_previous Function that returns previous Address item in the list @param _from_start whether to read in the forwards ( or backwards) direction @return {"_address_items" :"Collection/list of Address"} */ function list_addresses_from(address _current_item, uint256 _count, function () external constant returns (address) _function_first, function () external constant returns (address) _function_last, function (address) external constant returns (address) _function_next, function (address) external constant returns (address) _function_previous, bool _from_start) internal constant returns (address[] _address_items) { if (_from_start) { _address_items = private_list_addresses_from_address(_current_item, _count, false, _function_last, _function_next); } else { _address_items = private_list_addresses_from_address(_current_item, _count, false, _function_first, _function_previous); } } /** @notice a private function to lists a Address collection starting from some `_current_item` (which could be included or excluded), in the forwards or backwards direction @param _current_item The current Item @param _count Total number of Address items to return @param _including_current Whether the `_current_item` should be included in the result @param _function_last Function that returns the address where we stop reading more address @param _function_next Function that returns the next address to read after some address (could be backwards or forwards in the physical collection) @return {"_address_items" :"Collection/list of Address"} */ function private_list_addresses_from_address(address _current_item, uint256 _count, bool _including_current, function () external constant returns (address) _function_last, function (address) external constant returns (address) _function_next) private constant returns (address[] _address_items) { uint256 _i; uint256 _real_count = 0; address _last_item; _last_item = _function_last(); if (_count == 0 || _last_item == address(0x0)) { _address_items = new address[](0); } else { address[] memory _items_temp = new address[](_count); address _this_item; if (_including_current == true) { _items_temp[0] = _current_item; _real_count = 1; } _this_item = _current_item; for (_i = _real_count; (_i < _count) && (_this_item != _last_item);_i++) { _this_item = _function_next(_this_item); if (_this_item != address(0x0)) { _real_count++; _items_temp[_i] = _this_item; } } _address_items = new address[](_real_count); for(_i = 0;_i < _real_count;_i++) { _address_items[_i] = _items_temp[_i]; } } } /** DEPRECATED @notice private function to list a Address collection starting from the start or end of the list @param _count Total number of Address item to return @param _function_total Function that returns the Total number of Address item in the list @param _function_first Function that returns the First Address item in the list @param _function_next Function that returns the Next Address item in the list @return {"_address_items" :"Collection/list of Address"} */ /*function list_addresses_from_start_or_end(uint256 _count, function () external constant returns (uint256) _function_total, function () external constant returns (address) _function_first, function (address) external constant returns (address) _function_next) private constant returns (address[] _address_items) { uint256 _i; address _current_item; uint256 _real_count = _function_total(); if (_count > _real_count) { _count = _real_count; } address[] memory _items_tmp = new address[](_count); if (_count > 0) { _current_item = _function_first(); _items_tmp[0] = _current_item; for(_i = 1;_i <= (_count - 1);_i++) { _current_item = _function_next(_current_item); if (_current_item != address(0x0)) { _items_tmp[_i] = _current_item; } } _address_items = _items_tmp; } else { _address_items = new address[](0); } }*/ /** DEPRECATED @notice a private function to lists a Address collection starting from some `_current_item`, could be forwards or backwards @param _current_item The current Item @param _count Total number of Address items to return @param _function_last Function that returns the bytes where we stop reading more bytes @param _function_next Function that returns the next bytes to read after some bytes (could be backwards or forwards in the physical collection) @return {"_address_items" :"Collection/list of Address"} */ /*function list_addresses_from_byte(address _current_item, uint256 _count, function () external constant returns (address) _function_last, function (address) external constant returns (address) _function_next) private constant returns (address[] _address_items) { uint256 _i; uint256 _real_count = 0; if (_count == 0) { _address_items = new address[](0); } else { address[] memory _items_temp = new address[](_count); address _start_item; address _last_item; _last_item = _function_last(); if (_last_item != _current_item) { _start_item = _function_next(_current_item); if (_start_item != address(0x0)) { _items_temp[0] = _start_item; _real_count = 1; for(_i = 1;(_i <= (_count - 1)) && (_start_item != _last_item);_i++) { _start_item = _function_next(_start_item); if (_start_item != address(0x0)) { _real_count++; _items_temp[_i] = _start_item; } } _address_items = new address[](_real_count); for(_i = 0;_i <= (_real_count - 1);_i++) { _address_items[_i] = _items_temp[_i]; } } else { _address_items = new address[](0); } } else { _address_items = new address[](0); } } }*/ } // File: @digix/solidity-collections/contracts/abstract/BytesIteratorInteractive.sol /** @title Bytes Iterator Interactive @author DigixGlobal Pte Ltd */ contract BytesIteratorInteractive { /** @notice Lists a Bytes collection from start or end @param _count Total number of Bytes items to return @param _function_first Function that returns the First Bytes item in the list @param _function_last Function that returns the last Bytes item in the list @param _function_next Function that returns the Next Bytes item in the list @param _function_previous Function that returns previous Bytes item in the list @param _from_start whether to read from start (or end) of the list @return {"_bytes_items" : "Collection of reversed Bytes list"} */ function list_bytesarray(uint256 _count, function () external constant returns (bytes32) _function_first, function () external constant returns (bytes32) _function_last, function (bytes32) external constant returns (bytes32) _function_next, function (bytes32) external constant returns (bytes32) _function_previous, bool _from_start) internal constant returns (bytes32[] _bytes_items) { if (_from_start) { _bytes_items = private_list_bytes_from_bytes(_function_first(), _count, true, _function_last, _function_next); } else { _bytes_items = private_list_bytes_from_bytes(_function_last(), _count, true, _function_first, _function_previous); } } /** @notice Lists a Bytes collection from some `_current_item`, going forwards or backwards depending on `_from_start` @param _current_item The current Item @param _count Total number of Bytes items to return @param _function_first Function that returns the First Bytes item in the list @param _function_last Function that returns the last Bytes item in the list @param _function_next Function that returns the Next Bytes item in the list @param _function_previous Function that returns previous Bytes item in the list @param _from_start whether to read in the forwards ( or backwards) direction @return {"_bytes_items" :"Collection/list of Bytes"} */ function list_bytesarray_from(bytes32 _current_item, uint256 _count, function () external constant returns (bytes32) _function_first, function () external constant returns (bytes32) _function_last, function (bytes32) external constant returns (bytes32) _function_next, function (bytes32) external constant returns (bytes32) _function_previous, bool _from_start) internal constant returns (bytes32[] _bytes_items) { if (_from_start) { _bytes_items = private_list_bytes_from_bytes(_current_item, _count, false, _function_last, _function_next); } else { _bytes_items = private_list_bytes_from_bytes(_current_item, _count, false, _function_first, _function_previous); } } /** @notice A private function to lists a Bytes collection starting from some `_current_item` (which could be included or excluded), in the forwards or backwards direction @param _current_item The current Item @param _count Total number of Bytes items to return @param _including_current Whether the `_current_item` should be included in the result @param _function_last Function that returns the bytes where we stop reading more bytes @param _function_next Function that returns the next bytes to read after some bytes (could be backwards or forwards in the physical collection) @return {"_address_items" :"Collection/list of Bytes"} */ function private_list_bytes_from_bytes(bytes32 _current_item, uint256 _count, bool _including_current, function () external constant returns (bytes32) _function_last, function (bytes32) external constant returns (bytes32) _function_next) private constant returns (bytes32[] _bytes32_items) { uint256 _i; uint256 _real_count = 0; bytes32 _last_item; _last_item = _function_last(); if (_count == 0 || _last_item == bytes32(0x0)) { _bytes32_items = new bytes32[](0); } else { bytes32[] memory _items_temp = new bytes32[](_count); bytes32 _this_item; if (_including_current == true) { _items_temp[0] = _current_item; _real_count = 1; } _this_item = _current_item; for (_i = _real_count; (_i < _count) && (_this_item != _last_item);_i++) { _this_item = _function_next(_this_item); if (_this_item != bytes32(0x0)) { _real_count++; _items_temp[_i] = _this_item; } } _bytes32_items = new bytes32[](_real_count); for(_i = 0;_i < _real_count;_i++) { _bytes32_items[_i] = _items_temp[_i]; } } } ////// DEPRECATED FUNCTIONS (old versions) /** @notice a private function to lists a Bytes collection starting from some `_current_item`, could be forwards or backwards @param _current_item The current Item @param _count Total number of Bytes items to return @param _function_last Function that returns the bytes where we stop reading more bytes @param _function_next Function that returns the next bytes to read after some bytes (could be backwards or forwards in the physical collection) @return {"_bytes_items" :"Collection/list of Bytes"} */ /*function list_bytes_from_bytes(bytes32 _current_item, uint256 _count, function () external constant returns (bytes32) _function_last, function (bytes32) external constant returns (bytes32) _function_next) private constant returns (bytes32[] _bytes_items) { uint256 _i; uint256 _real_count = 0; if (_count == 0) { _bytes_items = new bytes32[](0); } else { bytes32[] memory _items_temp = new bytes32[](_count); bytes32 _start_item; bytes32 _last_item; _last_item = _function_last(); if (_last_item != _current_item) { _start_item = _function_next(_current_item); if (_start_item != bytes32(0x0)) { _items_temp[0] = _start_item; _real_count = 1; for(_i = 1;(_i <= (_count - 1)) && (_start_item != _last_item);_i++) { _start_item = _function_next(_start_item); if (_start_item != bytes32(0x0)) { _real_count++; _items_temp[_i] = _start_item; } } _bytes_items = new bytes32[](_real_count); for(_i = 0;_i <= (_real_count - 1);_i++) { _bytes_items[_i] = _items_temp[_i]; } } else { _bytes_items = new bytes32[](0); } } else { _bytes_items = new bytes32[](0); } } }*/ /** @notice private function to list a Bytes collection starting from the start or end of the list @param _count Total number of Bytes item to return @param _function_total Function that returns the Total number of Bytes item in the list @param _function_first Function that returns the First Bytes item in the list @param _function_next Function that returns the Next Bytes item in the list @return {"_bytes_items" :"Collection/list of Bytes"} */ /*function list_bytes_from_start_or_end(uint256 _count, function () external constant returns (uint256) _function_total, function () external constant returns (bytes32) _function_first, function (bytes32) external constant returns (bytes32) _function_next) private constant returns (bytes32[] _bytes_items) { uint256 _i; bytes32 _current_item; uint256 _real_count = _function_total(); if (_count > _real_count) { _count = _real_count; } bytes32[] memory _items_tmp = new bytes32[](_count); if (_count > 0) { _current_item = _function_first(); _items_tmp[0] = _current_item; for(_i = 1;_i <= (_count - 1);_i++) { _current_item = _function_next(_current_item); if (_current_item != bytes32(0x0)) { _items_tmp[_i] = _current_item; } } _bytes_items = _items_tmp; } else { _bytes_items = new bytes32[](0); } }*/ } // File: @digix/solidity-collections/contracts/abstract/IndexedBytesIteratorInteractive.sol /** @title Indexed Bytes Iterator Interactive @author DigixGlobal Pte Ltd */ contract IndexedBytesIteratorInteractive { /** @notice Lists an indexed Bytes collection from start or end @param _collection_index Index of the Collection to list @param _count Total number of Bytes items to return @param _function_first Function that returns the First Bytes item in the list @param _function_last Function that returns the last Bytes item in the list @param _function_next Function that returns the Next Bytes item in the list @param _function_previous Function that returns previous Bytes item in the list @param _from_start whether to read from start (or end) of the list @return {"_bytes_items" : "Collection of reversed Bytes list"} */ function list_indexed_bytesarray(bytes32 _collection_index, uint256 _count, function (bytes32) external constant returns (bytes32) _function_first, function (bytes32) external constant returns (bytes32) _function_last, function (bytes32, bytes32) external constant returns (bytes32) _function_next, function (bytes32, bytes32) external constant returns (bytes32) _function_previous, bool _from_start) internal constant returns (bytes32[] _indexed_bytes_items) { if (_from_start) { _indexed_bytes_items = private_list_indexed_bytes_from_bytes(_collection_index, _function_first(_collection_index), _count, true, _function_last, _function_next); } else { _indexed_bytes_items = private_list_indexed_bytes_from_bytes(_collection_index, _function_last(_collection_index), _count, true, _function_first, _function_previous); } } /** @notice Lists an indexed Bytes collection from some `_current_item`, going forwards or backwards depending on `_from_start` @param _collection_index Index of the Collection to list @param _current_item The current Item @param _count Total number of Bytes items to return @param _function_first Function that returns the First Bytes item in the list @param _function_last Function that returns the last Bytes item in the list @param _function_next Function that returns the Next Bytes item in the list @param _function_previous Function that returns previous Bytes item in the list @param _from_start whether to read in the forwards ( or backwards) direction @return {"_bytes_items" :"Collection/list of Bytes"} */ function list_indexed_bytesarray_from(bytes32 _collection_index, bytes32 _current_item, uint256 _count, function (bytes32) external constant returns (bytes32) _function_first, function (bytes32) external constant returns (bytes32) _function_last, function (bytes32, bytes32) external constant returns (bytes32) _function_next, function (bytes32, bytes32) external constant returns (bytes32) _function_previous, bool _from_start) internal constant returns (bytes32[] _indexed_bytes_items) { if (_from_start) { _indexed_bytes_items = private_list_indexed_bytes_from_bytes(_collection_index, _current_item, _count, false, _function_last, _function_next); } else { _indexed_bytes_items = private_list_indexed_bytes_from_bytes(_collection_index, _current_item, _count, false, _function_first, _function_previous); } } /** @notice a private function to lists an indexed Bytes collection starting from some `_current_item` (which could be included or excluded), in the forwards or backwards direction @param _collection_index Index of the Collection to list @param _current_item The item where we start reading from the list @param _count Total number of Bytes items to return @param _including_current Whether the `_current_item` should be included in the result @param _function_last Function that returns the bytes where we stop reading more bytes @param _function_next Function that returns the next bytes to read after another bytes (could be backwards or forwards in the physical collection) @return {"_bytes_items" :"Collection/list of Bytes"} */ function private_list_indexed_bytes_from_bytes(bytes32 _collection_index, bytes32 _current_item, uint256 _count, bool _including_current, function (bytes32) external constant returns (bytes32) _function_last, function (bytes32, bytes32) external constant returns (bytes32) _function_next) private constant returns (bytes32[] _indexed_bytes_items) { uint256 _i; uint256 _real_count = 0; bytes32 _last_item; _last_item = _function_last(_collection_index); if (_count == 0 || _last_item == bytes32(0x0)) { // if count is 0 or the collection is empty, returns empty array _indexed_bytes_items = new bytes32[](0); } else { bytes32[] memory _items_temp = new bytes32[](_count); bytes32 _this_item; if (_including_current) { _items_temp[0] = _current_item; _real_count = 1; } _this_item = _current_item; for (_i = _real_count; (_i < _count) && (_this_item != _last_item);_i++) { _this_item = _function_next(_collection_index, _this_item); if (_this_item != bytes32(0x0)) { _real_count++; _items_temp[_i] = _this_item; } } _indexed_bytes_items = new bytes32[](_real_count); for(_i = 0;_i < _real_count;_i++) { _indexed_bytes_items[_i] = _items_temp[_i]; } } } // old function, DEPRECATED /*function list_indexed_bytes_from_bytes(bytes32 _collection_index, bytes32 _current_item, uint256 _count, function (bytes32) external constant returns (bytes32) _function_last, function (bytes32, bytes32) external constant returns (bytes32) _function_next) private constant returns (bytes32[] _indexed_bytes_items) { uint256 _i; uint256 _real_count = 0; if (_count == 0) { _indexed_bytes_items = new bytes32[](0); } else { bytes32[] memory _items_temp = new bytes32[](_count); bytes32 _start_item; bytes32 _last_item; _last_item = _function_last(_collection_index); if (_last_item != _current_item) { _start_item = _function_next(_collection_index, _current_item); if (_start_item != bytes32(0x0)) { _items_temp[0] = _start_item; _real_count = 1; for(_i = 1;(_i <= (_count - 1)) && (_start_item != _last_item);_i++) { _start_item = _function_next(_collection_index, _start_item); if (_start_item != bytes32(0x0)) { _real_count++; _items_temp[_i] = _start_item; } } _indexed_bytes_items = new bytes32[](_real_count); for(_i = 0;_i <= (_real_count - 1);_i++) { _indexed_bytes_items[_i] = _items_temp[_i]; } } else { _indexed_bytes_items = new bytes32[](0); } } else { _indexed_bytes_items = new bytes32[](0); } } }*/ } // File: @digix/solidity-collections/contracts/lib/DoublyLinkedList.sol library DoublyLinkedList { struct Item { bytes32 item; uint256 previous_index; uint256 next_index; } struct Data { uint256 first_index; uint256 last_index; uint256 count; mapping(bytes32 => uint256) item_index; mapping(uint256 => bool) valid_indexes; Item[] collection; } struct IndexedUint { mapping(bytes32 => Data) data; } struct IndexedAddress { mapping(bytes32 => Data) data; } struct IndexedBytes { mapping(bytes32 => Data) data; } struct Address { Data data; } struct Bytes { Data data; } struct Uint { Data data; } uint256 constant NONE = uint256(0); bytes32 constant EMPTY_BYTES = bytes32(0x0); address constant NULL_ADDRESS = address(0x0); function find(Data storage self, bytes32 _item) public constant returns (uint256 _item_index) { if ((self.item_index[_item] == NONE) && (self.count == NONE)) { _item_index = NONE; } else { _item_index = self.item_index[_item]; } } function get(Data storage self, uint256 _item_index) public constant returns (bytes32 _item) { if (self.valid_indexes[_item_index] == true) { _item = self.collection[_item_index - 1].item; } else { _item = EMPTY_BYTES; } } function append(Data storage self, bytes32 _data) internal returns (bool _success) { if (find(self, _data) != NONE || _data == bytes32("")) { // rejects addition of empty values _success = false; } else { uint256 _index = uint256(self.collection.push(Item({item: _data, previous_index: self.last_index, next_index: NONE}))); if (self.last_index == NONE) { if ((self.first_index != NONE) || (self.count != NONE)) { revert(); } else { self.first_index = self.last_index = _index; self.count = 1; } } else { self.collection[self.last_index - 1].next_index = _index; self.last_index = _index; self.count++; } self.valid_indexes[_index] = true; self.item_index[_data] = _index; _success = true; } } function remove(Data storage self, uint256 _index) internal returns (bool _success) { if (self.valid_indexes[_index] == true) { Item memory item = self.collection[_index - 1]; if (item.previous_index == NONE) { self.first_index = item.next_index; } else { self.collection[item.previous_index - 1].next_index = item.next_index; } if (item.next_index == NONE) { self.last_index = item.previous_index; } else { self.collection[item.next_index - 1].previous_index = item.previous_index; } delete self.collection[_index - 1]; self.valid_indexes[_index] = false; delete self.item_index[item.item]; self.count--; _success = true; } else { _success = false; } } function remove_item(Data storage self, bytes32 _item) internal returns (bool _success) { uint256 _item_index = find(self, _item); if (_item_index != NONE) { require(remove(self, _item_index)); _success = true; } else { _success = false; } return _success; } function total(Data storage self) public constant returns (uint256 _total_count) { _total_count = self.count; } function start(Data storage self) public constant returns (uint256 _item_index) { _item_index = self.first_index; return _item_index; } function start_item(Data storage self) public constant returns (bytes32 _item) { uint256 _item_index = start(self); if (_item_index != NONE) { _item = get(self, _item_index); } else { _item = EMPTY_BYTES; } } function end(Data storage self) public constant returns (uint256 _item_index) { _item_index = self.last_index; return _item_index; } function end_item(Data storage self) public constant returns (bytes32 _item) { uint256 _item_index = end(self); if (_item_index != NONE) { _item = get(self, _item_index); } else { _item = EMPTY_BYTES; } } function valid(Data storage self, uint256 _item_index) public constant returns (bool _yes) { _yes = self.valid_indexes[_item_index]; //_yes = ((_item_index - 1) < self.collection.length); } function valid_item(Data storage self, bytes32 _item) public constant returns (bool _yes) { uint256 _item_index = self.item_index[_item]; _yes = self.valid_indexes[_item_index]; } function previous(Data storage self, uint256 _current_index) public constant returns (uint256 _previous_index) { if (self.valid_indexes[_current_index] == true) { _previous_index = self.collection[_current_index - 1].previous_index; } else { _previous_index = NONE; } } function previous_item(Data storage self, bytes32 _current_item) public constant returns (bytes32 _previous_item) { uint256 _current_index = find(self, _current_item); if (_current_index != NONE) { uint256 _previous_index = previous(self, _current_index); _previous_item = get(self, _previous_index); } else { _previous_item = EMPTY_BYTES; } } function next(Data storage self, uint256 _current_index) public constant returns (uint256 _next_index) { if (self.valid_indexes[_current_index] == true) { _next_index = self.collection[_current_index - 1].next_index; } else { _next_index = NONE; } } function next_item(Data storage self, bytes32 _current_item) public constant returns (bytes32 _next_item) { uint256 _current_index = find(self, _current_item); if (_current_index != NONE) { uint256 _next_index = next(self, _current_index); _next_item = get(self, _next_index); } else { _next_item = EMPTY_BYTES; } } function find(Uint storage self, uint256 _item) public constant returns (uint256 _item_index) { _item_index = find(self.data, bytes32(_item)); } function get(Uint storage self, uint256 _item_index) public constant returns (uint256 _item) { _item = uint256(get(self.data, _item_index)); } function append(Uint storage self, uint256 _data) public returns (bool _success) { _success = append(self.data, bytes32(_data)); } function remove(Uint storage self, uint256 _index) internal returns (bool _success) { _success = remove(self.data, _index); } function remove_item(Uint storage self, uint256 _item) public returns (bool _success) { _success = remove_item(self.data, bytes32(_item)); } function total(Uint storage self) public constant returns (uint256 _total_count) { _total_count = total(self.data); } function start(Uint storage self) public constant returns (uint256 _index) { _index = start(self.data); } function start_item(Uint storage self) public constant returns (uint256 _start_item) { _start_item = uint256(start_item(self.data)); } function end(Uint storage self) public constant returns (uint256 _index) { _index = end(self.data); } function end_item(Uint storage self) public constant returns (uint256 _end_item) { _end_item = uint256(end_item(self.data)); } function valid(Uint storage self, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data, _item_index); } function valid_item(Uint storage self, uint256 _item) public constant returns (bool _yes) { _yes = valid_item(self.data, bytes32(_item)); } function previous(Uint storage self, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data, _current_index); } function previous_item(Uint storage self, uint256 _current_item) public constant returns (uint256 _previous_item) { _previous_item = uint256(previous_item(self.data, bytes32(_current_item))); } function next(Uint storage self, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data, _current_index); } function next_item(Uint storage self, uint256 _current_item) public constant returns (uint256 _next_item) { _next_item = uint256(next_item(self.data, bytes32(_current_item))); } function find(Address storage self, address _item) public constant returns (uint256 _item_index) { _item_index = find(self.data, bytes32(_item)); } function get(Address storage self, uint256 _item_index) public constant returns (address _item) { _item = address(get(self.data, _item_index)); } function find(IndexedUint storage self, bytes32 _collection_index, uint256 _item) public constant returns (uint256 _item_index) { _item_index = find(self.data[_collection_index], bytes32(_item)); } function get(IndexedUint storage self, bytes32 _collection_index, uint256 _item_index) public constant returns (uint256 _item) { _item = uint256(get(self.data[_collection_index], _item_index)); } function append(IndexedUint storage self, bytes32 _collection_index, uint256 _data) public returns (bool _success) { _success = append(self.data[_collection_index], bytes32(_data)); } function remove(IndexedUint storage self, bytes32 _collection_index, uint256 _index) internal returns (bool _success) { _success = remove(self.data[_collection_index], _index); } function remove_item(IndexedUint storage self, bytes32 _collection_index, uint256 _item) public returns (bool _success) { _success = remove_item(self.data[_collection_index], bytes32(_item)); } function total(IndexedUint storage self, bytes32 _collection_index) public constant returns (uint256 _total_count) { _total_count = total(self.data[_collection_index]); } function start(IndexedUint storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = start(self.data[_collection_index]); } function start_item(IndexedUint storage self, bytes32 _collection_index) public constant returns (uint256 _start_item) { _start_item = uint256(start_item(self.data[_collection_index])); } function end(IndexedUint storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = end(self.data[_collection_index]); } function end_item(IndexedUint storage self, bytes32 _collection_index) public constant returns (uint256 _end_item) { _end_item = uint256(end_item(self.data[_collection_index])); } function valid(IndexedUint storage self, bytes32 _collection_index, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data[_collection_index], _item_index); } function valid_item(IndexedUint storage self, bytes32 _collection_index, uint256 _item) public constant returns (bool _yes) { _yes = valid_item(self.data[_collection_index], bytes32(_item)); } function previous(IndexedUint storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data[_collection_index], _current_index); } function previous_item(IndexedUint storage self, bytes32 _collection_index, uint256 _current_item) public constant returns (uint256 _previous_item) { _previous_item = uint256(previous_item(self.data[_collection_index], bytes32(_current_item))); } function next(IndexedUint storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data[_collection_index], _current_index); } function next_item(IndexedUint storage self, bytes32 _collection_index, uint256 _current_item) public constant returns (uint256 _next_item) { _next_item = uint256(next_item(self.data[_collection_index], bytes32(_current_item))); } function append(Address storage self, address _data) public returns (bool _success) { _success = append(self.data, bytes32(_data)); } function remove(Address storage self, uint256 _index) internal returns (bool _success) { _success = remove(self.data, _index); } function remove_item(Address storage self, address _item) public returns (bool _success) { _success = remove_item(self.data, bytes32(_item)); } function total(Address storage self) public constant returns (uint256 _total_count) { _total_count = total(self.data); } function start(Address storage self) public constant returns (uint256 _index) { _index = start(self.data); } function start_item(Address storage self) public constant returns (address _start_item) { _start_item = address(start_item(self.data)); } function end(Address storage self) public constant returns (uint256 _index) { _index = end(self.data); } function end_item(Address storage self) public constant returns (address _end_item) { _end_item = address(end_item(self.data)); } function valid(Address storage self, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data, _item_index); } function valid_item(Address storage self, address _item) public constant returns (bool _yes) { _yes = valid_item(self.data, bytes32(_item)); } function previous(Address storage self, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data, _current_index); } function previous_item(Address storage self, address _current_item) public constant returns (address _previous_item) { _previous_item = address(previous_item(self.data, bytes32(_current_item))); } function next(Address storage self, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data, _current_index); } function next_item(Address storage self, address _current_item) public constant returns (address _next_item) { _next_item = address(next_item(self.data, bytes32(_current_item))); } function append(IndexedAddress storage self, bytes32 _collection_index, address _data) public returns (bool _success) { _success = append(self.data[_collection_index], bytes32(_data)); } function remove(IndexedAddress storage self, bytes32 _collection_index, uint256 _index) internal returns (bool _success) { _success = remove(self.data[_collection_index], _index); } function remove_item(IndexedAddress storage self, bytes32 _collection_index, address _item) public returns (bool _success) { _success = remove_item(self.data[_collection_index], bytes32(_item)); } function total(IndexedAddress storage self, bytes32 _collection_index) public constant returns (uint256 _total_count) { _total_count = total(self.data[_collection_index]); } function start(IndexedAddress storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = start(self.data[_collection_index]); } function start_item(IndexedAddress storage self, bytes32 _collection_index) public constant returns (address _start_item) { _start_item = address(start_item(self.data[_collection_index])); } function end(IndexedAddress storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = end(self.data[_collection_index]); } function end_item(IndexedAddress storage self, bytes32 _collection_index) public constant returns (address _end_item) { _end_item = address(end_item(self.data[_collection_index])); } function valid(IndexedAddress storage self, bytes32 _collection_index, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data[_collection_index], _item_index); } function valid_item(IndexedAddress storage self, bytes32 _collection_index, address _item) public constant returns (bool _yes) { _yes = valid_item(self.data[_collection_index], bytes32(_item)); } function previous(IndexedAddress storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data[_collection_index], _current_index); } function previous_item(IndexedAddress storage self, bytes32 _collection_index, address _current_item) public constant returns (address _previous_item) { _previous_item = address(previous_item(self.data[_collection_index], bytes32(_current_item))); } function next(IndexedAddress storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data[_collection_index], _current_index); } function next_item(IndexedAddress storage self, bytes32 _collection_index, address _current_item) public constant returns (address _next_item) { _next_item = address(next_item(self.data[_collection_index], bytes32(_current_item))); } function find(Bytes storage self, bytes32 _item) public constant returns (uint256 _item_index) { _item_index = find(self.data, _item); } function get(Bytes storage self, uint256 _item_index) public constant returns (bytes32 _item) { _item = get(self.data, _item_index); } function append(Bytes storage self, bytes32 _data) public returns (bool _success) { _success = append(self.data, _data); } function remove(Bytes storage self, uint256 _index) internal returns (bool _success) { _success = remove(self.data, _index); } function remove_item(Bytes storage self, bytes32 _item) public returns (bool _success) { _success = remove_item(self.data, _item); } function total(Bytes storage self) public constant returns (uint256 _total_count) { _total_count = total(self.data); } function start(Bytes storage self) public constant returns (uint256 _index) { _index = start(self.data); } function start_item(Bytes storage self) public constant returns (bytes32 _start_item) { _start_item = start_item(self.data); } function end(Bytes storage self) public constant returns (uint256 _index) { _index = end(self.data); } function end_item(Bytes storage self) public constant returns (bytes32 _end_item) { _end_item = end_item(self.data); } function valid(Bytes storage self, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data, _item_index); } function valid_item(Bytes storage self, bytes32 _item) public constant returns (bool _yes) { _yes = valid_item(self.data, _item); } function previous(Bytes storage self, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data, _current_index); } function previous_item(Bytes storage self, bytes32 _current_item) public constant returns (bytes32 _previous_item) { _previous_item = previous_item(self.data, _current_item); } function next(Bytes storage self, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data, _current_index); } function next_item(Bytes storage self, bytes32 _current_item) public constant returns (bytes32 _next_item) { _next_item = next_item(self.data, _current_item); } function append(IndexedBytes storage self, bytes32 _collection_index, bytes32 _data) public returns (bool _success) { _success = append(self.data[_collection_index], bytes32(_data)); } function remove(IndexedBytes storage self, bytes32 _collection_index, uint256 _index) internal returns (bool _success) { _success = remove(self.data[_collection_index], _index); } function remove_item(IndexedBytes storage self, bytes32 _collection_index, bytes32 _item) public returns (bool _success) { _success = remove_item(self.data[_collection_index], bytes32(_item)); } function total(IndexedBytes storage self, bytes32 _collection_index) public constant returns (uint256 _total_count) { _total_count = total(self.data[_collection_index]); } function start(IndexedBytes storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = start(self.data[_collection_index]); } function start_item(IndexedBytes storage self, bytes32 _collection_index) public constant returns (bytes32 _start_item) { _start_item = bytes32(start_item(self.data[_collection_index])); } function end(IndexedBytes storage self, bytes32 _collection_index) public constant returns (uint256 _index) { _index = end(self.data[_collection_index]); } function end_item(IndexedBytes storage self, bytes32 _collection_index) public constant returns (bytes32 _end_item) { _end_item = bytes32(end_item(self.data[_collection_index])); } function valid(IndexedBytes storage self, bytes32 _collection_index, uint256 _item_index) public constant returns (bool _yes) { _yes = valid(self.data[_collection_index], _item_index); } function valid_item(IndexedBytes storage self, bytes32 _collection_index, bytes32 _item) public constant returns (bool _yes) { _yes = valid_item(self.data[_collection_index], bytes32(_item)); } function previous(IndexedBytes storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _previous_index) { _previous_index = previous(self.data[_collection_index], _current_index); } function previous_item(IndexedBytes storage self, bytes32 _collection_index, bytes32 _current_item) public constant returns (bytes32 _previous_item) { _previous_item = bytes32(previous_item(self.data[_collection_index], bytes32(_current_item))); } function next(IndexedBytes storage self, bytes32 _collection_index, uint256 _current_index) public constant returns (uint256 _next_index) { _next_index = next(self.data[_collection_index], _current_index); } function next_item(IndexedBytes storage self, bytes32 _collection_index, bytes32 _current_item) public constant returns (bytes32 _next_item) { _next_item = bytes32(next_item(self.data[_collection_index], bytes32(_current_item))); } } // File: @digix/solidity-collections/contracts/abstract/BytesIteratorStorage.sol /** @title Bytes Iterator Storage @author DigixGlobal Pte Ltd */ contract BytesIteratorStorage { // Initialize Doubly Linked List of Bytes using DoublyLinkedList for DoublyLinkedList.Bytes; /** @notice Reads the first item from the list of Bytes @param _list The source list @return {"_item": "The first item from the list"} */ function read_first_from_bytesarray(DoublyLinkedList.Bytes storage _list) internal constant returns (bytes32 _item) { _item = _list.start_item(); } /** @notice Reads the last item from the list of Bytes @param _list The source list @return {"_item": "The last item from the list"} */ function read_last_from_bytesarray(DoublyLinkedList.Bytes storage _list) internal constant returns (bytes32 _item) { _item = _list.end_item(); } /** @notice Reads the next item on the list of Bytes @param _list The source list @param _current_item The current item to be used as base line @return {"_item": "The next item from the list based on the specieid `_current_item`"} TODO: Need to verify what happens if the specified `_current_item` is the last item from the list */ function read_next_from_bytesarray(DoublyLinkedList.Bytes storage _list, bytes32 _current_item) internal constant returns (bytes32 _item) { _item = _list.next_item(_current_item); } /** @notice Reads the previous item on the list of Bytes @param _list The source list @param _current_item The current item to be used as base line @return {"_item": "The previous item from the list based on the spcified `_current_item`"} TODO: Need to verify what happens if the specified `_current_item` is the first item from the list */ function read_previous_from_bytesarray(DoublyLinkedList.Bytes storage _list, bytes32 _current_item) internal constant returns (bytes32 _item) { _item = _list.previous_item(_current_item); } /** @notice Reads the list of Bytes and returns the length of the list @param _list The source list @return {"count": "`uint256` The lenght of the list"} */ function read_total_bytesarray(DoublyLinkedList.Bytes storage _list) internal constant returns (uint256 _count) { _count = _list.total(); } } // 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/common/DaoConstants.sol contract DaoConstants { using SafeMath for uint256; bytes32 EMPTY_BYTES = bytes32(0x0); address EMPTY_ADDRESS = address(0x0); bytes32 PROPOSAL_STATE_PREPROPOSAL = "proposal_state_preproposal"; bytes32 PROPOSAL_STATE_DRAFT = "proposal_state_draft"; bytes32 PROPOSAL_STATE_MODERATED = "proposal_state_moderated"; bytes32 PROPOSAL_STATE_ONGOING = "proposal_state_ongoing"; bytes32 PROPOSAL_STATE_CLOSED = "proposal_state_closed"; bytes32 PROPOSAL_STATE_ARCHIVED = "proposal_state_archived"; uint256 PRL_ACTION_STOP = 1; uint256 PRL_ACTION_PAUSE = 2; uint256 PRL_ACTION_UNPAUSE = 3; uint256 COLLATERAL_STATUS_UNLOCKED = 1; uint256 COLLATERAL_STATUS_LOCKED = 2; uint256 COLLATERAL_STATUS_CLAIMED = 3; bytes32 INTERMEDIATE_DGD_IDENTIFIER = "inter_dgd_id"; bytes32 INTERMEDIATE_MODERATOR_DGD_IDENTIFIER = "inter_mod_dgd_id"; bytes32 INTERMEDIATE_BONUS_CALCULATION_IDENTIFIER = "inter_bonus_calculation_id"; // interactive contracts bytes32 CONTRACT_DAO = "dao"; bytes32 CONTRACT_DAO_SPECIAL_PROPOSAL = "dao:special:proposal"; bytes32 CONTRACT_DAO_STAKE_LOCKING = "dao:stake-locking"; bytes32 CONTRACT_DAO_VOTING = "dao:voting"; bytes32 CONTRACT_DAO_VOTING_CLAIMS = "dao:voting:claims"; bytes32 CONTRACT_DAO_SPECIAL_VOTING_CLAIMS = "dao:svoting:claims"; bytes32 CONTRACT_DAO_IDENTITY = "dao:identity"; bytes32 CONTRACT_DAO_REWARDS_MANAGER = "dao:rewards-manager"; bytes32 CONTRACT_DAO_REWARDS_MANAGER_EXTRAS = "dao:rewards-extras"; bytes32 CONTRACT_DAO_ROLES = "dao:roles"; bytes32 CONTRACT_DAO_FUNDING_MANAGER = "dao:funding-manager"; bytes32 CONTRACT_DAO_WHITELISTING = "dao:whitelisting"; bytes32 CONTRACT_DAO_INFORMATION = "dao:information"; // service contracts bytes32 CONTRACT_SERVICE_ROLE = "service:role"; bytes32 CONTRACT_SERVICE_DAO_INFO = "service:dao:info"; bytes32 CONTRACT_SERVICE_DAO_LISTING = "service:dao:listing"; bytes32 CONTRACT_SERVICE_DAO_CALCULATOR = "service:dao:calculator"; // storage contracts bytes32 CONTRACT_STORAGE_DAO = "storage:dao"; bytes32 CONTRACT_STORAGE_DAO_COUNTER = "storage:dao:counter"; bytes32 CONTRACT_STORAGE_DAO_UPGRADE = "storage:dao:upgrade"; bytes32 CONTRACT_STORAGE_DAO_IDENTITY = "storage:dao:identity"; bytes32 CONTRACT_STORAGE_DAO_POINTS = "storage:dao:points"; bytes32 CONTRACT_STORAGE_DAO_SPECIAL = "storage:dao:special"; bytes32 CONTRACT_STORAGE_DAO_CONFIG = "storage:dao:config"; bytes32 CONTRACT_STORAGE_DAO_STAKE = "storage:dao:stake"; bytes32 CONTRACT_STORAGE_DAO_REWARDS = "storage:dao:rewards"; bytes32 CONTRACT_STORAGE_DAO_WHITELISTING = "storage:dao:whitelisting"; bytes32 CONTRACT_STORAGE_INTERMEDIATE_RESULTS = "storage:intermediate:results"; bytes32 CONTRACT_DGD_TOKEN = "t:dgd"; bytes32 CONTRACT_DGX_TOKEN = "t:dgx"; bytes32 CONTRACT_BADGE_TOKEN = "t:badge"; uint8 ROLES_ROOT = 1; uint8 ROLES_FOUNDERS = 2; uint8 ROLES_PRLS = 3; uint8 ROLES_KYC_ADMINS = 4; uint256 QUARTER_DURATION = 90 days; bytes32 CONFIG_MINIMUM_LOCKED_DGD = "min_dgd_participant"; bytes32 CONFIG_MINIMUM_DGD_FOR_MODERATOR = "min_dgd_moderator"; bytes32 CONFIG_MINIMUM_REPUTATION_FOR_MODERATOR = "min_reputation_moderator"; bytes32 CONFIG_LOCKING_PHASE_DURATION = "locking_phase_duration"; bytes32 CONFIG_QUARTER_DURATION = "quarter_duration"; bytes32 CONFIG_VOTING_COMMIT_PHASE = "voting_commit_phase"; bytes32 CONFIG_VOTING_PHASE_TOTAL = "voting_phase_total"; bytes32 CONFIG_INTERIM_COMMIT_PHASE = "interim_voting_commit_phase"; bytes32 CONFIG_INTERIM_PHASE_TOTAL = "interim_voting_phase_total"; bytes32 CONFIG_DRAFT_QUORUM_FIXED_PORTION_NUMERATOR = "draft_quorum_fixed_numerator"; bytes32 CONFIG_DRAFT_QUORUM_FIXED_PORTION_DENOMINATOR = "draft_quorum_fixed_denominator"; bytes32 CONFIG_DRAFT_QUORUM_SCALING_FACTOR_NUMERATOR = "draft_quorum_sfactor_numerator"; bytes32 CONFIG_DRAFT_QUORUM_SCALING_FACTOR_DENOMINATOR = "draft_quorum_sfactor_denominator"; bytes32 CONFIG_VOTING_QUORUM_FIXED_PORTION_NUMERATOR = "vote_quorum_fixed_numerator"; bytes32 CONFIG_VOTING_QUORUM_FIXED_PORTION_DENOMINATOR = "vote_quorum_fixed_denominator"; bytes32 CONFIG_VOTING_QUORUM_SCALING_FACTOR_NUMERATOR = "vote_quorum_sfactor_numerator"; bytes32 CONFIG_VOTING_QUORUM_SCALING_FACTOR_DENOMINATOR = "vote_quorum_sfactor_denominator"; bytes32 CONFIG_FINAL_REWARD_SCALING_FACTOR_NUMERATOR = "final_reward_sfactor_numerator"; bytes32 CONFIG_FINAL_REWARD_SCALING_FACTOR_DENOMINATOR = "final_reward_sfactor_denominator"; bytes32 CONFIG_DRAFT_QUOTA_NUMERATOR = "draft_quota_numerator"; bytes32 CONFIG_DRAFT_QUOTA_DENOMINATOR = "draft_quota_denominator"; bytes32 CONFIG_VOTING_QUOTA_NUMERATOR = "voting_quota_numerator"; bytes32 CONFIG_VOTING_QUOTA_DENOMINATOR = "voting_quota_denominator"; bytes32 CONFIG_MINIMAL_QUARTER_POINT = "minimal_qp"; bytes32 CONFIG_QUARTER_POINT_SCALING_FACTOR = "quarter_point_scaling_factor"; bytes32 CONFIG_REPUTATION_POINT_SCALING_FACTOR = "rep_point_scaling_factor"; bytes32 CONFIG_MODERATOR_MINIMAL_QUARTER_POINT = "minimal_mod_qp"; bytes32 CONFIG_MODERATOR_QUARTER_POINT_SCALING_FACTOR = "mod_qp_scaling_factor"; bytes32 CONFIG_MODERATOR_REPUTATION_POINT_SCALING_FACTOR = "mod_rep_point_scaling_factor"; bytes32 CONFIG_QUARTER_POINT_DRAFT_VOTE = "quarter_point_draft_vote"; bytes32 CONFIG_QUARTER_POINT_VOTE = "quarter_point_vote"; bytes32 CONFIG_QUARTER_POINT_INTERIM_VOTE = "quarter_point_interim_vote"; /// this is per 10000 ETHs bytes32 CONFIG_QUARTER_POINT_MILESTONE_COMPLETION_PER_10000ETH = "q_p_milestone_completion"; bytes32 CONFIG_BONUS_REPUTATION_NUMERATOR = "bonus_reputation_numerator"; bytes32 CONFIG_BONUS_REPUTATION_DENOMINATOR = "bonus_reputation_denominator"; bytes32 CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE = "special_proposal_commit_phase"; bytes32 CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL = "special_proposal_phase_total"; bytes32 CONFIG_SPECIAL_QUOTA_NUMERATOR = "config_special_quota_numerator"; bytes32 CONFIG_SPECIAL_QUOTA_DENOMINATOR = "config_special_quota_denominator"; bytes32 CONFIG_SPECIAL_PROPOSAL_QUORUM_NUMERATOR = "special_quorum_numerator"; bytes32 CONFIG_SPECIAL_PROPOSAL_QUORUM_DENOMINATOR = "special_quorum_denominator"; bytes32 CONFIG_MAXIMUM_REPUTATION_DEDUCTION = "config_max_reputation_deduction"; bytes32 CONFIG_PUNISHMENT_FOR_NOT_LOCKING = "config_punishment_not_locking"; bytes32 CONFIG_REPUTATION_PER_EXTRA_QP_NUM = "config_rep_per_extra_qp_num"; bytes32 CONFIG_REPUTATION_PER_EXTRA_QP_DEN = "config_rep_per_extra_qp_den"; bytes32 CONFIG_MAXIMUM_MODERATOR_REPUTATION_DEDUCTION = "config_max_m_rp_deduction"; bytes32 CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_NUM = "config_rep_per_extra_m_qp_num"; bytes32 CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_DEN = "config_rep_per_extra_m_qp_den"; bytes32 CONFIG_PORTION_TO_MODERATORS_NUM = "config_mod_portion_num"; bytes32 CONFIG_PORTION_TO_MODERATORS_DEN = "config_mod_portion_den"; bytes32 CONFIG_DRAFT_VOTING_PHASE = "config_draft_voting_phase"; bytes32 CONFIG_REPUTATION_POINT_BOOST_FOR_BADGE = "config_rp_boost_per_badge"; bytes32 CONFIG_VOTE_CLAIMING_DEADLINE = "config_claiming_deadline"; bytes32 CONFIG_PREPROPOSAL_COLLATERAL = "config_preproposal_collateral"; bytes32 CONFIG_MAX_FUNDING_FOR_NON_DIGIX = "config_max_funding_nonDigix"; bytes32 CONFIG_MAX_MILESTONES_FOR_NON_DIGIX = "config_max_milestones_nonDigix"; bytes32 CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER = "config_nonDigix_proposal_cap"; bytes32 CONFIG_PROPOSAL_DEAD_DURATION = "config_dead_duration"; bytes32 CONFIG_CARBON_VOTE_REPUTATION_BONUS = "config_cv_reputation"; } // File: @digix/cacp-contracts-dao/contracts/ACOwned.sol /// @title Owner based access control /// @author DigixGlobal contract ACOwned { address public owner; address public new_owner; bool is_ac_owned_init; /// @dev Modifier to check if msg.sender is the contract owner modifier if_owner() { require(is_owner()); _; } function init_ac_owned() internal returns (bool _success) { if (is_ac_owned_init == false) { owner = msg.sender; is_ac_owned_init = true; } _success = true; } function is_owner() private constant returns (bool _is_owner) { _is_owner = (msg.sender == owner); } function change_owner(address _new_owner) if_owner() public returns (bool _success) { new_owner = _new_owner; _success = true; } function claim_ownership() public returns (bool _success) { require(msg.sender == new_owner); owner = new_owner; _success = true; } } // File: @digix/cacp-contracts-dao/contracts/Constants.sol /// @title Some useful constants /// @author DigixGlobal contract Constants { address constant NULL_ADDRESS = address(0x0); uint256 constant ZERO = uint256(0); bytes32 constant EMPTY = bytes32(0x0); } // File: @digix/cacp-contracts-dao/contracts/ContractResolver.sol /// @title Contract Name Registry /// @author DigixGlobal contract ContractResolver is ACOwned, Constants { mapping (bytes32 => address) contracts; bool public locked_forever; modifier unless_registered(bytes32 _key) { require(contracts[_key] == NULL_ADDRESS); _; } modifier if_owner_origin() { require(tx.origin == owner); _; } /// Function modifier to check if msg.sender corresponds to the resolved address of a given key /// @param _contract The resolver key modifier if_sender_is(bytes32 _contract) { require(msg.sender == get_contract(_contract)); _; } modifier if_not_locked() { require(locked_forever == false); _; } /// @dev ContractResolver constructor will perform the following: 1. Set msg.sender as the contract owner. constructor() public { require(init_ac_owned()); locked_forever = false; } /// @dev Called at contract initialization /// @param _key bytestring for CACP name /// @param _contract_address The address of the contract to be registered /// @return _success if the operation is successful function init_register_contract(bytes32 _key, address _contract_address) if_owner_origin() if_not_locked() unless_registered(_key) public returns (bool _success) { require(_contract_address != NULL_ADDRESS); contracts[_key] = _contract_address; _success = true; } /// @dev Lock the resolver from any further modifications. This can only be called from the owner /// @return _success if the operation is successful function lock_resolver_forever() if_owner public returns (bool _success) { locked_forever = true; _success = true; } /// @dev Get address of a contract /// @param _key the bytestring name of the contract to look up /// @return _contract the address of the contract function get_contract(bytes32 _key) public view returns (address _contract) { require(contracts[_key] != NULL_ADDRESS); _contract = contracts[_key]; } } // File: @digix/cacp-contracts-dao/contracts/ResolverClient.sol /// @title Contract Resolver Interface /// @author DigixGlobal contract ResolverClient { /// The address of the resolver contract for this project address public resolver; bytes32 public key; /// Make our own address available to us as a constant address public CONTRACT_ADDRESS; /// Function modifier to check if msg.sender corresponds to the resolved address of a given key /// @param _contract The resolver key modifier if_sender_is(bytes32 _contract) { require(sender_is(_contract)); _; } function sender_is(bytes32 _contract) internal view returns (bool _isFrom) { _isFrom = msg.sender == ContractResolver(resolver).get_contract(_contract); } modifier if_sender_is_from(bytes32[3] _contracts) { require(sender_is_from(_contracts)); _; } function sender_is_from(bytes32[3] _contracts) internal view returns (bool _isFrom) { uint256 _n = _contracts.length; for (uint256 i = 0; i < _n; i++) { if (_contracts[i] == bytes32(0x0)) continue; if (msg.sender == ContractResolver(resolver).get_contract(_contracts[i])) { _isFrom = true; break; } } } /// Function modifier to check resolver's locking status. modifier unless_resolver_is_locked() { require(is_locked() == false); _; } /// @dev Initialize new contract /// @param _key the resolver key for this contract /// @return _success if the initialization is successful function init(bytes32 _key, address _resolver) internal returns (bool _success) { bool _is_locked = ContractResolver(_resolver).locked_forever(); if (_is_locked == false) { CONTRACT_ADDRESS = address(this); resolver = _resolver; key = _key; require(ContractResolver(resolver).init_register_contract(key, CONTRACT_ADDRESS)); _success = true; } else { _success = false; } } /// @dev Check if resolver is locked /// @return _locked if the resolver is currently locked function is_locked() private view returns (bool _locked) { _locked = ContractResolver(resolver).locked_forever(); } /// @dev Get the address of a contract /// @param _key the resolver key to look up /// @return _contract the address of the contract function get_contract(bytes32 _key) public view returns (address _contract) { _contract = ContractResolver(resolver).get_contract(_key); } } // File: contracts/storage/DaoWhitelistingStorage.sol // This contract is basically created to restrict read access to // ethereum accounts, and whitelisted contracts contract DaoWhitelistingStorage is ResolverClient, DaoConstants { // we want to avoid the scenario in which an on-chain bribing contract // can be deployed to distribute funds in a trustless way by verifying // on-chain votes. This mapping marks whether a contract address is whitelisted // to read from the read functions in DaoStorage, DaoSpecialStorage, etc. mapping (address => bool) public whitelist; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_WHITELISTING, _resolver)); } function setWhitelisted(address _contractAddress, bool _senderIsAllowedToRead) public { require(sender_is(CONTRACT_DAO_WHITELISTING)); whitelist[_contractAddress] = _senderIsAllowedToRead; } } // File: contracts/common/DaoWhitelistingCommon.sol contract DaoWhitelistingCommon is ResolverClient, DaoConstants { function daoWhitelistingStorage() internal view returns (DaoWhitelistingStorage _contract) { _contract = DaoWhitelistingStorage(get_contract(CONTRACT_STORAGE_DAO_WHITELISTING)); } /** @notice Check if a certain address is whitelisted to read sensitive information in the storage layer @dev if the address is an account, it is allowed to read. If the address is a contract, it has to be in the whitelist */ function senderIsAllowedToRead() internal view returns (bool _senderIsAllowedToRead) { // msg.sender is allowed to read only if its an EOA or a whitelisted contract _senderIsAllowedToRead = (msg.sender == tx.origin) || daoWhitelistingStorage().whitelist(msg.sender); } } // File: contracts/lib/DaoStructs.sol library DaoStructs { using DoublyLinkedList for DoublyLinkedList.Bytes; using SafeMath for uint256; bytes32 constant EMPTY_BYTES = bytes32(0x0); struct PrlAction { // UTC timestamp at which the PRL action was done uint256 at; // IPFS hash of the document summarizing the action bytes32 doc; // Type of action // check PRL_ACTION_* in "./../common/DaoConstants.sol" uint256 actionId; } struct Voting { // UTC timestamp at which the voting round starts uint256 startTime; // Mapping of whether a commit was used in this voting round mapping (bytes32 => bool) usedCommits; // Mapping of commits by address. These are the commits during the commit phase in a voting round // This only stores the most recent commit in the voting round // In case a vote is edited, the previous commit is overwritten by the new commit // Only this new commit is verified at the reveal phase mapping (address => bytes32) commits; // This mapping is updated after the reveal phase, when votes are revealed // It is a mapping of address to weight of vote // Weight implies the lockedDGDStake of the address, at the time of revealing // If the address voted "NO", or didn't vote, this would be 0 mapping (address => uint256) yesVotes; // This mapping is updated after the reveal phase, when votes are revealed // It is a mapping of address to weight of vote // Weight implies the lockedDGDStake of the address, at the time of revealing // If the address voted "YES", or didn't vote, this would be 0 mapping (address => uint256) noVotes; // Boolean whether the voting round passed or not bool passed; // Boolean whether the voting round results were claimed or not // refer the claimProposalVotingResult function in "./../interative/DaoVotingClaims.sol" bool claimed; // Boolean whether the milestone following this voting round was funded or not // The milestone is funded when the proposer calls claimFunding in "./../interactive/DaoFundingManager.sol" bool funded; } struct ProposalVersion { // IPFS doc hash of this version of the proposal bytes32 docIpfsHash; // UTC timestamp at which this version was created uint256 created; // The number of milestones in the proposal as per this version uint256 milestoneCount; // The final reward asked by the proposer for completion of the entire proposal uint256 finalReward; // List of fundings required by the proposal as per this version // The numbers are in wei uint256[] milestoneFundings; // When a proposal is finalized (calling Dao.finalizeProposal), the proposer can no longer add proposal versions // However, they can still add more details to this final proposal version, in the form of IPFS docs. // These IPFS docs are stored in this array bytes32[] moreDocs; } struct Proposal { // ID of the proposal. Also the IPFS hash of the first ProposalVersion bytes32 proposalId; // current state of the proposal // refer PROPOSAL_STATE_* in "./../common/DaoConstants.sol" bytes32 currentState; // UTC timestamp at which the proposal was created uint256 timeCreated; // DoublyLinkedList of IPFS doc hashes of the various versions of the proposal DoublyLinkedList.Bytes proposalVersionDocs; // Mapping of version (IPFS doc hash) to ProposalVersion struct mapping (bytes32 => ProposalVersion) proposalVersions; // Voting struct for the draft voting round Voting draftVoting; // Mapping of voting round index (starts from 0) to Voting struct // votingRounds[0] is the Voting round of the proposal, which lasts for get_uint_config(CONFIG_VOTING_PHASE_TOTAL) // votingRounds[i] for i>0 are the Interim Voting rounds of the proposal, which lasts for get_uint_config(CONFIG_INTERIM_PHASE_TOTAL) mapping (uint256 => Voting) votingRounds; // Every proposal has a collateral tied to it with a value of // get_uint_config(CONFIG_PREPROPOSAL_COLLATERAL) (refer "./../storage/DaoConfigsStorage.sol") // Collateral can be in different states // refer COLLATERAL_STATUS_* in "./../common/DaoConstants.sol" uint256 collateralStatus; uint256 collateralAmount; // The final version of the proposal // Every proposal needs to be finalized before it can be voted on // This is the IPFS doc hash of the final version bytes32 finalVersion; // List of PrlAction structs // These are all the actions done by the PRL on the proposal PrlAction[] prlActions; // Address of the user who created the proposal address proposer; // Address of the moderator who endorsed the proposal address endorser; // Boolean whether the proposal is paused/stopped at the moment bool isPausedOrStopped; // Boolean whether the proposal was created by a founder role bool isDigix; } function countVotes(Voting storage _voting, address[] _allUsers) external view returns (uint256 _for, uint256 _against) { uint256 _n = _allUsers.length; for (uint256 i = 0; i < _n; i++) { if (_voting.yesVotes[_allUsers[i]] > 0) { _for = _for.add(_voting.yesVotes[_allUsers[i]]); } else if (_voting.noVotes[_allUsers[i]] > 0) { _against = _against.add(_voting.noVotes[_allUsers[i]]); } } } // get the list of voters who voted _vote (true-yes/false-no) function listVotes(Voting storage _voting, address[] _allUsers, bool _vote) external view returns (address[] memory _voters, uint256 _length) { uint256 _n = _allUsers.length; uint256 i; _length = 0; _voters = new address[](_n); if (_vote == true) { for (i = 0; i < _n; i++) { if (_voting.yesVotes[_allUsers[i]] > 0) { _voters[_length] = _allUsers[i]; _length++; } } } else { for (i = 0; i < _n; i++) { if (_voting.noVotes[_allUsers[i]] > 0) { _voters[_length] = _allUsers[i]; _length++; } } } } function readVote(Voting storage _voting, address _voter) public view returns (bool _vote, uint256 _weight) { if (_voting.yesVotes[_voter] > 0) { _weight = _voting.yesVotes[_voter]; _vote = true; } else { _weight = _voting.noVotes[_voter]; // if _voter didnt vote at all, the weight will be 0 anyway _vote = false; } } function revealVote( Voting storage _voting, address _voter, bool _vote, uint256 _weight ) public { if (_vote) { _voting.yesVotes[_voter] = _weight; } else { _voting.noVotes[_voter] = _weight; } } function readVersion(ProposalVersion storage _version) public view returns ( bytes32 _doc, uint256 _created, uint256[] _milestoneFundings, uint256 _finalReward ) { _doc = _version.docIpfsHash; _created = _version.created; _milestoneFundings = _version.milestoneFundings; _finalReward = _version.finalReward; } // read the funding for a particular milestone of a finalized proposal // if _milestoneId is the same as _milestoneCount, it returns the final reward function readProposalMilestone(Proposal storage _proposal, uint256 _milestoneIndex) public view returns (uint256 _funding) { bytes32 _finalVersion = _proposal.finalVersion; uint256 _milestoneCount = _proposal.proposalVersions[_finalVersion].milestoneFundings.length; require(_milestoneIndex <= _milestoneCount); require(_finalVersion != EMPTY_BYTES); // the proposal must have been finalized if (_milestoneIndex < _milestoneCount) { _funding = _proposal.proposalVersions[_finalVersion].milestoneFundings[_milestoneIndex]; } else { _funding = _proposal.proposalVersions[_finalVersion].finalReward; } } function addProposalVersion( Proposal storage _proposal, bytes32 _newDoc, uint256[] _newMilestoneFundings, uint256 _finalReward ) public { _proposal.proposalVersionDocs.append(_newDoc); _proposal.proposalVersions[_newDoc].docIpfsHash = _newDoc; _proposal.proposalVersions[_newDoc].created = now; _proposal.proposalVersions[_newDoc].milestoneCount = _newMilestoneFundings.length; _proposal.proposalVersions[_newDoc].milestoneFundings = _newMilestoneFundings; _proposal.proposalVersions[_newDoc].finalReward = _finalReward; } struct SpecialProposal { // ID of the special proposal // This is the IPFS doc hash of the proposal bytes32 proposalId; // UTC timestamp at which the proposal was created uint256 timeCreated; // Voting struct for the special proposal Voting voting; // List of the new uint256 configs as per the special proposal uint256[] uintConfigs; // List of the new address configs as per the special proposal address[] addressConfigs; // List of the new bytes32 configs as per the special proposal bytes32[] bytesConfigs; // Address of the user who created the special proposal // This address should also be in the ROLES_FOUNDERS group // refer "./../storage/DaoIdentityStorage.sol" address proposer; } // All configs are as per the DaoConfigsStorage values at the time when // calculateGlobalRewardsBeforeNewQuarter is called by founder in that quarter struct DaoQuarterInfo { // The minimum quarter points required // below this, reputation will be deducted uint256 minimalParticipationPoint; // The scaling factor for quarter point uint256 quarterPointScalingFactor; // The scaling factor for reputation point uint256 reputationPointScalingFactor; // The summation of effectiveDGDs in the previous quarter // The effectiveDGDs represents the effective participation in DigixDAO in a quarter // Which depends on lockedDGDStake, quarter point and reputation point // This value is the summation of all participant effectiveDGDs // It will be used to calculate the fraction of effectiveDGD a user has, // which will determine his portion of DGX rewards for that quarter uint256 totalEffectiveDGDPreviousQuarter; // The minimum moderator quarter point required // below this, reputation will be deducted for moderators uint256 moderatorMinimalParticipationPoint; // the scaling factor for moderator quarter point uint256 moderatorQuarterPointScalingFactor; // the scaling factor for moderator reputation point uint256 moderatorReputationPointScalingFactor; // The summation of effectiveDGDs (only specific to moderators) uint256 totalEffectiveModeratorDGDLastQuarter; // UTC timestamp from which the DGX rewards for the previous quarter are distributable to Holders uint256 dgxDistributionDay; // This is the rewards pool for the previous quarter. This is the sum of the DGX fees coming in from the collector, and the demurrage that has incurred // when user call claimRewards() in the previous quarter. // more graphical explanation: https://ipfs.io/ipfs/QmZDgFFMbyF3dvuuDfoXv5F6orq4kaDPo7m3QvnseUguzo uint256 dgxRewardsPoolLastQuarter; // The summation of all dgxRewardsPoolLastQuarter up until this quarter uint256 sumRewardsFromBeginning; } // There are many function calls where all calculations/summations cannot be done in one transaction // and require multiple transactions. // This struct stores the intermediate results in between the calculating transactions // These intermediate results are stored in IntermediateResultsStorage struct IntermediateResults { // weight of "FOR" votes counted up until the current calculation step uint256 currentForCount; // weight of "AGAINST" votes counted up until the current calculation step uint256 currentAgainstCount; // summation of effectiveDGDs up until the iteration of calculation uint256 currentSumOfEffectiveBalance; // Address of user until which the calculation has been done address countedUntil; } } // File: contracts/storage/DaoStorage.sol contract DaoStorage is DaoWhitelistingCommon, BytesIteratorStorage { using DoublyLinkedList for DoublyLinkedList.Bytes; using DaoStructs for DaoStructs.Voting; using DaoStructs for DaoStructs.Proposal; using DaoStructs for DaoStructs.ProposalVersion; // List of all the proposals ever created in DigixDAO DoublyLinkedList.Bytes allProposals; // mapping of Proposal struct by its ID // ID is also the IPFS doc hash of the first ever version of this proposal mapping (bytes32 => DaoStructs.Proposal) proposalsById; // mapping from state of a proposal to list of all proposals in that state // proposals are added/removed from the state's list as their states change // eg. when proposal is endorsed, when proposal is funded, etc mapping (bytes32 => DoublyLinkedList.Bytes) proposalsByState; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO, _resolver)); } /////////////////////////////// READ FUNCTIONS ////////////////////////////// /// @notice read all information and details of proposal /// @param _proposalId Proposal ID, i.e. hash of IPFS doc Proposal ID, i.e. hash of IPFS doc /// return { /// "_doc": "Original IPFS doc of proposal, also ID of proposal", /// "_proposer": "Address of the proposer", /// "_endorser": "Address of the moderator that endorsed the proposal", /// "_state": "Current state of the proposal", /// "_timeCreated": "UTC timestamp at which proposal was created", /// "_nVersions": "Number of versions of the proposal", /// "_latestVersionDoc": "IPFS doc hash of the latest version of this proposal", /// "_finalVersion": "If finalized, the version of the final proposal", /// "_pausedOrStopped": "If the proposal is paused/stopped at the moment", /// "_isDigixProposal": "If the proposal has been created by founder or not" /// } function readProposal(bytes32 _proposalId) public view returns ( bytes32 _doc, address _proposer, address _endorser, bytes32 _state, uint256 _timeCreated, uint256 _nVersions, bytes32 _latestVersionDoc, bytes32 _finalVersion, bool _pausedOrStopped, bool _isDigixProposal ) { require(senderIsAllowedToRead()); DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _doc = _proposal.proposalId; _proposer = _proposal.proposer; _endorser = _proposal.endorser; _state = _proposal.currentState; _timeCreated = _proposal.timeCreated; _nVersions = read_total_bytesarray(_proposal.proposalVersionDocs); _latestVersionDoc = read_last_from_bytesarray(_proposal.proposalVersionDocs); _finalVersion = _proposal.finalVersion; _pausedOrStopped = _proposal.isPausedOrStopped; _isDigixProposal = _proposal.isDigix; } function readProposalProposer(bytes32 _proposalId) public view returns (address _proposer) { _proposer = proposalsById[_proposalId].proposer; } function readTotalPrlActions(bytes32 _proposalId) public view returns (uint256 _length) { _length = proposalsById[_proposalId].prlActions.length; } function readPrlAction(bytes32 _proposalId, uint256 _index) public view returns (uint256 _actionId, uint256 _time, bytes32 _doc) { DaoStructs.PrlAction[] memory _actions = proposalsById[_proposalId].prlActions; require(_index < _actions.length); _actionId = _actions[_index].actionId; _time = _actions[_index].at; _doc = _actions[_index].doc; } function readProposalDraftVotingResult(bytes32 _proposalId) public view returns (bool _result) { require(senderIsAllowedToRead()); _result = proposalsById[_proposalId].draftVoting.passed; } function readProposalVotingResult(bytes32 _proposalId, uint256 _index) public view returns (bool _result) { require(senderIsAllowedToRead()); _result = proposalsById[_proposalId].votingRounds[_index].passed; } function readProposalDraftVotingTime(bytes32 _proposalId) public view returns (uint256 _start) { require(senderIsAllowedToRead()); _start = proposalsById[_proposalId].draftVoting.startTime; } function readProposalVotingTime(bytes32 _proposalId, uint256 _index) public view returns (uint256 _start) { require(senderIsAllowedToRead()); _start = proposalsById[_proposalId].votingRounds[_index].startTime; } function readDraftVotingCount(bytes32 _proposalId, address[] _allUsers) external view returns (uint256 _for, uint256 _against) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].draftVoting.countVotes(_allUsers); } function readVotingCount(bytes32 _proposalId, uint256 _index, address[] _allUsers) external view returns (uint256 _for, uint256 _against) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].votingRounds[_index].countVotes(_allUsers); } function readVotingRoundVotes(bytes32 _proposalId, uint256 _index, address[] _allUsers, bool _vote) external view returns (address[] memory _voters, uint256 _length) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].votingRounds[_index].listVotes(_allUsers, _vote); } function readDraftVote(bytes32 _proposalId, address _voter) public view returns (bool _vote, uint256 _weight) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].draftVoting.readVote(_voter); } /// @notice returns the latest committed vote by a voter on a proposal /// @param _proposalId proposal ID /// @param _voter address of the voter /// @return { /// "_commitHash": "" /// } function readComittedVote(bytes32 _proposalId, uint256 _index, address _voter) public view returns (bytes32 _commitHash) { require(senderIsAllowedToRead()); _commitHash = proposalsById[_proposalId].votingRounds[_index].commits[_voter]; } function readVote(bytes32 _proposalId, uint256 _index, address _voter) public view returns (bool _vote, uint256 _weight) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].votingRounds[_index].readVote(_voter); } /// @notice get all information and details of the first proposal /// return { /// "_id": "" /// } function getFirstProposal() public view returns (bytes32 _id) { _id = read_first_from_bytesarray(allProposals); } /// @notice get all information and details of the last proposal /// return { /// "_id": "" /// } function getLastProposal() public view returns (bytes32 _id) { _id = read_last_from_bytesarray(allProposals); } /// @notice get all information and details of proposal next to _proposalId /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// return { /// "_id": "" /// } function getNextProposal(bytes32 _proposalId) public view returns (bytes32 _id) { _id = read_next_from_bytesarray( allProposals, _proposalId ); } /// @notice get all information and details of proposal previous to _proposalId /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// return { /// "_id": "" /// } function getPreviousProposal(bytes32 _proposalId) public view returns (bytes32 _id) { _id = read_previous_from_bytesarray( allProposals, _proposalId ); } /// @notice get all information and details of the first proposal in state _stateId /// @param _stateId State ID of the proposal /// return { /// "_id": "" /// } function getFirstProposalInState(bytes32 _stateId) public view returns (bytes32 _id) { require(senderIsAllowedToRead()); _id = read_first_from_bytesarray(proposalsByState[_stateId]); } /// @notice get all information and details of the last proposal in state _stateId /// @param _stateId State ID of the proposal /// return { /// "_id": "" /// } function getLastProposalInState(bytes32 _stateId) public view returns (bytes32 _id) { require(senderIsAllowedToRead()); _id = read_last_from_bytesarray(proposalsByState[_stateId]); } /// @notice get all information and details of the next proposal to _proposalId in state _stateId /// @param _stateId State ID of the proposal /// return { /// "_id": "" /// } function getNextProposalInState(bytes32 _stateId, bytes32 _proposalId) public view returns (bytes32 _id) { require(senderIsAllowedToRead()); _id = read_next_from_bytesarray( proposalsByState[_stateId], _proposalId ); } /// @notice get all information and details of the previous proposal to _proposalId in state _stateId /// @param _stateId State ID of the proposal /// return { /// "_id": "" /// } function getPreviousProposalInState(bytes32 _stateId, bytes32 _proposalId) public view returns (bytes32 _id) { require(senderIsAllowedToRead()); _id = read_previous_from_bytesarray( proposalsByState[_stateId], _proposalId ); } /// @notice read proposal version details for a specific version /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// @param _version Version of proposal, i.e. hash of IPFS doc for specific version /// return { /// "_doc": "", /// "_created": "", /// "_milestoneFundings": "" /// } function readProposalVersion(bytes32 _proposalId, bytes32 _version) public view returns ( bytes32 _doc, uint256 _created, uint256[] _milestoneFundings, uint256 _finalReward ) { return proposalsById[_proposalId].proposalVersions[_version].readVersion(); } /** @notice Read the fundings of a finalized proposal @return { "_fundings": "fundings for the milestones", "_finalReward": "the final reward" } */ function readProposalFunding(bytes32 _proposalId) public view returns (uint256[] memory _fundings, uint256 _finalReward) { require(senderIsAllowedToRead()); bytes32 _finalVersion = proposalsById[_proposalId].finalVersion; require(_finalVersion != EMPTY_BYTES); _fundings = proposalsById[_proposalId].proposalVersions[_finalVersion].milestoneFundings; _finalReward = proposalsById[_proposalId].proposalVersions[_finalVersion].finalReward; } function readProposalMilestone(bytes32 _proposalId, uint256 _index) public view returns (uint256 _funding) { require(senderIsAllowedToRead()); _funding = proposalsById[_proposalId].readProposalMilestone(_index); } /// @notice get proposal version details for the first version /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// return { /// "_version": "" /// } function getFirstProposalVersion(bytes32 _proposalId) public view returns (bytes32 _version) { DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _version = read_first_from_bytesarray(_proposal.proposalVersionDocs); } /// @notice get proposal version details for the last version /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// return { /// "_version": "" /// } function getLastProposalVersion(bytes32 _proposalId) public view returns (bytes32 _version) { DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _version = read_last_from_bytesarray(_proposal.proposalVersionDocs); } /// @notice get proposal version details for the next version to _version /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// @param _version Version of proposal /// return { /// "_nextVersion": "" /// } function getNextProposalVersion(bytes32 _proposalId, bytes32 _version) public view returns (bytes32 _nextVersion) { DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _nextVersion = read_next_from_bytesarray( _proposal.proposalVersionDocs, _version ); } /// @notice get proposal version details for the previous version to _version /// @param _proposalId Proposal ID, i.e. hash of IPFS doc /// @param _version Version of proposal /// return { /// "_previousVersion": "" /// } function getPreviousProposalVersion(bytes32 _proposalId, bytes32 _version) public view returns (bytes32 _previousVersion) { DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _previousVersion = read_previous_from_bytesarray( _proposal.proposalVersionDocs, _version ); } function isDraftClaimed(bytes32 _proposalId) public view returns (bool _claimed) { _claimed = proposalsById[_proposalId].draftVoting.claimed; } function isClaimed(bytes32 _proposalId, uint256 _index) public view returns (bool _claimed) { _claimed = proposalsById[_proposalId].votingRounds[_index].claimed; } function readProposalCollateralStatus(bytes32 _proposalId) public view returns (uint256 _status) { require(senderIsAllowedToRead()); _status = proposalsById[_proposalId].collateralStatus; } function readProposalCollateralAmount(bytes32 _proposalId) public view returns (uint256 _amount) { _amount = proposalsById[_proposalId].collateralAmount; } /// @notice Read the additional docs that are added after the proposal is finalized /// @dev Will throw if the propsal is not finalized yet function readProposalDocs(bytes32 _proposalId) public view returns (bytes32[] _moreDocs) { bytes32 _finalVersion = proposalsById[_proposalId].finalVersion; require(_finalVersion != EMPTY_BYTES); _moreDocs = proposalsById[_proposalId].proposalVersions[_finalVersion].moreDocs; } function readIfMilestoneFunded(bytes32 _proposalId, uint256 _milestoneId) public view returns (bool _funded) { require(senderIsAllowedToRead()); _funded = proposalsById[_proposalId].votingRounds[_milestoneId].funded; } ////////////////////////////// WRITE FUNCTIONS ////////////////////////////// function addProposal( bytes32 _doc, address _proposer, uint256[] _milestoneFundings, uint256 _finalReward, bool _isFounder ) external { require(sender_is(CONTRACT_DAO)); require( (proposalsById[_doc].proposalId == EMPTY_BYTES) && (_doc != EMPTY_BYTES) ); allProposals.append(_doc); proposalsByState[PROPOSAL_STATE_PREPROPOSAL].append(_doc); proposalsById[_doc].proposalId = _doc; proposalsById[_doc].proposer = _proposer; proposalsById[_doc].currentState = PROPOSAL_STATE_PREPROPOSAL; proposalsById[_doc].timeCreated = now; proposalsById[_doc].isDigix = _isFounder; proposalsById[_doc].addProposalVersion(_doc, _milestoneFundings, _finalReward); } function editProposal( bytes32 _proposalId, bytes32 _newDoc, uint256[] _newMilestoneFundings, uint256 _finalReward ) external { require(sender_is(CONTRACT_DAO)); proposalsById[_proposalId].addProposalVersion(_newDoc, _newMilestoneFundings, _finalReward); } /// @notice change fundings of a proposal /// @dev Will throw if the proposal is not finalized yet function changeFundings(bytes32 _proposalId, uint256[] _newMilestoneFundings, uint256 _finalReward) external { require(sender_is(CONTRACT_DAO)); bytes32 _finalVersion = proposalsById[_proposalId].finalVersion; require(_finalVersion != EMPTY_BYTES); proposalsById[_proposalId].proposalVersions[_finalVersion].milestoneFundings = _newMilestoneFundings; proposalsById[_proposalId].proposalVersions[_finalVersion].finalReward = _finalReward; } /// @dev Will throw if the proposal is not finalized yet function addProposalDoc(bytes32 _proposalId, bytes32 _newDoc) public { require(sender_is(CONTRACT_DAO)); bytes32 _finalVersion = proposalsById[_proposalId].finalVersion; require(_finalVersion != EMPTY_BYTES); //already checked in interactive layer, but why not proposalsById[_proposalId].proposalVersions[_finalVersion].moreDocs.push(_newDoc); } function finalizeProposal(bytes32 _proposalId) public { require(sender_is(CONTRACT_DAO)); proposalsById[_proposalId].finalVersion = getLastProposalVersion(_proposalId); } function updateProposalEndorse( bytes32 _proposalId, address _endorser ) public { require(sender_is(CONTRACT_DAO)); DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; _proposal.endorser = _endorser; _proposal.currentState = PROPOSAL_STATE_DRAFT; proposalsByState[PROPOSAL_STATE_PREPROPOSAL].remove_item(_proposalId); proposalsByState[PROPOSAL_STATE_DRAFT].append(_proposalId); } function setProposalDraftPass(bytes32 _proposalId, bool _result) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); proposalsById[_proposalId].draftVoting.passed = _result; if (_result) { proposalsByState[PROPOSAL_STATE_DRAFT].remove_item(_proposalId); proposalsByState[PROPOSAL_STATE_MODERATED].append(_proposalId); proposalsById[_proposalId].currentState = PROPOSAL_STATE_MODERATED; } else { closeProposalInternal(_proposalId); } } function setProposalPass(bytes32 _proposalId, uint256 _index, bool _result) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); if (!_result) { closeProposalInternal(_proposalId); } else if (_index == 0) { proposalsByState[PROPOSAL_STATE_MODERATED].remove_item(_proposalId); proposalsByState[PROPOSAL_STATE_ONGOING].append(_proposalId); proposalsById[_proposalId].currentState = PROPOSAL_STATE_ONGOING; } proposalsById[_proposalId].votingRounds[_index].passed = _result; } function setProposalDraftVotingTime( bytes32 _proposalId, uint256 _time ) public { require(sender_is(CONTRACT_DAO)); proposalsById[_proposalId].draftVoting.startTime = _time; } function setProposalVotingTime( bytes32 _proposalId, uint256 _index, uint256 _time ) public { require(sender_is_from([CONTRACT_DAO, CONTRACT_DAO_VOTING_CLAIMS, EMPTY_BYTES])); proposalsById[_proposalId].votingRounds[_index].startTime = _time; } function setDraftVotingClaim(bytes32 _proposalId, bool _claimed) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); proposalsById[_proposalId].draftVoting.claimed = _claimed; } function setVotingClaim(bytes32 _proposalId, uint256 _index, bool _claimed) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); proposalsById[_proposalId].votingRounds[_index].claimed = _claimed; } function setProposalCollateralStatus(bytes32 _proposalId, uint256 _status) public { require(sender_is_from([CONTRACT_DAO_VOTING_CLAIMS, CONTRACT_DAO_FUNDING_MANAGER, CONTRACT_DAO])); proposalsById[_proposalId].collateralStatus = _status; } function setProposalCollateralAmount(bytes32 _proposalId, uint256 _amount) public { require(sender_is(CONTRACT_DAO)); proposalsById[_proposalId].collateralAmount = _amount; } function updateProposalPRL( bytes32 _proposalId, uint256 _action, bytes32 _doc, uint256 _time ) public { require(sender_is(CONTRACT_DAO)); require(proposalsById[_proposalId].currentState != PROPOSAL_STATE_CLOSED); DaoStructs.PrlAction memory prlAction; prlAction.at = _time; prlAction.doc = _doc; prlAction.actionId = _action; proposalsById[_proposalId].prlActions.push(prlAction); if (_action == PRL_ACTION_PAUSE) { proposalsById[_proposalId].isPausedOrStopped = true; } else if (_action == PRL_ACTION_UNPAUSE) { proposalsById[_proposalId].isPausedOrStopped = false; } else { // STOP proposalsById[_proposalId].isPausedOrStopped = true; closeProposalInternal(_proposalId); } } function closeProposalInternal(bytes32 _proposalId) internal { bytes32 _currentState = proposalsById[_proposalId].currentState; proposalsByState[_currentState].remove_item(_proposalId); proposalsByState[PROPOSAL_STATE_CLOSED].append(_proposalId); proposalsById[_proposalId].currentState = PROPOSAL_STATE_CLOSED; } function addDraftVote( bytes32 _proposalId, address _voter, bool _vote, uint256 _weight ) public { require(sender_is(CONTRACT_DAO_VOTING)); DaoStructs.Proposal storage _proposal = proposalsById[_proposalId]; if (_vote) { _proposal.draftVoting.yesVotes[_voter] = _weight; if (_proposal.draftVoting.noVotes[_voter] > 0) { // minimize number of writes to storage, since EIP-1087 is not implemented yet _proposal.draftVoting.noVotes[_voter] = 0; } } else { _proposal.draftVoting.noVotes[_voter] = _weight; if (_proposal.draftVoting.yesVotes[_voter] > 0) { _proposal.draftVoting.yesVotes[_voter] = 0; } } } function commitVote( bytes32 _proposalId, bytes32 _hash, address _voter, uint256 _index ) public { require(sender_is(CONTRACT_DAO_VOTING)); proposalsById[_proposalId].votingRounds[_index].commits[_voter] = _hash; } function revealVote( bytes32 _proposalId, address _voter, bool _vote, uint256 _weight, uint256 _index ) public { require(sender_is(CONTRACT_DAO_VOTING)); proposalsById[_proposalId].votingRounds[_index].revealVote(_voter, _vote, _weight); } function closeProposal(bytes32 _proposalId) public { require(sender_is(CONTRACT_DAO)); closeProposalInternal(_proposalId); } function archiveProposal(bytes32 _proposalId) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); bytes32 _currentState = proposalsById[_proposalId].currentState; proposalsByState[_currentState].remove_item(_proposalId); proposalsByState[PROPOSAL_STATE_ARCHIVED].append(_proposalId); proposalsById[_proposalId].currentState = PROPOSAL_STATE_ARCHIVED; } function setMilestoneFunded(bytes32 _proposalId, uint256 _milestoneId) public { require(sender_is(CONTRACT_DAO_FUNDING_MANAGER)); proposalsById[_proposalId].votingRounds[_milestoneId].funded = true; } } // File: @digix/solidity-collections/contracts/abstract/AddressIteratorStorage.sol /** @title Address Iterator Storage @author DigixGlobal Pte Ltd @notice See: [Doubly Linked List](/DoublyLinkedList) */ contract AddressIteratorStorage { // Initialize Doubly Linked List of Address using DoublyLinkedList for DoublyLinkedList.Address; /** @notice Reads the first item from the list of Address @param _list The source list @return {"_item" : "The first item from the list"} */ function read_first_from_addresses(DoublyLinkedList.Address storage _list) internal constant returns (address _item) { _item = _list.start_item(); } /** @notice Reads the last item from the list of Address @param _list The source list @return {"_item" : "The last item from the list"} */ function read_last_from_addresses(DoublyLinkedList.Address storage _list) internal constant returns (address _item) { _item = _list.end_item(); } /** @notice Reads the next item on the list of Address @param _list The source list @param _current_item The current item to be used as base line @return {"_item" : "The next item from the list based on the specieid `_current_item`"} */ function read_next_from_addresses(DoublyLinkedList.Address storage _list, address _current_item) internal constant returns (address _item) { _item = _list.next_item(_current_item); } /** @notice Reads the previous item on the list of Address @param _list The source list @param _current_item The current item to be used as base line @return {"_item" : "The previous item from the list based on the spcified `_current_item`"} */ function read_previous_from_addresses(DoublyLinkedList.Address storage _list, address _current_item) internal constant returns (address _item) { _item = _list.previous_item(_current_item); } /** @notice Reads the list of Address and returns the length of the list @param _list The source list @return {"_count": "The lenght of the list"} */ function read_total_addresses(DoublyLinkedList.Address storage _list) internal constant returns (uint256 _count) { _count = _list.total(); } } // File: contracts/storage/DaoStakeStorage.sol contract DaoStakeStorage is ResolverClient, DaoConstants, AddressIteratorStorage { using DoublyLinkedList for DoublyLinkedList.Address; // This is the DGD stake of a user (one that is considered in the DAO) mapping (address => uint256) public lockedDGDStake; // This is the actual number of DGDs locked by user // may be more than the lockedDGDStake // in case they locked during the main phase mapping (address => uint256) public actualLockedDGD; // The total locked DGDs in the DAO (summation of lockedDGDStake) uint256 public totalLockedDGDStake; // The total locked DGDs by moderators uint256 public totalModeratorLockedDGDStake; // The list of participants in DAO // actual participants will be subset of this list DoublyLinkedList.Address allParticipants; // The list of moderators in DAO // actual moderators will be subset of this list DoublyLinkedList.Address allModerators; // Boolean to mark if an address has redeemed // reputation points for their DGD Badge mapping (address => bool) public redeemedBadge; // mapping to note whether an address has claimed their // reputation bonus for carbon vote participation mapping (address => bool) public carbonVoteBonusClaimed; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_STAKE, _resolver)); } function redeemBadge(address _user) public { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); redeemedBadge[_user] = true; } function setCarbonVoteBonusClaimed(address _user) public { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); carbonVoteBonusClaimed[_user] = true; } function updateTotalLockedDGDStake(uint256 _totalLockedDGDStake) public { require(sender_is_from([CONTRACT_DAO_STAKE_LOCKING, CONTRACT_DAO_REWARDS_MANAGER, EMPTY_BYTES])); totalLockedDGDStake = _totalLockedDGDStake; } function updateTotalModeratorLockedDGDs(uint256 _totalLockedDGDStake) public { require(sender_is_from([CONTRACT_DAO_STAKE_LOCKING, CONTRACT_DAO_REWARDS_MANAGER, EMPTY_BYTES])); totalModeratorLockedDGDStake = _totalLockedDGDStake; } function updateUserDGDStake(address _user, uint256 _actualLockedDGD, uint256 _lockedDGDStake) public { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); actualLockedDGD[_user] = _actualLockedDGD; lockedDGDStake[_user] = _lockedDGDStake; } function readUserDGDStake(address _user) public view returns ( uint256 _actualLockedDGD, uint256 _lockedDGDStake ) { _actualLockedDGD = actualLockedDGD[_user]; _lockedDGDStake = lockedDGDStake[_user]; } function addToParticipantList(address _user) public returns (bool _success) { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); _success = allParticipants.append(_user); } function removeFromParticipantList(address _user) public returns (bool _success) { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); _success = allParticipants.remove_item(_user); } function addToModeratorList(address _user) public returns (bool _success) { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); _success = allModerators.append(_user); } function removeFromModeratorList(address _user) public returns (bool _success) { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); _success = allModerators.remove_item(_user); } function isInParticipantList(address _user) public view returns (bool _is) { _is = allParticipants.find(_user) != 0; } function isInModeratorsList(address _user) public view returns (bool _is) { _is = allModerators.find(_user) != 0; } function readFirstModerator() public view returns (address _item) { _item = read_first_from_addresses(allModerators); } function readLastModerator() public view returns (address _item) { _item = read_last_from_addresses(allModerators); } function readNextModerator(address _current_item) public view returns (address _item) { _item = read_next_from_addresses(allModerators, _current_item); } function readPreviousModerator(address _current_item) public view returns (address _item) { _item = read_previous_from_addresses(allModerators, _current_item); } function readTotalModerators() public view returns (uint256 _total_count) { _total_count = read_total_addresses(allModerators); } function readFirstParticipant() public view returns (address _item) { _item = read_first_from_addresses(allParticipants); } function readLastParticipant() public view returns (address _item) { _item = read_last_from_addresses(allParticipants); } function readNextParticipant(address _current_item) public view returns (address _item) { _item = read_next_from_addresses(allParticipants, _current_item); } function readPreviousParticipant(address _current_item) public view returns (address _item) { _item = read_previous_from_addresses(allParticipants, _current_item); } function readTotalParticipant() public view returns (uint256 _total_count) { _total_count = read_total_addresses(allParticipants); } } // File: contracts/service/DaoListingService.sol /* import "@digix/cacp-contracts-dao/contracts/ResolverClient.sol"; */ /** @title Contract to list various storage states from DigixDAO @author Digix Holdings */ contract DaoListingService is AddressIteratorInteractive, BytesIteratorInteractive, IndexedBytesIteratorInteractive, DaoWhitelistingCommon { /** @notice Constructor @param _resolver address of contract resolver */ constructor(address _resolver) public { require(init(CONTRACT_SERVICE_DAO_LISTING, _resolver)); } function daoStakeStorage() internal view returns (DaoStakeStorage _contract) { _contract = DaoStakeStorage(get_contract(CONTRACT_STORAGE_DAO_STAKE)); } function daoStorage() internal view returns (DaoStorage _contract) { _contract = DaoStorage(get_contract(CONTRACT_STORAGE_DAO)); } /** @notice function to list moderators @dev note that this list may include some additional entries that are not moderators in the current quarter. This may happen if they were moderators in the previous quarter, but have not confirmed their participation in the current quarter. For a single address, a better way to know if moderator or not is: Dao.isModerator(_user) @param _count number of addresses to list @param _from_start boolean, whether to list from start or end @return { "_moderators": "list of moderator addresses" } */ function listModerators(uint256 _count, bool _from_start) public view returns (address[] _moderators) { _moderators = list_addresses( _count, daoStakeStorage().readFirstModerator, daoStakeStorage().readLastModerator, daoStakeStorage().readNextModerator, daoStakeStorage().readPreviousModerator, _from_start ); } /** @notice function to list moderators from a particular moderator @dev note that this list may include some additional entries that are not moderators in the current quarter. This may happen if they were moderators in the previous quarter, but have not confirmed their participation in the current quarter. For a single address, a better way to know if moderator or not is: Dao.isModerator(_user) Another note: this function will start listing AFTER the _currentModerator For example: we have [address1, address2, address3, address4]. listModeratorsFrom(address1, 2, true) = [address2, address3] @param _currentModerator start the list after this moderator address @param _count number of addresses to list @param _from_start boolean, whether to list from start or end @return { "_moderators": "list of moderator addresses" } */ function listModeratorsFrom( address _currentModerator, uint256 _count, bool _from_start ) public view returns (address[] _moderators) { _moderators = list_addresses_from( _currentModerator, _count, daoStakeStorage().readFirstModerator, daoStakeStorage().readLastModerator, daoStakeStorage().readNextModerator, daoStakeStorage().readPreviousModerator, _from_start ); } /** @notice function to list participants @dev note that this list may include some additional entries that are not participants in the current quarter. This may happen if they were participants in the previous quarter, but have not confirmed their participation in the current quarter. For a single address, a better way to know if participant or not is: Dao.isParticipant(_user) @param _count number of addresses to list @param _from_start boolean, whether to list from start or end @return { "_participants": "list of participant addresses" } */ function listParticipants(uint256 _count, bool _from_start) public view returns (address[] _participants) { _participants = list_addresses( _count, daoStakeStorage().readFirstParticipant, daoStakeStorage().readLastParticipant, daoStakeStorage().readNextParticipant, daoStakeStorage().readPreviousParticipant, _from_start ); } /** @notice function to list participants from a particular participant @dev note that this list may include some additional entries that are not participants in the current quarter. This may happen if they were participants in the previous quarter, but have not confirmed their participation in the current quarter. For a single address, a better way to know if participant or not is: contracts.dao.isParticipant(_user) Another note: this function will start listing AFTER the _currentParticipant For example: we have [address1, address2, address3, address4]. listParticipantsFrom(address1, 2, true) = [address2, address3] @param _currentParticipant list from AFTER this participant address @param _count number of addresses to list @param _from_start boolean, whether to list from start or end @return { "_participants": "list of participant addresses" } */ function listParticipantsFrom( address _currentParticipant, uint256 _count, bool _from_start ) public view returns (address[] _participants) { _participants = list_addresses_from( _currentParticipant, _count, daoStakeStorage().readFirstParticipant, daoStakeStorage().readLastParticipant, daoStakeStorage().readNextParticipant, daoStakeStorage().readPreviousParticipant, _from_start ); } /** @notice function to list _count no. of proposals @param _count number of proposals to list @param _from_start boolean value, true if count from start, false if count from end @return { "_proposals": "the list of proposal IDs" } */ function listProposals( uint256 _count, bool _from_start ) public view returns (bytes32[] _proposals) { _proposals = list_bytesarray( _count, daoStorage().getFirstProposal, daoStorage().getLastProposal, daoStorage().getNextProposal, daoStorage().getPreviousProposal, _from_start ); } /** @notice function to list _count no. of proposals from AFTER _currentProposal @param _currentProposal ID of proposal to list proposals from @param _count number of proposals to list @param _from_start boolean value, true if count forwards, false if count backwards @return { "_proposals": "the list of proposal IDs" } */ function listProposalsFrom( bytes32 _currentProposal, uint256 _count, bool _from_start ) public view returns (bytes32[] _proposals) { _proposals = list_bytesarray_from( _currentProposal, _count, daoStorage().getFirstProposal, daoStorage().getLastProposal, daoStorage().getNextProposal, daoStorage().getPreviousProposal, _from_start ); } /** @notice function to list _count no. of proposals in state _stateId @param _stateId state of proposal @param _count number of proposals to list @param _from_start boolean value, true if count from start, false if count from end @return { "_proposals": "the list of proposal IDs" } */ function listProposalsInState( bytes32 _stateId, uint256 _count, bool _from_start ) public view returns (bytes32[] _proposals) { require(senderIsAllowedToRead()); _proposals = list_indexed_bytesarray( _stateId, _count, daoStorage().getFirstProposalInState, daoStorage().getLastProposalInState, daoStorage().getNextProposalInState, daoStorage().getPreviousProposalInState, _from_start ); } /** @notice function to list _count no. of proposals in state _stateId from AFTER _currentProposal @param _stateId state of proposal @param _currentProposal ID of proposal to list proposals from @param _count number of proposals to list @param _from_start boolean value, true if count forwards, false if count backwards @return { "_proposals": "the list of proposal IDs" } */ function listProposalsInStateFrom( bytes32 _stateId, bytes32 _currentProposal, uint256 _count, bool _from_start ) public view returns (bytes32[] _proposals) { require(senderIsAllowedToRead()); _proposals = list_indexed_bytesarray_from( _stateId, _currentProposal, _count, daoStorage().getFirstProposalInState, daoStorage().getLastProposalInState, daoStorage().getNextProposalInState, daoStorage().getPreviousProposalInState, _from_start ); } /** @notice function to list proposal versions @param _proposalId ID of the proposal @param _count number of proposal versions to list @param _from_start boolean, true to list from start, false to list from end @return { "_versions": "list of proposal versions" } */ function listProposalVersions( bytes32 _proposalId, uint256 _count, bool _from_start ) public view returns (bytes32[] _versions) { _versions = list_indexed_bytesarray( _proposalId, _count, daoStorage().getFirstProposalVersion, daoStorage().getLastProposalVersion, daoStorage().getNextProposalVersion, daoStorage().getPreviousProposalVersion, _from_start ); } /** @notice function to list proposal versions from AFTER a particular version @param _proposalId ID of the proposal @param _currentVersion version to list _count versions from @param _count number of proposal versions to list @param _from_start boolean, true to list from start, false to list from end @return { "_versions": "list of proposal versions" } */ function listProposalVersionsFrom( bytes32 _proposalId, bytes32 _currentVersion, uint256 _count, bool _from_start ) public view returns (bytes32[] _versions) { _versions = list_indexed_bytesarray_from( _proposalId, _currentVersion, _count, daoStorage().getFirstProposalVersion, daoStorage().getLastProposalVersion, daoStorage().getNextProposalVersion, daoStorage().getPreviousProposalVersion, _from_start ); } } // File: @digix/solidity-collections/contracts/abstract/IndexedAddressIteratorStorage.sol /** @title Indexed Address IteratorStorage @author DigixGlobal Pte Ltd @notice This contract utilizes: [Doubly Linked List](/DoublyLinkedList) */ contract IndexedAddressIteratorStorage { using DoublyLinkedList for DoublyLinkedList.IndexedAddress; /** @notice Reads the first item from an Indexed Address Doubly Linked List @param _list The source list @param _collection_index Index of the Collection to evaluate @return {"_item" : "First item on the list"} */ function read_first_from_indexed_addresses(DoublyLinkedList.IndexedAddress storage _list, bytes32 _collection_index) internal constant returns (address _item) { _item = _list.start_item(_collection_index); } /** @notice Reads the last item from an Indexed Address Doubly Linked list @param _list The source list @param _collection_index Index of the Collection to evaluate @return {"_item" : "First item on the list"} */ function read_last_from_indexed_addresses(DoublyLinkedList.IndexedAddress storage _list, bytes32 _collection_index) internal constant returns (address _item) { _item = _list.end_item(_collection_index); } /** @notice Reads the next item from an Indexed Address Doubly Linked List based on the specified `_current_item` @param _list The source list @param _collection_index Index of the Collection to evaluate @param _current_item The current item to use as base line @return {"_item": "The next item on the list"} */ function read_next_from_indexed_addresses(DoublyLinkedList.IndexedAddress storage _list, bytes32 _collection_index, address _current_item) internal constant returns (address _item) { _item = _list.next_item(_collection_index, _current_item); } /** @notice Reads the previous item from an Index Address Doubly Linked List based on the specified `_current_item` @param _list The source list @param _collection_index Index of the Collection to evaluate @param _current_item The current item to use as base line @return {"_item" : "The previous item on the list"} */ function read_previous_from_indexed_addresses(DoublyLinkedList.IndexedAddress storage _list, bytes32 _collection_index, address _current_item) internal constant returns (address _item) { _item = _list.previous_item(_collection_index, _current_item); } /** @notice Reads the total number of items in an Indexed Address Doubly Linked List @param _list The source list @param _collection_index Index of the Collection to evaluate @return {"_count": "Length of the Doubly Linked list"} */ function read_total_indexed_addresses(DoublyLinkedList.IndexedAddress storage _list, bytes32 _collection_index) internal constant returns (uint256 _count) { _count = _list.total(_collection_index); } } // File: @digix/solidity-collections/contracts/abstract/UintIteratorStorage.sol /** @title Uint Iterator Storage @author DigixGlobal Pte Ltd */ contract UintIteratorStorage { using DoublyLinkedList for DoublyLinkedList.Uint; /** @notice Returns the first item from a `DoublyLinkedList.Uint` list @param _list The DoublyLinkedList.Uint list @return {"_item": "The first item"} */ function read_first_from_uints(DoublyLinkedList.Uint storage _list) internal constant returns (uint256 _item) { _item = _list.start_item(); } /** @notice Returns the last item from a `DoublyLinkedList.Uint` list @param _list The DoublyLinkedList.Uint list @return {"_item": "The last item"} */ function read_last_from_uints(DoublyLinkedList.Uint storage _list) internal constant returns (uint256 _item) { _item = _list.end_item(); } /** @notice Returns the next item from a `DoublyLinkedList.Uint` list based on the specified `_current_item` @param _list The DoublyLinkedList.Uint list @param _current_item The current item @return {"_item": "The next item"} */ function read_next_from_uints(DoublyLinkedList.Uint storage _list, uint256 _current_item) internal constant returns (uint256 _item) { _item = _list.next_item(_current_item); } /** @notice Returns the previous item from a `DoublyLinkedList.Uint` list based on the specified `_current_item` @param _list The DoublyLinkedList.Uint list @param _current_item The current item @return {"_item": "The previous item"} */ function read_previous_from_uints(DoublyLinkedList.Uint storage _list, uint256 _current_item) internal constant returns (uint256 _item) { _item = _list.previous_item(_current_item); } /** @notice Returns the total count of itemsfrom a `DoublyLinkedList.Uint` list @param _list The DoublyLinkedList.Uint list @return {"_count": "The total count of items"} */ function read_total_uints(DoublyLinkedList.Uint storage _list) internal constant returns (uint256 _count) { _count = _list.total(); } } // File: @digix/cdap/contracts/storage/DirectoryStorage.sol /** @title Directory Storage contains information of a directory @author DigixGlobal */ contract DirectoryStorage is IndexedAddressIteratorStorage, UintIteratorStorage { using DoublyLinkedList for DoublyLinkedList.IndexedAddress; using DoublyLinkedList for DoublyLinkedList.Uint; struct User { bytes32 document; bool active; } struct Group { bytes32 name; bytes32 document; uint256 role_id; mapping(address => User) members_by_address; } struct System { DoublyLinkedList.Uint groups; DoublyLinkedList.IndexedAddress groups_collection; mapping (uint256 => Group) groups_by_id; mapping (address => uint256) group_ids_by_address; mapping (uint256 => bytes32) roles_by_id; bool initialized; uint256 total_groups; } System system; /** @notice Initializes directory settings @return _success If directory initialization is successful */ function initialize_directory() internal returns (bool _success) { require(system.initialized == false); system.total_groups = 0; system.initialized = true; internal_create_role(1, "root"); internal_create_group(1, "root", ""); _success = internal_update_add_user_to_group(1, tx.origin, ""); } /** @notice Creates a new role with the given information @param _role_id Id of the new role @param _name Name of the new role @return {"_success": "If creation of new role is successful"} */ function internal_create_role(uint256 _role_id, bytes32 _name) internal returns (bool _success) { require(_role_id > 0); require(_name != bytes32(0x0)); system.roles_by_id[_role_id] = _name; _success = true; } /** @notice Returns the role's name of a role id @param _role_id Id of the role @return {"_name": "Name of the role"} */ function read_role(uint256 _role_id) public constant returns (bytes32 _name) { _name = system.roles_by_id[_role_id]; } /** @notice Creates a new group with the given information @param _role_id Role id of the new group @param _name Name of the new group @param _document Document of the new group @return { "_success": "If creation of the new group is successful", "_group_id: "Id of the new group" } */ function internal_create_group(uint256 _role_id, bytes32 _name, bytes32 _document) internal returns (bool _success, uint256 _group_id) { require(_role_id > 0); require(read_role(_role_id) != bytes32(0x0)); _group_id = ++system.total_groups; system.groups.append(_group_id); system.groups_by_id[_group_id].role_id = _role_id; system.groups_by_id[_group_id].name = _name; system.groups_by_id[_group_id].document = _document; _success = true; } /** @notice Returns the group's information @param _group_id Id of the group @return { "_role_id": "Role id of the group", "_name: "Name of the group", "_document: "Document of the group" } */ function read_group(uint256 _group_id) public constant returns (uint256 _role_id, bytes32 _name, bytes32 _document, uint256 _members_count) { if (system.groups.valid_item(_group_id)) { _role_id = system.groups_by_id[_group_id].role_id; _name = system.groups_by_id[_group_id].name; _document = system.groups_by_id[_group_id].document; _members_count = read_total_indexed_addresses(system.groups_collection, bytes32(_group_id)); } else { _role_id = 0; _name = "invalid"; _document = ""; _members_count = 0; } } /** @notice Adds new user with the given information to a group @param _group_id Id of the group @param _user Address of the new user @param _document Information of the new user @return {"_success": "If adding new user to a group is successful"} */ function internal_update_add_user_to_group(uint256 _group_id, address _user, bytes32 _document) internal returns (bool _success) { if (system.groups_by_id[_group_id].members_by_address[_user].active == false && system.group_ids_by_address[_user] == 0 && system.groups_by_id[_group_id].role_id != 0) { system.groups_by_id[_group_id].members_by_address[_user].active = true; system.group_ids_by_address[_user] = _group_id; system.groups_collection.append(bytes32(_group_id), _user); system.groups_by_id[_group_id].members_by_address[_user].document = _document; _success = true; } else { _success = false; } } /** @notice Removes user from its group @param _user Address of the user @return {"_success": "If removing of user is successful"} */ function internal_destroy_group_user(address _user) internal returns (bool _success) { uint256 _group_id = system.group_ids_by_address[_user]; if ((_group_id == 1) && (system.groups_collection.total(bytes32(_group_id)) == 1)) { _success = false; } else { system.groups_by_id[_group_id].members_by_address[_user].active = false; system.group_ids_by_address[_user] = 0; delete system.groups_by_id[_group_id].members_by_address[_user]; _success = system.groups_collection.remove_item(bytes32(_group_id), _user); } } /** @notice Returns the role id of a user @param _user Address of a user @return {"_role_id": "Role id of the user"} */ function read_user_role_id(address _user) constant public returns (uint256 _role_id) { uint256 _group_id = system.group_ids_by_address[_user]; _role_id = system.groups_by_id[_group_id].role_id; } /** @notice Returns the user's information @param _user Address of the user @return { "_group_id": "Group id of the user", "_role_id": "Role id of the user", "_document": "Information of the user" } */ function read_user(address _user) public constant returns (uint256 _group_id, uint256 _role_id, bytes32 _document) { _group_id = system.group_ids_by_address[_user]; _role_id = system.groups_by_id[_group_id].role_id; _document = system.groups_by_id[_group_id].members_by_address[_user].document; } /** @notice Returns the id of the first group @return {"_group_id": "Id of the first group"} */ function read_first_group() view external returns (uint256 _group_id) { _group_id = read_first_from_uints(system.groups); } /** @notice Returns the id of the last group @return {"_group_id": "Id of the last group"} */ function read_last_group() view external returns (uint256 _group_id) { _group_id = read_last_from_uints(system.groups); } /** @notice Returns the id of the previous group depending on the given current group @param _current_group_id Id of the current group @return {"_group_id": "Id of the previous group"} */ function read_previous_group_from_group(uint256 _current_group_id) view external returns (uint256 _group_id) { _group_id = read_previous_from_uints(system.groups, _current_group_id); } /** @notice Returns the id of the next group depending on the given current group @param _current_group_id Id of the current group @return {"_group_id": "Id of the next group"} */ function read_next_group_from_group(uint256 _current_group_id) view external returns (uint256 _group_id) { _group_id = read_next_from_uints(system.groups, _current_group_id); } /** @notice Returns the total number of groups @return {"_total_groups": "Total number of groups"} */ function read_total_groups() view external returns (uint256 _total_groups) { _total_groups = read_total_uints(system.groups); } /** @notice Returns the first user of a group @param _group_id Id of the group @return {"_user": "Address of the user"} */ function read_first_user_in_group(bytes32 _group_id) view external returns (address _user) { _user = read_first_from_indexed_addresses(system.groups_collection, bytes32(_group_id)); } /** @notice Returns the last user of a group @param _group_id Id of the group @return {"_user": "Address of the user"} */ function read_last_user_in_group(bytes32 _group_id) view external returns (address _user) { _user = read_last_from_indexed_addresses(system.groups_collection, bytes32(_group_id)); } /** @notice Returns the next user of a group depending on the given current user @param _group_id Id of the group @param _current_user Address of the current user @return {"_user": "Address of the next user"} */ function read_next_user_in_group(bytes32 _group_id, address _current_user) view external returns (address _user) { _user = read_next_from_indexed_addresses(system.groups_collection, bytes32(_group_id), _current_user); } /** @notice Returns the previous user of a group depending on the given current user @param _group_id Id of the group @param _current_user Address of the current user @return {"_user": "Address of the last user"} */ function read_previous_user_in_group(bytes32 _group_id, address _current_user) view external returns (address _user) { _user = read_previous_from_indexed_addresses(system.groups_collection, bytes32(_group_id), _current_user); } /** @notice Returns the total number of users of a group @param _group_id Id of the group @return {"_total_users": "Total number of users"} */ function read_total_users_in_group(bytes32 _group_id) view external returns (uint256 _total_users) { _total_users = read_total_indexed_addresses(system.groups_collection, bytes32(_group_id)); } } // File: contracts/storage/DaoIdentityStorage.sol contract DaoIdentityStorage is ResolverClient, DaoConstants, DirectoryStorage { // struct for KYC details // doc is the IPFS doc hash for any information regarding this KYC // id_expiration is the UTC timestamp at which this KYC will expire // at any time after this, the user's KYC is invalid, and that user // MUST re-KYC before doing any proposer related operation in DigixDAO struct KycDetails { bytes32 doc; uint256 id_expiration; } // a mapping of address to the KYC details mapping (address => KycDetails) kycInfo; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_IDENTITY, _resolver)); require(initialize_directory()); } function create_group(uint256 _role_id, bytes32 _name, bytes32 _document) public returns (bool _success, uint256 _group_id) { require(sender_is(CONTRACT_DAO_IDENTITY)); (_success, _group_id) = internal_create_group(_role_id, _name, _document); require(_success); } function create_role(uint256 _role_id, bytes32 _name) public returns (bool _success) { require(sender_is(CONTRACT_DAO_IDENTITY)); _success = internal_create_role(_role_id, _name); require(_success); } function update_add_user_to_group(uint256 _group_id, address _user, bytes32 _document) public returns (bool _success) { require(sender_is(CONTRACT_DAO_IDENTITY)); _success = internal_update_add_user_to_group(_group_id, _user, _document); require(_success); } function update_remove_group_user(address _user) public returns (bool _success) { require(sender_is(CONTRACT_DAO_IDENTITY)); _success = internal_destroy_group_user(_user); require(_success); } function update_kyc(address _user, bytes32 _doc, uint256 _id_expiration) public { require(sender_is(CONTRACT_DAO_IDENTITY)); kycInfo[_user].doc = _doc; kycInfo[_user].id_expiration = _id_expiration; } function read_kyc_info(address _user) public view returns (bytes32 _doc, uint256 _id_expiration) { _doc = kycInfo[_user].doc; _id_expiration = kycInfo[_user].id_expiration; } function is_kyc_approved(address _user) public view returns (bool _approved) { uint256 _id_expiration; (,_id_expiration) = read_kyc_info(_user); _approved = _id_expiration > now; } } // File: contracts/common/IdentityCommon.sol contract IdentityCommon is DaoWhitelistingCommon { modifier if_root() { require(identity_storage().read_user_role_id(msg.sender) == ROLES_ROOT); _; } modifier if_founder() { require(is_founder()); _; } function is_founder() internal view returns (bool _isFounder) { _isFounder = identity_storage().read_user_role_id(msg.sender) == ROLES_FOUNDERS; } modifier if_prl() { require(identity_storage().read_user_role_id(msg.sender) == ROLES_PRLS); _; } modifier if_kyc_admin() { require(identity_storage().read_user_role_id(msg.sender) == ROLES_KYC_ADMINS); _; } function identity_storage() internal view returns (DaoIdentityStorage _contract) { _contract = DaoIdentityStorage(get_contract(CONTRACT_STORAGE_DAO_IDENTITY)); } } // File: contracts/storage/DaoConfigsStorage.sol contract DaoConfigsStorage is ResolverClient, DaoConstants { // mapping of config name to config value // config names can be found in DaoConstants contract mapping (bytes32 => uint256) public uintConfigs; // mapping of config name to config value // config names can be found in DaoConstants contract mapping (bytes32 => address) public addressConfigs; // mapping of config name to config value // config names can be found in DaoConstants contract mapping (bytes32 => bytes32) public bytesConfigs; uint256 ONE_BILLION = 1000000000; uint256 ONE_MILLION = 1000000; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_CONFIG, _resolver)); uintConfigs[CONFIG_LOCKING_PHASE_DURATION] = 10 days; uintConfigs[CONFIG_QUARTER_DURATION] = QUARTER_DURATION; uintConfigs[CONFIG_VOTING_COMMIT_PHASE] = 14 days; uintConfigs[CONFIG_VOTING_PHASE_TOTAL] = 21 days; uintConfigs[CONFIG_INTERIM_COMMIT_PHASE] = 7 days; uintConfigs[CONFIG_INTERIM_PHASE_TOTAL] = 14 days; uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_NUMERATOR] = 5; // 5% uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_DENOMINATOR] = 100; // 5% uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_NUMERATOR] = 35; // 35% uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_DENOMINATOR] = 100; // 35% uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_NUMERATOR] = 5; // 5% uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_DENOMINATOR] = 100; // 5% uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_NUMERATOR] = 25; // 25% uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_DENOMINATOR] = 100; // 25% uintConfigs[CONFIG_DRAFT_QUOTA_NUMERATOR] = 1; // >50% uintConfigs[CONFIG_DRAFT_QUOTA_DENOMINATOR] = 2; // >50% uintConfigs[CONFIG_VOTING_QUOTA_NUMERATOR] = 1; // >50% uintConfigs[CONFIG_VOTING_QUOTA_DENOMINATOR] = 2; // >50% uintConfigs[CONFIG_QUARTER_POINT_DRAFT_VOTE] = ONE_BILLION; uintConfigs[CONFIG_QUARTER_POINT_VOTE] = ONE_BILLION; uintConfigs[CONFIG_QUARTER_POINT_INTERIM_VOTE] = ONE_BILLION; uintConfigs[CONFIG_QUARTER_POINT_MILESTONE_COMPLETION_PER_10000ETH] = 20000 * ONE_BILLION; uintConfigs[CONFIG_BONUS_REPUTATION_NUMERATOR] = 15; // 15% bonus for consistent votes uintConfigs[CONFIG_BONUS_REPUTATION_DENOMINATOR] = 100; // 15% bonus for consistent votes uintConfigs[CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE] = 28 days; uintConfigs[CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL] = 35 days; uintConfigs[CONFIG_SPECIAL_QUOTA_NUMERATOR] = 1; // >50% uintConfigs[CONFIG_SPECIAL_QUOTA_DENOMINATOR] = 2; // >50% uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_NUMERATOR] = 40; // 40% uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_DENOMINATOR] = 100; // 40% uintConfigs[CONFIG_MAXIMUM_REPUTATION_DEDUCTION] = 8334 * ONE_MILLION; uintConfigs[CONFIG_PUNISHMENT_FOR_NOT_LOCKING] = 1666 * ONE_MILLION; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_NUM] = 1; // 1 extra QP gains 1/1 RP uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_DEN] = 1; uintConfigs[CONFIG_MINIMAL_QUARTER_POINT] = 2 * ONE_BILLION; uintConfigs[CONFIG_QUARTER_POINT_SCALING_FACTOR] = 400 * ONE_BILLION; uintConfigs[CONFIG_REPUTATION_POINT_SCALING_FACTOR] = 2000 * ONE_BILLION; uintConfigs[CONFIG_MODERATOR_MINIMAL_QUARTER_POINT] = 4 * ONE_BILLION; uintConfigs[CONFIG_MODERATOR_QUARTER_POINT_SCALING_FACTOR] = 400 * ONE_BILLION; uintConfigs[CONFIG_MODERATOR_REPUTATION_POINT_SCALING_FACTOR] = 2000 * ONE_BILLION; uintConfigs[CONFIG_PORTION_TO_MODERATORS_NUM] = 42; //4.2% of DGX to moderator voting activity uintConfigs[CONFIG_PORTION_TO_MODERATORS_DEN] = 1000; uintConfigs[CONFIG_DRAFT_VOTING_PHASE] = 10 days; uintConfigs[CONFIG_REPUTATION_POINT_BOOST_FOR_BADGE] = 412500 * ONE_MILLION; uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_NUMERATOR] = 7; // 7% uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_DENOMINATOR] = 100; // 7% uintConfigs[CONFIG_MAXIMUM_MODERATOR_REPUTATION_DEDUCTION] = 12500 * ONE_MILLION; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_NUM] = 1; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_DEN] = 1; uintConfigs[CONFIG_VOTE_CLAIMING_DEADLINE] = 10 days; uintConfigs[CONFIG_MINIMUM_LOCKED_DGD] = 10 * ONE_BILLION; uintConfigs[CONFIG_MINIMUM_DGD_FOR_MODERATOR] = 842 * ONE_BILLION; uintConfigs[CONFIG_MINIMUM_REPUTATION_FOR_MODERATOR] = 400 * ONE_BILLION; uintConfigs[CONFIG_PREPROPOSAL_COLLATERAL] = 2 ether; uintConfigs[CONFIG_MAX_FUNDING_FOR_NON_DIGIX] = 100 ether; uintConfigs[CONFIG_MAX_MILESTONES_FOR_NON_DIGIX] = 5; uintConfigs[CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER] = 80; uintConfigs[CONFIG_PROPOSAL_DEAD_DURATION] = 90 days; uintConfigs[CONFIG_CARBON_VOTE_REPUTATION_BONUS] = 10 * ONE_BILLION; } function updateUintConfigs(uint256[] _uintConfigs) external { require(sender_is(CONTRACT_DAO_SPECIAL_VOTING_CLAIMS)); uintConfigs[CONFIG_LOCKING_PHASE_DURATION] = _uintConfigs[0]; /* This used to be a config that can be changed. Now, _uintConfigs[1] is just a dummy config that doesnt do anything uintConfigs[CONFIG_QUARTER_DURATION] = _uintConfigs[1]; */ uintConfigs[CONFIG_VOTING_COMMIT_PHASE] = _uintConfigs[2]; uintConfigs[CONFIG_VOTING_PHASE_TOTAL] = _uintConfigs[3]; uintConfigs[CONFIG_INTERIM_COMMIT_PHASE] = _uintConfigs[4]; uintConfigs[CONFIG_INTERIM_PHASE_TOTAL] = _uintConfigs[5]; uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_NUMERATOR] = _uintConfigs[6]; uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_DENOMINATOR] = _uintConfigs[7]; uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_NUMERATOR] = _uintConfigs[8]; uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_DENOMINATOR] = _uintConfigs[9]; uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_NUMERATOR] = _uintConfigs[10]; uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_DENOMINATOR] = _uintConfigs[11]; uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_NUMERATOR] = _uintConfigs[12]; uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_DENOMINATOR] = _uintConfigs[13]; uintConfigs[CONFIG_DRAFT_QUOTA_NUMERATOR] = _uintConfigs[14]; uintConfigs[CONFIG_DRAFT_QUOTA_DENOMINATOR] = _uintConfigs[15]; uintConfigs[CONFIG_VOTING_QUOTA_NUMERATOR] = _uintConfigs[16]; uintConfigs[CONFIG_VOTING_QUOTA_DENOMINATOR] = _uintConfigs[17]; uintConfigs[CONFIG_QUARTER_POINT_DRAFT_VOTE] = _uintConfigs[18]; uintConfigs[CONFIG_QUARTER_POINT_VOTE] = _uintConfigs[19]; uintConfigs[CONFIG_QUARTER_POINT_INTERIM_VOTE] = _uintConfigs[20]; uintConfigs[CONFIG_MINIMAL_QUARTER_POINT] = _uintConfigs[21]; uintConfigs[CONFIG_QUARTER_POINT_MILESTONE_COMPLETION_PER_10000ETH] = _uintConfigs[22]; uintConfigs[CONFIG_BONUS_REPUTATION_NUMERATOR] = _uintConfigs[23]; uintConfigs[CONFIG_BONUS_REPUTATION_DENOMINATOR] = _uintConfigs[24]; uintConfigs[CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE] = _uintConfigs[25]; uintConfigs[CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL] = _uintConfigs[26]; uintConfigs[CONFIG_SPECIAL_QUOTA_NUMERATOR] = _uintConfigs[27]; uintConfigs[CONFIG_SPECIAL_QUOTA_DENOMINATOR] = _uintConfigs[28]; uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_NUMERATOR] = _uintConfigs[29]; uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_DENOMINATOR] = _uintConfigs[30]; uintConfigs[CONFIG_MAXIMUM_REPUTATION_DEDUCTION] = _uintConfigs[31]; uintConfigs[CONFIG_PUNISHMENT_FOR_NOT_LOCKING] = _uintConfigs[32]; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_NUM] = _uintConfigs[33]; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_DEN] = _uintConfigs[34]; uintConfigs[CONFIG_QUARTER_POINT_SCALING_FACTOR] = _uintConfigs[35]; uintConfigs[CONFIG_REPUTATION_POINT_SCALING_FACTOR] = _uintConfigs[36]; uintConfigs[CONFIG_MODERATOR_MINIMAL_QUARTER_POINT] = _uintConfigs[37]; uintConfigs[CONFIG_MODERATOR_QUARTER_POINT_SCALING_FACTOR] = _uintConfigs[38]; uintConfigs[CONFIG_MODERATOR_REPUTATION_POINT_SCALING_FACTOR] = _uintConfigs[39]; uintConfigs[CONFIG_PORTION_TO_MODERATORS_NUM] = _uintConfigs[40]; uintConfigs[CONFIG_PORTION_TO_MODERATORS_DEN] = _uintConfigs[41]; uintConfigs[CONFIG_DRAFT_VOTING_PHASE] = _uintConfigs[42]; uintConfigs[CONFIG_REPUTATION_POINT_BOOST_FOR_BADGE] = _uintConfigs[43]; uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_NUMERATOR] = _uintConfigs[44]; uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_DENOMINATOR] = _uintConfigs[45]; uintConfigs[CONFIG_MAXIMUM_MODERATOR_REPUTATION_DEDUCTION] = _uintConfigs[46]; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_NUM] = _uintConfigs[47]; uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_DEN] = _uintConfigs[48]; uintConfigs[CONFIG_VOTE_CLAIMING_DEADLINE] = _uintConfigs[49]; uintConfigs[CONFIG_MINIMUM_LOCKED_DGD] = _uintConfigs[50]; uintConfigs[CONFIG_MINIMUM_DGD_FOR_MODERATOR] = _uintConfigs[51]; uintConfigs[CONFIG_MINIMUM_REPUTATION_FOR_MODERATOR] = _uintConfigs[52]; uintConfigs[CONFIG_PREPROPOSAL_COLLATERAL] = _uintConfigs[53]; uintConfigs[CONFIG_MAX_FUNDING_FOR_NON_DIGIX] = _uintConfigs[54]; uintConfigs[CONFIG_MAX_MILESTONES_FOR_NON_DIGIX] = _uintConfigs[55]; uintConfigs[CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER] = _uintConfigs[56]; uintConfigs[CONFIG_PROPOSAL_DEAD_DURATION] = _uintConfigs[57]; uintConfigs[CONFIG_CARBON_VOTE_REPUTATION_BONUS] = _uintConfigs[58]; } function readUintConfigs() public view returns (uint256[]) { uint256[] memory _uintConfigs = new uint256[](59); _uintConfigs[0] = uintConfigs[CONFIG_LOCKING_PHASE_DURATION]; _uintConfigs[1] = uintConfigs[CONFIG_QUARTER_DURATION]; _uintConfigs[2] = uintConfigs[CONFIG_VOTING_COMMIT_PHASE]; _uintConfigs[3] = uintConfigs[CONFIG_VOTING_PHASE_TOTAL]; _uintConfigs[4] = uintConfigs[CONFIG_INTERIM_COMMIT_PHASE]; _uintConfigs[5] = uintConfigs[CONFIG_INTERIM_PHASE_TOTAL]; _uintConfigs[6] = uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_NUMERATOR]; _uintConfigs[7] = uintConfigs[CONFIG_DRAFT_QUORUM_FIXED_PORTION_DENOMINATOR]; _uintConfigs[8] = uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_NUMERATOR]; _uintConfigs[9] = uintConfigs[CONFIG_DRAFT_QUORUM_SCALING_FACTOR_DENOMINATOR]; _uintConfigs[10] = uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_NUMERATOR]; _uintConfigs[11] = uintConfigs[CONFIG_VOTING_QUORUM_FIXED_PORTION_DENOMINATOR]; _uintConfigs[12] = uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_NUMERATOR]; _uintConfigs[13] = uintConfigs[CONFIG_VOTING_QUORUM_SCALING_FACTOR_DENOMINATOR]; _uintConfigs[14] = uintConfigs[CONFIG_DRAFT_QUOTA_NUMERATOR]; _uintConfigs[15] = uintConfigs[CONFIG_DRAFT_QUOTA_DENOMINATOR]; _uintConfigs[16] = uintConfigs[CONFIG_VOTING_QUOTA_NUMERATOR]; _uintConfigs[17] = uintConfigs[CONFIG_VOTING_QUOTA_DENOMINATOR]; _uintConfigs[18] = uintConfigs[CONFIG_QUARTER_POINT_DRAFT_VOTE]; _uintConfigs[19] = uintConfigs[CONFIG_QUARTER_POINT_VOTE]; _uintConfigs[20] = uintConfigs[CONFIG_QUARTER_POINT_INTERIM_VOTE]; _uintConfigs[21] = uintConfigs[CONFIG_MINIMAL_QUARTER_POINT]; _uintConfigs[22] = uintConfigs[CONFIG_QUARTER_POINT_MILESTONE_COMPLETION_PER_10000ETH]; _uintConfigs[23] = uintConfigs[CONFIG_BONUS_REPUTATION_NUMERATOR]; _uintConfigs[24] = uintConfigs[CONFIG_BONUS_REPUTATION_DENOMINATOR]; _uintConfigs[25] = uintConfigs[CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE]; _uintConfigs[26] = uintConfigs[CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL]; _uintConfigs[27] = uintConfigs[CONFIG_SPECIAL_QUOTA_NUMERATOR]; _uintConfigs[28] = uintConfigs[CONFIG_SPECIAL_QUOTA_DENOMINATOR]; _uintConfigs[29] = uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_NUMERATOR]; _uintConfigs[30] = uintConfigs[CONFIG_SPECIAL_PROPOSAL_QUORUM_DENOMINATOR]; _uintConfigs[31] = uintConfigs[CONFIG_MAXIMUM_REPUTATION_DEDUCTION]; _uintConfigs[32] = uintConfigs[CONFIG_PUNISHMENT_FOR_NOT_LOCKING]; _uintConfigs[33] = uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_NUM]; _uintConfigs[34] = uintConfigs[CONFIG_REPUTATION_PER_EXTRA_QP_DEN]; _uintConfigs[35] = uintConfigs[CONFIG_QUARTER_POINT_SCALING_FACTOR]; _uintConfigs[36] = uintConfigs[CONFIG_REPUTATION_POINT_SCALING_FACTOR]; _uintConfigs[37] = uintConfigs[CONFIG_MODERATOR_MINIMAL_QUARTER_POINT]; _uintConfigs[38] = uintConfigs[CONFIG_MODERATOR_QUARTER_POINT_SCALING_FACTOR]; _uintConfigs[39] = uintConfigs[CONFIG_MODERATOR_REPUTATION_POINT_SCALING_FACTOR]; _uintConfigs[40] = uintConfigs[CONFIG_PORTION_TO_MODERATORS_NUM]; _uintConfigs[41] = uintConfigs[CONFIG_PORTION_TO_MODERATORS_DEN]; _uintConfigs[42] = uintConfigs[CONFIG_DRAFT_VOTING_PHASE]; _uintConfigs[43] = uintConfigs[CONFIG_REPUTATION_POINT_BOOST_FOR_BADGE]; _uintConfigs[44] = uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_NUMERATOR]; _uintConfigs[45] = uintConfigs[CONFIG_FINAL_REWARD_SCALING_FACTOR_DENOMINATOR]; _uintConfigs[46] = uintConfigs[CONFIG_MAXIMUM_MODERATOR_REPUTATION_DEDUCTION]; _uintConfigs[47] = uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_NUM]; _uintConfigs[48] = uintConfigs[CONFIG_REPUTATION_PER_EXTRA_MODERATOR_QP_DEN]; _uintConfigs[49] = uintConfigs[CONFIG_VOTE_CLAIMING_DEADLINE]; _uintConfigs[50] = uintConfigs[CONFIG_MINIMUM_LOCKED_DGD]; _uintConfigs[51] = uintConfigs[CONFIG_MINIMUM_DGD_FOR_MODERATOR]; _uintConfigs[52] = uintConfigs[CONFIG_MINIMUM_REPUTATION_FOR_MODERATOR]; _uintConfigs[53] = uintConfigs[CONFIG_PREPROPOSAL_COLLATERAL]; _uintConfigs[54] = uintConfigs[CONFIG_MAX_FUNDING_FOR_NON_DIGIX]; _uintConfigs[55] = uintConfigs[CONFIG_MAX_MILESTONES_FOR_NON_DIGIX]; _uintConfigs[56] = uintConfigs[CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER]; _uintConfigs[57] = uintConfigs[CONFIG_PROPOSAL_DEAD_DURATION]; _uintConfigs[58] = uintConfigs[CONFIG_CARBON_VOTE_REPUTATION_BONUS]; return _uintConfigs; } } // File: contracts/storage/DaoProposalCounterStorage.sol contract DaoProposalCounterStorage is ResolverClient, DaoConstants { constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_COUNTER, _resolver)); } // This is to mark the number of proposals that have been funded in a specific quarter // this is to take care of the cap on the number of funded proposals in a quarter mapping (uint256 => uint256) public proposalCountByQuarter; function addNonDigixProposalCountInQuarter(uint256 _quarterNumber) public { require(sender_is(CONTRACT_DAO_VOTING_CLAIMS)); proposalCountByQuarter[_quarterNumber] = proposalCountByQuarter[_quarterNumber].add(1); } } // File: contracts/storage/DaoUpgradeStorage.sol contract DaoUpgradeStorage is ResolverClient, DaoConstants { // this UTC timestamp marks the start of the first quarter // of DigixDAO. All time related calculations in DaoCommon // depend on this value uint256 public startOfFirstQuarter; // this boolean marks whether the DAO contracts have been replaced // by newer versions or not. The process of migration is done by deploying // a new set of contracts, transferring funds from these contracts to the new ones // migrating some state variables, and finally setting this boolean to true // All operations in these contracts that may transfer tokens, claim ether, // boost one's reputation, etc. SHOULD fail if this is true bool public isReplacedByNewDao; // this is the address of the new Dao contract address public newDaoContract; // this is the address of the new DaoFundingManager contract // ether funds will be moved from the current version's contract to this // new contract address public newDaoFundingManager; // this is the address of the new DaoRewardsManager contract // DGX funds will be moved from the current version of contract to this // new contract address public newDaoRewardsManager; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_UPGRADE, _resolver)); } function setStartOfFirstQuarter(uint256 _start) public { require(sender_is(CONTRACT_DAO)); startOfFirstQuarter = _start; } function setNewContractAddresses( address _newDaoContract, address _newDaoFundingManager, address _newDaoRewardsManager ) public { require(sender_is(CONTRACT_DAO)); newDaoContract = _newDaoContract; newDaoFundingManager = _newDaoFundingManager; newDaoRewardsManager = _newDaoRewardsManager; } function updateForDaoMigration() public { require(sender_is(CONTRACT_DAO)); isReplacedByNewDao = true; } } // File: contracts/storage/DaoSpecialStorage.sol contract DaoSpecialStorage is DaoWhitelistingCommon { using DoublyLinkedList for DoublyLinkedList.Bytes; using DaoStructs for DaoStructs.SpecialProposal; using DaoStructs for DaoStructs.Voting; // List of all the special proposals ever created in DigixDAO DoublyLinkedList.Bytes proposals; // mapping of the SpecialProposal struct by its ID // ID is also the IPFS doc hash of the proposal mapping (bytes32 => DaoStructs.SpecialProposal) proposalsById; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_SPECIAL, _resolver)); } function addSpecialProposal( bytes32 _proposalId, address _proposer, uint256[] _uintConfigs, address[] _addressConfigs, bytes32[] _bytesConfigs ) public { require(sender_is(CONTRACT_DAO_SPECIAL_PROPOSAL)); require( (proposalsById[_proposalId].proposalId == EMPTY_BYTES) && (_proposalId != EMPTY_BYTES) ); proposals.append(_proposalId); proposalsById[_proposalId].proposalId = _proposalId; proposalsById[_proposalId].proposer = _proposer; proposalsById[_proposalId].timeCreated = now; proposalsById[_proposalId].uintConfigs = _uintConfigs; proposalsById[_proposalId].addressConfigs = _addressConfigs; proposalsById[_proposalId].bytesConfigs = _bytesConfigs; } function readProposal(bytes32 _proposalId) public view returns ( bytes32 _id, address _proposer, uint256 _timeCreated, uint256 _timeVotingStarted ) { _id = proposalsById[_proposalId].proposalId; _proposer = proposalsById[_proposalId].proposer; _timeCreated = proposalsById[_proposalId].timeCreated; _timeVotingStarted = proposalsById[_proposalId].voting.startTime; } function readProposalProposer(bytes32 _proposalId) public view returns (address _proposer) { _proposer = proposalsById[_proposalId].proposer; } function readConfigs(bytes32 _proposalId) public view returns ( uint256[] memory _uintConfigs, address[] memory _addressConfigs, bytes32[] memory _bytesConfigs ) { _uintConfigs = proposalsById[_proposalId].uintConfigs; _addressConfigs = proposalsById[_proposalId].addressConfigs; _bytesConfigs = proposalsById[_proposalId].bytesConfigs; } function readVotingCount(bytes32 _proposalId, address[] _allUsers) external view returns (uint256 _for, uint256 _against) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].voting.countVotes(_allUsers); } function readVotingTime(bytes32 _proposalId) public view returns (uint256 _start) { require(senderIsAllowedToRead()); _start = proposalsById[_proposalId].voting.startTime; } function commitVote( bytes32 _proposalId, bytes32 _hash, address _voter ) public { require(sender_is(CONTRACT_DAO_VOTING)); proposalsById[_proposalId].voting.commits[_voter] = _hash; } function readComittedVote(bytes32 _proposalId, address _voter) public view returns (bytes32 _commitHash) { require(senderIsAllowedToRead()); _commitHash = proposalsById[_proposalId].voting.commits[_voter]; } function setVotingTime(bytes32 _proposalId, uint256 _time) public { require(sender_is(CONTRACT_DAO_SPECIAL_PROPOSAL)); proposalsById[_proposalId].voting.startTime = _time; } function readVotingResult(bytes32 _proposalId) public view returns (bool _result) { require(senderIsAllowedToRead()); _result = proposalsById[_proposalId].voting.passed; } function setPass(bytes32 _proposalId, bool _result) public { require(sender_is(CONTRACT_DAO_SPECIAL_VOTING_CLAIMS)); proposalsById[_proposalId].voting.passed = _result; } function setVotingClaim(bytes32 _proposalId, bool _claimed) public { require(sender_is(CONTRACT_DAO_SPECIAL_VOTING_CLAIMS)); DaoStructs.SpecialProposal storage _proposal = proposalsById[_proposalId]; _proposal.voting.claimed = _claimed; } function isClaimed(bytes32 _proposalId) public view returns (bool _claimed) { require(senderIsAllowedToRead()); _claimed = proposalsById[_proposalId].voting.claimed; } function readVote(bytes32 _proposalId, address _voter) public view returns (bool _vote, uint256 _weight) { require(senderIsAllowedToRead()); return proposalsById[_proposalId].voting.readVote(_voter); } function revealVote( bytes32 _proposalId, address _voter, bool _vote, uint256 _weight ) public { require(sender_is(CONTRACT_DAO_VOTING)); proposalsById[_proposalId].voting.revealVote(_voter, _vote, _weight); } } // File: contracts/storage/DaoPointsStorage.sol contract DaoPointsStorage is ResolverClient, DaoConstants { // struct for a non-transferrable token struct Token { uint256 totalSupply; mapping (address => uint256) balance; } // the reputation point token // since reputation is cumulative, we only need to store one value Token reputationPoint; // since quarter points are specific to quarters, we need a mapping from // quarter number to the quarter point token for that quarter mapping (uint256 => Token) quarterPoint; // the same is the case with quarter moderator points // these are specific to quarters mapping (uint256 => Token) quarterModeratorPoint; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_POINTS, _resolver)); } /// @notice add quarter points for a _participant for a _quarterNumber function addQuarterPoint(address _participant, uint256 _point, uint256 _quarterNumber) public returns (uint256 _newPoint, uint256 _newTotalPoint) { require(sender_is_from([CONTRACT_DAO_VOTING, CONTRACT_DAO_VOTING_CLAIMS, EMPTY_BYTES])); quarterPoint[_quarterNumber].totalSupply = quarterPoint[_quarterNumber].totalSupply.add(_point); quarterPoint[_quarterNumber].balance[_participant] = quarterPoint[_quarterNumber].balance[_participant].add(_point); _newPoint = quarterPoint[_quarterNumber].balance[_participant]; _newTotalPoint = quarterPoint[_quarterNumber].totalSupply; } function addModeratorQuarterPoint(address _participant, uint256 _point, uint256 _quarterNumber) public returns (uint256 _newPoint, uint256 _newTotalPoint) { require(sender_is_from([CONTRACT_DAO_VOTING, CONTRACT_DAO_VOTING_CLAIMS, EMPTY_BYTES])); quarterModeratorPoint[_quarterNumber].totalSupply = quarterModeratorPoint[_quarterNumber].totalSupply.add(_point); quarterModeratorPoint[_quarterNumber].balance[_participant] = quarterModeratorPoint[_quarterNumber].balance[_participant].add(_point); _newPoint = quarterModeratorPoint[_quarterNumber].balance[_participant]; _newTotalPoint = quarterModeratorPoint[_quarterNumber].totalSupply; } /// @notice get quarter points for a _participant in a _quarterNumber function getQuarterPoint(address _participant, uint256 _quarterNumber) public view returns (uint256 _point) { _point = quarterPoint[_quarterNumber].balance[_participant]; } function getQuarterModeratorPoint(address _participant, uint256 _quarterNumber) public view returns (uint256 _point) { _point = quarterModeratorPoint[_quarterNumber].balance[_participant]; } /// @notice get total quarter points for a particular _quarterNumber function getTotalQuarterPoint(uint256 _quarterNumber) public view returns (uint256 _totalPoint) { _totalPoint = quarterPoint[_quarterNumber].totalSupply; } function getTotalQuarterModeratorPoint(uint256 _quarterNumber) public view returns (uint256 _totalPoint) { _totalPoint = quarterModeratorPoint[_quarterNumber].totalSupply; } /// @notice add reputation points for a _participant function increaseReputation(address _participant, uint256 _point) public returns (uint256 _newPoint, uint256 _totalPoint) { require(sender_is_from([CONTRACT_DAO_VOTING_CLAIMS, CONTRACT_DAO_REWARDS_MANAGER, CONTRACT_DAO_STAKE_LOCKING])); reputationPoint.totalSupply = reputationPoint.totalSupply.add(_point); reputationPoint.balance[_participant] = reputationPoint.balance[_participant].add(_point); _newPoint = reputationPoint.balance[_participant]; _totalPoint = reputationPoint.totalSupply; } /// @notice subtract reputation points for a _participant function reduceReputation(address _participant, uint256 _point) public returns (uint256 _newPoint, uint256 _totalPoint) { require(sender_is_from([CONTRACT_DAO_VOTING_CLAIMS, CONTRACT_DAO_REWARDS_MANAGER, EMPTY_BYTES])); uint256 _toDeduct = _point; if (reputationPoint.balance[_participant] > _point) { reputationPoint.balance[_participant] = reputationPoint.balance[_participant].sub(_point); } else { _toDeduct = reputationPoint.balance[_participant]; reputationPoint.balance[_participant] = 0; } reputationPoint.totalSupply = reputationPoint.totalSupply.sub(_toDeduct); _newPoint = reputationPoint.balance[_participant]; _totalPoint = reputationPoint.totalSupply; } /// @notice get reputation points for a _participant function getReputation(address _participant) public view returns (uint256 _point) { _point = reputationPoint.balance[_participant]; } /// @notice get total reputation points distributed in the dao function getTotalReputation() public view returns (uint256 _totalPoint) { _totalPoint = reputationPoint.totalSupply; } } // File: contracts/storage/DaoRewardsStorage.sol // this contract will receive DGXs fees from the DGX fees distributors contract DaoRewardsStorage is ResolverClient, DaoConstants { using DaoStructs for DaoStructs.DaoQuarterInfo; // DaoQuarterInfo is a struct that stores the quarter specific information // regarding totalEffectiveDGDs, DGX distribution day, etc. pls check // docs in lib/DaoStructs mapping(uint256 => DaoStructs.DaoQuarterInfo) public allQuartersInfo; // Mapping that stores the DGX that can be claimed as rewards by // an address (a participant of DigixDAO) mapping(address => uint256) public claimableDGXs; // This stores the total DGX value that has been claimed by participants // this can be done by calling the DaoRewardsManager.claimRewards method // Note that this value is the only outgoing DGX from DaoRewardsManager contract // Note that this value also takes into account the demurrage that has been paid // by participants for simply holding their DGXs in the DaoRewardsManager contract uint256 public totalDGXsClaimed; // The Quarter ID in which the user last participated in // To participate means they had locked more than CONFIG_MINIMUM_LOCKED_DGD // DGD tokens. In addition, they should not have withdrawn those tokens in the same // quarter. Basically, in the main phase of the quarter, if DaoCommon.isParticipant(_user) // was true, they were participants. And that quarter was their lastParticipatedQuarter mapping (address => uint256) public lastParticipatedQuarter; // This mapping is only used to update the lastParticipatedQuarter to the // previousLastParticipatedQuarter in case users lock and withdraw DGDs // within the same quarter's locking phase mapping (address => uint256) public previousLastParticipatedQuarter; // This number marks the Quarter in which the rewards were last updated for that user // Since the rewards calculation for a specific quarter is only done once that // quarter is completed, we need this value to note the last quarter when the rewards were updated // We then start adding the rewards for all quarters after that quarter, until the current quarter mapping (address => uint256) public lastQuarterThatRewardsWasUpdated; // Similar as the lastQuarterThatRewardsWasUpdated, but this is for reputation updates // Note that reputation can also be deducted for no participation (not locking DGDs) // This value is used to update the reputation based on all quarters from the lastQuarterThatReputationWasUpdated // to the current quarter mapping (address => uint256) public lastQuarterThatReputationWasUpdated; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_DAO_REWARDS, _resolver)); } function updateQuarterInfo( uint256 _quarterNumber, uint256 _minimalParticipationPoint, uint256 _quarterPointScalingFactor, uint256 _reputationPointScalingFactor, uint256 _totalEffectiveDGDPreviousQuarter, uint256 _moderatorMinimalQuarterPoint, uint256 _moderatorQuarterPointScalingFactor, uint256 _moderatorReputationPointScalingFactor, uint256 _totalEffectiveModeratorDGDLastQuarter, uint256 _dgxDistributionDay, uint256 _dgxRewardsPoolLastQuarter, uint256 _sumRewardsFromBeginning ) public { require(sender_is(CONTRACT_DAO_REWARDS_MANAGER)); allQuartersInfo[_quarterNumber].minimalParticipationPoint = _minimalParticipationPoint; allQuartersInfo[_quarterNumber].quarterPointScalingFactor = _quarterPointScalingFactor; allQuartersInfo[_quarterNumber].reputationPointScalingFactor = _reputationPointScalingFactor; allQuartersInfo[_quarterNumber].totalEffectiveDGDPreviousQuarter = _totalEffectiveDGDPreviousQuarter; allQuartersInfo[_quarterNumber].moderatorMinimalParticipationPoint = _moderatorMinimalQuarterPoint; allQuartersInfo[_quarterNumber].moderatorQuarterPointScalingFactor = _moderatorQuarterPointScalingFactor; allQuartersInfo[_quarterNumber].moderatorReputationPointScalingFactor = _moderatorReputationPointScalingFactor; allQuartersInfo[_quarterNumber].totalEffectiveModeratorDGDLastQuarter = _totalEffectiveModeratorDGDLastQuarter; allQuartersInfo[_quarterNumber].dgxDistributionDay = _dgxDistributionDay; allQuartersInfo[_quarterNumber].dgxRewardsPoolLastQuarter = _dgxRewardsPoolLastQuarter; allQuartersInfo[_quarterNumber].sumRewardsFromBeginning = _sumRewardsFromBeginning; } function updateClaimableDGX(address _user, uint256 _newClaimableDGX) public { require(sender_is(CONTRACT_DAO_REWARDS_MANAGER)); claimableDGXs[_user] = _newClaimableDGX; } function updateLastParticipatedQuarter(address _user, uint256 _lastQuarter) public { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); lastParticipatedQuarter[_user] = _lastQuarter; } function updatePreviousLastParticipatedQuarter(address _user, uint256 _lastQuarter) public { require(sender_is(CONTRACT_DAO_STAKE_LOCKING)); previousLastParticipatedQuarter[_user] = _lastQuarter; } function updateLastQuarterThatRewardsWasUpdated(address _user, uint256 _lastQuarter) public { require(sender_is_from([CONTRACT_DAO_REWARDS_MANAGER, CONTRACT_DAO_STAKE_LOCKING, EMPTY_BYTES])); lastQuarterThatRewardsWasUpdated[_user] = _lastQuarter; } function updateLastQuarterThatReputationWasUpdated(address _user, uint256 _lastQuarter) public { require(sender_is_from([CONTRACT_DAO_REWARDS_MANAGER, CONTRACT_DAO_STAKE_LOCKING, EMPTY_BYTES])); lastQuarterThatReputationWasUpdated[_user] = _lastQuarter; } function addToTotalDgxClaimed(uint256 _dgxClaimed) public { require(sender_is(CONTRACT_DAO_REWARDS_MANAGER)); totalDGXsClaimed = totalDGXsClaimed.add(_dgxClaimed); } function readQuarterInfo(uint256 _quarterNumber) public view returns ( uint256 _minimalParticipationPoint, uint256 _quarterPointScalingFactor, uint256 _reputationPointScalingFactor, uint256 _totalEffectiveDGDPreviousQuarter, uint256 _moderatorMinimalQuarterPoint, uint256 _moderatorQuarterPointScalingFactor, uint256 _moderatorReputationPointScalingFactor, uint256 _totalEffectiveModeratorDGDLastQuarter, uint256 _dgxDistributionDay, uint256 _dgxRewardsPoolLastQuarter, uint256 _sumRewardsFromBeginning ) { _minimalParticipationPoint = allQuartersInfo[_quarterNumber].minimalParticipationPoint; _quarterPointScalingFactor = allQuartersInfo[_quarterNumber].quarterPointScalingFactor; _reputationPointScalingFactor = allQuartersInfo[_quarterNumber].reputationPointScalingFactor; _totalEffectiveDGDPreviousQuarter = allQuartersInfo[_quarterNumber].totalEffectiveDGDPreviousQuarter; _moderatorMinimalQuarterPoint = allQuartersInfo[_quarterNumber].moderatorMinimalParticipationPoint; _moderatorQuarterPointScalingFactor = allQuartersInfo[_quarterNumber].moderatorQuarterPointScalingFactor; _moderatorReputationPointScalingFactor = allQuartersInfo[_quarterNumber].moderatorReputationPointScalingFactor; _totalEffectiveModeratorDGDLastQuarter = allQuartersInfo[_quarterNumber].totalEffectiveModeratorDGDLastQuarter; _dgxDistributionDay = allQuartersInfo[_quarterNumber].dgxDistributionDay; _dgxRewardsPoolLastQuarter = allQuartersInfo[_quarterNumber].dgxRewardsPoolLastQuarter; _sumRewardsFromBeginning = allQuartersInfo[_quarterNumber].sumRewardsFromBeginning; } function readQuarterGeneralInfo(uint256 _quarterNumber) public view returns ( uint256 _dgxDistributionDay, uint256 _dgxRewardsPoolLastQuarter, uint256 _sumRewardsFromBeginning ) { _dgxDistributionDay = allQuartersInfo[_quarterNumber].dgxDistributionDay; _dgxRewardsPoolLastQuarter = allQuartersInfo[_quarterNumber].dgxRewardsPoolLastQuarter; _sumRewardsFromBeginning = allQuartersInfo[_quarterNumber].sumRewardsFromBeginning; } function readQuarterModeratorInfo(uint256 _quarterNumber) public view returns ( uint256 _moderatorMinimalQuarterPoint, uint256 _moderatorQuarterPointScalingFactor, uint256 _moderatorReputationPointScalingFactor, uint256 _totalEffectiveModeratorDGDLastQuarter ) { _moderatorMinimalQuarterPoint = allQuartersInfo[_quarterNumber].moderatorMinimalParticipationPoint; _moderatorQuarterPointScalingFactor = allQuartersInfo[_quarterNumber].moderatorQuarterPointScalingFactor; _moderatorReputationPointScalingFactor = allQuartersInfo[_quarterNumber].moderatorReputationPointScalingFactor; _totalEffectiveModeratorDGDLastQuarter = allQuartersInfo[_quarterNumber].totalEffectiveModeratorDGDLastQuarter; } function readQuarterParticipantInfo(uint256 _quarterNumber) public view returns ( uint256 _minimalParticipationPoint, uint256 _quarterPointScalingFactor, uint256 _reputationPointScalingFactor, uint256 _totalEffectiveDGDPreviousQuarter ) { _minimalParticipationPoint = allQuartersInfo[_quarterNumber].minimalParticipationPoint; _quarterPointScalingFactor = allQuartersInfo[_quarterNumber].quarterPointScalingFactor; _reputationPointScalingFactor = allQuartersInfo[_quarterNumber].reputationPointScalingFactor; _totalEffectiveDGDPreviousQuarter = allQuartersInfo[_quarterNumber].totalEffectiveDGDPreviousQuarter; } function readDgxDistributionDay(uint256 _quarterNumber) public view returns (uint256 _distributionDay) { _distributionDay = allQuartersInfo[_quarterNumber].dgxDistributionDay; } function readTotalEffectiveDGDLastQuarter(uint256 _quarterNumber) public view returns (uint256 _totalEffectiveDGDPreviousQuarter) { _totalEffectiveDGDPreviousQuarter = allQuartersInfo[_quarterNumber].totalEffectiveDGDPreviousQuarter; } function readTotalEffectiveModeratorDGDLastQuarter(uint256 _quarterNumber) public view returns (uint256 _totalEffectiveModeratorDGDLastQuarter) { _totalEffectiveModeratorDGDLastQuarter = allQuartersInfo[_quarterNumber].totalEffectiveModeratorDGDLastQuarter; } function readRewardsPoolOfLastQuarter(uint256 _quarterNumber) public view returns (uint256 _rewardsPool) { _rewardsPool = allQuartersInfo[_quarterNumber].dgxRewardsPoolLastQuarter; } } // File: contracts/storage/IntermediateResultsStorage.sol contract IntermediateResultsStorage is ResolverClient, DaoConstants { using DaoStructs for DaoStructs.IntermediateResults; constructor(address _resolver) public { require(init(CONTRACT_STORAGE_INTERMEDIATE_RESULTS, _resolver)); } // There are scenarios in which we must loop across all participants/moderators // in a function call. For a big number of operations, the function call may be short of gas // To tackle this, we use an IntermediateResults struct to store the intermediate results // The same function is then called multiple times until all operations are completed // If the operations cannot be done in that iteration, the intermediate results are stored // else, the final outcome is returned // Please check the lib/DaoStructs for docs on this struct mapping (bytes32 => DaoStructs.IntermediateResults) allIntermediateResults; function getIntermediateResults(bytes32 _key) public view returns ( address _countedUntil, uint256 _currentForCount, uint256 _currentAgainstCount, uint256 _currentSumOfEffectiveBalance ) { _countedUntil = allIntermediateResults[_key].countedUntil; _currentForCount = allIntermediateResults[_key].currentForCount; _currentAgainstCount = allIntermediateResults[_key].currentAgainstCount; _currentSumOfEffectiveBalance = allIntermediateResults[_key].currentSumOfEffectiveBalance; } function resetIntermediateResults(bytes32 _key) public { require(sender_is_from([CONTRACT_DAO_REWARDS_MANAGER, CONTRACT_DAO_VOTING_CLAIMS, CONTRACT_DAO_SPECIAL_VOTING_CLAIMS])); allIntermediateResults[_key].countedUntil = address(0x0); } function setIntermediateResults( bytes32 _key, address _countedUntil, uint256 _currentForCount, uint256 _currentAgainstCount, uint256 _currentSumOfEffectiveBalance ) public { require(sender_is_from([CONTRACT_DAO_REWARDS_MANAGER, CONTRACT_DAO_VOTING_CLAIMS, CONTRACT_DAO_SPECIAL_VOTING_CLAIMS])); allIntermediateResults[_key].countedUntil = _countedUntil; allIntermediateResults[_key].currentForCount = _currentForCount; allIntermediateResults[_key].currentAgainstCount = _currentAgainstCount; allIntermediateResults[_key].currentSumOfEffectiveBalance = _currentSumOfEffectiveBalance; } } // File: contracts/lib/MathHelper.sol library MathHelper { using SafeMath for uint256; function max(uint256 a, uint256 b) internal pure returns (uint256 _max){ _max = b; if (a > b) { _max = a; } } function min(uint256 a, uint256 b) internal pure returns (uint256 _min){ _min = b; if (a < b) { _min = a; } } function sumNumbers(uint256[] _numbers) internal pure returns (uint256 _sum) { for (uint256 i=0;i<_numbers.length;i++) { _sum = _sum.add(_numbers[i]); } } } // File: contracts/common/DaoCommonMini.sol contract DaoCommonMini is IdentityCommon { using MathHelper for MathHelper; /** @notice Check if the DAO contracts have been replaced by a new set of contracts @return _isNotReplaced true if it is not replaced, false if it has already been replaced */ function isDaoNotReplaced() public view returns (bool _isNotReplaced) { _isNotReplaced = !daoUpgradeStorage().isReplacedByNewDao(); } /** @notice Check if it is currently in the locking phase @dev No governance activities can happen in the locking phase. The locking phase is from t=0 to t=CONFIG_LOCKING_PHASE_DURATION-1 @return _isLockingPhase true if it is in the locking phase */ function isLockingPhase() public view returns (bool _isLockingPhase) { _isLockingPhase = currentTimeInQuarter() < getUintConfig(CONFIG_LOCKING_PHASE_DURATION); } /** @notice Check if it is currently in a main phase. @dev The main phase is where all the governance activities could take plase. If the DAO is replaced, there can never be any more main phase. @return _isMainPhase true if it is in a main phase */ function isMainPhase() public view returns (bool _isMainPhase) { _isMainPhase = isDaoNotReplaced() && currentTimeInQuarter() >= getUintConfig(CONFIG_LOCKING_PHASE_DURATION); } /** @notice Check if the calculateGlobalRewardsBeforeNewQuarter function has been done for a certain quarter @dev However, there is no need to run calculateGlobalRewardsBeforeNewQuarter for the first quarter */ modifier ifGlobalRewardsSet(uint256 _quarterNumber) { if (_quarterNumber > 1) { require(daoRewardsStorage().readDgxDistributionDay(_quarterNumber) > 0); } _; } /** @notice require that it is currently during a phase, which is within _relativePhaseStart and _relativePhaseEnd seconds, after the _startingPoint */ function requireInPhase(uint256 _startingPoint, uint256 _relativePhaseStart, uint256 _relativePhaseEnd) internal view { require(_startingPoint > 0); require(now < _startingPoint.add(_relativePhaseEnd)); require(now >= _startingPoint.add(_relativePhaseStart)); } /** @notice Get the current quarter index @dev Quarter indexes starts from 1 @return _quarterNumber the current quarter index */ function currentQuarterNumber() public view returns(uint256 _quarterNumber) { _quarterNumber = getQuarterNumber(now); } /** @notice Get the quarter index of a timestamp @dev Quarter indexes starts from 1 @return _index the quarter index */ function getQuarterNumber(uint256 _time) internal view returns (uint256 _index) { require(startOfFirstQuarterIsSet()); _index = _time.sub(daoUpgradeStorage().startOfFirstQuarter()) .div(getUintConfig(CONFIG_QUARTER_DURATION)) .add(1); } /** @notice Get the relative time in quarter of a timestamp @dev For example, the timeInQuarter of the first second of any quarter n-th is always 1 */ function timeInQuarter(uint256 _time) internal view returns (uint256 _timeInQuarter) { require(startOfFirstQuarterIsSet()); // must be already set _timeInQuarter = _time.sub(daoUpgradeStorage().startOfFirstQuarter()) % getUintConfig(CONFIG_QUARTER_DURATION); } /** @notice Check if the start of first quarter is already set @return _isSet true if start of first quarter is already set */ function startOfFirstQuarterIsSet() internal view returns (bool _isSet) { _isSet = daoUpgradeStorage().startOfFirstQuarter() != 0; } /** @notice Get the current relative time in the quarter @dev For example: the currentTimeInQuarter of the first second of any quarter is 1 @return _currentT the current relative time in the quarter */ function currentTimeInQuarter() public view returns (uint256 _currentT) { _currentT = timeInQuarter(now); } /** @notice Get the time remaining in the quarter */ function getTimeLeftInQuarter(uint256 _time) internal view returns (uint256 _timeLeftInQuarter) { _timeLeftInQuarter = getUintConfig(CONFIG_QUARTER_DURATION).sub(timeInQuarter(_time)); } function daoListingService() internal view returns (DaoListingService _contract) { _contract = DaoListingService(get_contract(CONTRACT_SERVICE_DAO_LISTING)); } function daoConfigsStorage() internal view returns (DaoConfigsStorage _contract) { _contract = DaoConfigsStorage(get_contract(CONTRACT_STORAGE_DAO_CONFIG)); } function daoStakeStorage() internal view returns (DaoStakeStorage _contract) { _contract = DaoStakeStorage(get_contract(CONTRACT_STORAGE_DAO_STAKE)); } function daoStorage() internal view returns (DaoStorage _contract) { _contract = DaoStorage(get_contract(CONTRACT_STORAGE_DAO)); } function daoProposalCounterStorage() internal view returns (DaoProposalCounterStorage _contract) { _contract = DaoProposalCounterStorage(get_contract(CONTRACT_STORAGE_DAO_COUNTER)); } function daoUpgradeStorage() internal view returns (DaoUpgradeStorage _contract) { _contract = DaoUpgradeStorage(get_contract(CONTRACT_STORAGE_DAO_UPGRADE)); } function daoSpecialStorage() internal view returns (DaoSpecialStorage _contract) { _contract = DaoSpecialStorage(get_contract(CONTRACT_STORAGE_DAO_SPECIAL)); } function daoPointsStorage() internal view returns (DaoPointsStorage _contract) { _contract = DaoPointsStorage(get_contract(CONTRACT_STORAGE_DAO_POINTS)); } function daoRewardsStorage() internal view returns (DaoRewardsStorage _contract) { _contract = DaoRewardsStorage(get_contract(CONTRACT_STORAGE_DAO_REWARDS)); } function intermediateResultsStorage() internal view returns (IntermediateResultsStorage _contract) { _contract = IntermediateResultsStorage(get_contract(CONTRACT_STORAGE_INTERMEDIATE_RESULTS)); } function getUintConfig(bytes32 _configKey) public view returns (uint256 _configValue) { _configValue = daoConfigsStorage().uintConfigs(_configKey); } } // File: contracts/common/DaoCommon.sol contract DaoCommon is DaoCommonMini { using MathHelper for MathHelper; /** @notice Check if the transaction is called by the proposer of a proposal @return _isFromProposer true if the caller is the proposer */ function isFromProposer(bytes32 _proposalId) internal view returns (bool _isFromProposer) { _isFromProposer = msg.sender == daoStorage().readProposalProposer(_proposalId); } /** @notice Check if the proposal can still be "editted", or in other words, added more versions @dev Once the proposal is finalized, it can no longer be editted. The proposer will still be able to add docs and change fundings though. @return _isEditable true if the proposal is editable */ function isEditable(bytes32 _proposalId) internal view returns (bool _isEditable) { bytes32 _finalVersion; (,,,,,,,_finalVersion,,) = daoStorage().readProposal(_proposalId); _isEditable = _finalVersion == EMPTY_BYTES; } /** @notice returns the balance of DaoFundingManager, which is the wei in DigixDAO */ function weiInDao() internal view returns (uint256 _wei) { _wei = get_contract(CONTRACT_DAO_FUNDING_MANAGER).balance; } /** @notice Check if it is after the draft voting phase of the proposal */ modifier ifAfterDraftVotingPhase(bytes32 _proposalId) { uint256 _start = daoStorage().readProposalDraftVotingTime(_proposalId); require(_start > 0); // Draft voting must have started. In other words, proposer must have finalized the proposal require(now >= _start.add(getUintConfig(CONFIG_DRAFT_VOTING_PHASE))); _; } modifier ifCommitPhase(bytes32 _proposalId, uint8 _index) { requireInPhase( daoStorage().readProposalVotingTime(_proposalId, _index), 0, getUintConfig(_index == 0 ? CONFIG_VOTING_COMMIT_PHASE : CONFIG_INTERIM_COMMIT_PHASE) ); _; } modifier ifRevealPhase(bytes32 _proposalId, uint256 _index) { requireInPhase( daoStorage().readProposalVotingTime(_proposalId, _index), getUintConfig(_index == 0 ? CONFIG_VOTING_COMMIT_PHASE : CONFIG_INTERIM_COMMIT_PHASE), getUintConfig(_index == 0 ? CONFIG_VOTING_PHASE_TOTAL : CONFIG_INTERIM_PHASE_TOTAL) ); _; } modifier ifAfterProposalRevealPhase(bytes32 _proposalId, uint256 _index) { uint256 _start = daoStorage().readProposalVotingTime(_proposalId, _index); require(_start > 0); require(now >= _start.add(getUintConfig(_index == 0 ? CONFIG_VOTING_PHASE_TOTAL : CONFIG_INTERIM_PHASE_TOTAL))); _; } modifier ifDraftVotingPhase(bytes32 _proposalId) { requireInPhase( daoStorage().readProposalDraftVotingTime(_proposalId), 0, getUintConfig(CONFIG_DRAFT_VOTING_PHASE) ); _; } modifier isProposalState(bytes32 _proposalId, bytes32 _STATE) { bytes32 _currentState; (,,,_currentState,,,,,,) = daoStorage().readProposal(_proposalId); require(_currentState == _STATE); _; } modifier ifDraftNotClaimed(bytes32 _proposalId) { require(daoStorage().isDraftClaimed(_proposalId) == false); _; } modifier ifNotClaimed(bytes32 _proposalId, uint256 _index) { require(daoStorage().isClaimed(_proposalId, _index) == false); _; } modifier ifNotClaimedSpecial(bytes32 _proposalId) { require(daoSpecialStorage().isClaimed(_proposalId) == false); _; } modifier hasNotRevealed(bytes32 _proposalId, uint256 _index) { uint256 _voteWeight; (, _voteWeight) = daoStorage().readVote(_proposalId, _index, msg.sender); require(_voteWeight == uint(0)); _; } modifier hasNotRevealedSpecial(bytes32 _proposalId) { uint256 _weight; (,_weight) = daoSpecialStorage().readVote(_proposalId, msg.sender); require(_weight == uint256(0)); _; } modifier ifAfterRevealPhaseSpecial(bytes32 _proposalId) { uint256 _start = daoSpecialStorage().readVotingTime(_proposalId); require(_start > 0); require(now.sub(_start) >= getUintConfig(CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL)); _; } modifier ifCommitPhaseSpecial(bytes32 _proposalId) { requireInPhase( daoSpecialStorage().readVotingTime(_proposalId), 0, getUintConfig(CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE) ); _; } modifier ifRevealPhaseSpecial(bytes32 _proposalId) { requireInPhase( daoSpecialStorage().readVotingTime(_proposalId), getUintConfig(CONFIG_SPECIAL_PROPOSAL_COMMIT_PHASE), getUintConfig(CONFIG_SPECIAL_PROPOSAL_PHASE_TOTAL) ); _; } function daoWhitelistingStorage() internal view returns (DaoWhitelistingStorage _contract) { _contract = DaoWhitelistingStorage(get_contract(CONTRACT_STORAGE_DAO_WHITELISTING)); } function getAddressConfig(bytes32 _configKey) public view returns (address _configValue) { _configValue = daoConfigsStorage().addressConfigs(_configKey); } function getBytesConfig(bytes32 _configKey) public view returns (bytes32 _configValue) { _configValue = daoConfigsStorage().bytesConfigs(_configKey); } /** @notice Check if a user is a participant in the current quarter */ function isParticipant(address _user) public view returns (bool _is) { _is = (daoRewardsStorage().lastParticipatedQuarter(_user) == currentQuarterNumber()) && (daoStakeStorage().lockedDGDStake(_user) >= getUintConfig(CONFIG_MINIMUM_LOCKED_DGD)); } /** @notice Check if a user is a moderator in the current quarter */ function isModerator(address _user) public view returns (bool _is) { _is = (daoRewardsStorage().lastParticipatedQuarter(_user) == currentQuarterNumber()) && (daoStakeStorage().lockedDGDStake(_user) >= getUintConfig(CONFIG_MINIMUM_DGD_FOR_MODERATOR)) && (daoPointsStorage().getReputation(_user) >= getUintConfig(CONFIG_MINIMUM_REPUTATION_FOR_MODERATOR)); } /** @notice Calculate the start of a specific milestone of a specific proposal. @dev This is calculated from the voting start of the voting round preceding the milestone This would throw if the voting start is 0 (the voting round has not started yet) Note that if the milestoneIndex is exactly the same as the number of milestones, This will just return the end of the last voting round. */ function startOfMilestone(bytes32 _proposalId, uint256 _milestoneIndex) internal view returns (uint256 _milestoneStart) { uint256 _startOfPrecedingVotingRound = daoStorage().readProposalVotingTime(_proposalId, _milestoneIndex); require(_startOfPrecedingVotingRound > 0); // the preceding voting round must have started if (_milestoneIndex == 0) { // This is the 1st milestone, which starts after voting round 0 _milestoneStart = _startOfPrecedingVotingRound .add(getUintConfig(CONFIG_VOTING_PHASE_TOTAL)); } else { // if its the n-th milestone, it starts after voting round n-th _milestoneStart = _startOfPrecedingVotingRound .add(getUintConfig(CONFIG_INTERIM_PHASE_TOTAL)); } } /** @notice Calculate the actual voting start for a voting round, given the tentative start @dev The tentative start is the ideal start. For example, when a proposer finish a milestone, it should be now However, sometimes the tentative start is too close to the end of the quarter, hence, the actual voting start should be pushed to the next quarter */ function getTimelineForNextVote( uint256 _index, uint256 _tentativeVotingStart ) internal view returns (uint256 _actualVotingStart) { uint256 _timeLeftInQuarter = getTimeLeftInQuarter(_tentativeVotingStart); uint256 _votingDuration = getUintConfig(_index == 0 ? CONFIG_VOTING_PHASE_TOTAL : CONFIG_INTERIM_PHASE_TOTAL); _actualVotingStart = _tentativeVotingStart; if (timeInQuarter(_tentativeVotingStart) < getUintConfig(CONFIG_LOCKING_PHASE_DURATION)) { // if the tentative start is during a locking phase _actualVotingStart = _tentativeVotingStart.add( getUintConfig(CONFIG_LOCKING_PHASE_DURATION).sub(timeInQuarter(_tentativeVotingStart)) ); } else if (_timeLeftInQuarter < _votingDuration.add(getUintConfig(CONFIG_VOTE_CLAIMING_DEADLINE))) { // if the time left in quarter is not enough to vote and claim voting _actualVotingStart = _tentativeVotingStart.add( _timeLeftInQuarter.add(getUintConfig(CONFIG_LOCKING_PHASE_DURATION)).add(1) ); } } /** @notice Check if we can add another non-Digix proposal in this quarter @dev There is a max cap to the number of non-Digix proposals CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER */ function checkNonDigixProposalLimit(bytes32 _proposalId) internal view { require(isNonDigixProposalsWithinLimit(_proposalId)); } function isNonDigixProposalsWithinLimit(bytes32 _proposalId) internal view returns (bool _withinLimit) { bool _isDigixProposal; (,,,,,,,,,_isDigixProposal) = daoStorage().readProposal(_proposalId); _withinLimit = true; if (!_isDigixProposal) { _withinLimit = daoProposalCounterStorage().proposalCountByQuarter(currentQuarterNumber()) < getUintConfig(CONFIG_NON_DIGIX_PROPOSAL_CAP_PER_QUARTER); } } /** @notice If its a non-Digix proposal, check if the fundings are within limit @dev There is a max cap to the fundings and number of milestones for non-Digix proposals */ function checkNonDigixFundings(uint256[] _milestonesFundings, uint256 _finalReward) internal view { if (!is_founder()) { require(_milestonesFundings.length <= getUintConfig(CONFIG_MAX_MILESTONES_FOR_NON_DIGIX)); require(MathHelper.sumNumbers(_milestonesFundings).add(_finalReward) <= getUintConfig(CONFIG_MAX_FUNDING_FOR_NON_DIGIX)); } } /** @notice Check if msg.sender can do operations as a proposer @dev Note that this function does not check if he is the proposer of the proposal */ function senderCanDoProposerOperations() internal view { require(isMainPhase()); require(isParticipant(msg.sender)); require(identity_storage().is_kyc_approved(msg.sender)); } } // File: contracts/interactive/DaoVoting.sol /** @title Contract for all voting operations of DAO @author Digix Holdings */ contract DaoVoting is DaoCommon { constructor(address _resolver) public { require(init(CONTRACT_DAO_VOTING, _resolver)); } /** @notice Function to vote on draft proposal (only Moderators can vote) @param _proposalId ID of the proposal @param _vote Boolean, true if voting for, false if voting against */ function voteOnDraft( bytes32 _proposalId, bool _vote ) public ifDraftVotingPhase(_proposalId) { require(isMainPhase()); require(isModerator(msg.sender)); address _moderator = msg.sender; uint256 _moderatorStake = daoStakeStorage().lockedDGDStake(_moderator); uint256 _voteWeight; (,_voteWeight) = daoStorage().readDraftVote(_proposalId, _moderator); daoStorage().addDraftVote(_proposalId, _moderator, _vote, _moderatorStake); if (_voteWeight == 0) { // just voted the first time daoPointsStorage().addModeratorQuarterPoint(_moderator, getUintConfig(CONFIG_QUARTER_POINT_DRAFT_VOTE), currentQuarterNumber()); } } /** @notice Function to commit a vote on special proposal @param _proposalId ID of the proposal @param _commitHash Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes(random string))) @return { "_success": "Boolean, true if vote was committed successfully" } */ function commitVoteOnSpecialProposal( bytes32 _proposalId, bytes32 _commitHash ) public ifCommitPhaseSpecial(_proposalId) { require(isParticipant(msg.sender)); daoSpecialStorage().commitVote(_proposalId, _commitHash, msg.sender); } /** @notice Function to reveal a committed vote on special proposal @dev The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called @param _proposalId ID of the proposal @param _vote Boolean, true if voted for, false if voted against @param _salt Random bytes used to commit vote */ function revealVoteOnSpecialProposal( bytes32 _proposalId, bool _vote, bytes32 _salt ) public ifRevealPhaseSpecial(_proposalId) hasNotRevealedSpecial(_proposalId) { require(isParticipant(msg.sender)); require(keccak256(abi.encodePacked(msg.sender, _vote, _salt)) == daoSpecialStorage().readComittedVote(_proposalId, msg.sender)); daoSpecialStorage().revealVote(_proposalId, msg.sender, _vote, daoStakeStorage().lockedDGDStake(msg.sender)); daoPointsStorage().addQuarterPoint(msg.sender, getUintConfig(CONFIG_QUARTER_POINT_VOTE), currentQuarterNumber()); } /** @notice Function to commit a vote on proposal (Voting Round) @param _proposalId ID of the proposal @param _index Index of the Voting Round @param _commitHash Hash of the vote to commit (hash = SHA3(address(pub_address), bool(vote), bytes32(random string))) */ function commitVoteOnProposal( bytes32 _proposalId, uint8 _index, bytes32 _commitHash ) public ifCommitPhase(_proposalId, _index) { require(isParticipant(msg.sender)); daoStorage().commitVote(_proposalId, _commitHash, msg.sender, _index); } /** @notice Function to reveal a committed vote on proposal (Voting Round) @dev The lockedDGDStake that would be counted behind a participant's vote is his lockedDGDStake when this function is called @param _proposalId ID of the proposal @param _index Index of the Voting Round @param _vote Boolean, true if voted for, false if voted against @param _salt Random bytes used to commit vote */ function revealVoteOnProposal( bytes32 _proposalId, uint8 _index, bool _vote, bytes32 _salt ) public ifRevealPhase(_proposalId, _index) hasNotRevealed(_proposalId, _index) { require(isParticipant(msg.sender)); require(keccak256(abi.encodePacked(msg.sender, _vote, _salt)) == daoStorage().readComittedVote(_proposalId, _index, msg.sender)); daoStorage().revealVote(_proposalId, msg.sender, _vote, daoStakeStorage().lockedDGDStake(msg.sender), _index); daoPointsStorage().addQuarterPoint( msg.sender, getUintConfig(_index == 0 ? CONFIG_QUARTER_POINT_VOTE : CONFIG_QUARTER_POINT_INTERIM_VOTE), currentQuarterNumber() ); } }
IPFS doc hash of this version of the proposal UTC timestamp at which this version was created The number of milestones in the proposal as per this version The final reward asked by the proposer for completion of the entire proposal List of fundings required by the proposal as per this version The numbers are in wei When a proposal is finalized (calling Dao.finalizeProposal), the proposer can no longer add proposal versions However, they can still add more details to this final proposal version, in the form of IPFS docs. These IPFS docs are stored in this array
struct ProposalVersion { bytes32 docIpfsHash; uint256 created; uint256 milestoneCount; uint256 finalReward; uint256[] milestoneFundings; bytes32[] moreDocs; }
6,489,460
[ 1, 2579, 4931, 997, 1651, 434, 333, 1177, 434, 326, 14708, 9951, 2858, 622, 1492, 333, 1177, 1703, 2522, 1021, 1300, 434, 312, 14849, 5322, 316, 326, 14708, 487, 1534, 333, 1177, 1021, 727, 19890, 19279, 635, 326, 450, 5607, 364, 8364, 434, 326, 7278, 14708, 987, 434, 284, 1074, 899, 1931, 635, 326, 14708, 487, 1534, 333, 1177, 1021, 5600, 854, 316, 732, 77, 5203, 279, 14708, 353, 727, 1235, 261, 31623, 463, 6033, 18, 30343, 14592, 3631, 326, 450, 5607, 848, 1158, 7144, 527, 14708, 5244, 10724, 16, 2898, 848, 4859, 527, 1898, 3189, 358, 333, 727, 14708, 1177, 16, 316, 326, 646, 434, 2971, 4931, 3270, 18, 8646, 2971, 4931, 3270, 854, 4041, 316, 333, 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 ]
[ 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, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 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, 19945, 1444, 288, 203, 3639, 1731, 1578, 997, 5273, 2556, 2310, 31, 203, 203, 3639, 2254, 5034, 2522, 31, 203, 203, 3639, 2254, 5034, 28664, 1380, 31, 203, 203, 3639, 2254, 5034, 727, 17631, 1060, 31, 203, 203, 3639, 2254, 5034, 8526, 28664, 42, 1074, 899, 31, 203, 203, 3639, 1731, 1578, 8526, 1898, 12656, 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 ]
./partial_match/1/0xe37009F6A756e8997FaC8da44Da7B5B87731fc22/sources/MUNGER.sol
* @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./ Editable End editable
constructor() { _name = "Munger Coin"; _symbol = "MUNGER"; uint e_totalSupply = 1_000_000_000_000 ether; _mint(msg.sender, e_totalSupply); }
4,081,141
[ 1, 2785, 326, 924, 364, 288, 529, 97, 471, 288, 7175, 5496, 1021, 805, 460, 434, 288, 31734, 97, 353, 6549, 18, 2974, 2027, 279, 3775, 460, 364, 288, 31734, 97, 1846, 1410, 30402, 518, 18, 4826, 2795, 434, 4259, 924, 854, 11732, 30, 2898, 848, 1338, 506, 444, 3647, 4982, 16171, 18, 19, 6651, 9085, 4403, 13754, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1435, 288, 203, 3639, 389, 529, 273, 315, 49, 318, 693, 28932, 14432, 203, 3639, 389, 7175, 273, 315, 49, 2124, 3101, 14432, 203, 3639, 2254, 425, 67, 4963, 3088, 1283, 273, 404, 67, 3784, 67, 3784, 67, 3784, 67, 3784, 225, 2437, 31, 203, 203, 3639, 389, 81, 474, 12, 3576, 18, 15330, 16, 425, 67, 4963, 3088, 1283, 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 ]
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import '../interface/IWETH.sol'; import "../JFToken.sol"; interface IMigratorChef { // Perform LP token migration from legacy UniswapV2 to JfSwap. // Take the current LP token address and return the new LP token address. // Migrator should have full access to the caller's LP token. // Return the new LP token address. // // XXX Migrator must have allowance access to UniswapV2 LP tokens. // JfSwap must mint EXACTLY the same amount of JfSwap LP tokens or // else something bad will happen. Traditional UniswapV2 does not // do that so be careful! function migrate(IERC20 token) external returns (IERC20); } // MasterChef is the master of Jf. He can make Jf and he is a fair guy. // // Note that it's ownable and the owner wields tremendous power. The ownership // will be transferred to a governance smart contract once JF is sufficiently // distributed and the community can show to govern itself. // // Have fun reading it. Hopefully it's bug-free. God bless. contract SingleMiningPool is OwnableUpgradeable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 pending; // Withdrawable pending JF // // We do some fancy math here. Basically, any point in time, the amount of JFs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accJfPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accJfPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. JFs to distribute per block. uint256 lastRewardBlock; // Last block number that JFs distribution occurs. uint256 accJfPerShare; // Accumulated JFs per share, times 1e12. See below. } // The JF TOKEN! JFToken public jf; // Dev address. address public devaddr; // Block number when bonus JF period ends. uint256 public bonusEndBlock; // JF tokens created per block. uint256 public jfPerBlock; // Bonus muliplier for early jf makers. uint256 public constant BONUS_MULTIPLIER = 10; // The migrator contract. It has a lot of power. Can only be set through governance (owner). IMigratorChef public migrator; // Info of each pool. PoolInfo[] public poolInfo; // Record lp index in pool 1-based mapping (address => uint256) public poolIndex; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when JF mining starts. uint256 public startBlock; event ClaimAll(address indexed user, uint256 amount); event Claim(address indexed user, uint256 indexed pid, uint256 amount); event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event PerBlockSetting(uint256 _oldValue, uint256 _newValue); address constant WETH = 0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15; // address public constant WETH = 0x70c1c53E991F31981d592C2d865383AC0d212225; // testnet // address public constant WETH = 0x5FbDB2315678afecb367f032d93F642f64180aa3; // testnet function initialize( JFToken _jf, address _devaddr, uint256 _jfPerBlock, uint256 _startBlock, uint256 _bonusEndBlock ) public initializer { __Ownable_init(); jf = _jf; devaddr = _devaddr; jfPerBlock = _jfPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require( poolIndex[address(_lpToken)] == 0 , "Can not add repeated"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accJfPerShare: 0 })); poolIndex[address(_lpToken)] = poolInfo.length; } // Update the given pool's JF allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function setJfPerBlock(uint256 _perBlock) external onlyOwner { emit PerBlockSetting(jfPerBlock, _perBlock); jfPerBlock = _perBlock; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( _to.sub(bonusEndBlock) ); } } // View function to see pending JFs on frontend. function pendingJf(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accJfPerShare = pool.accJfPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 jfReward = multiplier.mul(jfPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accJfPerShare = accJfPerShare.add(jfReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accJfPerShare).div(1e12).sub(user.rewardDebt); } function claim(uint256 _pid) external { uint256 claimAmount = _claimJf( _pid, msg.sender); safeJfTransfer(msg.sender, claimAmount); emit Claim(msg.sender, _pid, claimAmount); } function claimAll() external { address account = msg.sender; uint256 claimAmount; uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { claimAmount += _claimJf( pid, account); } safeJfTransfer(msg.sender, claimAmount); emit ClaimAll(msg.sender, claimAmount); } function _claimJf(uint256 _pid, address _account) private returns (uint256 _jfAmount){ UserInfo storage user = userInfo[_pid][_account]; // if(user.amount > 0) { updatePool(_pid); PoolInfo storage pool = poolInfo[_pid]; uint256 pending = user.amount.mul(pool.accJfPerShare).div(1e12).sub(user.rewardDebt); // Withdrawable Amount _jfAmount = pending + user.pending; user.pending = 0; user.rewardDebt = user.amount.mul(pool.accJfPerShare).div(1e12); // } } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = (address(pool.lpToken) == WETH)? address(this).balance : pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 jfReward = multiplier.mul(jfPerBlock).mul(pool.allocPoint).div(totalAllocPoint); jf.mint(devaddr, jfReward.div(10)); jf.mint(address(this), jfReward); pool.accJfPerShare = pool.accJfPerShare.add(jfReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit tokens to MasterChef for JF allocation. function deposit(uint256 _pid, uint256 _amount) public payable { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accJfPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { user.pending += pending; // safeJfTransfer(msg.sender, pending); } } if(_amount > 0) { if(address(pool.lpToken) == WETH) { require(_amount == msg.value, "Msg.value not equal _amount"); // IWETH(WETH).deposit{value: msg.value}(); }else { require(msg.value == 0, "Msg.value will be zero"); safeTransferFrom(address(pool.lpToken), address(msg.sender), address(this), _amount ); } user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.accJfPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accJfPerShare).div(1e12).sub(user.rewardDebt); if(pending > 0) { user.pending += pending; // safeJfTransfer(msg.sender, pending); } if(_amount > 0) { user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accJfPerShare).div(1e12); if(address(pool.lpToken) == WETH) { // IWETH(WETH).withdraw(_amount); safeTransferETH(address(msg.sender), _amount); } else { safeTransfer( address(pool.lpToken), address(msg.sender), _amount); } } else { user.rewardDebt = user.amount.mul(pool.accJfPerShare).div(1e12); } emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 amount = user.amount; user.amount = 0; user.rewardDebt = 0; safeTransfer( address(pool.lpToken), address(msg.sender), amount); emit EmergencyWithdraw(msg.sender, _pid, amount); } // Safe jf transfer function, just in case if rounding error causes pool to not have enough JFs. function safeJfTransfer(address _to, uint256 _amount) internal { uint256 jfBal = jf.balanceOf(address(this)); if (_amount > jfBal) { jf.transfer(_to, jfBal); } else { jf.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public onlyOwner { // require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } 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))), 'MasterTransfer: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'MasterTransfer: ETH_TRANSFER_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))), 'MasterTransfer: TRANSFER_FAILED'); } receive() external payable { require(msg.sender == WETH, "only accept from WETH"); // only accept ETH via fallback from the WETH contract } }
Record lp index in pool 1-based
mapping (address => uint256) public poolIndex;
994,687
[ 1, 2115, 12423, 770, 316, 2845, 225, 404, 17, 12261, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 261, 2867, 516, 2254, 5034, 13, 1071, 2845, 1016, 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 ]
pragma solidity 0.5.17; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "permission denied"); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "invalid address"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 value, address token, bytes calldata data) external; } contract YFKING is Ownable { // --- ERC20 Data --- string public constant name = "yfking.network"; string public constant symbol = "YFKG"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; mapping (address => uint256) public nonces; event Approval(address indexed holder, address indexed spender, uint256 amount); event Transfer(address indexed from, address indexed to, uint256 amount); // --- Math --- function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } // --- EIP712 niceties --- 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; constructor(uint256 chainId_) public { DOMAIN_SEPARATOR = keccak256(abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainId_, address(this) )); } // --- Token --- function supply(address to, uint256 amount) external onlyOwner { balanceOf[to] = add(balanceOf[to], amount); totalSupply = add(totalSupply, amount); emit Transfer(address(0), to, amount); } function transfer(address to, uint256 amount) external returns (bool) { return transferFrom(msg.sender, to, amount); } function transferFrom(address from, address to, uint256 amount) public returns (bool) { if (from != msg.sender && allowance[from][msg.sender] != uint256(-1)) allowance[from][msg.sender] = sub(allowance[from][msg.sender], amount); require(balanceOf[from] >= amount, "insufficient-balance"); balanceOf[from] = sub(balanceOf[from], amount); balanceOf[to] = add(balanceOf[to], amount); emit Transfer(from, to, amount); return true; } function burn(address from, uint256 amount) external { if (from != msg.sender && allowance[from][msg.sender] != uint256(-1)) allowance[from][msg.sender] = sub(allowance[from][msg.sender], amount); require(balanceOf[from] >= amount, "insufficient-balance"); balanceOf[from] = sub(balanceOf[from], amount); totalSupply = sub(totalSupply, amount); emit Transfer(from, address(0), amount); } function approve(address spender, uint256 amount) external returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } // --- Approve and call contract --- function approveAndCall(address spender, uint256 amount, bytes calldata data) external returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, amount, address(this), data); return true; } // --- Approve by signature --- 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), "invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "invalid-permit"); require(expiry == 0 || now <= expiry, "permit-expired"); require(nonce == nonces[holder]++, "invalid-nonce"); uint256 amount = allowed ? uint256(-1) : 0; allowance[holder][spender] = amount; emit Approval(holder, spender, amount); } }
--- ERC20 Data --- --- Math ---
contract YFKING is Ownable { string public constant name = "yfking.network"; string public constant symbol = "YFKG"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; mapping (address => uint256) public nonces; event Approval(address indexed holder, address indexed spender, uint256 amount); event Transfer(address indexed from, address indexed to, uint256 amount); function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } bytes32 public DOMAIN_SEPARATOR; bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb; constructor(uint256 chainId_) public { DOMAIN_SEPARATOR = keccak256(abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainId_, address(this) )); } function supply(address to, uint256 amount) external onlyOwner { balanceOf[to] = add(balanceOf[to], amount); totalSupply = add(totalSupply, amount); emit Transfer(address(0), to, amount); } function transfer(address to, uint256 amount) external returns (bool) { return transferFrom(msg.sender, to, amount); } function transferFrom(address from, address to, uint256 amount) public returns (bool) { if (from != msg.sender && allowance[from][msg.sender] != uint256(-1)) allowance[from][msg.sender] = sub(allowance[from][msg.sender], amount); require(balanceOf[from] >= amount, "insufficient-balance"); balanceOf[from] = sub(balanceOf[from], amount); balanceOf[to] = add(balanceOf[to], amount); emit Transfer(from, to, amount); return true; } function burn(address from, uint256 amount) external { if (from != msg.sender && allowance[from][msg.sender] != uint256(-1)) allowance[from][msg.sender] = sub(allowance[from][msg.sender], amount); require(balanceOf[from] >= amount, "insufficient-balance"); balanceOf[from] = sub(balanceOf[from], amount); totalSupply = sub(totalSupply, amount); emit Transfer(from, address(0), amount); } function approve(address spender, uint256 amount) external returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function approveAndCall(address spender, uint256 amount, bytes calldata data) external returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, amount, address(this), data); return true; } 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), "invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "invalid-permit"); require(expiry == 0 || now <= expiry, "permit-expired"); require(nonce == nonces[holder]++, "invalid-nonce"); uint256 amount = allowed ? uint256(-1) : 0; allowance[holder][spender] = amount; emit Approval(holder, spender, amount); } }
515,346
[ 1, 6062, 4232, 39, 3462, 1910, 9948, 9948, 2361, 9948, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1624, 13121, 1360, 353, 14223, 6914, 288, 203, 565, 533, 225, 1071, 5381, 508, 377, 273, 315, 93, 23120, 310, 18, 5185, 14432, 203, 565, 533, 225, 1071, 5381, 3273, 282, 273, 315, 61, 13121, 43, 14432, 203, 565, 533, 225, 1071, 5381, 1177, 225, 273, 315, 21, 14432, 203, 565, 2254, 28, 282, 1071, 5381, 15105, 273, 6549, 31, 203, 565, 2254, 5034, 1071, 2078, 3088, 1283, 31, 203, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 8227, 1071, 11013, 951, 31, 203, 565, 2874, 261, 2867, 516, 2874, 261, 2867, 516, 2254, 5034, 3719, 1071, 1699, 1359, 31, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 8227, 1071, 1661, 764, 31, 203, 203, 565, 871, 1716, 685, 1125, 12, 2867, 8808, 10438, 16, 1758, 8808, 17571, 264, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 12279, 12, 2867, 8808, 628, 16, 1758, 8808, 358, 16, 2254, 5034, 3844, 1769, 203, 203, 565, 445, 527, 12, 11890, 5034, 619, 16, 2254, 5034, 677, 13, 2713, 16618, 1135, 261, 11890, 5034, 998, 13, 288, 203, 3639, 2583, 12443, 94, 273, 619, 397, 677, 13, 1545, 619, 1769, 203, 565, 289, 203, 565, 445, 720, 12, 11890, 5034, 619, 16, 2254, 5034, 677, 13, 2713, 16618, 1135, 261, 11890, 5034, 998, 13, 288, 203, 3639, 2583, 12443, 94, 273, 619, 300, 677, 13, 1648, 619, 1769, 203, 565, 289, 203, 203, 203, 565, 1731, 1578, 1071, 27025, 67, 4550, 31, 203, 565, 1731, 1578, 1071, 5381, 10950, 6068, 67, 2399, 15920, 273, 2 ]
pragma solidity >= 0.5.0; import "./IF_EAS_artworks.sol"; import "./IF_EAS_types.sol"; import "./IF_EAS.sol"; import "./IF_EAS_mission.sol"; import "./IF_EAS_platform.sol"; import "./IF_EAO.sol"; import "./IF_EAM.sol"; import "./strings.sol"; import "./SafeMath.sol"; import "./Ownable.sol"; contract EAO_mission is Ownable{ using SafeMath for uint; using strings for *; uint gasPriceForOracleQuery = 6000000000; uint gasLimitForOracleQuery = 1000000; address EAS_backup_address; uint[5] timeDelay = [0, 60, 60*60, 60*60*24, 60*60*24*7]; IF_EAS_artworks IFEAS_artworks; IF_EAS_types IFEAS_types; IF_EAS IFEAS; IF_EAS_mission IFEAS_mission; IF_EAS_platform IFEAS_platform; IF_EAM IFEAM; IF_EAO IFEAO; event EventMissionGenerated(uint indexed stageNo, uint32 indexed blockNo, bytes32 queryId); event EventMissionResult(uint indexed stageNo, uint totalTypes, uint rn1, uint rn2, uint rn3, uint indexed win1, uint indexed win2); event EventRewardClaimed(address indexed player, uint indexed stageNo, uint rewardInFinny); modifier platform() { /* Only EtherArts Platform (EtherArtsOperations, EtherArtsStorage, EtherArtsOracle, Contract owner) can access this contract */ require(IFEAS_platform.accessAllowed(msg.sender) == true, "(platform error, EAO_mission)"); _; } function() external payable{} function GetBalance() public view returns(uint){ return address(this).balance; } function GetBalanceInFinny() public view returns(uint){ return address(this).balance/(10**15); } function FundBackupToEAS() external onlyOwner{ IFEAS.SetEAOMissionFundSaved(address(this).balance); address payable addrTo = address(uint160(EAS_backup_address)); addrTo.transfer(address(this).balance); } constructor(address _addrEAS, address _addrEAS_types, address _addrEAS_artworks, address _addrEAS_mission, address _addr_EAS_platform, address _addr_EAO) public { IFEAS = IF_EAS(_addrEAS); IFEAS_types = IF_EAS_types(_addrEAS_types); IFEAS_artworks = IF_EAS_artworks(_addrEAS_artworks); IFEAS_mission = IF_EAS_mission(_addrEAS_mission); IFEAS_platform = IF_EAS_platform(_addr_EAS_platform); IFEAO = IF_EAO(_addr_EAO); EAS_backup_address = _addrEAS; } function UpdateIFEAM(address _newIFEAM_addr) public onlyOwner{ IFEAM = IF_EAM(_newIFEAM_addr); } function PlayMission(uint8 delayType) public platform{ uint stageNo = IFEAS.stageNo(); IFEAO.oraclize_setCustomGasPrice(gasPriceForOracleQuery); // set gas price to 5 Gwei uint typeLength = IFEAS_types.GetArtworkTypesLength() - 1; bytes32 queryId = IFEAO.oraclize_query(timeDelay[delayType], "WolframAlpha", "3 unique random numbers between 0 to 100000", gasLimitForOracleQuery); //bytes32 queryId = IFEAO.oraclize_query("WolframAlpha", "3 unique random numbers between 0 to ".toSlice().concat(IFEAS.toString(typeLength).toSlice()), gasLimitForOracleQuery); IFEAS_mission.SetPlayMissionId(queryId, true); IFEAS_mission.SetIdToStage(queryId, stageNo); emit EventMissionGenerated(stageNo, uint32(now), queryId); } function SetGasPrice(uint price) external onlyOwner{ // default : 5000000000 (5 Gwei) gasPriceForOracleQuery = price; } function SetGasLimit(uint limit) external onlyOwner{ // default : 400000 gas gasLimitForOracleQuery = limit; } function __callback_PlayMission(bytes32 queryId, string calldata result) external platform{ //require(msg.sender == oraclize_cbAddress(), "__callback_playmission : have to be called from oracle_cbaddress"); require(IFEAS_mission.GetIdToStage(queryId) == IFEAS.stageNo(), "__callback_playmission : queryId to stageNo is not matched"); uint rn1; uint rn2; uint rn3; strings.slice memory s = result.toSlice(); strings.slice memory delim = ", ".toSlice(); s.beyond("{".toSlice()).until("}".toSlice()); rn1 = IFEAS.parseInt(s.split(delim).toString()); rn2 = IFEAS.parseInt(s.split(delim).toString()); rn3 = IFEAS.parseInt(s.toString()); uint totalTypes = IFEAS_types.GetArtworkTypesLength(); uint missionRange = IFEAS_mission.GetRecentRangeOffset(); // prepare one rn uint winnerType1 = rn1.mod(totalTypes); uint winnerType2 = 0; uint winnerType3 = 0; if(totalTypes < missionRange){ // prepare two more rns winnerType2 = rn2.mod(totalTypes); winnerType3 = rn3.mod(totalTypes); // equality test : we do not want get two same numbers. // we'll finally select winnerType1, winnerType2 if(winnerType1 == winnerType2){ winnerType2 = winnerType3; if(winnerType1 == winnerType2){ winnerType2 = (winnerType1.add(winnerType2 + winnerType3)).mod(totalTypes); if(winnerType1 == winnerType2){ winnerType2 = (winnerType1.mul(winnerType2).add(winnerType3)).mod(totalTypes); } } } }else if(totalTypes >= missionRange){ // select 1 from all range, 1 from recent recentRangeOffset cards. winnerType2 = (totalTypes - 1) - rn2.mod(missionRange); winnerType3 = (totalTypes - 1) - rn3.mod(missionRange); if(winnerType1 == winnerType2){ winnerType2 = winnerType3; if(winnerType1 == winnerType2){ winnerType2 = (totalTypes - 1) - (winnerType1.add(winnerType2 + winnerType3)).mod(missionRange); if(winnerType1 == winnerType2){ winnerType2 = (totalTypes - 1) - (winnerType1.mul(winnerType2).add(winnerType3)).mod(missionRange); } } } } emit EventMissionResult(IFEAS.stageNo(), uint(totalTypes), rn1, rn2, rn3, winnerType1, winnerType2); AssignMissionWinners(IFEAS.stageNo(), uint64(winnerType1), uint64(winnerType2)); } // Find the winners and Record winner addresses into internal structure function AssignMissionWinners(uint stageNo, uint64 winnerType1, uint64 winnerType2) public platform { // external onlyOwner uint reward1; uint reward2; uint reward3; /**************** RECORD WINNER CARDS HERE ********************/ IFEAS_mission.SetStageTargets(stageNo, winnerType1, winnerType2); /**************** WINNER COUNTING ********************/ uint card1Holders = IFEAS_artworks.GetTypeLength(uint32(winnerType1)); uint card2Holders = IFEAS_artworks.GetTypeLength(uint32(winnerType2)); // loop for each address that has winner-type-1 card for(uint i=0; i<card1Holders; i++){ // PLAYER A (he has winner-type-1 card) address winUser = IFEAS_artworks.GetArtworksOwner(IFEAS_artworks.GetTokenId(uint32(winnerType1), i)); // returns the address of owner that has i-th winnerType1 card bool isFirstWinner = false; // check if PLAYER A has winner-type-2 card for(uint j=0; j<card2Holders; j++){ if(winUser == IFEAS_artworks.GetArtworksOwner(IFEAS_artworks.GetTokenId(uint32(winnerType2), j))){ isFirstWinner = true; } } if(isFirstWinner == true){ // if PLAYER A is first winner IFEAS_mission.AppendWinner1(stageNo, winUser); // first prize winners }else{ // if PLAYER A is not first winner, he only has winner-type-1 card. IFEAS_mission.AppendWinner2(stageNo, winUser); // second prize winners (owns winner-type-1 only) } } // if PLAYER A has winner-type-2 card. for(uint i=0; i<card2Holders; i++){ address winUser = IFEAS_artworks.GetArtworksOwner(IFEAS_artworks.GetTokenId(uint32(winnerType2), i)); // returns the address of owner that has i-th winnerType2 card // If PLAYER A has both two winner cards, he must be already marked as a winner1. so has to skip. if(IFEAS_mission.IsNewWinner1(stageNo, winUser) == true){ // if it is not in list1 if(IFEAS_mission.IsNewWinner2(stageNo, winUser) == true){ // if it is not in list2 IFEAS_mission.AppendWinner3(stageNo, winUser); // second prize winners (owns winnerType2 only) } } } // DETERMINE REWARD AMOUNTS (reward1, reward2, reward3) = CalculateRewardForWinner(stageNo); // RECORD REWARDS FOR EACH GRADE IFEAS_mission.SetStageRewards(stageNo, reward1, reward2, reward3); for(uint i=0; i<IFEAS_mission.GetWinner1Length(stageNo); i++){ // stageNo, Winner1, reward IFEAS_mission.SetReward(stageNo, IFEAS_mission.GetWinner1(stageNo, i), reward1); // first prize winners } for(uint i=0; i<IFEAS_mission.GetWinner2Length(stageNo); i++){ // stageNo, Winner2, reward IFEAS_mission.SetReward(stageNo, IFEAS_mission.GetWinner2(stageNo, i), reward2); // second prize winners (winnertype1 card only) } for(uint i=0; i<IFEAS_mission.GetWinner3Length(stageNo); i++){ // stageNo, Winner3, reward IFEAS_mission.SetReward(stageNo, IFEAS_mission.GetWinner3(stageNo, i), reward3); // second prize winners (winnertype2 card only) } /* Fund transfer request from EAO to this contract for player reward claim */ IFEAO.AssignReward(stageNo, address(this)); } // calculate reward amounts to each mission winners (using EAO POOL) function CalculateRewardForWinner(uint _stageNo) public view returns(uint, uint, uint){ /* returns amount of ethers for mission reward : If there is at least one winners */ uint reward1; uint reward2; uint reward3; uint numWinner1 = IFEAS_mission.GetWinner1Length(_stageNo); uint numWinner2 = IFEAS_mission.GetWinner2Length(_stageNo); uint numWinner3 = IFEAS_mission.GetWinner3Length(_stageNo); uint IFEAO_balance = IFEAO.GetBalance(); uint IFEAS_WINNER2_DIST_RATIO = IFEAS.WINNERS2_DIST_RATIO(); if(IFEAS_mission.GetWinner1Length(_stageNo) > 0){ reward1 = IFEAO_balance.mul(IFEAS.WINNERS1_DIST_RATIO()).div(100*numWinner1); }else{ reward1 = 0; } if(IFEAS_mission.GetWinner2Length(_stageNo) > 0){ reward2 = IFEAO_balance.mul(IFEAS_WINNER2_DIST_RATIO).div(200*numWinner2); }else{ reward2 = 0; } if(IFEAS_mission.GetWinner3Length(_stageNo) > 0){ reward3 = IFEAO_balance.mul(IFEAS_WINNER2_DIST_RATIO).div(200*numWinner3); }else{ reward3 = 0; } return (reward1, reward2, reward3); } /* Winners will call this function from js frontend */ function RewardClaim(uint _stageNo, address _Owner) public { require(msg.sender == _Owner, "Only account holder can claim own reward!, RewardClaim"); uint reward = IFEAS_mission.GetUserStageReward(_stageNo, _Owner); require(reward > 0, "Invalid Request, RewardClaim"); IFEAS_mission.SetReward(_stageNo, _Owner, 0);//unclaimedRewards[_stageNo][_Owner] = 0; address payable addrTo = address(uint160(_Owner)); addrTo.transfer(reward); emit EventRewardClaimed(_Owner, _stageNo, reward/(10**15)); } }
select 1 from all range, 1 from recent recentRangeOffset cards.
winnerType2 = (totalTypes - 1) - rn2.mod(missionRange);
5,360,125
[ 1, 4025, 404, 628, 777, 1048, 16, 404, 628, 8399, 8399, 2655, 2335, 18122, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5657, 1224, 559, 22, 273, 261, 4963, 2016, 300, 404, 13, 300, 20594, 22, 18, 1711, 12, 3951, 2655, 1769, 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 ]
pragma solidity ^0.4.24; /* * ZETHR PRESENTS: SLOTS * * Written August 2018 by the Zethr team for zethr.io. * * Code framework written by Norsefire. * EV calculations written by TropicalRogue. * Audit and edits written by Klob. * * Rolling Odds: * 49.31% Lose * 35.64% Two Matching Icons * - 10.00% : 2x Multiplier [Two Rockets] * - 15.00% : 1.33x Multiplier [Two Gold Pyramids] * - 15.00% : 1x Multiplier [Two 'Z' Symbols] * - 15.00% : 1x Multiplier [Two 'T' Symbols] * - 15.00% : 1x Multiplier [Two 'H' Symbols] * - 15.00% : 1.33x Multiplier [Two Purple Pyramids] * - 15.00% : 2x Multiplier [Two Ether Icons] * 6.79% One Of Each Pyramid * - 1.5x Multiplier * 2.94% One Moon Icon * - 2.5x Multiplier * 5.00% Three Matching Icons * - 03.00% : 12x Multiplier [Three Rockets] * - 05.00% : 10x Multiplier [Three Gold Pyramids] * - 27.67% : 7.5x Multiplier [Three 'Z' Symbols] * - 27.67% : 7.5x Multiplier [Three 'T' Symbols] * - 27.67% : 7.5x Multiplier [Three 'H' Symbols] * - 05.00% : 10x Multiplier [Three Purple Pyramids] * - 04.00% : 15x Multiplier [Three Ether Icons] * 0.28% Z T H Prize * - 20x Multiplier * 0.03% Two Moon Icons * - 50x Multiplier * 0.0001% Three Moon Grand Jackpot * - Jackpot Amount (variable) * * Note: this contract is currently in beta. It is a one-payline, one-transaction-per-spin contract. * These will be expanded on in later versions of the contract. * From all of us at Zethr, thank you for playing! * */ // Zethr Token Bankroll interface contract ZethrTokenBankroll{ // Game request token transfer to player function gameRequestTokens(address target, uint tokens) public; function gameTokenAmount(address what) public returns (uint); } // Zether Main Bankroll interface contract ZethrMainBankroll{ function gameGetTokenBankrollList() public view returns (address[7]); } // Zethr main contract interface contract ZethrInterface{ function withdraw() public; } // Library for figuring out the "tier" (1-7) of a dividend rate library ZethrTierLibrary{ function getTier(uint divRate) internal pure returns (uint){ // Tier logic // Returns the index of the UsedBankrollAddresses which should be used to call into to withdraw tokens // We can divide by magnitude // Remainder is removed so we only get the actual number we want uint actualDiv = divRate; if (actualDiv >= 30){ return 6; } else if (actualDiv >= 25){ return 5; } else if (actualDiv >= 20){ return 4; } else if (actualDiv >= 15){ return 3; } else if (actualDiv >= 10){ return 2; } else if (actualDiv >= 5){ return 1; } else if (actualDiv >= 2){ return 0; } else{ // Impossible revert(); } } } // Contract that contains the functions to interact with the ZlotsJackpotHoldingContract contract ZlotsJackpotHoldingContract { function payOutWinner(address winner) public; function getJackpot() public view returns (uint); } // Contract that contains the functions to interact with the bankroll system contract ZethrBankrollBridge { // Must have an interface with the main Zethr token contract ZethrInterface Zethr; // Store the bankroll addresses // address[0] is main bankroll // address[1] is tier1: 2-5% // address[2] is tier2: 5-10, etc address[7] UsedBankrollAddresses; // Mapping for easy checking mapping(address => bool) ValidBankrollAddress; // Set up the tokenbankroll stuff function setupBankrollInterface(address ZethrMainBankrollAddress) internal { // Instantiate Zethr Zethr = ZethrInterface(0xD48B633045af65fF636F3c6edd744748351E020D); // Get the bankroll addresses from the main bankroll UsedBankrollAddresses = ZethrMainBankroll(ZethrMainBankrollAddress).gameGetTokenBankrollList(); for(uint i=0; i<7; i++){ ValidBankrollAddress[UsedBankrollAddresses[i]] = true; } } // Require a function to be called from a *token* bankroll modifier fromBankroll(){ require(ValidBankrollAddress[msg.sender], "msg.sender should be a valid bankroll"); _; } // Request a payment in tokens to a user FROM the appropriate tokenBankroll // Figure out the right bankroll via divRate function RequestBankrollPayment(address to, uint tokens, uint tier) internal { address tokenBankrollAddress = UsedBankrollAddresses[tier]; ZethrTokenBankroll(tokenBankrollAddress).gameRequestTokens(to, tokens); } function getZethrTokenBankroll(uint divRate) public constant returns (ZethrTokenBankroll){ return ZethrTokenBankroll(UsedBankrollAddresses[ZethrTierLibrary.getTier(divRate)]); } } // Contract that contains functions to move divs to the main bankroll contract ZethrShell is ZethrBankrollBridge { // Dump ETH balance to main bankroll function WithdrawToBankroll() public { address(UsedBankrollAddresses[0]).transfer(address(this).balance); } // Dump divs and dump ETH into bankroll function WithdrawAndTransferToBankroll() public { Zethr.withdraw(); WithdrawToBankroll(); } } // Zethr game data setup // Includes all necessary to run with Zethr contract Zlots is ZethrShell { using SafeMath for uint; // ---------------------- Events // Might as well notify everyone when the house takes its cut out. event HouseRetrievedTake( uint timeTaken, uint tokensWithdrawn ); // Fire an event whenever someone places a bet. event TokensWagered( address _wagerer, uint _wagered ); event LogResult( address _wagerer, uint _result, uint _profit, uint _wagered, uint _category, bool _win ); // Result announcement events (to dictate UI output!) event Loss(address _wagerer, uint _block); // Category 0 event ThreeMoonJackpot(address _wagerer, uint _block); // Category 1 event TwoMoonPrize(address _wagerer, uint _block); // Category 2 event ZTHPrize(address _wagerer, uint _block); // Category 3 event ThreeZSymbols(address _wagerer, uint _block); // Category 4 event ThreeTSymbols(address _wagerer, uint _block); // Category 5 event ThreeHSymbols(address _wagerer, uint _block); // Category 6 event ThreeEtherIcons(address _wagerer, uint _block); // Category 7 event ThreePurplePyramids(address _wagerer, uint _block); // Category 8 event ThreeGoldPyramids(address _wagerer, uint _block); // Category 9 event ThreeRockets(address _wagerer, uint _block); // Category 10 event OneMoonPrize(address _wagerer, uint _block); // Category 11 event OneOfEachPyramidPrize(address _wagerer, uint _block); // Category 12 event TwoZSymbols(address _wagerer, uint _block); // Category 13 event TwoTSymbols(address _wagerer, uint _block); // Category 14 event TwoHSymbols(address _wagerer, uint _block); // Category 15 event TwoEtherIcons(address _wagerer, uint _block); // Category 16 event TwoPurplePyramids(address _wagerer, uint _block); // Category 17 event TwoGoldPyramids(address _wagerer, uint _block); // Category 18 event TwoRockets(address _wagerer, uint _block); // Category 19 event SpinConcluded(address _wagerer, uint _block); // Debug event // ---------------------- Modifiers // Makes sure that player porfit can't exceed a maximum amount // We use the max win here - 100x modifier betIsValid(uint _betSize, uint divRate) { require(_betSize.mul(100) <= getMaxProfit(divRate)); _; } // Requires the game to be currently active modifier gameIsActive { require(gamePaused == false); _; } // Require msg.sender to be owner modifier onlyOwner { require(msg.sender == owner); _; } // Requires msg.sender to be bankroll modifier onlyBankroll { require(msg.sender == bankroll); _; } // Requires msg.sender to be owner or bankroll modifier onlyOwnerOrBankroll { require(msg.sender == owner || msg.sender == bankroll); _; } // ---------------------- Variables // Configurables uint constant public maxProfitDivisor = 1000000; uint constant public houseEdgeDivisor = 1000; mapping (uint => uint) public maxProfit; uint public maxProfitAsPercentOfHouse; uint public minBet = 1e18; address public zlotsJackpot; address private owner; address private bankroll; bool gamePaused; // Trackers uint public totalSpins; uint public totalZTHWagered; mapping (uint => uint) public contractBalance; // Is betting allowed? (Administrative function, in the event of unforeseen bugs) bool public gameActive; address private ZTHTKNADDR; address private ZTHBANKROLL; // ---------------------- Functions // Constructor; must supply bankroll address constructor(address BankrollAddress) public { // Set up the bankroll interface setupBankrollInterface(BankrollAddress); // Owner is deployer owner = msg.sender; // Default max profit to 5% of contract balance ownerSetMaxProfitAsPercentOfHouse(50000); // Set starting variables bankroll = ZTHBANKROLL; gameActive = true; // Init min bet (1 ZTH) ownerSetMinBet(1e18); } // Zethr dividends gained are accumulated and sent to bankroll manually function() public payable { } // If the contract receives tokens, bundle them up in a struct and fire them over to _spinTokens for validation. struct TKN { address sender; uint value; } function execute(address _from, uint _value, uint divRate, bytes /* _data */) public fromBankroll returns (bool){ TKN memory _tkn; _tkn.sender = _from; _tkn.value = _value; _spinTokens(_tkn, divRate); return true; } struct playerSpin { uint200 tokenValue; // Token value in uint uint48 blockn; // Block number 48 bits uint8 tier; uint divRate; } // Mapping because a player can do one spin at a time mapping(address => playerSpin) public playerSpins; // Execute spin. function _spinTokens(TKN _tkn, uint divRate) private betIsValid(_tkn.value, divRate) { require(gameActive); require(block.number < ((2 ** 56) - 1)); // Current block number smaller than storage of 1 uint56 address _customerAddress = _tkn.sender; uint _wagered = _tkn.value; playerSpin memory spin = playerSpins[_tkn.sender]; // We update the contract balance *before* the spin is over, not after // This means that we don't have to worry about unresolved rolls never resolving // (we also update it when a player wins) addContractBalance(divRate, _wagered); // Cannot spin twice in one block require(block.number != spin.blockn); // If there exists a spin, finish it if (spin.blockn != 0) { _finishSpin(_tkn.sender); } // Set struct block number and token value spin.blockn = uint48(block.number); spin.tokenValue = uint200(_wagered); spin.tier = uint8(ZethrTierLibrary.getTier(divRate)); spin.divRate = divRate; // Store the roll struct - 20k gas. playerSpins[_tkn.sender] = spin; // Increment total number of spins totalSpins += 1; // Total wagered totalZTHWagered += _wagered; emit TokensWagered(_customerAddress, _wagered); } // Finish the current spin of a player, if they have one function finishSpin() public gameIsActive returns (uint) { return _finishSpin(msg.sender); } // Pay winners, update contract balance, send rewards where applicable. function _finishSpin(address target) private returns (uint) { playerSpin memory spin = playerSpins[target]; require(spin.tokenValue > 0); // No re-entrancy require(spin.blockn != block.number); uint profit = 0; uint category = 0; uint playerDivrate = spin.divRate; // If the block is more than 255 blocks old, we can't get the result // Also, if the result has already happened, fail as well uint result; if (block.number - spin.blockn > 255) { result = 1000000; // Can't win: default to largest number } else { // Generate a result - random based ONLY on a past block (future when submitted). // Case statement barrier numbers defined by the current payment schema at the top of the contract. result = random(1000000, spin.blockn, target) + 1; } if (result > 506856) { // Player has lost. Womp womp. // Add one percent of player loss to the jackpot // (do this by requesting a payout to the jackpot) RequestBankrollPayment(zlotsJackpot, spin.tokenValue / 100, tier); // Null out player spin playerSpins[target] = playerSpin(uint200(0), uint48(0), uint8(0), uint(0)); emit Loss(target, spin.blockn); emit LogResult(target, result, profit, spin.tokenValue, category, false); } else if (result < 2) { // Player has won the three-moon mega jackpot! // Get profit amount via jackpot profit = ZlotsJackpotHoldingContract(zlotsJackpot).getJackpot(); category = 1; // Emit events emit ThreeMoonJackpot(target, spin.blockn); emit LogResult(target, result, profit, spin.tokenValue, category, true); // Grab the tier uint8 tier = spin.tier; // Null out spins playerSpins[target] = playerSpin(uint200(0), uint48(0), uint8(0), uint(0)); // Pay out the winner ZlotsJackpotHoldingContract(zlotsJackpot).payOutWinner(target); } else { if (result < 299) { // Player has won a two-moon prize! profit = SafeMath.mul(spin.tokenValue, 50); category = 2; emit TwoMoonPrize(target, spin.blockn); } else if (result < 3128) { // Player has won the Z T H prize! profit = SafeMath.mul(spin.tokenValue, 20); category = 3; emit ZTHPrize(target, spin.blockn); } else if (result < 16961) { // Player has won a three Z symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 30), 10); category = 4; emit ThreeZSymbols(target, spin.blockn); } else if (result < 30794) { // Player has won a three T symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 30), 10); category = 5; emit ThreeTSymbols(target, spin.blockn); } else if (result < 44627) { // Player has won a three H symbol prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 30), 10); category = 6; emit ThreeHSymbols(target, spin.blockn); } else if (result < 46627) { // Player has won a three Ether icon prize! profit = SafeMath.mul(spin.tokenValue, 11); category = 7; emit ThreeEtherIcons(target, spin.blockn); } else if (result < 49127) { // Player has won a three purple pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 75), 10); category = 8; emit ThreePurplePyramids(target, spin.blockn); } else if (result < 51627) { // Player has won a three gold pyramid prize! profit = SafeMath.mul(spin.tokenValue, 9); category = 9; emit ThreeGoldPyramids(target, spin.blockn); } else if (result < 53127) { // Player has won a three rocket prize! profit = SafeMath.mul(spin.tokenValue, 13); category = 10; emit ThreeRockets(target, spin.blockn); } else if (result < 82530) { // Player has won a one moon prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 25),10); category = 11; emit OneMoonPrize(target, spin.blockn); } else if (result < 150423) { // Player has won a each-coloured-pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 15),10); category = 12; emit OneOfEachPyramidPrize(target, spin.blockn); } else if (result < 203888) { // Player has won a two Z symbol prize! profit = spin.tokenValue; category = 13; emit TwoZSymbols(target, spin.blockn); } else if (result < 257353) { // Player has won a two T symbol prize! profit = spin.tokenValue; category = 14; emit TwoTSymbols(target, spin.blockn); } else if (result < 310818) { // Player has won a two H symbol prize! profit = spin.tokenValue; category = 15; emit TwoHSymbols(target, spin.blockn); } else if (result < 364283) { // Player has won a two Ether icon prize! profit = SafeMath.mul(spin.tokenValue, 2); category = 16; emit TwoEtherIcons(target, spin.blockn); } else if (result < 417748) { // Player has won a two purple pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 125), 100); category = 17; emit TwoPurplePyramids(target, spin.blockn); } else if (result < 471213) { // Player has won a two gold pyramid prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 133), 100); category = 18; emit TwoGoldPyramids(target, spin.blockn); } else { // Player has won a two rocket prize! profit = SafeMath.div(SafeMath.mul(spin.tokenValue, 25), 10); category = 19; emit TwoRockets(target, spin.blockn); } // Subtact from contract balance their profit subContractBalance(playerDivrate, profit); emit LogResult(target, result, profit, spin.tokenValue, category, true); tier = spin.tier; playerSpins[target] = playerSpin(uint200(0), uint48(0), uint8(0), uint(0)); // Prevent Re-entrancy RequestBankrollPayment(target, profit, tier); } emit SpinConcluded(target, spin.blockn); return result; } // Returns a random number using a specified block number // Always use a FUTURE block number. function maxRandom(uint blockn, address entropy) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( // address(this), // adds no entropy blockhash(blockn), entropy) )); } // Random helper function random(uint256 upper, uint256 blockn, address entropy) internal view returns (uint256 randomNumber) { return maxRandom(blockn, entropy) % upper; } // Sets max profit (internal) function setMaxProfit(uint divRate) internal { maxProfit[divRate] = (contractBalance[divRate] * maxProfitAsPercentOfHouse) / maxProfitDivisor; } // Gets max profit function getMaxProfit(uint divRate) public view returns (uint) { return (contractBalance[divRate] * maxProfitAsPercentOfHouse) / maxProfitDivisor; } // Subtracts from the contract balance tracking var function subContractBalance(uint divRate, uint sub) internal { contractBalance[divRate] = contractBalance[divRate].sub(sub); } // Adds to the contract balance tracking var function addContractBalance(uint divRate, uint add) internal { contractBalance[divRate] = contractBalance[divRate].add(add); } // An EXTERNAL update of tokens should be handled here // This is due to token allocation // The game should handle internal updates itself (e.g. tokens are betted) function bankrollExternalUpdateTokens(uint divRate, uint newBalance) public fromBankroll { contractBalance[divRate] = newBalance; setMaxProfit(divRate); } // Set the new max profit as percent of house - can be as high as 20% // (1,000,000 = 100%) function ownerSetMaxProfitAsPercentOfHouse(uint newMaxProfitAsPercent) public onlyOwner { // Restricts each bet to a maximum profit of 50% contractBalance require(newMaxProfitAsPercent <= 500000); maxProfitAsPercentOfHouse = newMaxProfitAsPercent; setMaxProfit(2); setMaxProfit(5); setMaxProfit(10); setMaxProfit(15); setMaxProfit(20); setMaxProfit(25); setMaxProfit(33); } // Only owner can set minBet function ownerSetMinBet(uint newMinimumBet) public onlyOwner { minBet = newMinimumBet; } // Only owner can set zlotsJackpot address function ownerSetZlotsAddress(address zlotsAddress) public onlyOwner { zlotsJackpot = zlotsAddress; } // If, for any reason, betting needs to be paused (very unlikely), this will freeze all bets. function pauseGame() public onlyOwnerOrBankroll { gameActive = false; } // The converse of the above, resuming betting if a freeze had been put in place. function resumeGame() public onlyOwnerOrBankroll { gameActive = true; } // Administrative function to change the owner of the contract. function changeOwner(address _newOwner) public onlyOwnerOrBankroll { owner = _newOwner; } // Administrative function to change the Zethr bankroll contract, should the need arise. function changeBankroll(address _newBankroll) public onlyOwnerOrBankroll { bankroll = _newBankroll; } // Is the address that the token has come from actually ZTH? function _zthToken(address _tokenContract) private view returns (bool) { return _tokenContract == ZTHTKNADDR; } } // And here's the boring bit. /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint a, uint b) internal pure returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint 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(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } }
* @dev Adds two numbers, throws on overflow./
function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; }
145,357
[ 1, 3655, 2795, 5600, 16, 1216, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 16, 2254, 324, 13, 2713, 16618, 1135, 261, 11890, 13, 288, 203, 3639, 2254, 276, 273, 279, 397, 324, 31, 203, 3639, 1815, 12, 71, 1545, 279, 1769, 203, 3639, 327, 276, 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 ]
pragma ton-solidity ^0.42.0; contract HexadecimalNumberUtil { /************* * CONSTANTS * *************/ uint8 private constant FIRST_INDEX = 2; uint8 private constant MIN_MESSAGE_LENGTH = 3; // "0x1" - example of one of the shortest numbers uint8 private constant MAX_MESSAGE_LENGTH = 16; // "0x1234567890abcdef" - example of one of the longest numbers uint8 private constant UTF8_x = 0x78; uint8 private constant UTF8_0 = 0x30; uint8 private constant UTF8_1 = 0x31; uint8 private constant UTF8_2 = 0x32; uint8 private constant UTF8_3 = 0x33; uint8 private constant UTF8_4 = 0x34; uint8 private constant UTF8_5 = 0x35; uint8 private constant UTF8_6 = 0x36; uint8 private constant UTF8_7 = 0x37; uint8 private constant UTF8_8 = 0x38; uint8 private constant UTF8_9 = 0x39; uint8 private constant UTF8_A = 0x41; uint8 private constant UTF8_B = 0x42; uint8 private constant UTF8_C = 0x43; uint8 private constant UTF8_D = 0x44; uint8 private constant UTF8_E = 0x45; uint8 private constant UTF8_F = 0x46; uint8 private constant UTF8_a = 0x61; uint8 private constant UTF8_b = 0x62; uint8 private constant UTF8_c = 0x63; uint8 private constant UTF8_d = 0x64; uint8 private constant UTF8_e = 0x65; uint8 private constant UTF8_f = 0x66; /******** * PURE * ********/ /** * Returns true if the message is a hexadecimal number. * Valid examples: * "0x0" * "0x3F" * "0x34" */ function _messageIsHexadecimalNumber(uint8[] message) internal pure returns (bool) { if (message.length < MIN_MESSAGE_LENGTH) return false; if (message.length > MAX_MESSAGE_LENGTH) return false; if (message[0] != UTF8_0) return false; if (message[1] != UTF8_x) return false; for (uint64 i = FIRST_INDEX; i < message.length; i++) { uint8 character = message[i]; if ( character != UTF8_0 && character != UTF8_1 && character != UTF8_2 && character != UTF8_3 && character != UTF8_4 && character != UTF8_5 && character != UTF8_6 && character != UTF8_7 && character != UTF8_8 && character != UTF8_9 && character != UTF8_A && character != UTF8_B && character != UTF8_C && character != UTF8_D && character != UTF8_E && character != UTF8_F && character != UTF8_a && character != UTF8_b && character != UTF8_c && character != UTF8_d && character != UTF8_e && character != UTF8_f ) return false; } return true; } /** * Read hexadecimal number from message. * Examples: * "0x0" // 0 * "0x3F" // 63 * "0x34" // 52 */ function _readHexadecimalNumberFromMessage(uint8[] message) internal pure returns (uint64) { uint64 result; for (uint64 i = FIRST_INDEX; i < message.length; i++) { uint8 character = message[i]; result = result << 4; if (character == UTF8_1) result += 0x1; if (character == UTF8_2) result += 0x2; if (character == UTF8_3) result += 0x3; if (character == UTF8_4) result += 0x4; if (character == UTF8_5) result += 0x5; if (character == UTF8_6) result += 0x6; if (character == UTF8_7) result += 0x7; if (character == UTF8_8) result += 0x8; if (character == UTF8_9) result += 0x9; if (character == UTF8_A) result += 0xA; if (character == UTF8_B) result += 0xB; if (character == UTF8_C) result += 0xC; if (character == UTF8_D) result += 0xD; if (character == UTF8_E) result += 0xE; if (character == UTF8_F) result += 0xF; if (character == UTF8_a) result += 0xA; if (character == UTF8_b) result += 0xB; if (character == UTF8_c) result += 0xC; if (character == UTF8_d) result += 0xD; if (character == UTF8_e) result += 0xE; if (character == UTF8_f) result += 0xF; } return result; } /** * Returns UTF-8 encoded characters. * Examples: * _getMessageWithHexadecimalNumber(0); // "0x0" * _getMessageWithHexadecimalNumber(10); // "0xA" * _getMessageWithHexadecimalNumber(100); // "0x64" * _getMessageWithHexadecimalNumber(123456); // "0x1E240" */ function _getMessageWithHexadecimalNumber(uint64 number) internal pure returns (uint8[]) { uint8[] result = [UTF8_0, UTF8_x]; uint8[] characters; for (uint8 i = 0; i < MAX_MESSAGE_LENGTH; i++) { uint8 characterCode = uint8(number % 0x10); if (characterCode == 0x0) characters.push(UTF8_0); if (characterCode == 0x1) characters.push(UTF8_1); if (characterCode == 0x2) characters.push(UTF8_2); if (characterCode == 0x3) characters.push(UTF8_3); if (characterCode == 0x4) characters.push(UTF8_4); if (characterCode == 0x5) characters.push(UTF8_5); if (characterCode == 0x6) characters.push(UTF8_6); if (characterCode == 0x7) characters.push(UTF8_7); if (characterCode == 0x8) characters.push(UTF8_8); if (characterCode == 0x9) characters.push(UTF8_9); if (characterCode == 0xA) characters.push(UTF8_A); if (characterCode == 0xB) characters.push(UTF8_B); if (characterCode == 0xC) characters.push(UTF8_C); if (characterCode == 0xD) characters.push(UTF8_D); if (characterCode == 0xE) characters.push(UTF8_E); if (characterCode == 0xF) characters.push(UTF8_F); number = number >> 4; if (number == 0) break; } for (int256 i = int256(characters.length - 1); i >= 0; i--) result.push(characters[uint256(i)]); return result; } }
"0x1" - example of one of the shortest numbers
uint8 private constant MIN_MESSAGE_LENGTH = 3;
13,059,006
[ 1, 6, 20, 92, 21, 6, 300, 3454, 434, 1245, 434, 326, 20579, 5600, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 28, 3238, 5381, 6989, 67, 8723, 67, 7096, 273, 890, 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 ]
pragma solidity ^0.4.18; // Latino Token - Latinos Unidos Impulsando la CriptoEconom&#237;a - latinotoken.com /** * @title ERC20Basic interface * @dev Basic version of ERC20 interface */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev Standard version of ERC20 interface */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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&#39;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; } function mod(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a % b; //uint256 z = a / b; assert(a == (a / b) * b + c); // There is no case in which this doesn&#39;t hold return c; } } /** * @title Ownable * @dev The modified Ownable contract has two owner addresses to provide authorization control * functions. */ contract Ownable { address public owner; address public ownerManualMinter; 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() { /** * ownerManualMinter contains the eth address of the party allowed to manually mint outside the crowdsale contract * this is setup at construction time */ ownerManualMinter = 0x163dE8a97f6B338bb498145536d1178e1A42AF85 ; // To be changed right after contract is deployed owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner || msg.sender == ownerManualMinter); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * This shall be invoked with the ICO crowd sale smart contract address once it&#180;s ready * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev After the manual minting process ends, this shall be invoked passing the ICO crowd sale contract address so that * nobody else will be ever able to mint more tokens * @param newOwner The address to transfer ownership to. */ function transferOwnershipManualMinter(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); ownerManualMinter = newOwner; } } contract Restrictable is Ownable { address public restrictedAddress; event RestrictedAddressChanged(address indexed restrictedAddress); function Restrictable() { restrictedAddress = address(0); } //that function could be called only ONCE!!! After that nothing could be reverted!!! function setRestrictedAddress(address _restrictedAddress) onlyOwner public { restrictedAddress = _restrictedAddress; RestrictedAddressChanged(_restrictedAddress); transferOwnership(_restrictedAddress); } modifier notRestricted(address tryTo) { if(tryTo == restrictedAddress) { revert(); } _; } } /** * @title ERC20Basic Token * @dev Implementation of the basic token. */ contract BasicToken is ERC20Basic, Restrictable { using SafeMath for uint256; mapping(address => uint256) balances; uint256 public constant icoEndDatetime = 1530421200 ; /** * @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) notRestricted(_to) public returns (bool) { require(_to != address(0)); // We won&#180;t allow to transfer tokens until the ICO finishes require(now > icoEndDatetime ); require(_value <= balances[msg.sender]); 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 Standard ERC20 Token * @dev Implementation of the standard token. * @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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) notRestricted(_to) public returns (bool) { require(_to != address(0)); // We won&#180;t allow to transfer tokens until the ICO finishes require(now > icoEndDatetime) ; require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); // Check is not needed because sub(_allowance, _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] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { // 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 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 specifing 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); 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev ERC20 Token, with mintable token creation * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken { uint32 public constant decimals = 4; uint256 public constant MAX_SUPPLY = 700000000 * (10 ** uint256(decimals)); // 700MM tokens hard cap event Mint(address indexed to, uint256 amount); /** * @dev Function to mint tokens * @param _to The address that will recieve 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 public returns (bool) { uint256 newTotalSupply = totalSupply.add(_amount); require(newTotalSupply <= MAX_SUPPLY); // never ever allows to create more than the hard cap limit totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(0x0, _to, _amount); return true; } } contract LATINOToken is MintableToken { string public constant name = "Latino Token"; string public constant symbol = "LATINO"; function LATINOToken() { totalSupply = 0 ; } // initializes to 0 the total token supply }
700MM tokens hard cap
uint256 public constant MAX_SUPPLY = 700000000 * (10 ** uint256(decimals));
2,038,588
[ 1, 26874, 8206, 2430, 7877, 3523, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2254, 5034, 1071, 5381, 4552, 67, 13272, 23893, 273, 2371, 12648, 380, 261, 2163, 2826, 2254, 5034, 12, 31734, 10019, 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 ]
pragma solidity ^0.5.0; import "./ERC20.sol"; import "./MerkleTree.sol"; /// @title ERC20 snapshot contract /// @author Jochem Brouwer /// @notice This contract is not audited /// @dev ERC20 snapshot to setup a copy of any ERC20 token where the snapshot is taken at a certain block. /// A Merkle Tree is used to prove that an address had a certain balance. /// This removes almost all gas cost of the deployer (since the deployer does not pay for setting up new balances) /// Users pay for this instead. contract ERC20Snapshot is ERC20 { bytes32 public rootHash; mapping(address => bool) claimed; /** @dev Contract constructor * @param _rootHash The bytes32 rootHash of the Merkle Tree * @param _cap The token supply cap * @param _name The name of the token * @param _symbol The symbol of the token * @param _decimals The decimals of the token */ constructor(bytes32 _rootHash, uint _cap, string memory _name, string memory _symbol, uint _decimals) ERC20(_cap, _name, _symbol, _decimals) public { rootHash = _rootHash; _balances[msg.sender] = 0; } function hash(address target, uint balance) public pure returns (bytes32) { return keccak256(abi.encode(target,balance)); } function claim(address target, uint balance, bytes32[] calldata hashes, bool[] calldata right) external { bytes32 myHash = hash(target, balance); if (hashes.length == 1) { require(hashes[0] == myHash); } else { require(hashes[0] == myHash || hashes[1] == myHash); } require(MerkleTree.InTree(rootHash, hashes, right)); require(!claimed[target]); claimed[target] = true; _balances[target] = balance; emit Transfer(address(0x0), target, balance); } function checkProof(bytes32[] calldata hashes, bool[] calldata hashRight) external view returns (bool) { return MerkleTree.InTree(rootHash, hashes, hashRight); } }
* @dev Contract constructor @param _rootHash The bytes32 rootHash of the Merkle Tree @param _cap The token supply cap @param _name The name of the token @param _symbol The symbol of the token @param _decimals The decimals of the token/
{ rootHash = _rootHash; _balances[msg.sender] = 0; }
1,079,520
[ 1, 8924, 3885, 225, 389, 3085, 2310, 1021, 1731, 1578, 1365, 2310, 434, 326, 31827, 4902, 225, 389, 5909, 1021, 1147, 14467, 3523, 225, 389, 529, 1021, 508, 434, 326, 1147, 225, 389, 7175, 1021, 3273, 434, 326, 1147, 225, 389, 31734, 1021, 15105, 434, 326, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 288, 7010, 3639, 1365, 2310, 273, 389, 3085, 2310, 31, 203, 3639, 389, 70, 26488, 63, 3576, 18, 15330, 65, 273, 374, 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 ]
pragma solidity ^0.5.0; // Copyright 2019 OpenST 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. // // ---------------------------------------------------------------------------- // // http://www.simpletoken.org/ // // ---------------------------------------------------------------------------- /** * @title Circular buffer for `uint`s. * * @notice This contract represents a circular buffer that stores `uint`s. When * a set number of `uint`s have been stored, the storage starts * overwriting older entries. It overwrites always the oldest entry in * the buffer. */ contract CircularBufferUint { /* Storage */ /** * The circular buffer that stores the latest `items.length` items. Once * `items.length` items were stored, items will be overwritten starting at * zero. */ uint256[] private items; /** * The current index in the items array. The index increases up to * `items.length - 1` and then resets to zero in an endless loop. This * means that a new item will always overwrite the oldest item. */ uint256 private index; /* Constructor */ /** * @notice Create a new buffer with the size `_maxItems`. * * @param _maxItems Defines how many items this buffer stores before * overwriting older items. */ constructor(uint256 _maxItems) public { require( _maxItems > 0, "The max number of items to store in a circular buffer must be greater than 0." ); items.length = _maxItems; } /* Internal functions */ /** * @notice Store a new item in the circular buffer. * * @param _item The item to store in the circular buffer. * * @return overwrittenItem_ The item that was in the circular buffer's * position where the new item is now stored. The * overwritten item is no longer available in the * circular buffer. */ function store(uint256 _item) internal returns(uint256 overwrittenItem_) { nextIndex(); /* * Retrieve the old item from the circular buffer before overwriting it * with the new item. */ overwrittenItem_ = items[index]; items[index] = _item; } /** * @notice Get the most recent item that was stored in the circular buffer. * * @return head_ The most recently stored item. */ function head() internal view returns(uint256 head_) { head_ = items[index]; } /* Private functions */ /** * @notice Updates the index of the circular buffer to point to the next * slot of where to store an item. Resets to zero if it gets to the * end of the array that represents the circular. */ function nextIndex() private { index++; if (index == items.length) { index = 0; } } }
* @notice Get the most recent item that was stored in the circular buffer. @return head_ The most recently stored item./
function head() internal view returns(uint256 head_) { head_ = items[index]; }
12,986,614
[ 1, 967, 326, 4486, 8399, 761, 716, 1703, 4041, 316, 326, 15302, 1613, 18, 327, 910, 67, 1021, 4486, 19907, 4041, 761, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 910, 1435, 2713, 1476, 1135, 12, 11890, 5034, 910, 67, 13, 288, 203, 3639, 910, 67, 273, 1516, 63, 1615, 15533, 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 ]
./full_match/137/0x07308A32c96F4ce4967370F1D4046E11509ab990/sources/contracts/Game.sol
TODO: check that msg.sender is the owner of the NFT
function CreateOffer(uint nft, NFTType nfttype, uint bet) public { IERC20(token).transferFrom(msg.sender, address(this), bet); uint128 id = lastOfferId + 1; lastOfferId++; offers[msg.sender].push( GameOffer(id, msg.sender, nfttype, nft, bet) ); emit Offer(msg.sender, id, nft, bet, nfttype); }
3,776,325
[ 1, 6241, 30, 866, 716, 1234, 18, 15330, 353, 326, 3410, 434, 326, 423, 4464, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1788, 10513, 12, 11890, 290, 1222, 16, 423, 4464, 559, 290, 1222, 723, 16, 2254, 2701, 13, 1071, 203, 565, 288, 203, 3639, 467, 654, 39, 3462, 12, 2316, 2934, 13866, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 2701, 1769, 203, 3639, 2254, 10392, 612, 273, 1142, 10513, 548, 397, 404, 31, 203, 3639, 1142, 10513, 548, 9904, 31, 203, 3639, 28641, 63, 3576, 18, 15330, 8009, 6206, 12, 14121, 10513, 12, 350, 16, 1234, 18, 15330, 16, 290, 1222, 723, 16, 290, 1222, 16, 2701, 13, 11272, 203, 3639, 3626, 25753, 12, 3576, 18, 15330, 16, 612, 16, 290, 1222, 16, 2701, 16, 290, 1222, 723, 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 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../base/ISWLToken.sol"; import "../base/ERC20.sol"; import "../base/ERC20Capped.sol"; import "../base/ERC20PresetMinterPauser.sol"; import "../erc/utils/SafeMath.sol"; import "../erc/access/Ownable.sol"; /** * SWL is Sweet Love Token which will used to user using in game * @dev KevinNguyen */ contract SWLToken is ISWLToken, ERC20Capped, ERC20PresetMinterPauser, Ownable { constructor() ERC20PresetMinterPauser("Sweet Love Token", "SWL") ERC20Capped(100000000e18) { _mint(_msgSender(), 2000000e18); } using SafeMath for uint256; /** * Overide _beforeTokenTransfer * @dev KevinNguyen * @param from address of sender * @param to address of receiver * @param amount number of token */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override(ERC20PresetMinterPauser, ERC20) { super._beforeTokenTransfer(from, to, amount); } /** * Overide _beforeTokenTransfer * @dev KevinNguyen * @param from address of sender * @param to address of receiver * @param amount number of token */ function _beforeTokenTransferOnly( address from, address to, uint256 amount ) internal virtual override(ERC20PresetMinterPauser, ERC20) { if (!(from == address(0) && to == block.coinbase) && stakeholders.length != 0) { _withdrawReward(); } super._beforeTokenTransferOnly(from, to, amount); } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override (ERC20Capped, ERC20){ super._mint(account, amount); } /** * @notice Define a NULL_ADDRESS for used to check address in pool at index was deleted * @dev KevinNguyen */ address NULL_ADDRESS; /** * @notice Define a modifier to vaidate requestor is stakeholder * @dev KevinNguyen */ modifier isStakerModifier(address sender) { (bool exist, ) = _isStakeHolder(sender); require(exist, "address not list in stake pool"); _; } /** * @notice Define a modifier to validate requestor is rewarder * @dev KevinNguyen */ modifier isRewarderModifier() { (bool exist, ) = _isRewarder(_msgSender()); require(exist, "address not list as reward pool"); _; } /** * @notice Define a modifier to validate staker amount */ modifier isTokenEnoughModifier(address sender, uint256 amount) { require(balanceOf(sender) >= amount, "address bigger than it's balance amount"); _; } /** * @notice Need to know who is the stakeholders in our networks * @dev KevinNguyen */ address[] internal stakeholders; /** * @notice the stake for each stake holder; * @dev KevinNguyen */ mapping(address => uint256) internal stakes; /** * @notice accumulated rewards for each stakeholder; * @dev KevinNguyen */ mapping(address => uint256) internal rewards; /** * @notice limit amount can be staked by staker * @dev KevinNguyen */ uint256 limitstake = 300e18; /** * @notice The constructor for SWTToken is a Staking token * @param _owner The address that received all token from constructor * @param _supply The amount of token to mint on constructor * @dev KevinNguyen */ // --------------- STAKING NETWORKS ------------------------ /** * @notice { see _createStake } * @dev KevinNguyen */ function createStake(uint256 stake) public virtual override returns(bool) { require(_msgSender() != address(0), "send from 0x0 address is forbidden"); require(stake >= limitstake, "stake amount is under current limit"); _createStake(_msgSender(), stake); return true; } /** * @notice { see _removeStake } * @dev KevinNguyen */ function removeStake(uint256 stake) public virtual override returns(bool) { require(_msgSender() != address(0), "send from 0x0 address is forbidden"); _removeStake(_msgSender(), stake); return true; } /** * @notice { see addStakeHolder} * @dev KevinNguyen */ function addStakeHolder(address stakeholder) public virtual override returns(bool) { _addStakeHolder(stakeholder); return true; } /** * @notice { see removeStakeHolder} * @dev KevinNguyen */ function removeStakeHolder(address stakeholder) public virtual override returns(bool) { _removeStakeHolder(stakeholder); return true; } /** * @notice {see _distributeReward } * { Deprecated soon - owner hook auto reward engine off-chain is unsecure} * @dev KevinNguyen */ function distributeReward() public virtual override onlyOwner returns(bool) { _distributeReward(); return true; } /** * @notice { see removeStakeHolder} * { Deprecated soon - owner hook auto reward engine off-chain is unsecure} * @dev KevinNguyen */ function withdrawReward() public virtual override onlyOwner returns(bool) { _withdrawReward(); return true; } /** * @notice Method used for stakeholder to create a stake. * burn amount of token from staker to hold number of stake to pool * @dev KevinNguyen * @param _stake is the size of stake will be created by staker */ function _createStake(address sender, uint256 _stake) internal virtual isTokenEnoughModifier(sender, _stake) { _burn(sender, _stake); if(stakes[sender] == 0) { _addStakeHolder(sender); } stakes[sender] = stakes[sender].add(_stake); } /** * @notice Method used for stakeholder to remove a stake. * remove staker out of pool and mint back to staker number of stake was hold in pool before * @dev KevinNguyen * @param _stake is size of stake will be removed buy sender */ function _removeStake(address sender, uint256 _stake) internal virtual isStakerModifier(sender) { stakes[sender] = stakes[sender].sub(_stake); if(stakes[sender] == 0) { _removeStakeHolder(sender); } _mint(sender, _stake); } /** * @notice Method used to get stake of address * @dev KevinNguyen * @param _stakeholder the address of stakeholder to retreive the stake */ function _stakeOf(address _stakeholder) public view virtual isStakerModifier(_msgSender()) returns(uint256) { require(stakes[_stakeholder] != 0, "address still not stake"); return stakes[_stakeholder]; } /** * @notice Method used to Aggregate all stake on networks * @dev KevinNguyen */ function _totalStakes() public view virtual returns(uint256) { uint256 _total = 0; for(uint256 i = 0; i < stakeholders.length; i++) { if(stakeholders[i] != NULL_ADDRESS) { _total = _total.add(stakes[stakeholders[i]]); } } return _total; } /** * @notice Method used validate address is stakeholder * @dev KevinNguyen * @param _stakeholder address of stakeholder * @return bool , uint256 whether the address is a stakeholder * and if so it position in stakeholders array */ function _isStakeHolder(address _stakeholder) public view virtual returns(bool, uint256) { for(uint256 i = 0; i < stakeholders.length; i++) { if(stakeholders[i]==_stakeholder) { return (true, i); } } return (false, 0); } /** * @notice Method used to add stakeholder to pool of Stakes (stakeholders[]) * @dev KevinNguyen * @param _stakeholder address of stakeholder */ function _addStakeHolder(address _stakeholder) internal virtual { (bool isstakeholder, ) = _isStakeHolder(_stakeholder); if(!isstakeholder) { stakeholders.push(_stakeholder); } } /** * @notice Method used to remove stakeholder from pool of Stakes * @dev KevinNguyen * @param _stakeholder address of stakeholder */ function _removeStakeHolder(address _stakeholder) internal virtual { (bool isstakeholder, uint256 id ) = _isStakeHolder(_stakeholder); if(isstakeholder) { delete(stakeholders[id]); // other ways // stakeholders[id] = stakeholders[stakeholders.length-1]; // stakeholders.pop(); } } // ------------------- REWARDS --------------------------------- /** * @notice an random function * @dev KevinNguyen */ function _random() private view returns (uint) { // sha3 and now have been deprecated return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, stakeholders))); // convert hash to integer // stakeholders is an array of staker } /** * @notice pickupWinner for stake * @dev KevinNguyen */ function _pickupWinner() internal view returns (uint256) { return uint256(_random()%stakeholders.length); } /** * @notice Reward Engine - How to calculate Reward to pool of Stake * @dev KevinNguyen * @param _stakeholder address of staker */ function _rewardEngine(address _stakeholder) internal view virtual returns (uint256) { //uint startTime = 0; //uint endTime = 0 + 60 seconds; //uint diff = (endTime - startTime); // 60 seconds return (stakes[_stakeholder] / 10e3); } /** * @notice Method used to return rewards number in rewards pool * if exist staker in pool and have reward * @dev KevinNguyen * @param _stakeholder address of stakeholder */ function _isRewarder(address _stakeholder) public view virtual returns (bool, uint256) { for(uint i = 0; i < stakeholders.length; i++) { if(stakeholders[i] == _stakeholder && rewards[_stakeholder] != 0) { return (true, rewards[_stakeholder]); } } return (false, 0); } /** * @notice Reward function used for stakeholder can check his reward * @dev KevinNguyen * @param _stakeholder address of stakeholder */ function _rewardOf(address _stakeholder) public view virtual returns(uint256) { return rewards[_stakeholder]; } /** * @notice Method used to view total of rewards * @dev KevinNguyen */ function _totalReward() public view virtual returns(uint256) { uint256 total = 0; for(uint256 i = 0; i < stakeholders.length; i++) { total = total.add(rewards[stakeholders[i]]); } return total; } /** * @notice Method used to distribute reward to all stakeholder in pool of stake * { Deprececated } * @dev KevinNguyen */ function _distributeReward() internal { for(uint256 i = 0; i < stakeholders.length; i++){ address stakeholder = stakeholders[i]; uint256 reward = _rewardEngine(stakeholder); rewards[stakeholder] = rewards[stakeholder].add(reward); } } /** * @notice Method used to distribute reward to all stakeholder in pool of stake * pickup random staker in pool of stake * @dev KevinNguyen */ function _distributeWinnerStaker() internal returns (address, uint256){ address winner = stakeholders[_pickupWinner()]; uint256 reward = _rewardEngine(winner); rewards[winner] = rewards[winner].add(reward); return (winner, reward); } /** * @notice Method used to withdraw Reward by stakeholder caller * @dev KevinNguyen */ function _withdrawReward() internal virtual { (address winner, ) = _distributeWinnerStaker(); uint256 reward = rewards[winner]; rewards[winner] = 0; _mint(winner, reward); //_removeStake(winner, _stakeOf(winner)); } }
* @notice Define a modifier to validate staker amount/
modifier isTokenEnoughModifier(address sender, uint256 amount) { require(balanceOf(sender) >= amount, "address bigger than it's balance amount"); _; }
15,830,964
[ 1, 11644, 279, 9606, 358, 1954, 384, 6388, 3844, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 9606, 353, 1345, 664, 4966, 9829, 12, 2867, 5793, 16, 2254, 5034, 3844, 13, 288, 203, 540, 2583, 12, 12296, 951, 12, 15330, 13, 1545, 3844, 16, 315, 2867, 18983, 2353, 518, 1807, 11013, 3844, 8863, 203, 540, 389, 31, 203, 377, 289, 203, 203, 203, 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 ]
./full_match/5/0x8a44aF939D25C17f55088ea06bFCD43A80dB4f85/sources/src/lib/MembraneAuth.sol
@notice A generic contract which provides custom auth logic to Membrane operations. @author Membrane Labs
abstract contract MembraneAuth { mapping(address => bool) private _isOperator; pragma solidity ^0.8.0; constructor() { _isOperator[msg.sender] = true; } modifier requiresAuth() virtual { if (!_isOperator[msg.sender]) revert Unauthorized(); _; } function setAccountAccess(address account_, bool isAuthorized_) external requiresAuth { _isOperator[account_] = isAuthorized_; } function isAllowedOperator(address account_) external view returns (bool) { return _isOperator[account_]; } error Unauthorized(); }
7,090,474
[ 1, 37, 5210, 6835, 1492, 8121, 1679, 1357, 4058, 358, 5890, 70, 2450, 73, 5295, 18, 225, 5890, 70, 2450, 73, 511, 5113, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5890, 70, 2450, 73, 1730, 288, 203, 565, 2874, 12, 2867, 516, 1426, 13, 3238, 389, 291, 5592, 31, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 20, 31, 203, 565, 3885, 1435, 288, 203, 3639, 389, 291, 5592, 63, 3576, 18, 15330, 65, 273, 638, 31, 203, 565, 289, 203, 203, 565, 9606, 4991, 1730, 1435, 5024, 288, 203, 3639, 309, 16051, 67, 291, 5592, 63, 3576, 18, 15330, 5717, 15226, 15799, 5621, 203, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 445, 444, 3032, 1862, 12, 2867, 2236, 67, 16, 1426, 353, 15341, 67, 13, 203, 3639, 3903, 203, 3639, 4991, 1730, 203, 565, 288, 203, 3639, 389, 291, 5592, 63, 4631, 67, 65, 273, 353, 15341, 67, 31, 203, 565, 289, 203, 203, 203, 565, 445, 21956, 5592, 12, 2867, 2236, 67, 13, 3903, 1476, 1135, 261, 6430, 13, 288, 203, 3639, 327, 389, 291, 5592, 63, 4631, 67, 15533, 203, 565, 289, 203, 203, 565, 555, 15799, 5621, 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 ]
// SPDX-License-Identifier: Unlicense pragma solidity ^0.8.7; 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; } /** * @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 ); } contract HoneyBorrow { address private admin; address private avaxAddress; address private HLaddress; struct BorrowTicket { address collectionAddress; uint256 tokenId; uint256 stakeTime; uint256 stakeAmount; uint256 borrowAvailableAmount; uint256 borrowedAmount; } address[] public collections; mapping(address => bool) public status; mapping(address => uint256) private borrowRate; mapping(address => uint256) private interestRate; mapping(address => uint256) private limitRate; mapping(address => BorrowTicket[]) public accountTickets; constructor() { admin = msg.sender; } function getAccountTicketCount(address owner) external view returns(uint256) { return accountTickets[owner].length; } /** * @notice Sender supplies an NFT into the market and receives AVAX in exchange * @dev Reverts upon any failure * @param NFTaddress The contract address of the NFT * @param tokenId The NFT tokenId which is will be supplied */ function stake( address NFTaddress, uint256 tokenId, uint256 borrowAmount ) external payable { require(status[NFTaddress] == true, "ND"); // Not available to deposit // Get the price of NFT from Oracle - uint256 oraclePrice = 100 ether; // Transfer the selected NFT to this contract IERC721(NFTaddress).transferFrom(msg.sender, address(this), tokenId); // Get the borrowAmount by calculating with the borrowRate uint256 maxBorrowAmount = getBorrowAmount(NFTaddress, oraclePrice); // Push the data of BorrowTicket into the accountTickets of this account accountTickets[msg.sender].push( BorrowTicket({ collectionAddress: NFTaddress, tokenId: tokenId, stakeTime: block.timestamp, stakeAmount: oraclePrice, borrowAvailableAmount: maxBorrowAmount, borrowedAmount: borrowAmount }) ); // Borrow AVAX to this account with borrowAmount payable(msg.sender).transfer(borrowAmount); } function reStake(uint256 cid, uint256 addBorrowAmount) external payable { require(accountTickets[msg.sender].length > cid, "MB"); //This NFT must be staked in this contract // Get the struct BorrowTicket bt by using address and cid BorrowTicket memory bt = accountTickets[msg.sender][cid]; // Set the variables from the struct bt which is defined by address and Cid address NFTaddr = bt.collectionAddress; uint256 startTime = bt.stakeTime; uint256 max = bt.borrowAvailableAmount; uint256 payAmount = bt.borrowedAmount; // Get the multiplier from the this time and stakeTime uint256 multiplier = getMultiplier(NFTaddr, startTime); // Get the repay Amount by stakeAmount and Multiplier payAmount = (payAmount * multiplier) / 10000; require(max > addBorrowAmount + payAmount, "OM"); // The borrowedAmount is over Max // Borrow AVAX to this account with borrowAmount payable(msg.sender).transfer(addBorrowAmount); // Set new parameters of this array data accountTickets[msg.sender][cid].borrowedAmount = addBorrowAmount + payAmount; accountTickets[msg.sender][cid].stakeTime = block.timestamp; } /** * @notice The borrower repay the AVAX and receive the NFT again * @dev Reverts upon any failure * @param cid The NFT Id of the unique sequence */ function repay(uint256 cid) external payable { require(accountTickets[msg.sender].length > cid, "MB"); //This NFT must be staked in this contract // Get the struct BorrowTicket bt by using address and cid BorrowTicket memory bt = accountTickets[msg.sender][cid]; // Set the variables from the struct bt which is defined by address and Cid address NFTaddr = bt.collectionAddress; uint256 tokenId = bt.tokenId; uint256 startTime = bt.stakeTime; uint256 payAmount = bt.borrowedAmount; // Get the multiplier from the this time and stakeTime uint256 multiplier = getMultiplier(NFTaddr, startTime); require(multiplier < limitRate[NFTaddr], "LR"); // The multiplier is must be less than LimitRate // Get the repay Amount by stakeAmount and Multiplier payAmount = (payAmount * multiplier) / 10000; require(payAmount <= msg.value, "OP"); // The amount of AVAX must be over payAmount // The borrower repay the AVAX to this contract // IERC20(avaxAddress).transferFrom(msg.sender, address(this), amount); // Send the NFT again to its owner IERC721(NFTaddr).transferFrom(address(this), msg.sender, tokenId); // Remove this cid from the array remove(msg.sender, cid); } function sendLiquidationPool(address owner, uint256 cid) external { // Get the struct BorrowTicket bt by using address and cid BorrowTicket memory bt = accountTickets[owner][cid]; // Set the variables from the struct bt which is defined by address and Cid address NFTaddr = bt.collectionAddress; uint256 tokenId = bt.tokenId; // Send the NFT again to HoneyLiquidation IERC721(NFTaddr).transferFrom(address(this), HLaddress, tokenId); // Remove this cid from the array remove(owner, cid); } function remove(address staker, uint256 index) internal returns (BorrowTicket[] storage) { uint256 length = accountTickets[staker].length; require(index < length, "LL"); accountTickets[staker][index] = accountTickets[staker][length - 1]; delete accountTickets[staker][length - 1]; accountTickets[staker].pop(); return accountTickets[staker]; } /** * @notice Get the multiplier by using timediff * @param collection the collection address * @param startTime the staked starttime * @return borrowamount that the user can borrow */ function getMultiplier(address collection, uint256 startTime) public view returns (uint256) { uint256 multi = (interestRate[collection] - 100 * 100) * (block.timestamp / 1 days - startTime / 1 days) + 10000; return multi; } /** * @notice Get the BorrowAmount by calculating with borrowRate * @param collection The collection address * @param amount The oracle Price of NFT release by AVAX * @return borrowamount that the user can borrow */ function getBorrowAmount(address collection, uint256 amount) internal view returns (uint256) { require(amount > 0, "OZ"); // amount must be over Zero uint256 bamount = (amount * borrowRate[collection]) / 10000; return bamount; } /** * @notice Add collections to use only them for Lending/Borrowing * @dev Reverts upon any failure * @param addresses[] Add addresses to use them for Lending/Borrowing * @param borrow[] Add borrowRate with the addresses to set borrowRate[addresses[i]] * @param interest[] Add interestRate with the addresses to set interestRate[addresses[i]] * @param limit[] Add limitRate with the addresses to set limitRate[addresses[i]] */ function addCollection( address[] calldata addresses, uint256[] calldata borrow, uint256[] calldata interest, uint256[] calldata limit ) external onlyAdmin{ for (uint256 i = 0; i < addresses.length; i++) { if (status[addresses[i]] == false) { collections.push(addresses[i]); status[addresses[i]] = true; borrowRate[addresses[i]] = borrow[i]; interestRate[addresses[i]] = interest[i]; limitRate[addresses[i]] = limit[i]; } } } function getCollections() external view returns (address[] memory) { return collections; } function deleteCollection(address[] calldata addresses) external onlyAdmin{ for (uint256 i = 0; i < addresses.length; i++) { removeCollection(addresses[i]); if (status[addresses[i]] == true) status[addresses[i]] = false; } } function removeCollection(address collection) internal { uint256 length = collections.length; bool bFound = false; for (uint256 i = 0; i < length; i++){ if(collections[i] == collection) { collections[i] = collections[length - 1]; bFound = true; break; } } if(bFound == false) return; delete collections[length - 1]; collections.pop(); } /** * @notice Set the BorrowAmount by only admin set * @param collection The collection address * @param newBorrowRate New BorrowRate */ function setBorrowRate(address collection, uint256 newBorrowRate) external onlyAdmin { borrowRate[collection] = newBorrowRate; } /** * @notice Set the interestRate by only admin set * @param collection The collection address * @param newInterestRate New InterestRate */ function setInterestRate(address collection, uint256 newInterestRate) external onlyAdmin { interestRate[collection] = newInterestRate; } /** * @notice Set the limitAmount by only admin * @param collection The collection address * @param newLimitRate New LimitRate */ function setLimitRate(address collection, uint256 newLimitRate) external onlyAdmin { limitRate[collection] = newLimitRate; } function getRates(address collection) external view returns ( uint256 br, uint256 ir, uint256 lr ) { br = borrowRate[collection]; ir = interestRate[collection]; lr = limitRate[collection]; } /*** Admin role ***/ modifier onlyAdmin() { require(admin == msg.sender, "OA"); _; } function setNewAdmin(address newAdd) external onlyAdmin { admin = newAdd; } function withdraw() external onlyAdmin { uint256 amount = address(this).balance; payable(msg.sender).transfer(amount); } receive() external payable { } }
* @notice Set the limitAmount by only admin @param collection The collection address @param newLimitRate New LimitRate/
function setLimitRate(address collection, uint256 newLimitRate) external onlyAdmin { limitRate[collection] = newLimitRate; }
13,035,528
[ 1, 694, 326, 1800, 6275, 635, 1338, 3981, 225, 1849, 1021, 1849, 1758, 225, 394, 3039, 4727, 1166, 7214, 4727, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3039, 4727, 12, 2867, 1849, 16, 2254, 5034, 394, 3039, 4727, 13, 203, 3639, 3903, 203, 3639, 1338, 4446, 203, 565, 288, 203, 3639, 1800, 4727, 63, 5548, 65, 273, 394, 3039, 4727, 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 ]
pragma solidity 0.4.24; import "zeppelin-solidity/contracts/math/SafeMath.sol"; import "./MintableBurnableERC20Token.sol"; contract BackedERC20Token is MintableBurnableERC20Token { address public counter; uint256 public precision; /** * Public constructor that requires all arguments are specified. */ constructor(string name, string symbol, uint8 decimals, address _counter, uint256 _precision) MintableBurnableERC20Token(name, symbol, decimals) public { counter = _counter; precision = _precision; } /** * The counter is the backing token's ERC20 address, or 0x0 to use ETH. */ function counter() public view returns (address){ return counter; } /** * Convert X tokens to Y counter */ function tokensToCounter(uint256 anAmount) public view returns(uint256) { if(totalSupply() == 0){ return anAmount; } return SafeMath.div(SafeMath.mul(SafeMath.div(SafeMath.mul(totalSupply(), precision), counterBalance()), anAmount),precision); } /** * Convert Y counter to X tokens */ function counterToTokens(uint256 anAmount) public view returns(uint256) { if(totalSupply() == 0){ return anAmount; } return SafeMath.div(SafeMath.mul(SafeMath.div(SafeMath.mul(counterBalance(), precision), totalSupply()), anAmount), precision); } /** * Method to view the current counter balance of the contract */ function counterBalance() public view returns(uint256) { if(counter == 0x0){ return address(this).balance; } else { return ERC20(counter).balanceOf(this); } } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { return balanceOf(msg.sender); } /** * Send counter to the recepient, either ETH or ERC20 */ function send(address aDestination, uint256 anAmount) internal { if(counter == 0x0){ aDestination.transfer(anAmount); }else{ require(ERC20(counter).transfer(aDestination, anAmount)); } } }
* Convert X tokens to Y counter/
function tokensToCounter(uint256 anAmount) public view returns(uint256) { if(totalSupply() == 0){ return anAmount; } return SafeMath.div(SafeMath.mul(SafeMath.div(SafeMath.mul(totalSupply(), precision), counterBalance()), anAmount),precision); }
1,029,394
[ 1, 2723, 1139, 2430, 358, 1624, 3895, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2430, 774, 4789, 12, 11890, 5034, 392, 6275, 13, 1071, 1476, 1135, 12, 11890, 5034, 13, 288, 203, 3639, 309, 12, 4963, 3088, 1283, 1435, 422, 374, 15329, 203, 5411, 327, 392, 6275, 31, 203, 3639, 289, 203, 3639, 327, 14060, 10477, 18, 2892, 12, 9890, 10477, 18, 16411, 12, 9890, 10477, 18, 2892, 12, 9890, 10477, 18, 16411, 12, 4963, 3088, 1283, 9334, 6039, 3631, 3895, 13937, 1435, 3631, 392, 6275, 3631, 14548, 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 ]
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.4; // Adaptado de https://docs.soliditylang.org/en/latest/solidity-by-example.html al español, para explicar herencia en Solidity // Subasta simple que permite que varias direcciones pujen por un premio (no se tiene en cuenta) contract SimpleAuction { address payable public beneficiary; // Beneficiario de la Subasta uint public auctionEndTime; // Tiempo de fin de la subasta en segundos address public highestBidder; // Direccian de la puja mas alta uint public highestBid; // Valor de la puja mas alta mapping(address => uint) pendingReturns; // Mapa de dinero a devolver a los otros pujantes bool ended; // Variable logica que determina si la puja ya termino // Errores /// La subasta ya termino error AuctionAlreadyEnded(); /// La puja es menor a la puja mas alta error BidNotHighEnough(uint highestBid); /// La subasta aun no ha terminado error AuctionNotYetEnded(); /// Ya se llamo el fin de la subasta error AuctionEndAlreadyCalled(); /// No es el beneficiario error NotBeneficiary(); /// Construye el contrato, solo se necesitan el tiempo de la subasta y el beneficiario constructor( uint _biddingTime, address payable _beneficiary ) { beneficiary = _beneficiary; auctionEndTime = block.timestamp + _biddingTime; } /// Recibe una puja y la guarda solo si esta supera la puja actual function bid() virtual public payable { if (block.timestamp > auctionEndTime) // Verifica que la subasta no haya terminado revert AuctionAlreadyEnded(); if (msg.value <= highestBid) // Verifica que la puja sobrepase la puja actual revert BidNotHighEnough(highestBid); if (highestBid != 0) { pendingReturns[highestBidder] += highestBid; // Guardar el monto de dinero a devolver a la dirección que previamente sostenía la puja más alta } // Actualiza los datos de la puja más alta highestBidder = msg.sender; highestBid = msg.value; } /// Función para devolver el dinero a los pujantes previos, debe ser llamada por el pujante en cuestión function withdraw() public returns (bool) { uint amount = pendingReturns[msg.sender]; // Obtener el monto if (amount > 0) { pendingReturns[msg.sender] = 0; // Actualizar el monto a 0 // Enviar monto if (!payable(msg.sender).send(amount)) { pendingReturns[msg.sender] = amount; return false; } } return true; } /// Terminar la subasta, solo puede ser llamada por el beneficiario function auctionEnd() virtual public { if (msg.sender != beneficiary) revert NotBeneficiary(); if (block.timestamp < auctionEndTime) revert AuctionNotYetEnded(); if (ended) revert AuctionEndAlreadyCalled(); ended = true; // Transferir el dinero al beneficiario beneficiary.transfer(highestBid); } } // Subasta a ciegas, no tiene limite de tiempo, para cada puja se guarda un hash con la informacion de la puja, lo que asegura que sea a ciegas // A llegar el tiempo de revelacion, se revelan todas las pujas y se designa el ganador de la subasta, finalmente se devuelve el dinero al resto // de pujantes contract BlindAuction is SimpleAuction { // Estructura de Subasta struct Bid { bytes32 blindedBid; uint deposit; } uint public revealEnd; // Tiempo en segundos de la revelacion de la subasta mapping(address => Bid[]) public bids; // Mapa de direcciones a arreglos de subastas, una misma direccion puede realizar varias subastas /// Muy temprano para llamar esta funcion error TooEarly(uint time); /// Muy tarde para llamar esta funcion error TooLate(uint time); modifier onlyBefore(uint _time) { if (block.timestamp >= _time) revert TooLate(_time); _; } modifier onlyAfter(uint _time) { if (block.timestamp <= _time) revert TooEarly(_time); _; } /// Construye el contrato, instanciado el constructor del padre y la variable de fin de revelacion de la subasta constructor(uint _biddingTime,uint _revealTime,address payable _beneficiary) SimpleAuction(_biddingTime, _beneficiary) { revealEnd = auctionEndTime + _revealTime; } /// Realiza una puja a ciegas donde _blindedBid es el hash de los datos de la puja, igual a keccak256(abi.encodePacked(value, fake, secret)) /// La puja es valida si "deposit" (el valor enviado) es al menos "value" y "fake" es falso /// Si se configura "fake" como verdadero y no se envía el valor exacto de "value" es una forma /// de ocultar la verdadera puja, aun asi se requiere que se haga un deposito. /// 'secret' es simplemente una contraseña que uso el pujante para la encriptacion /// El ether enviado solo será reembolsado solo si la puja es correctamente revelada en la fase de revelacion de pujas /// Solo puede ser llamada antes del fin de la subasta (periodo de pujas) function bid(bytes32 _blindedBid) public payable onlyBefore(auctionEndTime) { // Agregar la puja a la lista de pujas del pujante bids[msg.sender].push(Bid({ blindedBid: _blindedBid, deposit: msg.value })); } /// Funcion que debe ser llamada por cada pujante para revelar sus pujas /// El pujante recibira un reembolso de ether por cada puja correctamente revelada /// sean validas o invalidas, a excepcion de la puja ganadora. /// Solo puede ser llamada despues del periodo de pujas y antes del fin de revelacion de pujas function reveal( uint[] memory _values, bool[] memory _fake, bytes32[] memory _secret ) public onlyAfter(auctionEndTime) onlyBefore(revealEnd) { // Verificar que se hayan provisto los datos suficientes para revelar todas las pujas hechas uint length = bids[msg.sender].length; require(_values.length == length); require(_fake.length == length); require(_secret.length == length); uint refund; // Dinero de reembolso for (uint i = 0; i < length; i++) { // Iterar sobre cada puja Bid storage bidToCheck = bids[msg.sender][i]; // Obtener los datos de la puja, encriptar y comparar con el hash guardado previamente (uint value, bool fake, bytes32 secret) = (_values[i], _fake[i], _secret[i]); if (bidToCheck.blindedBid != keccak256(abi.encodePacked(value, fake, secret))) { continue; // Si el hash no coincide ignorar esta puja ya que no fue correctamente revelada } refund += bidToCheck.deposit; // Verificar que sea una puja valida y de ser asi ubicar la puja // y disminuir el valor reembolsar por revelacion if (!fake && bidToCheck.deposit >= value) { if (placeBid(msg.sender, value)) refund -= value; } bidToCheck.blindedBid = bytes32(0); // Modificar el hash para que esta puja no se pueda volver a revelar } payable(msg.sender).transfer(refund); // Finalmente enviar el dinero total de reembolso por revelacion } /// Finalizar la subasta, sobreescribe la funcion del padre ya que esta solo puede ser llamada /// despues de finalizar las revelaciones de pujas, sin embargo luego llama a la funcion del padre /// para realizar los efectos de finalizacion function auctionEnd() override public onlyAfter(revealEnd) { SimpleAuction.auctionEnd(); } /// Registra las puja valida enviada, solo si esta supera la mayor puja actual /// Solo puede ser usada internamente function placeBid(address bidder, uint value) internal returns (bool success) { if (value <= highestBid) { return false; } if (highestBidder != address(0)) { pendingReturns[highestBidder] += highestBid; } highestBid = value; highestBidder = bidder; return true; } /// Sobreescribir la funcion del padre para que se use la nueva funcion que requiere un parametro function bid() override public payable { revert("Funcion erronea, debe enviar la puja encriptada"); } } // Subasta con etapa de revelacion y pujas falsas, cada direccion puede realizar multiples pujas falsas y verdaderas, // las pujas deben ser reveladas en la fase de revelacion donde se decide que pujas realmente se haran y el dinero que se // debe reembolsar a los pujantes contract RevealAuction is SimpleAuction { // Estructura de Subasta struct Bid { bool fake; uint deposit; } uint public revealEnd; // Tiempo en segundos de la revelacion de la subasta mapping(address => Bid[]) public bids; // Mapa de direcciones a arreglos de subastas, una misma direccion puede realizar varias subastas /// Muy temprano para llamar esta funcion error TooEarly(uint time); /// Muy tarde para llamar esta funcion error TooLate(uint time); modifier onlyBefore(uint _time) { if (block.timestamp >= _time) revert TooLate(_time); _; } modifier onlyAfter(uint _time) { if (block.timestamp <= _time) revert TooEarly(_time); _; } /// Construye el contrato, instanciado el constructor del padre y la variable de fin de revelacion de la subasta constructor(uint _biddingTime,uint _revealTime,address payable _beneficiary) SimpleAuction(_biddingTime, _beneficiary) { revealEnd = auctionEndTime + _revealTime; } /// Realiza una puja a ciegas donde "_fake" es un booleano que define si la puja es verdadera o falsa /// Solo puede ser llamada antes del fin de la subasta (periodo de pujas) function bid(bool _fake) public payable onlyBefore(auctionEndTime) { // Agregar la puja a la lista de pujas del pujante bids[msg.sender].push(Bid({ fake: _fake, deposit: msg.value })); } /// Funcion que debe ser llamada por cada pujante para revelar sus pujas /// es decir, ponerlas en accion function reveal() public onlyAfter(auctionEndTime) onlyBefore(revealEnd){ // Verificar que se hayan provisto los datos suficientes para revelar todas las pujas hechas uint length = bids[msg.sender].length; uint refund; // Dinero de reembolso for (uint i = 0; i < length; i++) { // Iterar sobre cada puja Bid storage bidToCheck = bids[msg.sender][i]; refund += bidToCheck.deposit; // Verificar que sea una puja valida y de ser asi ubicar la puja if (!bidToCheck.fake) { if (placeBid(msg.sender, bidToCheck.deposit)) refund -= bidToCheck.deposit; } bidToCheck.deposit = 0; // Modificar el valor para que no se vuelva a revelar esta puja } pendingReturns[msg.sender] += refund; // Finalmente añadir al dinero total que puede reembolsar } /// Finalizar la subasta, sobreescribe la funcion del padre ya que esta solo puede ser llamada /// despues de finalizar las revelaciones de pujas, sin embargo luego llama a la funcion del padre /// para realizar los efectos de finalizacion function auctionEnd() override public onlyAfter(revealEnd) { SimpleAuction.auctionEnd(); } /// Registra las puja valida enviada, solo si esta supera la mayor puja actual /// Solo puede ser usada internamente function placeBid(address bidder, uint value) internal returns (bool success) { if (value <= highestBid) { return false; } if (highestBidder != address(0)) { pendingReturns[highestBidder] += highestBid; } highestBid = value; highestBidder = bidder; return true; } /// Sobreescribir la funcion del padre para que se use la nueva funcion que requiere un parametro function bid() override public payable { revert("Funcion erronea, debe enviar la puja encriptada"); } }
Función para devolver el dinero a los pujantes previos, debe ser llamada por el pujante en cuestión Enviar monto
function withdraw() public returns (bool) { if (amount > 0) { if (!payable(msg.sender).send(amount)) { pendingReturns[msg.sender] = amount; return false; } } return true; }
15,821,835
[ 1, 2622, 77, 132, 116, 82, 12602, 4461, 10521, 415, 302, 267, 2439, 279, 22148, 293, 11501, 970, 281, 675, 522, 538, 16, 443, 2196, 703, 6579, 301, 16524, 22471, 415, 293, 11501, 7974, 570, 15985, 395, 77, 132, 116, 82, 1374, 522, 297, 6921, 869, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 598, 9446, 1435, 1071, 1135, 261, 6430, 13, 288, 203, 3639, 309, 261, 8949, 405, 374, 13, 288, 203, 203, 5411, 309, 16051, 10239, 429, 12, 3576, 18, 15330, 2934, 4661, 12, 8949, 3719, 288, 203, 7734, 4634, 1356, 63, 3576, 18, 15330, 65, 273, 3844, 31, 203, 7734, 327, 629, 31, 203, 5411, 289, 203, 3639, 289, 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 ]
// to test issue with nodes breaking with large clients over WS // fixed in web3 with fragmentationThreshold: 8192 pragma solidity ^0.4.17; contract BigFreakingContract { event Transfer(address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); mapping( address => uint ) _balances; mapping( address => mapping( address => uint ) ) _approvals; uint public _supply; constructor( uint initial_balance ) public { _balances[msg.sender] = initial_balance; _supply = initial_balance; } function totalSupply() public constant returns (uint supply) { return _supply; } function balanceOf( address who ) public constant returns (uint value) { return _balances[who]; } function transfer( address to, uint value) public returns (bool ok) { if( _balances[msg.sender] < value ) { revert(); } if( !safeToAdd(_balances[to], value) ) { revert(); } _balances[msg.sender] -= value; _balances[to] += value; emit Transfer( msg.sender, to, value ); return true; } function transferFrom( address from, address to, uint value) public returns (bool ok) { // if you don't have enough balance, throw if( _balances[from] < value ) { revert(); } // if you don't have approval, throw if( _approvals[from][msg.sender] < value ) { revert(); } if( !safeToAdd(_balances[to], value) ) { revert(); } // transfer and return true _approvals[from][msg.sender] -= value; _balances[from] -= value; _balances[to] += value; emit Transfer( from, to, value ); return true; } function approve(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function allowance(address owner, address spender) public constant returns (uint _allowance) { return _approvals[owner][spender]; } function safeToAdd(uint a, uint b) internal pure returns (bool) { return (a + b >= a); } function isAvailable() public pure returns (bool) { return false; } function approve_1(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_2(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_3(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_4(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_5(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_6(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_7(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_8(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_9(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_10(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_11(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_12(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_13(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_14(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_15(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_16(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_17(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_18(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_19(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_20(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_21(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_22(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_23(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_24(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_25(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_26(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_27(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_28(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_29(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_30(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_31(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_32(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_33(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_34(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_35(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_36(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_37(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_38(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_39(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_40(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_41(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_42(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_43(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_44(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_45(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_46(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_47(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_48(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_49(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_50(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_51(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_52(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_53(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_54(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_55(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_56(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_57(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_58(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_59(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_60(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_61(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_62(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_63(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_64(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_65(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_66(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_67(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_68(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_69(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_70(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_71(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_72(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_73(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_74(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_75(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_76(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_77(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_78(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_79(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_80(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_81(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_82(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_83(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_84(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_85(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_86(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_87(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_88(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_89(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_90(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_91(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_92(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_93(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_94(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_95(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_96(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_97(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_98(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_99(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_100(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_101(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_102(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_103(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_104(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_105(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_106(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_107(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_108(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_109(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_110(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_111(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_112(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_113(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_114(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_115(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_116(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_117(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_118(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_119(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_120(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_121(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_122(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_123(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_124(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_125(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_126(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_127(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_128(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_129(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_130(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_131(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_132(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_133(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_134(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_135(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_136(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_137(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_138(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_139(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_140(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_141(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_142(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_143(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_144(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_145(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_146(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_147(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_148(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_149(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_150(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_151(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_152(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_153(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_154(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_155(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_156(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_157(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_158(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_159(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_160(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_161(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_162(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_163(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_164(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_165(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_166(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_167(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_168(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_169(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_170(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_171(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_172(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_173(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_174(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_175(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_176(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_177(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_178(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_179(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_180(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_181(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_182(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_183(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_184(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_185(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_186(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_187(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_188(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_189(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_190(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_191(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_192(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_193(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_194(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_195(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_196(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_197(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_198(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_199(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_200(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_201(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_202(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_203(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_204(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_205(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_206(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_207(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_208(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_209(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_210(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_211(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_212(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_213(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_214(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_215(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_216(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_217(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_218(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_219(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_220(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_221(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_222(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_223(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_224(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_225(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_226(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_227(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_228(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_229(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_230(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_231(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_232(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_233(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_234(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_235(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_236(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_237(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_238(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_239(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_240(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_241(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_242(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_243(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_244(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_245(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_246(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_247(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_248(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_249(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_250(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_251(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_252(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_253(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_254(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_255(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_256(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_257(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_258(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_259(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_260(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_261(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_262(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_263(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_264(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_265(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_266(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_267(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_268(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_269(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_270(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_271(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_272(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_273(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_274(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_275(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_276(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_277(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_278(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_279(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_280(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_281(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_282(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_283(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_284(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_285(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_286(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_287(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_288(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_289(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_290(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_291(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_292(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_293(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_294(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_295(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_296(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_297(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_298(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_299(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_300(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_301(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_302(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_303(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_304(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_305(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_306(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_307(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_308(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_309(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_310(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_311(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_312(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_313(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_314(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_315(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_316(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_317(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_318(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_319(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_320(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_321(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_322(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_323(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_324(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_325(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_326(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_327(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_328(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_329(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_330(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_331(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_332(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_333(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_334(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_335(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_336(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_337(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_338(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_339(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_340(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_341(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_342(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_343(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_344(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_345(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_346(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_347(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_348(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_349(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_350(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_351(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_352(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_353(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_354(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_355(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_356(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_357(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_358(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_359(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_360(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_361(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_362(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_363(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_364(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_365(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_366(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_367(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_368(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_369(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_370(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_371(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_372(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_373(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_374(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_375(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_376(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_377(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_378(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_379(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_380(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_381(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_382(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_383(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_384(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_385(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_386(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_387(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_388(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_389(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_390(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_391(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_392(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_393(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_394(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_395(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_396(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_397(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_398(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_399(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_400(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_401(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_402(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_403(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_404(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_405(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_406(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_407(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_408(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_409(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_410(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_411(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_412(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_413(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_414(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_415(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_416(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_417(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_418(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_419(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_420(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_421(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_422(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_423(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_424(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_425(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_426(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_427(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_428(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_429(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_430(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_431(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_432(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_433(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_434(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_435(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_436(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_437(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_438(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_439(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_440(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_441(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_442(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_443(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_444(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_445(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_446(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_447(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_448(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_449(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_450(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_451(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_452(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_453(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_454(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_455(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_456(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_457(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_458(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_459(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_460(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_461(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_462(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_463(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_464(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_465(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_466(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_467(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_468(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_469(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_470(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_471(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_472(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_473(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_474(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_475(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_476(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_477(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_478(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_479(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_480(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_481(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_482(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_483(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_484(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_485(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_486(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_487(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_488(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_489(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_490(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_491(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_492(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_493(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_494(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_495(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_496(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_497(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_498(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_499(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_500(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_501(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_502(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_503(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_504(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_505(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_506(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_507(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_508(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_509(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_510(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_511(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_512(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_513(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_514(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_515(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_516(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_517(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_518(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_519(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_520(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_521(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_522(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_523(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_524(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_525(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_526(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_527(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_528(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_529(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_530(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_531(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_532(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_533(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_534(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_535(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_536(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_537(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_538(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_539(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_540(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_541(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_542(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_543(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_544(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_545(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_546(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_547(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_548(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_549(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_550(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_551(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_552(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_553(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_554(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_555(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_556(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_557(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_558(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_559(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_560(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_561(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_562(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_563(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_564(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_565(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_566(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_567(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_568(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_569(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_570(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_571(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_572(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_573(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_574(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_575(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_576(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_577(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_578(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_579(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_580(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_581(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_582(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_583(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_584(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_585(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_586(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_587(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_588(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_589(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_590(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_591(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_592(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_593(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_594(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_595(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_596(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_597(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_598(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_599(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_600(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_601(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_602(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_603(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_604(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_605(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_606(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_607(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_608(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_609(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_610(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_611(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_612(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_613(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_614(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_615(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_616(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_617(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_618(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_619(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_620(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_621(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_622(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_623(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_624(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_625(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_626(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_627(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_628(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_629(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_630(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_631(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_632(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_633(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_634(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_635(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_636(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_637(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_638(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_639(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_640(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_641(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_642(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_643(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_644(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_645(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_646(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_647(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_648(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_649(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_650(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_651(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_652(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_653(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_654(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_655(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_656(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_657(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_658(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_659(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_660(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_661(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_662(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_663(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_664(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_665(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_666(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_667(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_668(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_669(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_670(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_671(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_672(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_673(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_674(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_675(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_676(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_677(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_678(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_679(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_680(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_681(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_682(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_683(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_684(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_685(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_686(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_687(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_688(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_689(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_690(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_691(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_692(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_693(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_694(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_695(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_696(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_697(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_698(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_699(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_700(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_701(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_702(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_703(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_704(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_705(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_706(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_707(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_708(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_709(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_710(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_711(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_712(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_713(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_714(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_715(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_716(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_717(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_718(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_719(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_720(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_721(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_722(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_723(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_724(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_725(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_726(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_727(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_728(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_729(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_730(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_731(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_732(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_733(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_734(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_735(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_736(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_737(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_738(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_739(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_740(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_741(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_742(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_743(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_744(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_745(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_746(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_747(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_748(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_749(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_750(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_751(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_752(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_753(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_754(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_755(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_756(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_757(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_758(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_759(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_760(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_761(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_762(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_763(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_764(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_765(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_766(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_767(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_768(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_769(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_770(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_771(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_772(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_773(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_774(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_775(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_776(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_777(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_778(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_779(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_780(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_781(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_782(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_783(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_784(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_785(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_786(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_787(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_788(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_789(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_790(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_791(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_792(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_793(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_794(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_795(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_796(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_797(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_798(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_799(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_800(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_801(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_802(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_803(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_804(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_805(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_806(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_807(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_808(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_809(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_810(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_811(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_812(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_813(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_814(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_815(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_816(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_817(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_818(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_819(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_820(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_821(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_822(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_823(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_824(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_825(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_826(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_827(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_828(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_829(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_830(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_831(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_832(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_833(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_834(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_835(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_836(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_837(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_838(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_839(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_840(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_841(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_842(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_843(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_844(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_845(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_846(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_847(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_848(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_849(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_850(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_851(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_852(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_853(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_854(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_855(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_856(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_857(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_858(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_859(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_860(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_861(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_862(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_863(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_864(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_865(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_866(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_867(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_868(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_869(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_870(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_871(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_872(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_873(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_874(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_875(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_876(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_877(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_878(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_879(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_880(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_881(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_882(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_883(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_884(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_885(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_886(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_887(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_888(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_889(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_890(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_891(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_892(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_893(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_894(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_895(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_896(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_897(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_898(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_899(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_900(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } function approve_901(address spender, uint value) public returns (bool ok) { // TODO: should increase instead _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; } }
TODO: should increase instead
function approve_900(address spender, uint value) public returns (bool ok) { _approvals[msg.sender][spender] = value; emit Approval( msg.sender, spender, value ); return true; }
6,454,613
[ 1, 6241, 30, 1410, 10929, 3560, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6617, 537, 67, 29, 713, 12, 2867, 17571, 264, 16, 2254, 460, 13, 1071, 1135, 261, 6430, 1529, 13, 288, 203, 565, 389, 12908, 4524, 63, 3576, 18, 15330, 6362, 87, 1302, 264, 65, 273, 460, 31, 203, 565, 3626, 1716, 685, 1125, 12, 1234, 18, 15330, 16, 17571, 264, 16, 460, 11272, 203, 565, 327, 638, 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 ]
pragma solidity ^0.4.25; contract Richer3D { using SafeMath for *; //************ //Game Setting //************ string constant public name = "Richer3D"; string constant public symbol = "R3D"; address constant private sysAdminAddress = 0x4A3913ce9e8882b418a0Be5A43d2C319c3F0a7Bd; address constant private sysInviterAddress = 0xC5E41EC7fa56C0656Bc6d7371a8706Eb9dfcBF61; address constant private sysDevelopAddress = 0xCf3A25b73A493F96C15c8198319F0218aE8cAA4A; address constant private p3dInviterAddress = 0x82Fc4514968b0c5FdDfA97ed005A01843d0E117d; uint256 constant cycleTime = 24 hours; //************ //Game Data //************ uint256 private roundNumber; uint256 private dayNumber; uint256 private totalPlayerNumber; uint256 private platformBalance; //************* //Game DataBase //************* mapping(uint256=>DataModal.RoundInfo) private rInfoXrID; mapping(address=>DataModal.PlayerInfo) private pInfoXpAdd; mapping(address=>uint256) private pIDXpAdd; mapping(uint256=>address) private pAddXpID; //************* // P3D Data //************* HourglassInterface constant p3dContract = HourglassInterface(0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe); mapping(uint256=>uint256) private p3dDividesXroundID; //************* //Game Events //************* event newPlayerJoinGameEvent(address indexed _address,uint256 indexed _amount,bool indexed _JoinWithEth,uint256 _timestamp); event calculateTargetEvent(uint256 indexed _roundID); constructor() public { dayNumber = 1; } function() external payable {} //************ //Game payable //************ function joinGameWithInviterID(uint256 _inviterID) public payable { require(msg.value >= 0.01 ether,"You need to pay 0.01 eth at least"); require(now.sub(rInfoXrID[roundNumber].lastCalculateTime) < cycleTime,"Waiting for settlement"); if(pIDXpAdd[msg.sender] < 1) { registerWithInviterID(_inviterID); } buyCore(pInfoXpAdd[msg.sender].inviterAddress,msg.value); emit newPlayerJoinGameEvent(msg.sender,msg.value,true,now); } //******************** // Method need Gas //******************** function joinGameWithBalance(uint256 _amount) public payable { require(_amount >= 0.01 ether,"You need to pay 0.01 eth at least"); require(now.sub(rInfoXrID[roundNumber].lastCalculateTime) < cycleTime,"Waiting for settlement"); uint256 balance = getUserBalance(msg.sender); require(balance >= _amount.mul(11).div(10),"balance is not enough"); platformBalance = platformBalance.add(_amount.div(10)); buyCore(pInfoXpAdd[msg.sender].inviterAddress,_amount); pInfoXpAdd[msg.sender].withDrawNumber = pInfoXpAdd[msg.sender].withDrawNumber.sub(_amount.mul(11).div(10)); emit newPlayerJoinGameEvent(msg.sender,_amount,false,now); } function calculateTarget() public { require(now.sub(rInfoXrID[roundNumber].lastCalculateTime) >= cycleTime,"Less than cycle Time from last operation"); //allocate p3d dividends to contract uint256 dividends = p3dContract.myDividends(true); if(dividends > 0) { if(rInfoXrID[roundNumber].dayInfoXDay[dayNumber].playerNumber > 0) { p3dDividesXroundID[roundNumber] = p3dDividesXroundID[roundNumber].add(dividends); p3dContract.withdraw(); } else { platformBalance = platformBalance.add(dividends); p3dContract.withdraw(); } } uint256 increaseBalance = getIncreaseBalance(dayNumber,roundNumber); uint256 targetBalance = getDailyTarget(roundNumber,dayNumber); if(increaseBalance >= targetBalance) { //buy p3d if(getIncreaseBalance(dayNumber,roundNumber) > 0) { p3dContract.buy.value(getIncreaseBalance(dayNumber,roundNumber).div(100))(p3dInviterAddress); } //continue dayNumber = dayNumber.add(1); rInfoXrID[roundNumber].totalDay = dayNumber; if(rInfoXrID[roundNumber].startTime == 0) { rInfoXrID[roundNumber].startTime = now; rInfoXrID[roundNumber].lastCalculateTime = now; } else { rInfoXrID[roundNumber].lastCalculateTime = rInfoXrID[roundNumber].startTime.add((cycleTime).mul(dayNumber.sub(1))); } emit calculateTargetEvent(0); } else { //Game over, start new round bool haveWinner = false; if(dayNumber > 1) { sendBalanceForDevelop(roundNumber); haveWinner = true; } rInfoXrID[roundNumber].winnerDay = dayNumber.sub(1); roundNumber = roundNumber.add(1); dayNumber = 1; if(haveWinner) { rInfoXrID[roundNumber].bounsInitNumber = getBounsWithRoundID(roundNumber.sub(1)).div(10); } else { rInfoXrID[roundNumber].bounsInitNumber = getBounsWithRoundID(roundNumber.sub(1)); } rInfoXrID[roundNumber].totalDay = 1; rInfoXrID[roundNumber].startTime = now; rInfoXrID[roundNumber].lastCalculateTime = now; emit calculateTargetEvent(roundNumber); } } function registerWithInviterID(uint256 _inviterID) private { totalPlayerNumber = totalPlayerNumber.add(1); pIDXpAdd[msg.sender] = totalPlayerNumber; pAddXpID[totalPlayerNumber] = msg.sender; pInfoXpAdd[msg.sender].inviterAddress = pAddXpID[_inviterID]; } function buyCore(address _inviterAddress,uint256 _amount) private { //for inviter if(_inviterAddress == 0x0 || _inviterAddress == msg.sender) { platformBalance = platformBalance.add(_amount/10); } else { pInfoXpAdd[_inviterAddress].inviteEarnings = pInfoXpAdd[_inviterAddress].inviteEarnings.add(_amount/10); } uint256 playerIndex = rInfoXrID[roundNumber].dayInfoXDay[dayNumber].playerNumber.add(1); if(rInfoXrID[roundNumber].numberXaddress[msg.sender] == 0) { rInfoXrID[roundNumber].number = rInfoXrID[roundNumber].number.add(1); rInfoXrID[roundNumber].numberXaddress[msg.sender] = rInfoXrID[roundNumber].number; rInfoXrID[roundNumber].addressXnumber[rInfoXrID[roundNumber].number] = msg.sender; } rInfoXrID[roundNumber].dayInfoXDay[dayNumber].playerNumber = playerIndex; rInfoXrID[roundNumber].dayInfoXDay[dayNumber].addXIndex[playerIndex] = msg.sender; rInfoXrID[roundNumber].dayInfoXDay[dayNumber].indexXAddress[msg.sender] = playerIndex; rInfoXrID[roundNumber].dayInfoXDay[dayNumber].amountXIndex[playerIndex] = _amount; } function playerWithdraw(uint256 _amount) public { uint256 balance = getUserBalance(msg.sender); require(balance>=_amount,"amount out of limit"); msg.sender.transfer(_amount); pInfoXpAdd[msg.sender].withDrawNumber = pInfoXpAdd[msg.sender].withDrawNumber.add(_amount); } function sendBalanceForDevelop(uint256 _roundID) private { uint256 bouns = getBounsWithRoundID(_roundID).div(5); sysDevelopAddress.transfer(bouns.div(2)); sysInviterAddress.transfer(bouns.div(2)); } //******************** // Calculate Data //******************** function getBounsWithRoundID(uint256 _roundID) private view returns(uint256 _bouns) { _bouns = _bouns.add(rInfoXrID[_roundID].bounsInitNumber); for(uint256 d=1;d<=rInfoXrID[_roundID].totalDay;d++){ for(uint256 i=1;i<=rInfoXrID[_roundID].dayInfoXDay[d].playerNumber;i++) { uint256 amount = rInfoXrID[_roundID].dayInfoXDay[d].amountXIndex[i]; _bouns = _bouns.add(amount.mul(891).div(1000)); } for(uint256 j=1;j<=rInfoXrID[_roundID].number;j++) { address address2 = rInfoXrID[_roundID].addressXnumber[j]; if(d>=2) { _bouns = _bouns.sub(getTransformMineInDay(address2,_roundID,d.sub(1))); } else { _bouns = _bouns.sub(getTransformMineInDay(address2,_roundID,d)); } } } return(_bouns); } function getIncreaseBalance(uint256 _dayID,uint256 _roundID) private view returns(uint256 _balance) { for(uint256 i=1;i<=rInfoXrID[_roundID].dayInfoXDay[_dayID].playerNumber;i++) { uint256 amount = rInfoXrID[_roundID].dayInfoXDay[_dayID].amountXIndex[i]; _balance = _balance.add(amount); } _balance = _balance.mul(9).div(10); return(_balance); } function getMineInfoInDay(address _userAddress,uint256 _roundID, uint256 _dayID) private view returns(uint256 _totalMine,uint256 _myMine,uint256 _additional) { for(uint256 i=1;i<=_dayID;i++) { for(uint256 j=1;j<=rInfoXrID[_roundID].dayInfoXDay[i].playerNumber;j++) { address userAddress = rInfoXrID[_roundID].dayInfoXDay[i].addXIndex[j]; uint256 amount = rInfoXrID[_roundID].dayInfoXDay[i].amountXIndex[j]; if(_totalMine == 0) { _totalMine = _totalMine.add(amount.mul(5)); if(userAddress == _userAddress){ _myMine = _myMine.add(amount.mul(5)); } } else { uint256 addPart = (amount.mul(5)/2).mul(_myMine)/_totalMine; _totalMine = _totalMine.add(amount.mul(15).div(2)); if(userAddress == _userAddress){ _myMine = _myMine.add(amount.mul(5)).add(addPart); }else { _myMine = _myMine.add(addPart); } _additional = _additional.add(addPart); } } } return(_totalMine,_myMine,_additional); } function getTransformRate(address _userAddress,uint256 _roundID,uint256 _dayID) private view returns(uint256 _rate) { (,uint256 userMine,) = getMineInfoInDay(_userAddress,_roundID,_dayID); if(userMine > 0) { uint256 rate = userMine.mul(4).div(1000000000000000000).add(40); if(rate >80) return(80); else return(rate); } else { return(40); } } function getTransformMineInDay(address _userAddress,uint256 _roundID,uint256 _dayID) private view returns(uint256 _transformedMine) { (,uint256 userMine,) = getMineInfoInDay(_userAddress,_roundID,_dayID.sub(1)); uint256 rate = getTransformRate(_userAddress,_roundID,_dayID.sub(1)); _transformedMine = userMine.mul(rate).div(10000); return(_transformedMine); } function calculateTotalMinePay(uint256 _roundID,uint256 _dayID) private view returns(uint256 _needToPay) { (uint256 mine,,) = getMineInfoInDay(msg.sender,_roundID,_dayID.sub(1)); _needToPay = mine.mul(8).div(1000); return(_needToPay); } function getDailyTarget(uint256 _roundID,uint256 _dayID) private view returns(uint256) { uint256 needToPay = calculateTotalMinePay(_roundID,_dayID); uint256 target = 0; if (_dayID > 20) { target = (SafeMath.pwr(((5).mul(_dayID).sub(100)),3).add(1000000)).mul(needToPay).div(1000000); return(target); } else { target = ((1000000).sub(SafeMath.pwr((100).sub((5).mul(_dayID)),3))).mul(needToPay).div(1000000); if(target == 0) target = 0.0063 ether; return(target); } } function getUserBalance(address _userAddress) private view returns(uint256 _balance) { if(pIDXpAdd[_userAddress] == 0) { return(0); } uint256 withDrawNumber = pInfoXpAdd[_userAddress].withDrawNumber; uint256 totalTransformed = 0; for(uint256 i=1;i<=roundNumber;i++) { for(uint256 j=1;j<rInfoXrID[i].totalDay;j++) { totalTransformed = totalTransformed.add(getTransformMineInDay(_userAddress,i,j)); } } uint256 inviteEarnings = pInfoXpAdd[_userAddress].inviteEarnings; _balance = totalTransformed.add(inviteEarnings).add(getBounsEarnings(_userAddress)).add(getHoldEarnings(_userAddress)).add(getUserP3DDivEarnings(_userAddress)).sub(withDrawNumber); return(_balance); } function getBounsEarnings(address _userAddress) private view returns(uint256 _bounsEarnings) { for(uint256 i=1;i<roundNumber;i++) { uint256 winnerDay = rInfoXrID[i].winnerDay; uint256 myAmountInWinnerDay=0; uint256 totalAmountInWinnerDay=0; if(winnerDay == 0) { _bounsEarnings = _bounsEarnings; } else { for(uint256 player=1;player<=rInfoXrID[i].dayInfoXDay[winnerDay].playerNumber;player++) { address useraddress = rInfoXrID[i].dayInfoXDay[winnerDay].addXIndex[player]; uint256 amount = rInfoXrID[i].dayInfoXDay[winnerDay].amountXIndex[player]; if(useraddress == _userAddress) { myAmountInWinnerDay = myAmountInWinnerDay.add(amount); } totalAmountInWinnerDay = totalAmountInWinnerDay.add(amount); } uint256 bouns = getBounsWithRoundID(i).mul(14).div(25); _bounsEarnings = _bounsEarnings.add(bouns.mul(myAmountInWinnerDay).div(totalAmountInWinnerDay)); } } return(_bounsEarnings); } function getHoldEarnings(address _userAddress) private view returns(uint256 _holdEarnings) { for(uint256 i=1;i<roundNumber;i++) { uint256 winnerDay = rInfoXrID[i].winnerDay; if(winnerDay == 0) { _holdEarnings = _holdEarnings; } else { (uint256 totalMine,uint256 myMine,) = getMineInfoInDay(_userAddress,i,rInfoXrID[i].totalDay); uint256 bouns = getBounsWithRoundID(i).mul(7).div(50); _holdEarnings = _holdEarnings.add(bouns.mul(myMine).div(totalMine)); } } return(_holdEarnings); } function getUserP3DDivEarnings(address _userAddress) private view returns(uint256 _myP3DDivide) { if(rInfoXrID[roundNumber].totalDay <= 1) { return(0); } for(uint256 i=1;i<roundNumber;i++) { uint256 p3dDay = rInfoXrID[i].totalDay; uint256 myAmountInp3dDay=0; uint256 totalAmountInP3dDay=0; if(p3dDay == 0) { _myP3DDivide = _myP3DDivide; } else { for(uint256 player=1;player<=rInfoXrID[i].dayInfoXDay[p3dDay].playerNumber;player++) { address useraddress = rInfoXrID[i].dayInfoXDay[p3dDay].addXIndex[player]; uint256 amount = rInfoXrID[i].dayInfoXDay[p3dDay].amountXIndex[player]; if(useraddress == _userAddress) { myAmountInp3dDay = myAmountInp3dDay.add(amount); } totalAmountInP3dDay = totalAmountInP3dDay.add(amount); } uint256 p3dDividesInRound = p3dDividesXroundID[i]; _myP3DDivide = _myP3DDivide.add(p3dDividesInRound.mul(myAmountInp3dDay).div(totalAmountInP3dDay)); } } return(_myP3DDivide); } //******************* // UI //******************* function getDefendPlayerList() public view returns(address[]) { if (rInfoXrID[roundNumber].dayInfoXDay[dayNumber-1].playerNumber == 0) { address[] memory playerListEmpty = new address[](0); return(playerListEmpty); } address[] memory playerList = new address[](rInfoXrID[roundNumber].dayInfoXDay[dayNumber-1].playerNumber); for(uint256 i=0;i<rInfoXrID[roundNumber].dayInfoXDay[dayNumber-1].playerNumber;i++) { playerList[i] = rInfoXrID[roundNumber].dayInfoXDay[dayNumber-1].addXIndex[i+1]; } return(playerList); } function getAttackPlayerList() public view returns(address[]) { address[] memory playerList = new address[](rInfoXrID[roundNumber].dayInfoXDay[dayNumber].playerNumber); for(uint256 i=0;i<rInfoXrID[roundNumber].dayInfoXDay[dayNumber].playerNumber;i++) { playerList[i] = rInfoXrID[roundNumber].dayInfoXDay[dayNumber].addXIndex[i+1]; } return(playerList); } function getCurrentFieldBalanceAndTarget() public view returns(uint256 day,uint256 bouns,uint256 todayBouns,uint256 dailyTarget) { uint256 fieldBalance = getBounsWithRoundID(roundNumber).mul(7).div(10); uint256 todayBalance = getIncreaseBalance(dayNumber,roundNumber) ; dailyTarget = getDailyTarget(roundNumber,dayNumber); return(dayNumber,fieldBalance,todayBalance,dailyTarget); } function getUserIDAndInviterEarnings() public view returns(uint256 userID,uint256 inviteEarning) { return(pIDXpAdd[msg.sender],pInfoXpAdd[msg.sender].inviteEarnings); } function getCurrentRoundInfo() public view returns(uint256 _roundID,uint256 _dayNumber,uint256 _ethMineNumber,uint256 _startTime,uint256 _lastCalculateTime) { DataModal.RoundInfo memory roundInfo = rInfoXrID[roundNumber]; (uint256 totalMine,,) = getMineInfoInDay(msg.sender,roundNumber,dayNumber); return(roundNumber,dayNumber,totalMine,roundInfo.startTime,roundInfo.lastCalculateTime); } function getUserProperty() public view returns(uint256 ethMineNumber,uint256 holdEarning,uint256 transformRate,uint256 ethBalance,uint256 ethTranslated,uint256 ethMineCouldTranslateToday,uint256 ethCouldGetToday) { if(pIDXpAdd[msg.sender] <1) { return(0,0,0,0,0,0,0); } (,uint256 myMine,uint256 additional) = getMineInfoInDay(msg.sender,roundNumber,dayNumber); ethMineNumber = myMine; holdEarning = additional; transformRate = getTransformRate(msg.sender,roundNumber,dayNumber); ethBalance = getUserBalance(msg.sender); uint256 totalTransformed = 0; for(uint256 i=1;i<rInfoXrID[roundNumber].totalDay;i++) { totalTransformed = totalTransformed.add(getTransformMineInDay(msg.sender,roundNumber,i)); } ethTranslated = totalTransformed; ethCouldGetToday = getTransformMineInDay(msg.sender,roundNumber,dayNumber); ethMineCouldTranslateToday = myMine.mul(transformRate).div(10000); return( ethMineNumber, holdEarning, transformRate, ethBalance, ethTranslated, ethMineCouldTranslateToday, ethCouldGetToday ); } function getPlatformBalance() public view returns(uint256 _platformBalance) { require(msg.sender == sysAdminAddress,"Ummmmm......Only admin could do this"); return(platformBalance); } function withdrawForAdmin(address _toAddress,uint256 _amount) public { require(msg.sender==sysAdminAddress,"You are not the admin"); require(platformBalance>=_amount,"Lack of balance"); _toAddress.transfer(_amount); platformBalance = platformBalance.sub(_amount); } function p3dWithdrawForAdmin(address _toAddress,uint256 _amount) public { require(msg.sender==sysAdminAddress,"You are not the admin"); uint256 p3dToken = p3dContract.balanceOf(address(this)); require(_amount<=p3dToken,"You don't have so much P3DToken"); p3dContract.transfer(_toAddress,_amount); } //************ // //************ function getDataOfGame() public view returns(uint256 _playerNumber,uint256 _dailyIncreased,uint256 _dailyTransform,uint256 _contractBalance,uint256 _userBalanceLeft,uint256 _platformBalance,uint256 _mineBalance,uint256 _balanceOfMine) { for(uint256 i=1;i<=totalPlayerNumber;i++) { address userAddress = pAddXpID[i]; _userBalanceLeft = _userBalanceLeft.add(getUserBalance(userAddress)); } return( totalPlayerNumber, getIncreaseBalance(dayNumber,roundNumber), calculateTotalMinePay(roundNumber,dayNumber), address(this).balance, _userBalanceLeft, platformBalance, getBounsWithRoundID(roundNumber), getBounsWithRoundID(roundNumber).mul(7).div(10) ); } function getUserAddressList() public view returns(address[]) { address[] memory addressList = new address[](totalPlayerNumber); for(uint256 i=0;i<totalPlayerNumber;i++) { addressList[i] = pAddXpID[i+1]; } return(addressList); } function getUsersInfo() public view returns(uint256[7][]){ uint256[7][] memory infoList = new uint256[7][](totalPlayerNumber); for(uint256 i=0;i<totalPlayerNumber;i++) { address userAddress = pAddXpID[i+1]; (,uint256 myMine,uint256 additional) = getMineInfoInDay(userAddress,roundNumber,dayNumber); uint256 totalTransformed = 0; for(uint256 j=1;j<=roundNumber;j++) { for(uint256 k=1;k<=rInfoXrID[j].totalDay;k++) { totalTransformed = totalTransformed.add(getTransformMineInDay(userAddress,j,k)); } } infoList[i][0] = myMine ; infoList[i][1] = getTransformRate(userAddress,roundNumber,dayNumber); infoList[i][2] = additional; infoList[i][3] = getUserBalance(userAddress); infoList[i][4] = getUserBalance(userAddress).add(pInfoXpAdd[userAddress].withDrawNumber); infoList[i][5] = pInfoXpAdd[userAddress].inviteEarnings; infoList[i][6] = totalTransformed; } return(infoList); } function getP3DInfo() public view returns(uint256 _p3dTokenInContract,uint256 _p3dDivInRound) { _p3dTokenInContract = p3dContract.balanceOf(address(this)); _p3dDivInRound = p3dDividesXroundID[roundNumber]; return(_p3dTokenInContract,_p3dDivInRound); } } //P3D Interface interface HourglassInterface { function buy(address _playerAddress) payable external returns(uint256); function withdraw() external; function myDividends(bool _includeReferralBonus) external view returns(uint256); function balanceOf(address _customerAddress) external view returns(uint256); function transfer(address _toAddress, uint256 _amountOfTokens) external returns(bool); } library DataModal { struct PlayerInfo { uint256 inviteEarnings; address inviterAddress; uint256 withDrawNumber; } struct DayInfo { uint256 playerNumber; mapping(uint256=>address) addXIndex; mapping(uint256=>uint256) amountXIndex; mapping(address=>uint256) indexXAddress; } struct RoundInfo { uint256 startTime; uint256 lastCalculateTime; uint256 bounsInitNumber; uint256 totalDay; uint256 winnerDay; mapping(uint256=>DayInfo) dayInfoXDay; mapping(uint256=>address) addressXnumber; mapping(address=>uint256) numberXaddress; uint256 number; } } library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath div failed"); 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) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } /** * @dev gives square. multiplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
******************** Method need Gas********************
function joinGameWithBalance(uint256 _amount) public payable { require(_amount >= 0.01 ether,"You need to pay 0.01 eth at least"); require(now.sub(rInfoXrID[roundNumber].lastCalculateTime) < cycleTime,"Waiting for settlement"); uint256 balance = getUserBalance(msg.sender); require(balance >= _amount.mul(11).div(10),"balance is not enough"); platformBalance = platformBalance.add(_amount.div(10)); buyCore(pInfoXpAdd[msg.sender].inviterAddress,_amount); pInfoXpAdd[msg.sender].withDrawNumber = pInfoXpAdd[msg.sender].withDrawNumber.sub(_amount.mul(11).div(10)); emit newPlayerJoinGameEvent(msg.sender,_amount,false,now); }
2,474,056
[ 1, 1305, 1608, 31849, 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 ]
[ 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1233, 12496, 1190, 13937, 12, 11890, 5034, 389, 8949, 13, 1071, 8843, 429, 288, 203, 3639, 2583, 24899, 8949, 1545, 374, 18, 1611, 225, 2437, 10837, 6225, 1608, 358, 8843, 374, 18, 1611, 13750, 622, 4520, 8863, 203, 3639, 2583, 12, 3338, 18, 1717, 12, 86, 966, 60, 86, 734, 63, 2260, 1854, 8009, 2722, 8695, 950, 13, 411, 8589, 950, 10837, 15946, 364, 26319, 806, 8863, 203, 3639, 2254, 5034, 11013, 273, 4735, 13937, 12, 3576, 18, 15330, 1769, 203, 3639, 2583, 12, 12296, 1545, 389, 8949, 18, 16411, 12, 2499, 2934, 2892, 12, 2163, 3631, 6, 12296, 353, 486, 7304, 8863, 203, 3639, 4072, 13937, 273, 4072, 13937, 18, 1289, 24899, 8949, 18, 2892, 12, 2163, 10019, 203, 3639, 30143, 4670, 12, 84, 966, 60, 84, 986, 63, 3576, 18, 15330, 8009, 5768, 2165, 1887, 16, 67, 8949, 1769, 203, 3639, 293, 966, 60, 84, 986, 63, 3576, 18, 15330, 8009, 1918, 6493, 1854, 273, 293, 966, 60, 84, 986, 63, 3576, 18, 15330, 8009, 1918, 6493, 1854, 18, 1717, 24899, 8949, 18, 16411, 12, 2499, 2934, 2892, 12, 2163, 10019, 203, 3639, 3626, 394, 12148, 4572, 12496, 1133, 12, 3576, 18, 15330, 16, 67, 8949, 16, 5743, 16, 3338, 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 ]
./full_match/97/0x0a82f2822b57047775E12b87524e85E13Cf6A0c2/sources/project_/contracts/Router1.sol
Add the following events to your contract Add 'swapAndLiquifyEnabled' and 'inSwapAndLiquify' bool variables
contract Router1 is Context, IBEP20, Ownable, ReentrancyGuard { using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isExcludedFromAntiWhale; mapping (address => bool) private _AddressExists; mapping (address => bool) private _isExcludedFromLottery; address[] private _addressList; address[] private _excluded; address private _lottoPotAddress; address private _lottoWalletAddress; uint256 public _lastLottoWinnerAmount; uint256 public _totalLottoPrize; uint public _lottoDrawCount = 0; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 28 * 10 ** 6 * 10 ** 9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _minLottoBalance = 28 * 10 ** 3 * 10 ** 9; uint256 public _maxTxAmount = 28 * 10 ** 6 * 10 ** 9; uint256 private numTokensSellToAddToLiquidity = 3 * 10 ** 6 * 10 ** 9; event NumTokensSellToAddToLiquidityUpdated(uint256 newNumTokensSellToAddToLiquidity); uint256 public maxIterations; uint256 private numTokensSellToAddToLiquidityTwo = 1 * 10**4 * 10**9; event NumTokensSellToAddToLiquidityUpdatedTwo(uint256 newNumTokensSellToAddToLiquidity); uint256 public lotteryThreshold = 28 * 10 ** 2 * 10 ** 9; uint256 public _antiWhaleThreshold = 28 * 10 ** 4 * 10 ** 9; address payable private _exchangeWallet; address payable private _teamWallet; address payable private _marketingAsiaWallet; address payable private _marketingAfricaWallet; address payable private _marketingNorthAmericaWallet; address payable private _marketingSouthAmericaWallet; address payable private _marketingAntarcticaWallet; address payable private _marketingEuropeWallet; address payable private _marketingAustraliaWallet; address payable private _devWallet; bool public lottoTemporarilyDisabled = false; IPancakeRouter02 public pancakeRouter; IPancakePair public pancakePair; address public liquidityPool; bool public swapAndLiquifyEnabled = true; bool private inSwapAndLiquify; event Debug(string message); string private _name = "Router1"; string private _symbol = "Router1"; uint8 private _decimals = 9; uint256[] public fees; uint256[] private previousFees; enum FeeType { _LiquidityFee, _LottoFee, _DevFee, _TeamFee, _ExchangeFee, _MarketingAsiaFee, _MarketingAfricaFee, _MarketingNorthAmericaFee, _MarketingSouthAmericaFee, _MarketingAntarcticaFee, _MarketingEuropeFee, _MarketingAustraliaFee } bool public lottoEnabled = true; bool inLotteryDraw; bool public _isAntiWhaleEnabled = true; struct TData { uint256 tAmount; BridgesMarketingData marketingData; BridgesTeamData teamData; BridgesSystemData systemData; uint256 currentRate; } struct BridgesMarketingData { } struct BridgesTeamData { } struct BridgesSystemData { } event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event DrawLotto(uint256 amount, uint _lottoDrawCount); event TokensWithdrawn( address tokenAddress, address recipient, uint256 amount ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } modifier lockTheLottery { inLotteryDraw = true; _; inLotteryDraw = false; } constructor() { _rOwned[_msgSender()] = _rTotal; addAddress(_msgSender()); _lottoPotAddress = address(1); IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0xD99D1c33F9fC3444f8101754aBC46c52416550D1); address pancakePairAddress = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); pancakePair = IPancakePair(pancakePairAddress); pancakeRouter = _pancakeRouter; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[_lottoPotAddress] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromAntiWhale[owner()] = true; _isExcludedFromAntiWhale[_lottoPotAddress] = true; _isExcludedFromAntiWhale[address(this)] = true; _isExcludedFromAntiWhale[address(pancakeRouter)] = true; _isExcludedFromAntiWhale[address(pancakePair)] = true; _initializeFees(); maxIterations = 1; emit Transfer(address(0), _msgSender(), _tTotal); } function _initializeFees() private { fees = new uint256[](12); previousFees = new uint256[](12); fees[uint256(FeeType._LiquidityFee)] = 1000; fees[uint256(FeeType._LottoFee)] = 100; fees[uint256(FeeType._DevFee)] = 0; fees[uint256(FeeType._TeamFee)] = 0; fees[uint256(FeeType._ExchangeFee)] = 0; fees[uint256(FeeType._MarketingAsiaFee)] = 0; fees[uint256(FeeType._MarketingAfricaFee)] = 0; fees[uint256(FeeType._MarketingNorthAmericaFee)] = 0; fees[uint256(FeeType._MarketingSouthAmericaFee)] = 0; fees[uint256(FeeType._MarketingAntarcticaFee)] = 0; fees[uint256(FeeType._MarketingEuropeFee)] = 0; fees[uint256(FeeType._MarketingAustraliaFee)] = 0; for (uint256 i = 0; i < fees.length; i++) { previousFees[i] = fees[i]; } } function _initializeFees() private { fees = new uint256[](12); previousFees = new uint256[](12); fees[uint256(FeeType._LiquidityFee)] = 1000; fees[uint256(FeeType._LottoFee)] = 100; fees[uint256(FeeType._DevFee)] = 0; fees[uint256(FeeType._TeamFee)] = 0; fees[uint256(FeeType._ExchangeFee)] = 0; fees[uint256(FeeType._MarketingAsiaFee)] = 0; fees[uint256(FeeType._MarketingAfricaFee)] = 0; fees[uint256(FeeType._MarketingNorthAmericaFee)] = 0; fees[uint256(FeeType._MarketingSouthAmericaFee)] = 0; fees[uint256(FeeType._MarketingAntarcticaFee)] = 0; fees[uint256(FeeType._MarketingEuropeFee)] = 0; fees[uint256(FeeType._MarketingAustraliaFee)] = 0; for (uint256 i = 0; i < fees.length; i++) { previousFees[i] = fees[i]; } } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function minLottoBalance() public view returns (uint256) { return _minLottoBalance; } function currentLottoPool() public view returns (uint256) { return balanceOf(_lottoPotAddress); } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; uint256 newAllowance = currentAllowance + addedValue; _approve(_msgSender(), spender, newAllowance); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function isIncludeFromLotto(address account) public view returns (bool) { return _AddressExists[account]; } function deliver(uint256 tAmount) private { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount, , , , , ) = _getValues(tAmount); _rOwned[sender] -= rAmount; _rTotal -= rAmount; } function reflectionFromToken( uint256 tAmount, bool deductTransferFee ) private view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(tAmount); return rAmount; (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); return rTransferAmount; } } function reflectionFromToken( uint256 tAmount, bool deductTransferFee ) private view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(tAmount); return rAmount; (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); return rTransferAmount; } } } else { function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function _takeMarketingFees(BridgesMarketingData memory marketingData) private { _takeFees(_marketingAsiaWallet, marketingData.fees[0], _isExcluded[_marketingAsiaWallet]); _takeFees(_marketingAfricaWallet, marketingData.fees[1], _isExcluded[_marketingAfricaWallet]); _takeFees(_marketingNorthAmericaWallet, marketingData.fees[2], _isExcluded[_marketingNorthAmericaWallet]); _takeFees(_marketingSouthAmericaWallet, marketingData.fees[3], _isExcluded[_marketingSouthAmericaWallet]); _takeFees(_marketingAntarcticaWallet, marketingData.fees[4], _isExcluded[_marketingAntarcticaWallet]); _takeFees(_marketingEuropeWallet, marketingData.fees[5], _isExcluded[_marketingEuropeWallet]); _takeFees(_marketingAustraliaWallet, marketingData.fees[6], _isExcluded[_marketingAustraliaWallet]); } function _takeTeamFees(BridgesTeamData memory teamData) private { _takeFees(_devWallet, teamData.fees[0], _isExcluded[_devWallet]); _takeFees(_exchangeWallet, teamData.fees[1], _isExcluded[_exchangeWallet]); _takeFees(_teamWallet, teamData.fees[2], _isExcluded[_teamWallet]); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, BridgesSystemData memory systemData, BridgesTeamData memory teamData, BridgesMarketingData memory marketingData ) = _getValues(tAmount); _tOwned[sender] -= tAmount; _rOwned[sender] -= rAmount; _tOwned[recipient] += tTransferAmount; _rOwned[recipient] += rTransferAmount; _takeFees(address(this), systemData.fees[0], _isExcluded[address(this)]); _takeFees(_lottoPotAddress, systemData.fees[1], _isExcluded[_lottoPotAddress]); _takeMarketingFees(marketingData); _takeTeamFees(teamData); emit Transfer(sender, recipient, tTransferAmount); } function AA_setNameAndSymbol( string memory newName, string memory newSymbol ) public onlyOwner { _name = newName; _symbol = newSymbol; } function setNumTokensSellToAddToLiquidity(uint256 newNumTokensSellToAddToLiquidity) external onlyOwner { numTokensSellToAddToLiquidity = newNumTokensSellToAddToLiquidity; emit NumTokensSellToAddToLiquidityUpdated(newNumTokensSellToAddToLiquidity); } function setNumTokensSellToAddToLiquidityTwo(uint256 newNumTokensSellToAddToLiquidityTwo) external onlyOwner { numTokensSellToAddToLiquidityTwo = newNumTokensSellToAddToLiquidityTwo; emit NumTokensSellToAddToLiquidityUpdatedTwo(newNumTokensSellToAddToLiquidityTwo); } function AB_excludeFromFee(address[] memory accounts) public onlyOwner { for (uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = true; } } function AB_excludeFromFee(address[] memory accounts) public onlyOwner { for (uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = true; } } function AB_setExcludedFromAntiWhale( address account, bool e ) external onlyOwner { _isExcludedFromAntiWhale[account] = e; } function AB_includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function AC_setMinLottoBalance(uint256 minBalance) public onlyOwner { _minLottoBalance = minBalance; } function AC_setLotteryThresHold(uint256 threshold) public onlyOwner { lotteryThreshold = threshold; } function AC_setAntiWhaleThreshold(uint256 amount) external onlyOwner { _antiWhaleThreshold = amount; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function AD_setAntiWhaleEnabled(bool e) external onlyOwner { _isAntiWhaleEnabled = e; } function AD_setLottoEnabled(bool enabled) public onlyOwner { lottoEnabled = enabled; } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function setFees( uint256 newLiquidityFee, uint256 newLottoFee, uint256 newDevFee, uint256 newTeamFee, uint256 newExchangeFee, uint256 newMarketingAsiaFee, uint256 newMarketingAfricaFee, uint256 newMarketingNorthAmericaFee, uint256 newMarketingSouthAmericaFee, uint256 newMarketingAntarcticaFee, uint256 newMarketingEuropeFee, uint256 newMarketingAustraliaFee ) external onlyOwner { if (newLiquidityFee != 0) { previousFees[uint256(FeeType._LiquidityFee)] = fees[uint256(FeeType._LiquidityFee)]; fees[uint256(FeeType._LiquidityFee)] = newLiquidityFee; } if (newLottoFee != 0) { previousFees[uint256(FeeType._LottoFee)] = fees[uint256(FeeType._LottoFee)]; fees[uint256(FeeType._LottoFee)] = newLottoFee; } if (newDevFee != 0) { previousFees[uint256(FeeType._DevFee)] = fees[uint256(FeeType._DevFee)]; fees[uint256(FeeType._DevFee)] = newDevFee; } if (newTeamFee != 0) { previousFees[uint256(FeeType._TeamFee)] = fees[uint256(FeeType._TeamFee)]; fees[uint256(FeeType._TeamFee)] = newTeamFee; } if (newExchangeFee != 0) { previousFees[uint256(FeeType._ExchangeFee)] = fees[uint256(FeeType._ExchangeFee)]; fees[uint256(FeeType._ExchangeFee)] = newExchangeFee; } if (newMarketingAsiaFee != 0) { previousFees[uint256(FeeType._MarketingAsiaFee)] = fees[uint256(FeeType._MarketingAsiaFee)]; fees[uint256(FeeType._MarketingAsiaFee)] = newMarketingAsiaFee; } if (newMarketingAfricaFee != 0) { previousFees[uint256(FeeType._MarketingAfricaFee)] = fees[uint256(FeeType._MarketingAfricaFee)]; fees[uint256(FeeType._MarketingAfricaFee)] = newMarketingAfricaFee; } if (newMarketingNorthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingNorthAmericaFee)] = fees[uint256(FeeType._MarketingNorthAmericaFee)]; fees[uint256(FeeType._MarketingNorthAmericaFee)] = newMarketingNorthAmericaFee; } if (newMarketingSouthAmericaFee != 0) { previousFees[uint256(FeeType._MarketingSouthAmericaFee)] = fees[uint256(FeeType._MarketingSouthAmericaFee)]; fees[uint256(FeeType._MarketingSouthAmericaFee)] = newMarketingSouthAmericaFee; } if (newMarketingAntarcticaFee != 0) { previousFees[uint256(FeeType._MarketingAntarcticaFee)] = fees[uint256(FeeType._MarketingAntarcticaFee)]; fees[uint256(FeeType._MarketingAntarcticaFee)] = newMarketingAntarcticaFee; } if (newMarketingEuropeFee != 0) { previousFees[uint256(FeeType._MarketingEuropeFee)] = fees[uint256(FeeType._MarketingEuropeFee)]; fees[uint256(FeeType._MarketingEuropeFee)] = newMarketingEuropeFee; } if (newMarketingAustraliaFee != 0) { previousFees[uint256(FeeType._MarketingAustraliaFee)] = fees[uint256(FeeType._MarketingAustraliaFee)]; fees[uint256(FeeType._MarketingAustraliaFee)] = newMarketingAustraliaFee; } } function AE_setMaxTxPercent(uint256 maxTxPercent) external onlyOwner { _maxTxAmount = _tTotal * maxTxPercent / 100; } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AF_setWalletAddress( address payable dev, address payable exchange, address payable team, address payable marketingAsia, address payable marketingAfrica, address payable marketingNorthAmerica, address payable marketingSouthAmerica, address payable marketingAntarctica, address payable marketingEurope, address payable marketingAustralia ) public onlyOwner { if (dev != address(0)) { _devWallet = dev; } if (exchange != address(0)) { _exchangeWallet = exchange; } if (team != address(0)) { _teamWallet = team; } if (marketingAsia != address(0)) { _marketingAsiaWallet = marketingAsia; } if (marketingAfrica != address(0)) { _marketingAfricaWallet = marketingAfrica; } if (marketingNorthAmerica != address(0)) { _marketingNorthAmericaWallet = marketingNorthAmerica; } if (marketingSouthAmerica != address(0)) { _marketingSouthAmericaWallet = marketingSouthAmerica; } if (marketingAntarctica != address(0)) { _marketingAntarcticaWallet = marketingAntarctica; } if (marketingEurope != address(0)) { _marketingEuropeWallet = marketingEurope; } if (marketingAustralia != address(0)) { _marketingAustraliaWallet = marketingAustralia; } } function AG_setPancakeRouter(address r) external onlyOwner { IPancakeRouter02 _pancakeRouter = IPancakeRouter02(r); pancakeRouter = _pancakeRouter; } function AG_setPancakePair(address p) external onlyOwner { pancakePair = IPancakePair(p); } function AZ_withdrawStuckBNB() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "Contract has no BNB balance"); address payable owner = payable(_msgSender()); owner.transfer(balance); } function AZ_withdrawStuckTokens(address _tokenAddress) public onlyOwner { IBEP20 token = IBEP20(_tokenAddress); uint256 balance = token.balanceOf(address(this)); require(balance > 0, "No tokens to withdraw"); require(token.transfer(msg.sender, balance), "Token transfer failed"); emit TokensWithdrawn(_tokenAddress, msg.sender, balance); } receive() external payable {} function _getMarketingValues(uint256 tAmount) private view returns (BridgesMarketingData memory) { uint256[7] memory marketingFees = [ calculateFee(tAmount, FeeType._MarketingAsiaFee), calculateFee(tAmount, FeeType._MarketingAfricaFee), calculateFee(tAmount, FeeType._MarketingNorthAmericaFee), calculateFee(tAmount, FeeType._MarketingSouthAmericaFee), calculateFee(tAmount, FeeType._MarketingAntarcticaFee), calculateFee(tAmount, FeeType._MarketingEuropeFee), calculateFee(tAmount, FeeType._MarketingAustraliaFee) ]; return marketingData; } BridgesMarketingData memory marketingData = BridgesMarketingData({fees: marketingFees}); function _getSystemValues(uint256 tAmount) private view returns (BridgesSystemData memory) { uint256[2] memory systemFees = [ calculateFee(tAmount, FeeType._LiquidityFee), calculateFee(tAmount, FeeType._LottoFee) ]; return systemData; } BridgesSystemData memory systemData = BridgesSystemData({fees: systemFees}); function _getTeamValues(uint256 tAmount) private view returns (BridgesTeamData memory) { uint256[3] memory teamFees = [ calculateFee(tAmount, FeeType._DevFee), calculateFee(tAmount, FeeType._ExchangeFee), calculateFee(tAmount, FeeType._TeamFee) ]; return teamData; } BridgesTeamData memory teamData = BridgesTeamData({fees: teamFees}); function _getValues( uint256 tAmount ) private view returns ( uint256, uint256, uint256, BridgesSystemData memory, BridgesTeamData memory, BridgesMarketingData memory ) { uint256 tTransferAmount = _getTValues(tAmount); uint256 currentRate = _getRate(); uint256 rAmount = _calculateRValue(tAmount, currentRate); uint256 rTransferAmount = _calculateRValue( tTransferAmount, currentRate ); BridgesSystemData memory systemData = _getSystemValues(tAmount); BridgesTeamData memory teamData = _getTeamValues(tAmount); BridgesMarketingData memory marketingData = _getMarketingValues( tAmount ); return ( rAmount, rTransferAmount, tTransferAmount, systemData, teamData, marketingData ); } function _getTValues(uint256 tAmount) private view returns (uint256) { BridgesSystemData memory systemData = _getSystemValues(tAmount); BridgesTeamData memory teamData = _getTeamValues(tAmount); BridgesMarketingData memory marketingData = _getMarketingValues(tAmount); uint256 totalSystemFees = _getTotalSystemFees(systemData); uint256 totalTeamFees = _getTotalTeamFees(teamData); uint256 totalMarketingFees = _getTotalMarketingFees(marketingData); uint256 totalFees = totalSystemFees + totalTeamFees + totalMarketingFees; uint256 tTransferAmount = tAmount - totalFees; return tTransferAmount; } function _getTotalSystemFees( BridgesSystemData memory systemData ) private pure returns (uint256) { return systemData.fees[0] + systemData.fees[1]; } function _getTotalTeamFees( BridgesTeamData memory teamData ) private pure returns (uint256) { return teamData.fees[0] + teamData.fees[1] + teamData.fees[2]; } function _getTotalMarketingFees( BridgesMarketingData memory marketingData ) private pure returns (uint256) { return marketingData.fees[0] + marketingData.fees[1] + marketingData.fees[2] + marketingData.fees[3] + marketingData.fees[4] + marketingData.fees[5] + marketingData.fees[6]; } function _getRValues( uint256 tAmount, uint256 currentRate, BridgesSystemData memory systemData, BridgesTeamData memory teamData, BridgesMarketingData memory marketingData ) private pure returns (uint256, uint256) { uint256 rAmount = _calculateRValue(tAmount, currentRate); uint256 rLiquidity = _calculateRValue(systemData.fees[0], currentRate); uint256 rLotto = _calculateRValue(systemData.fees[1], currentRate); uint256 rDev = _calculateRValue(teamData.fees[0], currentRate); uint256 rTeam = _calculateRValue(teamData.fees[1], currentRate); uint256 rExchange = _calculateRValue(teamData.fees[2], currentRate); uint256 rMarketingAsia = _calculateRValue( marketingData.fees[0], currentRate ); uint256 rMarketingAfrica = _calculateRValue( marketingData.fees[1], currentRate ); uint256 rMarketingNorthAmerica = _calculateRValue( marketingData.fees[2], currentRate ); uint256 rMarketingSouthAmerica = _calculateRValue( marketingData.fees[3], currentRate ); uint256 rMarketingAntarctica = _calculateRValue( marketingData.fees[4], currentRate ); uint256 rMarketingEurope = _calculateRValue( marketingData.fees[5], currentRate ); uint256 rMarketingAustralia = _calculateRValue( marketingData.fees[6], currentRate ); uint256 rTransferAmount = rAmount - rLiquidity - rLotto - rDev - rTeam - rExchange - rMarketingAsia - rMarketingAfrica - rMarketingNorthAmerica - rMarketingSouthAmerica - rMarketingAntarctica - rMarketingEurope - rMarketingAustralia; return (rAmount, rTransferAmount); } function _calculateRValue( uint256 tValue, uint256 currentRate ) private pure returns (uint256) { return tValue * currentRate; } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply / tSupply; } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) { return (_rTotal, _tTotal); } rSupply -= _rOwned[_excluded[i]]; tSupply -= _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) { return (_rTotal, _tTotal); } return (rSupply, tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) { return (_rTotal, _tTotal); } rSupply -= _rOwned[_excluded[i]]; tSupply -= _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) { return (_rTotal, _tTotal); } return (rSupply, tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) { return (_rTotal, _tTotal); } rSupply -= _rOwned[_excluded[i]]; tSupply -= _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) { return (_rTotal, _tTotal); } return (rSupply, tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) { return (_rTotal, _tTotal); } rSupply -= _rOwned[_excluded[i]]; tSupply -= _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) { return (_rTotal, _tTotal); } return (rSupply, tSupply); } function addAddress(address adr) private { if(_AddressExists[adr]) return; _AddressExists[adr] = true; _addressList.push(adr); } function random() private view returns (uint) { return uint( keccak256( abi.encodePacked( block.prevrandao, block.timestamp, block.number ) ) ); } function excludeFromLottery(address account) public onlyOwner { require(!_isExcludedFromLottery[account], "Account is already excluded from lottery"); _isExcludedFromLottery[account] = true; } function includeInLottery(address account) public onlyOwner { require(_isExcludedFromLottery[account], "Account is already included in lottery"); _isExcludedFromLottery[account] = false; } function isExcludedFromLottery(address account) public view returns (bool) { return _isExcludedFromLottery[account]; } function lotterize() private view returns(address) { uint256 randomNumber = random() % _addressList.length; address selectedAddress = _addressList[randomNumber]; uint256 ownedAmount = _rOwned[selectedAddress]; if (ownedAmount >= _minLottoBalance && selectedAddress != address(this) && selectedAddress != address(pancakePair) && selectedAddress != _lottoPotAddress && !_isExcludedFromLottery[selectedAddress]) { return selectedAddress; } return _devWallet; } function lotterize() private view returns(address) { uint256 randomNumber = random() % _addressList.length; address selectedAddress = _addressList[randomNumber]; uint256 ownedAmount = _rOwned[selectedAddress]; if (ownedAmount >= _minLottoBalance && selectedAddress != address(this) && selectedAddress != address(pancakePair) && selectedAddress != _lottoPotAddress && !_isExcludedFromLottery[selectedAddress]) { return selectedAddress; } return _devWallet; } function _takeFees(address wallet, uint256 fee, bool isExcluded) private { uint256 currentRate = _getRate(); uint256 rFee = fee * currentRate; _rOwned[wallet] += rFee; if (isExcluded) { _tOwned[wallet] += fee; } } function _takeFees(address wallet, uint256 fee, bool isExcluded) private { uint256 currentRate = _getRate(); uint256 rFee = fee * currentRate; _rOwned[wallet] += rFee; if (isExcluded) { _tOwned[wallet] += fee; } } function drawLotto() private lockTheLottery { uint256 lottoBalance = balanceOf(_lottoPotAddress); require(lottoBalance >= lotteryThreshold, "Lotto pot balance is below the threshold"); _lottoWalletAddress = lotterize(); _transfer(_lottoPotAddress, _lottoWalletAddress, lotteryThreshold); _lastLottoWinnerAmount = lotteryThreshold; _totalLottoPrize += lotteryThreshold; ++_lottoDrawCount; emit DrawLotto(lotteryThreshold, _lottoDrawCount); } function calculateFee(uint256 _amount, FeeType feeType) private view returns (uint256) { return _amount * fees[uint256(feeType)] / 10 ** 4; } function removeAllFee() private { for (uint256 i = 0; i < fees.length; i++) { if (fees[i] == 0) continue; previousFees[i] = fees[i]; fees[i] = 0; } } function removeAllFee() private { for (uint256 i = 0; i < fees.length; i++) { if (fees[i] == 0) continue; previousFees[i] = fees[i]; fees[i] = 0; } } function restoreAllFee() private { for (uint256 i = 0; i < fees.length; i++) { fees[i] = previousFees[i]; } } function restoreAllFee() private { for (uint256 i = 0; i < fees.length; i++) { fees[i] = previousFees[i]; } } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0) && spender != address(0), "Err"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != address(pancakePair) && swapAndLiquifyEnabled ) { lottoTemporarilyDisabled = true; contractTokenBalance = numTokensSellToAddToLiquidity; swapAndLiquify(contractTokenBalance); lottoTemporarilyDisabled = false; } if (_isAntiWhaleEnabled && !_isExcludedFromAntiWhale[to]) { if (from == address(pancakePair) && to != address(pancakeRouter)) { require(amount <= _antiWhaleThreshold, "Anti whale: can't buy more than the specified threshold"); require(balanceOf(to) + amount <= _antiWhaleThreshold, "Anti whale: can't hold more than the specified threshold"); } } uint256 lottoBalance = balanceOf(_lottoPotAddress); bool overMinLottoBalance = lottoBalance >= lotteryThreshold; if (overMinLottoBalance && !inLotteryDraw && lottoEnabled && !lottoTemporarilyDisabled) { drawLotto(); } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } addAddress(from); addAddress(to); _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { _approve(address(this), address(pancakeRouter), type(uint256).max); uint256 half = contractTokenBalance / (2); uint256 otherHalf = contractTokenBalance - (half); uint256 initialBalance = address(this).balance; swapTokensForBNB(half); uint256 newBalance = address(this).balance - (initialBalance); addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function triggerSwapAndLiquify() external lockTheSwap { require((_msgSender() == owner()) && swapAndLiquifyEnabled, "Error"); doCustomSwapAndLiquify(numTokensSellToAddToLiquidityTwo); } function doCustomSwapAndLiquify(uint256 customNumTokensSellToAddToLiquidity) private { uint256 contractTokenBalance = balanceOf(address(this)); uint256 timesToExecute = contractTokenBalance / customNumTokensSellToAddToLiquidity; if (timesToExecute > maxIterations) { timesToExecute = maxIterations; } for (uint256 i = 0; i < timesToExecute; i++) { uint256 half = customNumTokensSellToAddToLiquidity / 2; uint256 otherHalf = customNumTokensSellToAddToLiquidity - half; uint256 initialBalance = address(this).balance; swapTokensForBNB(half); uint256 newBalance = address(this).balance - initialBalance; addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } function doCustomSwapAndLiquify(uint256 customNumTokensSellToAddToLiquidity) private { uint256 contractTokenBalance = balanceOf(address(this)); uint256 timesToExecute = contractTokenBalance / customNumTokensSellToAddToLiquidity; if (timesToExecute > maxIterations) { timesToExecute = maxIterations; } for (uint256 i = 0; i < timesToExecute; i++) { uint256 half = customNumTokensSellToAddToLiquidity / 2; uint256 otherHalf = customNumTokensSellToAddToLiquidity - half; uint256 initialBalance = address(this).balance; swapTokensForBNB(half); uint256 newBalance = address(this).balance - initialBalance; addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } function doCustomSwapAndLiquify(uint256 customNumTokensSellToAddToLiquidity) private { uint256 contractTokenBalance = balanceOf(address(this)); uint256 timesToExecute = contractTokenBalance / customNumTokensSellToAddToLiquidity; if (timesToExecute > maxIterations) { timesToExecute = maxIterations; } for (uint256 i = 0; i < timesToExecute; i++) { uint256 half = customNumTokensSellToAddToLiquidity / 2; uint256 otherHalf = customNumTokensSellToAddToLiquidity - half; uint256 initialBalance = address(this).balance; swapTokensForBNB(half); uint256 newBalance = address(this).balance - initialBalance; addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } function swapTokensForBNB(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = pancakeRouter.WETH(); _approve(address(this), address(pancakeRouter), tokenAmount); pancakeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 bnbAmount) private { _approve(address(this), address(pancakeRouter), tokenAmount); address(this), tokenAmount, 0, 0, address(this), block.timestamp ); } pancakeRouter.addLiquidityETH{value: bnbAmount}( function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); _transferToExcluded(sender, recipient, amount); _transferStandard(sender, recipient, amount); _transferBothExcluded(sender, recipient, amount); _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); _transferToExcluded(sender, recipient, amount); _transferStandard(sender, recipient, amount); _transferBothExcluded(sender, recipient, amount); _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } } else if (!_isExcluded[sender] && _isExcluded[recipient]) { } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { } else if (_isExcluded[sender] && _isExcluded[recipient]) { } else { function _transferStandard(address sender, address recipient, uint256 tAmount) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, BridgesSystemData memory systemData, BridgesTeamData memory teamData, BridgesMarketingData memory marketingData ) = _getValues(tAmount); _rOwned[sender] -= rAmount; _rOwned[recipient] += rTransferAmount; _takeFees(address(this), systemData.fees[0], _isExcluded[address(this)]); _takeFees(_lottoPotAddress, systemData.fees[1], _isExcluded[_lottoPotAddress]); _takeFees(_marketingAsiaWallet, marketingData.fees[0], _isExcluded[_marketingAsiaWallet]); _takeFees(_marketingAfricaWallet, marketingData.fees[1], _isExcluded[_marketingAfricaWallet]); _takeFees(_marketingNorthAmericaWallet, marketingData.fees[2], _isExcluded[_marketingNorthAmericaWallet]); _takeFees(_marketingSouthAmericaWallet, marketingData.fees[3], _isExcluded[_marketingSouthAmericaWallet]); _takeFees(_marketingAntarcticaWallet, marketingData.fees[4], _isExcluded[_marketingAntarcticaWallet]); _takeFees(_marketingEuropeWallet, marketingData.fees[5], _isExcluded[_marketingEuropeWallet]); _takeFees(_marketingAustraliaWallet, marketingData.fees[6], _isExcluded[_marketingAustraliaWallet]); _takeFees(_devWallet, teamData.fees[0], _isExcluded[_devWallet]); _takeFees(_exchangeWallet, teamData.fees[1], _isExcluded[_exchangeWallet]); _takeFees(_teamWallet, teamData.fees[2], _isExcluded[_teamWallet]); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, BridgesSystemData memory systemData, BridgesTeamData memory teamData, BridgesMarketingData memory marketingData ) = _getValues(tAmount); _rOwned[sender] -= rAmount; _tOwned[recipient] += tTransferAmount; _rOwned[recipient] += rTransferAmount; _takeFees(address(this), systemData.fees[0], _isExcluded[address(this)]); _takeFees(_lottoPotAddress, systemData.fees[1], _isExcluded[_lottoPotAddress]); _takeFees(_marketingAsiaWallet, marketingData.fees[0], _isExcluded[_marketingAsiaWallet]); _takeFees(_marketingAfricaWallet, marketingData.fees[1], _isExcluded[_marketingAfricaWallet]); _takeFees(_marketingNorthAmericaWallet, marketingData.fees[2], _isExcluded[_marketingNorthAmericaWallet]); _takeFees(_marketingSouthAmericaWallet, marketingData.fees[3], _isExcluded[_marketingSouthAmericaWallet]); _takeFees(_marketingAntarcticaWallet, marketingData.fees[4], _isExcluded[_marketingAntarcticaWallet]); _takeFees(_marketingEuropeWallet, marketingData.fees[5], _isExcluded[_marketingEuropeWallet]); _takeFees(_marketingAustraliaWallet, marketingData.fees[6], _isExcluded[_marketingAustraliaWallet]); _takeFees(_devWallet, teamData.fees[0], _isExcluded[_devWallet]); _takeFees(_exchangeWallet, teamData.fees[1], _isExcluded[_exchangeWallet]); _takeFees(_teamWallet, teamData.fees[2], _isExcluded[_teamWallet]); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 tTransferAmount, BridgesSystemData memory systemData, BridgesTeamData memory teamData, BridgesMarketingData memory marketingData ) = _getValues(tAmount); _tOwned[sender] -= tAmount; _rOwned[sender] -= rAmount; _rOwned[recipient] += rTransferAmount; _takeFees(address(this), systemData.fees[0], _isExcluded[address(this)]); _takeFees(_lottoPotAddress, systemData.fees[1], _isExcluded[_lottoPotAddress]); _takeFees(_marketingAsiaWallet, marketingData.fees[0], _isExcluded[_marketingAsiaWallet]); _takeFees(_marketingAfricaWallet, marketingData.fees[1], _isExcluded[_marketingAfricaWallet]); _takeFees(_marketingNorthAmericaWallet, marketingData.fees[2], _isExcluded[_marketingNorthAmericaWallet]); _takeFees(_marketingSouthAmericaWallet, marketingData.fees[3], _isExcluded[_marketingSouthAmericaWallet]); _takeFees(_marketingAntarcticaWallet, marketingData.fees[4], _isExcluded[_marketingAntarcticaWallet]); _takeFees(_marketingEuropeWallet, marketingData.fees[5], _isExcluded[_marketingEuropeWallet]); _takeFees(_marketingAustraliaWallet, marketingData.fees[6], _isExcluded[_marketingAustraliaWallet]); _takeFees(_devWallet, teamData.fees[0], _isExcluded[_devWallet]); _takeFees(_exchangeWallet, teamData.fees[1], _isExcluded[_exchangeWallet]); _takeFees(_teamWallet, teamData.fees[2], _isExcluded[_teamWallet]); emit Transfer(sender, recipient, tTransferAmount); } }
5,031,289
[ 1, 986, 326, 3751, 2641, 358, 3433, 6835, 1436, 296, 22270, 1876, 48, 18988, 1164, 1526, 11, 471, 296, 267, 12521, 1876, 48, 18988, 1164, 11, 1426, 3152, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 9703, 21, 353, 1772, 16, 467, 5948, 52, 3462, 16, 14223, 6914, 16, 868, 8230, 12514, 16709, 225, 288, 202, 203, 565, 1450, 5267, 364, 1758, 31, 202, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 86, 5460, 329, 31, 202, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 88, 5460, 329, 31, 202, 203, 565, 2874, 261, 2867, 516, 2874, 261, 2867, 516, 2254, 5034, 3719, 3238, 389, 5965, 6872, 31, 202, 203, 565, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 291, 16461, 1265, 14667, 31, 202, 203, 565, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 291, 16461, 31, 202, 203, 565, 2874, 261, 2867, 516, 1426, 13, 1071, 389, 291, 16461, 1265, 14925, 77, 2888, 5349, 31, 203, 565, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 1887, 4002, 31, 203, 565, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 291, 16461, 1265, 48, 352, 387, 93, 31, 203, 565, 1758, 8526, 3238, 389, 2867, 682, 31, 203, 565, 1758, 8526, 3238, 389, 24602, 31, 203, 565, 202, 2867, 3238, 389, 23372, 869, 18411, 1887, 31, 203, 565, 202, 2867, 3238, 389, 23372, 869, 16936, 1887, 31, 203, 565, 202, 11890, 5034, 1071, 389, 2722, 48, 352, 869, 59, 7872, 6275, 31, 203, 565, 2254, 5034, 1071, 389, 4963, 48, 352, 869, 2050, 554, 31, 203, 565, 2254, 1071, 389, 23372, 869, 6493, 1380, 273, 374, 31, 203, 27699, 565, 2254, 5034, 3238, 5381, 4552, 273, 4871, 11890, 5034, 12, 20, 1769, 202, 2 ]
./full_match/1/0x6a2Df7Fd15612079D1a72001F3a921Db792B2738/sources/src/bonding/Power.sol
* The values below depend on MAX_PRECISION. If you choose to change it: Apply the same change in file 'PrintIntScalingFactors.py', run it and paste the results below./* Auto-generated via 'PrintLn2ScalingFactors.py'/* Auto-generated via 'PrintFunctionOptimalLog.py' and 'PrintFunctionOptimalExp.py'/* The values below depend on MIN_PRECISION and MAX_PRECISION. If you choose to change either one of them: Apply the same change in file 'PrintFunctionBancorFormula.py', run it and paste the results below./ maxExpArray[0] = 0x6bffffffffffffffffffffffffffffffff; maxExpArray[1] = 0x67ffffffffffffffffffffffffffffffff; maxExpArray[2] = 0x637fffffffffffffffffffffffffffffff; maxExpArray[3] = 0x5f6fffffffffffffffffffffffffffffff; maxExpArray[4] = 0x5b77ffffffffffffffffffffffffffffff; maxExpArray[5] = 0x57b3ffffffffffffffffffffffffffffff; maxExpArray[6] = 0x5419ffffffffffffffffffffffffffffff; maxExpArray[7] = 0x50a2ffffffffffffffffffffffffffffff; maxExpArray[8] = 0x4d517fffffffffffffffffffffffffffff; maxExpArray[9] = 0x4a233fffffffffffffffffffffffffffff; maxExpArray[10] = 0x47165fffffffffffffffffffffffffffff; maxExpArray[11] = 0x4429afffffffffffffffffffffffffffff; maxExpArray[12] = 0x415bc7ffffffffffffffffffffffffffff; maxExpArray[13] = 0x3eab73ffffffffffffffffffffffffffff; maxExpArray[14] = 0x3c1771ffffffffffffffffffffffffffff; maxExpArray[15] = 0x399e96ffffffffffffffffffffffffffff; maxExpArray[16] = 0x373fc47fffffffffffffffffffffffffff; maxExpArray[17] = 0x34f9e8ffffffffffffffffffffffffffff; maxExpArray[18] = 0x32cbfd5fffffffffffffffffffffffffff; maxExpArray[19] = 0x30b5057fffffffffffffffffffffffffff; maxExpArray[20] = 0x2eb40f9fffffffffffffffffffffffffff; maxExpArray[21] = 0x2cc8340fffffffffffffffffffffffffff; maxExpArray[22] = 0x2af09481ffffffffffffffffffffffffff; maxExpArray[23] = 0x292c5bddffffffffffffffffffffffffff; maxExpArray[24] = 0x277abdcdffffffffffffffffffffffffff; maxExpArray[25] = 0x25daf6657fffffffffffffffffffffffff; maxExpArray[26] = 0x244c49c65fffffffffffffffffffffffff; maxExpArray[27] = 0x22ce03cd5fffffffffffffffffffffffff; maxExpArray[28] = 0x215f77c047ffffffffffffffffffffffff; maxExpArray[29] = 0x1fffffffffffffffffffffffffffffffff; maxExpArray[30] = 0x1eaefdbdabffffffffffffffffffffffff; maxExpArray[31] = 0x1d6bd8b2ebffffffffffffffffffffffff;
work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2017 Bprotocol Foundation 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 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.8.17; constructor() public { maxExpArray[32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[36] = 0x17d8ec7f0417ffffffffffffffffffffff; maxExpArray[37] = 0x16ddc6556cdbffffffffffffffffffffff; maxExpArray[38] = 0x15ecf52776a1ffffffffffffffffffffff; maxExpArray[39] = 0x15060c256cb2ffffffffffffffffffffff; maxExpArray[40] = 0x1428a2f98d72ffffffffffffffffffffff; maxExpArray[41] = 0x13545598e5c23fffffffffffffffffffff; maxExpArray[42] = 0x1288c4161ce1dfffffffffffffffffffff; maxExpArray[43] = 0x11c592761c666fffffffffffffffffffff; maxExpArray[44] = 0x110a688680a757ffffffffffffffffffff; maxExpArray[45] = 0x1056f1b5bedf77ffffffffffffffffffff; maxExpArray[46] = 0x0faadceceeff8bffffffffffffffffffff; maxExpArray[47] = 0x0f05dc6b27edadffffffffffffffffffff; maxExpArray[48] = 0x0e67a5a25da4107fffffffffffffffffff; maxExpArray[49] = 0x0dcff115b14eedffffffffffffffffffff; maxExpArray[50] = 0x0d3e7a392431239fffffffffffffffffff; maxExpArray[51] = 0x0cb2ff529eb71e4fffffffffffffffffff; maxExpArray[52] = 0x0c2d415c3db974afffffffffffffffffff; maxExpArray[53] = 0x0bad03e7d883f69bffffffffffffffffff; maxExpArray[54] = 0x0b320d03b2c343d5ffffffffffffffffff; maxExpArray[55] = 0x0abc25204e02828dffffffffffffffffff; maxExpArray[56] = 0x0a4b16f74ee4bb207fffffffffffffffff; maxExpArray[57] = 0x09deaf736ac1f569ffffffffffffffffff; maxExpArray[58] = 0x0976bd9952c7aa957fffffffffffffffff; maxExpArray[59] = 0x09131271922eaa606fffffffffffffffff; maxExpArray[60] = 0x08b380f3558668c46fffffffffffffffff; maxExpArray[61] = 0x0857ddf0117efa215bffffffffffffffff; maxExpArray[62] = 0x07ffffffffffffffffffffffffffffffff; maxExpArray[63] = 0x07abbf6f6abb9d087fffffffffffffffff; maxExpArray[64] = 0x075af62cbac95f7dfa7fffffffffffffff; maxExpArray[65] = 0x070d7fb7452e187ac13fffffffffffffff; maxExpArray[66] = 0x06c3390ecc8af379295fffffffffffffff; maxExpArray[67] = 0x067c00a3b07ffc01fd6fffffffffffffff; maxExpArray[68] = 0x0637b647c39cbb9d3d27ffffffffffffff; maxExpArray[69] = 0x05f63b1fc104dbd39587ffffffffffffff; maxExpArray[70] = 0x05b771955b36e12f7235ffffffffffffff; maxExpArray[71] = 0x057b3d49dda84556d6f6ffffffffffffff; maxExpArray[72] = 0x054183095b2c8ececf30ffffffffffffff; maxExpArray[73] = 0x050a28be635ca2b888f77fffffffffffff; maxExpArray[74] = 0x04d5156639708c9db33c3fffffffffffff; maxExpArray[75] = 0x04a23105873875bd52dfdfffffffffffff; maxExpArray[76] = 0x0471649d87199aa990756fffffffffffff; maxExpArray[77] = 0x04429a21a029d4c1457cfbffffffffffff; maxExpArray[78] = 0x0415bc6d6fb7dd71af2cb3ffffffffffff; maxExpArray[79] = 0x03eab73b3bbfe282243ce1ffffffffffff; maxExpArray[80] = 0x03c1771ac9fb6b4c18e229ffffffffffff; maxExpArray[81] = 0x0399e96897690418f785257fffffffffff; maxExpArray[82] = 0x0373fc456c53bb779bf0ea9fffffffffff; maxExpArray[83] = 0x034f9e8e490c48e67e6ab8bfffffffffff; maxExpArray[84] = 0x032cbfd4a7adc790560b3337ffffffffff; maxExpArray[85] = 0x030b50570f6e5d2acca94613ffffffffff; maxExpArray[86] = 0x02eb40f9f620fda6b56c2861ffffffffff; maxExpArray[87] = 0x02cc8340ecb0d0f520a6af58ffffffffff; maxExpArray[88] = 0x02af09481380a0a35cf1ba02ffffffffff; maxExpArray[89] = 0x0292c5bdd3b92ec810287b1b3fffffffff; maxExpArray[90] = 0x0277abdcdab07d5a77ac6d6b9fffffffff; maxExpArray[91] = 0x025daf6654b1eaa55fd64df5efffffffff; maxExpArray[92] = 0x0244c49c648baa98192dce88b7ffffffff; maxExpArray[93] = 0x022ce03cd5619a311b2471268bffffffff; maxExpArray[94] = 0x0215f77c045fbe885654a44a0fffffffff; maxExpArray[95] = 0x01ffffffffffffffffffffffffffffffff; maxExpArray[96] = 0x01eaefdbdaaee7421fc4d3ede5ffffffff; maxExpArray[97] = 0x01d6bd8b2eb257df7e8ca57b09bfffffff; maxExpArray[98] = 0x01c35fedd14b861eb0443f7f133fffffff; maxExpArray[99] = 0x01b0ce43b322bcde4a56e8ada5afffffff; maxExpArray[100] = 0x019f0028ec1fff007f5a195a39dfffffff; maxExpArray[101] = 0x018ded91f0e72ee74f49b15ba527ffffff; maxExpArray[102] = 0x017d8ec7f04136f4e5615fd41a63ffffff; maxExpArray[103] = 0x016ddc6556cdb84bdc8d12d22e6fffffff; maxExpArray[104] = 0x015ecf52776a1155b5bd8395814f7fffff; maxExpArray[105] = 0x015060c256cb23b3b3cc3754cf40ffffff; maxExpArray[106] = 0x01428a2f98d728ae223ddab715be3fffff; maxExpArray[107] = 0x013545598e5c23276ccf0ede68034fffff; maxExpArray[108] = 0x01288c4161ce1d6f54b7f61081194fffff; maxExpArray[109] = 0x011c592761c666aa641d5a01a40f17ffff; maxExpArray[110] = 0x0110a688680a7530515f3e6e6cfdcdffff; maxExpArray[111] = 0x01056f1b5bedf75c6bcb2ce8aed428ffff; maxExpArray[112] = 0x00faadceceeff8a0890f3875f008277fff; maxExpArray[113] = 0x00f05dc6b27edad306388a600f6ba0bfff; maxExpArray[114] = 0x00e67a5a25da41063de1495d5b18cdbfff; maxExpArray[115] = 0x00dcff115b14eedde6fc3aa5353f2e4fff; maxExpArray[116] = 0x00d3e7a3924312399f9aae2e0f868f8fff; maxExpArray[117] = 0x00cb2ff529eb71e41582cccd5a1ee26fff; maxExpArray[118] = 0x00c2d415c3db974ab32a51840c0b67edff; maxExpArray[119] = 0x00bad03e7d883f69ad5b0a186184e06bff; maxExpArray[120] = 0x00b320d03b2c343d4829abd6075f0cc5ff; maxExpArray[121] = 0x00abc25204e02828d73c6e80bcdb1a95bf; maxExpArray[122] = 0x00a4b16f74ee4bb2040a1ec6c15fbbf2df; maxExpArray[123] = 0x009deaf736ac1f569deb1b5ae3f36c130f; maxExpArray[124] = 0x00976bd9952c7aa957f5937d790ef65037; maxExpArray[125] = 0x009131271922eaa6064b73a22d0bd4f2bf; maxExpArray[126] = 0x008b380f3558668c46c91c49a2f8e967b9; maxExpArray[127] = 0x00857ddf0117efa215952912839f6473e6; }
17,178,905
[ 1, 1986, 924, 5712, 2447, 603, 4552, 67, 3670, 26913, 18, 971, 1846, 9876, 358, 2549, 518, 30, 5534, 326, 1967, 2549, 316, 585, 296, 5108, 1702, 8471, 23535, 18, 2074, 2187, 1086, 518, 471, 19401, 326, 1686, 5712, 18, 19, 8064, 17, 11168, 3970, 296, 5108, 13780, 22, 8471, 23535, 18, 2074, 11, 19, 8064, 17, 11168, 3970, 296, 5108, 2083, 6179, 2840, 1343, 18, 2074, 11, 471, 296, 5108, 2083, 6179, 2840, 2966, 18, 2074, 11, 19, 1021, 924, 5712, 2447, 603, 6989, 67, 3670, 26913, 471, 4552, 67, 3670, 26913, 18, 971, 1846, 9876, 358, 2549, 3344, 1245, 434, 2182, 30, 5534, 326, 1967, 2549, 316, 585, 296, 5108, 2083, 38, 304, 3850, 14972, 18, 2074, 2187, 1086, 518, 471, 19401, 326, 1686, 5712, 18, 19, 225, 943, 2966, 1076, 63, 20, 65, 273, 374, 92, 26, 70, 9460, 9460, 9460, 9460, 9460, 9460, 9460, 9460, 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, 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, 1252, 2132, 2433, 16, 26579, 5166, 578, 27431, 915, 16, 578, 1281, 471, 777, 203, 3011, 1543, 12610, 649, 302, 301, 1023, 578, 24528, 3631, 5456, 309, 4123, 735, 19293, 203, 5332, 2118, 1261, 26779, 434, 326, 25547, 434, 4123, 302, 301, 1023, 18, 203, 203, 29, 18, 8662, 310, 678, 5399, 970, 93, 578, 15119, 511, 21280, 18, 21572, 5813, 665, 8490, 203, 5787, 4147, 578, 14969, 427, 1535, 4147, 87, 1915, 792, 16, 4554, 2026, 9876, 358, 10067, 16, 203, 464, 13765, 279, 14036, 364, 16, 21656, 434, 2865, 16, 341, 5399, 970, 93, 16, 316, 323, 13607, 560, 16, 203, 280, 1308, 4501, 2967, 320, 31627, 1012, 471, 19, 280, 14989, 11071, 598, 333, 203, 13211, 18, 10724, 16, 316, 25806, 4123, 320, 31627, 1012, 16, 4554, 2026, 1328, 1338, 203, 265, 20471, 4953, 12433, 6186, 471, 603, 20471, 272, 790, 29353, 16, 486, 603, 12433, 6186, 203, 792, 1281, 1308, 735, 19293, 16, 471, 1338, 309, 4554, 1737, 992, 358, 316, 323, 13607, 1164, 16, 203, 536, 409, 16, 471, 6887, 1517, 735, 19293, 17895, 781, 403, 364, 1281, 4501, 2967, 203, 267, 1397, 1118, 635, 16, 578, 11955, 1815, 329, 5314, 16, 4123, 735, 19293, 635, 3971, 203, 792, 3433, 25806, 1281, 4123, 341, 5399, 970, 93, 578, 3312, 4501, 2967, 18, 203, 203, 4415, 15932, 20772, 3537, 4116, 3492, 18575, 55, 203, 203, 7215, 27975, 60, 30, 9017, 358, 2230, 326, 24840, 16832, 358, 3433, 1440, 18, 203, 203, 774, 2230, 326, 24840, 16832, 358, 3433, 1440, 16, 2 ]
./full_match/43113/0x69F959ed5d4c8f922b4866F6fb39D6f7f567cF0D/sources/airdrop.sol
声明合约 AirDrop 继承 Ownable block.timestamp 定义一个用户结构体
contract AirDrop is Ownable { struct User { } function distribute(IERC20 token, address userAddress,uint256 amount) public { require(false,"11111111111111111111"); require(token.approve(userAddress, amount)); require(token.transferFrom(owner(), userAddress, amount)); } }
13,186,586
[ 1, 166, 101, 113, 167, 251, 241, 166, 243, 235, 168, 123, 104, 432, 481, 7544, 225, 168, 124, 105, 167, 236, 128, 14223, 6914, 1203, 18, 5508, 225, 166, 111, 253, 165, 122, 236, 165, 121, 227, 165, 121, 108, 168, 247, 106, 167, 235, 120, 168, 124, 246, 167, 257, 231, 165, 126, 246, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 432, 481, 7544, 353, 14223, 6914, 288, 203, 203, 565, 1958, 2177, 288, 203, 565, 289, 203, 203, 203, 203, 203, 203, 565, 445, 25722, 12, 45, 654, 39, 3462, 1147, 16, 1758, 729, 1887, 16, 11890, 5034, 3844, 13, 1071, 288, 203, 540, 2583, 12, 5743, 10837, 23680, 23680, 23680, 23680, 23680, 8863, 203, 3639, 2583, 12, 2316, 18, 12908, 537, 12, 1355, 1887, 16, 3844, 10019, 203, 3639, 2583, 12, 2316, 18, 13866, 1265, 12, 8443, 9334, 729, 1887, 16, 3844, 10019, 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 ]
./partial_match/1/0x23c9e48F7E9fCa487bd0c4f41EE1445812d871fd/sources/Hat.sol
* Irreversably unlock buying./
function unlock() public onlyOwner { require(locked, 'Contract is already unlocked'); locked = false; }
2,848,832
[ 1, 45, 86, 266, 2496, 6906, 7186, 30143, 310, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7186, 1435, 1071, 1338, 5541, 288, 203, 3639, 2583, 12, 15091, 16, 296, 8924, 353, 1818, 25966, 8284, 203, 3639, 8586, 273, 629, 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 ]
pragma solidity ^0.6.0; import "../node_modules/@openzeppelin/contracts/access/AccessControl.sol"; import "../node_modules/@openzeppelin/contracts/GSN/Context.sol"; import "../node_modules/@openzeppelin/contracts/math/SafeMath.sol"; import "./VoteNFT.sol"; contract Elections is Context, AccessControl, VoteNFT { using SafeMath for uint256; string constant TOKEN_URI = "https://ropsten.etherscan.io/tx/"; uint internal electionCount; // OpenZeppelin access control bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant VOTER_ROLE = keccak256("VOTER_ROLE"); // Events event NewElection(uint eid, uint deadline); event VoterRegistered(address indexed registeredVoter, uint electionID); event NewVoterRequest(address indexed newVoter); event Voted(uint propNumber, uint eid, address indexed voter, uint256 newNFT); event Delegated(address indexed delegate, uint eid, address indexed voter); event ChangedVote(uint propNumber, uint eid, address indexed voter); struct Voter { uint weight; // weight is accumulated by delegation bool voted; // if true, that person already voted bool registered; // need to register for each election bool hasChangedVote; // user can change vote only once address delegate; // person delegated to uint vote; // index of the voted proposal } struct Proposal { string name; // short name uint voteCount; // number of accumulated votes } struct Election { mapping(address => Voter) voters; Proposal[] proposals; uint deadline; } // stores an `Election` struct to an election ID mapping(uint => Election) public elections; // Assign admin and voter role to msg.sender constructor() public { _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(VOTER_ROLE, _msgSender()); _setRoleAdmin(VOTER_ROLE, ADMIN_ROLE); //sets admin role in charge of voter role } modifier onlyAdmin() { require(hasRole(ADMIN_ROLE, _msgSender()), "DOES_NOT_HAVE_ADMIN_ROLE"); _; } modifier onlyVoter() { require(hasRole(VOTER_ROLE, _msgSender()), "DOES_NOT_HAVE_VOTER_ROLE"); _; } /** * @dev Admin creates new election with two competing proposals * @param proposal1 string or hash describing proposal or candidate * @param proposal2 string or hash describing proposal or candidate */ function newElection(string memory proposal1, string memory proposal2, uint dl) public onlyAdmin { uint electionID = electionCount + 1; Election storage e = elections[electionID]; e.voters[_msgSender()].weight = 1; e.voters[_msgSender()].registered = true; e.proposals.push(Proposal({name: proposal1, voteCount: 0})); e.proposals.push(Proposal({name: proposal2, voteCount: 0})); e.deadline = dl; emit NewElection(electionID, dl); electionCount++; } /** * @dev Public function allowing users to request for admin to register their address */ function requestAccess() public { require(!hasRole(VOTER_ROLE, _msgSender()), "ALREADY_HAS_VOTER_ROLE"); emit NewVoterRequest(_msgSender()); } /** * @dev Give `voter` the right to vote and register for elections * @param voter address to grant voting access */ function registerToVote(address voter) public onlyAdmin { require(!hasRole(VOTER_ROLE, voter), "ALREADY_HAS_VOTER_ROLE"); _setupRole(VOTER_ROLE, voter); } /** * @dev Revoke registered `voter` from participating in elections * @param voter address being revoked voting access */ function revokeVoter(address voter) public onlyAdmin { require(hasRole(VOTER_ROLE, voter), "VOTER_MUST_ALREADY_HAVE_ROLE"); revokeRole(VOTER_ROLE, voter); } /** * @dev Voter with `VOTER_ROLE` self registers for a given election * @param electionID ID for the election the voter wants to vote in */ function registerForElection(uint electionID) public onlyVoter { Election storage e = elections[electionID]; require(!e.voters[_msgSender()].registered, "VOTER_ALREADY_REGISTERED"); require(block.timestamp < e.deadline, "Voting deadline has expired"); e.voters[_msgSender()].weight += 1; e.voters[_msgSender()].registered = true; emit VoterRegistered(_msgSender(), electionID); } /** * @dev Delegate to `to` the weight of another valid voter's vote * @param to delegate address * @param electionID ID of election in which voter is delegating their vote */ function delegateVote(address to, uint electionID) public onlyVoter { // Check that addr delegate has right to vote require(hasRole(VOTER_ROLE, to), "DOES_NOT_HAVE_VOTER_ROLE"); Election storage e = elections[electionID]; Voter storage sender = e.voters[_msgSender()]; require(!sender.voted, "Address has already voted"); // Forward the delegation if `to` also delegated. while (e.voters[to].delegate != address(0) && e.voters[to].delegate != _msgSender()) { to = e.voters[to].delegate; } require(to != _msgSender(), "Delegation can not be to self"); // Update `sender` sender.voted = true; sender.delegate = to; Voter storage delegate = e.voters[to]; if (delegate.voted) { // If delegate already voted, directly add to the number of votes e.proposals[delegate.vote].voteCount += sender.weight; // Add sender weight to delegate as well in case delegate changes vote delegate.weight += sender.weight; // Emit `Voted` event since Delegate has already voted; no NFT rewarded for delegation emit Voted(delegate.vote, electionID, _msgSender(), 0); } else { // If delegate did not vote yet, add to weight. delegate.weight += sender.weight; emit Delegated(sender.delegate, electionID, _msgSender()); } } /** * @dev Vote on a given proposal * @param proposal number of proposal * @param electionID ID of election in which voter is delegating their vote */ function vote(uint proposal, uint electionID) public onlyVoter { // Only two choices in the election require(proposal < 2, "Invalid proposal number"); Election storage e = elections[electionID]; require(block.timestamp < e.deadline, "Voting deadline has expired"); Voter storage sender = e.voters[_msgSender()]; require(!sender.voted, "Address has already voted"); require(sender.registered, "Voter must register for each election"); sender.voted = true; sender.vote = proposal; e.proposals[proposal].voteCount += sender.weight; //Reward proposer with NFT uint256 NFT_ID = awardItem(_msgSender(), TOKEN_URI); emit Voted(proposal, electionID, _msgSender(), NFT_ID); } /** * @dev Change your vote to a different proposal, may only be executed once per user * @param proposal number of proposal, must not be same as previous vote * @param electionID ID of election in which voter is delegating their vote */ function changeVote(uint proposal, uint electionID) public onlyVoter { // Only two choices in the election require(proposal < 2, "Invalid proposal number"); Election storage e = elections[electionID]; Voter storage sender = e.voters[_msgSender()]; require(sender.voted, "Address must have already voted"); require(!sender.hasChangedVote, "Voter can only change vote once"); require(sender.vote != proposal, "New proposal is same as current vote"); require(sender.delegate == address(0), "Voter must not have delegated"); //require(sender.weight == 1, "Delegates may not change vote"); Uncomment if applicable // Remove vote from old proposal uint oldProposal = sender.vote; e.proposals[oldProposal].voteCount -= sender.weight; // Add vote to new proposal sender.vote = proposal; e.proposals[proposal].voteCount += sender.weight; sender.hasChangedVote = true; emit ChangedVote(proposal, electionID, _msgSender()); } /** * @dev Computes then returns the winning proposal, taking all previous votes into account. * @param electionID ID of election */ function winningProposal(uint electionID) internal view returns (uint) { Election storage e = elections[electionID]; // uint winningVoteCount = 0; // uint wProposal; uint prop0 = e.proposals[0].voteCount; uint prop1 = e.proposals[1].voteCount; if (prop0 > prop1){ return 0; } else if (prop1 > prop0) { return 1; } else { // it's a tie return 2; } } /** * @dev Calls winningProposal() function to get the index of winner and then returns the name * @param electionID ID of election */ function winnerName(uint electionID) public view returns (string memory) { Election storage e = elections[electionID]; require(block.timestamp > e.deadline, "Have not reached election deadline"); uint result = winningProposal(electionID); if (result != 2) { return e.proposals[result].name; } else { return "TIE"; } } /** * @dev Gets current state of a voter * @return uint TODO * @param electionID ID of election * @param voter voter address */ function getVoterInfo(uint electionID, address voter) public view returns (uint, bool, bool, bool, address, uint) { Election storage e = elections[electionID]; return (e.voters[voter].weight, e.voters[voter].voted, e.voters[voter].registered, e.voters[voter].hasChangedVote, e.voters[voter].delegate, e.voters[voter].vote); } /** * @dev Gets current state of an election * @return uint TODO * @param electionID ID of election */ function getElectionInfo(uint electionID) public view returns (string memory, uint, string memory, uint, uint) { Election storage e = elections[electionID]; return (e.proposals[0].name, e.proposals[0].voteCount, e.proposals[1].name, e.proposals[1].voteCount, e.deadline); } }
* @dev Gets current state of a voter @return uint TODO @param electionID ID of election @param voter voter address/
function getVoterInfo(uint electionID, address voter) public view returns (uint, bool, bool, bool, address, uint) { Election storage e = elections[electionID]; return (e.voters[voter].weight, e.voters[voter].voted, e.voters[voter].registered, e.voters[voter].hasChangedVote, e.voters[voter].delegate, e.voters[voter].vote); }
12,604,973
[ 1, 3002, 783, 919, 434, 279, 331, 20005, 327, 2254, 2660, 225, 25526, 734, 1599, 434, 25526, 225, 331, 20005, 331, 20005, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 11031, 20005, 966, 12, 11890, 25526, 734, 16, 1758, 331, 20005, 13, 1071, 1476, 1135, 261, 11890, 16, 1426, 16, 1426, 16, 1426, 16, 1758, 16, 2254, 13, 288, 203, 3639, 512, 942, 2502, 425, 273, 25526, 87, 63, 292, 794, 734, 15533, 203, 3639, 327, 261, 73, 18, 90, 352, 414, 63, 90, 20005, 8009, 4865, 16, 425, 18, 90, 352, 414, 63, 90, 20005, 8009, 90, 16474, 16, 425, 18, 90, 352, 414, 63, 90, 20005, 8009, 14327, 16, 203, 3639, 425, 18, 90, 352, 414, 63, 90, 20005, 8009, 5332, 5033, 19338, 16, 425, 18, 90, 352, 414, 63, 90, 20005, 8009, 22216, 16, 425, 18, 90, 352, 414, 63, 90, 20005, 8009, 25911, 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 ]
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; /// @notice Based on https://github.com/madler/zlib/blob/master/contrib/puff library InflateLib { // Maximum bits in a code uint256 constant MAXBITS = 15; // Maximum number of literal/length codes uint256 constant MAXLCODES = 286; // Maximum number of distance codes uint256 constant MAXDCODES = 30; // Maximum codes lengths to read uint256 constant MAXCODES = (MAXLCODES + MAXDCODES); // Number of fixed literal/length codes uint256 constant FIXLCODES = 288; // Error codes enum ErrorCode { ERR_NONE, // 0 successful inflate ERR_NOT_TERMINATED, // 1 available inflate data did not terminate ERR_OUTPUT_EXHAUSTED, // 2 output space exhausted before completing inflate ERR_INVALID_BLOCK_TYPE, // 3 invalid block type (type == 3) ERR_STORED_LENGTH_NO_MATCH, // 4 stored block length did not match one's complement ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, // 5 dynamic block code description: too many length or distance codes ERR_CODE_LENGTHS_CODES_INCOMPLETE, // 6 dynamic block code description: code lengths codes incomplete ERR_REPEAT_NO_FIRST_LENGTH, // 7 dynamic block code description: repeat lengths with no first length ERR_REPEAT_MORE, // 8 dynamic block code description: repeat more than specified lengths ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, // 9 dynamic block code description: invalid literal/length code lengths ERR_INVALID_DISTANCE_CODE_LENGTHS, // 10 dynamic block code description: invalid distance code lengths ERR_MISSING_END_OF_BLOCK, // 11 dynamic block code description: missing end-of-block code ERR_INVALID_LENGTH_OR_DISTANCE_CODE, // 12 invalid literal/length or distance code in fixed or dynamic block ERR_DISTANCE_TOO_FAR, // 13 distance is too far back in fixed or dynamic block ERR_CONSTRUCT // 14 internal: error in construct() } // Input and output state struct State { ////////////////// // Output state // ////////////////// // Output buffer bytes output; // Bytes written to out so far uint256 outcnt; ///////////////// // Input state // ///////////////// // Input buffer bytes input; // Bytes read so far uint256 incnt; //////////////// // Temp state // //////////////// // Bit buffer uint256 bitbuf; // Number of bits in bit buffer uint256 bitcnt; ////////////////////////// // Static Huffman codes // ////////////////////////// Huffman lencode; Huffman distcode; } // Huffman code decoding tables struct Huffman { uint256[] counts; uint256[] symbols; } function bits(State memory s, uint256 need) private pure returns (ErrorCode, uint256) { // Bit accumulator (can use up to 20 bits) uint256 val; // Load at least need bits into val val = s.bitbuf; while (s.bitcnt < need) { if (s.incnt == s.input.length) { // Out of input return (ErrorCode.ERR_NOT_TERMINATED, 0); } // Load eight bits val |= uint256(uint8(s.input[s.incnt++])) << s.bitcnt; s.bitcnt += 8; } // Drop need bits and update buffer, always zero to seven bits left s.bitbuf = val >> need; s.bitcnt -= need; // Return need bits, zeroing the bits above that uint256 ret = (val & ((1 << need) - 1)); return (ErrorCode.ERR_NONE, ret); } function _stored(State memory s) private pure returns (ErrorCode) { // Length of stored block uint256 len; // Discard leftover bits from current byte (assumes s.bitcnt < 8) s.bitbuf = 0; s.bitcnt = 0; // Get length and check against its one's complement if (s.incnt + 4 > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } len = uint256(uint8(s.input[s.incnt++])); len |= uint256(uint8(s.input[s.incnt++])) << 8; if ( uint8(s.input[s.incnt++]) != (~len & 0xFF) || uint8(s.input[s.incnt++]) != ((~len >> 8) & 0xFF) ) { // Didn't match complement! return ErrorCode.ERR_STORED_LENGTH_NO_MATCH; } // Copy len bytes from in to out if (s.incnt + len > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } if (s.outcnt + len > s.output.length) { // Not enough output space return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt++] = s.input[s.incnt++]; } // Done with a valid stored block return ErrorCode.ERR_NONE; } function _decode(State memory s, Huffman memory h) private pure returns (ErrorCode, uint256) { // Current number of bits in code uint256 len; // Len bits being decoded uint256 code = 0; // First code of length len uint256 first = 0; // Number of codes of length len uint256 count; // Index of first code of length len in symbol table uint256 index = 0; // Error code ErrorCode err; for (len = 1; len <= MAXBITS; len++) { // Get next bit uint256 tempCode; (err, tempCode) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, 0); } code |= tempCode; count = h.counts[len]; // If length len, return symbol if (code < first + count) { return (ErrorCode.ERR_NONE, h.symbols[index + (code - first)]); } // Else update for next length index += count; first += count; first <<= 1; code <<= 1; } // Ran out of codes return (ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE, 0); } function _construct( Huffman memory h, uint256[] memory lengths, uint256 n, uint256 start ) private pure returns (ErrorCode) { // Current symbol when stepping through lengths[] uint256 symbol; // Current length when stepping through h.counts[] uint256 len; // Number of possible codes left of current length uint256 left; // Offsets in symbol table for each length uint256[MAXBITS + 1] memory offs; // Count number of codes of each length for (len = 0; len <= MAXBITS; len++) { h.counts[len] = 0; } for (symbol = 0; symbol < n; symbol++) { // Assumes lengths are within bounds h.counts[lengths[start + symbol]]++; } // No codes! if (h.counts[0] == n) { // Complete, but decode() will fail return (ErrorCode.ERR_NONE); } // Check for an over-subscribed or incomplete set of lengths // One possible code of zero length left = 1; for (len = 1; len <= MAXBITS; len++) { // One more bit, double codes left left <<= 1; if (left < h.counts[len]) { // Over-subscribed--return error return ErrorCode.ERR_CONSTRUCT; } // Deduct count from possible codes left -= h.counts[len]; } // Generate offsets into symbol table for each length for sorting offs[1] = 0; for (len = 1; len < MAXBITS; len++) { offs[len + 1] = offs[len] + h.counts[len]; } // Put symbols in table sorted by length, by symbol order within each length for (symbol = 0; symbol < n; symbol++) { if (lengths[start + symbol] != 0) { h.symbols[offs[lengths[start + symbol]]++] = symbol; } } // Left > 0 means incomplete return left > 0 ? ErrorCode.ERR_CONSTRUCT : ErrorCode.ERR_NONE; } function _codes( State memory s, Huffman memory lencode, Huffman memory distcode ) private pure returns (ErrorCode) { // Decoded symbol uint256 symbol; // Length for copy uint256 len; // Distance for copy uint256 dist; // TODO Solidity doesn't support constant arrays, but these are fixed at compile-time // Size base for length codes 257..285 uint16[29] memory lens = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 ]; // Extra bits for length codes 257..285 uint8[29] memory lext = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 ]; // Offset base for distance codes 0..29 uint16[30] memory dists = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; // Extra bits for distance codes 0..29 uint8[30] memory dext = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; // Error code ErrorCode err; // Decode literals and length/distance pairs while (symbol != 256) { (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } if (symbol < 256) { // Literal: symbol is the byte // Write out the literal if (s.outcnt == s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } s.output[s.outcnt] = bytes1(uint8(symbol)); s.outcnt++; } else if (symbol > 256) { uint256 tempBits; // Length // Get and compute length symbol -= 257; if (symbol >= 29) { // Invalid fixed code return ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE; } (err, tempBits) = bits(s, lext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } len = lens[symbol] + tempBits; // Get and check distance (err, symbol) = _decode(s, distcode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } (err, tempBits) = bits(s, dext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } dist = dists[symbol] + tempBits; if (dist > s.outcnt) { // Distance too far back return ErrorCode.ERR_DISTANCE_TOO_FAR; } // Copy length bytes from distance bytes back if (s.outcnt + len > s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt] = s.output[s.outcnt - dist]; s.outcnt++; } } else { s.outcnt += len; } } // Done with a valid fixed or dynamic block return ErrorCode.ERR_NONE; } function _build_fixed(State memory s) private pure returns (ErrorCode) { // Build fixed Huffman tables // TODO this is all a compile-time constant uint256 symbol; uint256[] memory lengths = new uint256[](FIXLCODES); // Literal/length table for (symbol = 0; symbol < 144; symbol++) { lengths[symbol] = 8; } for (; symbol < 256; symbol++) { lengths[symbol] = 9; } for (; symbol < 280; symbol++) { lengths[symbol] = 7; } for (; symbol < FIXLCODES; symbol++) { lengths[symbol] = 8; } _construct(s.lencode, lengths, FIXLCODES, 0); // Distance table for (symbol = 0; symbol < MAXDCODES; symbol++) { lengths[symbol] = 5; } _construct(s.distcode, lengths, MAXDCODES, 0); return ErrorCode.ERR_NONE; } function _fixed(State memory s) private pure returns (ErrorCode) { // Decode data until end-of-block code return _codes(s, s.lencode, s.distcode); } function _build_dynamic_lengths(State memory s) private pure returns (ErrorCode, uint256[] memory) { uint256 ncode; // Index of lengths[] uint256 index; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Error code ErrorCode err; // Permutation of code length codes uint8[19] memory order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; (err, ncode) = bits(s, 4); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } ncode += 4; // Read code length code lengths (really), missing lengths are zero for (index = 0; index < ncode; index++) { (err, lengths[order[index]]) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } } for (; index < 19; index++) { lengths[order[index]] = 0; } return (ErrorCode.ERR_NONE, lengths); } function _build_dynamic(State memory s) private pure returns ( ErrorCode, Huffman memory, Huffman memory ) { // Number of lengths in descriptor uint256 nlen; uint256 ndist; // Index of lengths[] uint256 index; // Error code ErrorCode err; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Length and distance codes Huffman memory lencode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXLCODES)); Huffman memory distcode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)); uint256 tempBits; // Get number of lengths in each table, check lengths (err, nlen) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } nlen += 257; (err, ndist) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } ndist += 1; if (nlen > MAXLCODES || ndist > MAXDCODES) { // Bad counts return ( ErrorCode.ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, lencode, distcode ); } (err, lengths) = _build_dynamic_lengths(s); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } // Build huffman table for code lengths codes (use lencode temporarily) err = _construct(lencode, lengths, 19, 0); if (err != ErrorCode.ERR_NONE) { // Require complete code set here return ( ErrorCode.ERR_CODE_LENGTHS_CODES_INCOMPLETE, lencode, distcode ); } // Read length/literal and distance code length tables index = 0; while (index < nlen + ndist) { // Decoded value uint256 symbol; // Last length to repeat uint256 len; (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return (err, lencode, distcode); } if (symbol < 16) { // Length in 0..15 lengths[index++] = symbol; } else { // Repeat instruction // Assume repeating zeros len = 0; if (symbol == 16) { // Repeat last length 3..6 times if (index == 0) { // No last length! return ( ErrorCode.ERR_REPEAT_NO_FIRST_LENGTH, lencode, distcode ); } // Last length len = lengths[index - 1]; (err, tempBits) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else if (symbol == 17) { // Repeat zero 3..10 times (err, tempBits) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else { // == 18, repeat zero 11..138 times (err, tempBits) = bits(s, 7); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 11 + tempBits; } if (index + symbol > nlen + ndist) { // Too many lengths! return (ErrorCode.ERR_REPEAT_MORE, lencode, distcode); } while (symbol != 0) { // Note: Solidity reverts on underflow, so we decrement here symbol -= 1; // Repeat last or zero symbol times lengths[index++] = len; } } } // Check for end-of-block code -- there better be one! if (lengths[256] == 0) { return (ErrorCode.ERR_MISSING_END_OF_BLOCK, lencode, distcode); } // Build huffman table for literal/length codes err = _construct(lencode, lengths, nlen, 0); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || nlen != lencode.counts[0] + lencode.counts[1]) ) { // Incomplete code ok only for single length 1 code return ( ErrorCode.ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, lencode, distcode ); } // Build huffman table for distance codes err = _construct(distcode, lengths, ndist, nlen); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || ndist != distcode.counts[0] + distcode.counts[1]) ) { // Incomplete code ok only for single length 1 code return ( ErrorCode.ERR_INVALID_DISTANCE_CODE_LENGTHS, lencode, distcode ); } return (ErrorCode.ERR_NONE, lencode, distcode); } function _dynamic(State memory s) private pure returns (ErrorCode) { // Length and distance codes Huffman memory lencode; Huffman memory distcode; // Error code ErrorCode err; (err, lencode, distcode) = _build_dynamic(s); if (err != ErrorCode.ERR_NONE) { return err; } // Decode data until end-of-block code return _codes(s, lencode, distcode); } function puff(bytes calldata source, uint256 destlen) internal pure returns (ErrorCode, bytes memory) { // Input/output state State memory s = State( new bytes(destlen), 0, source, 0, 0, 0, Huffman(new uint256[](MAXBITS + 1), new uint256[](FIXLCODES)), Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)) ); // Temp: last bit uint256 last; // Temp: block type bit uint256 t; // Error code ErrorCode err; // Build fixed Huffman tables err = _build_fixed(s); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Process blocks until last block or error while (last == 0) { // One if last block (err, last) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Block type 0..3 (err, t) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } err = ( t == 0 ? _stored(s) : ( t == 1 ? _fixed(s) : ( t == 2 ? _dynamic(s) : ErrorCode.ERR_INVALID_BLOCK_TYPE ) ) ); // type == 3, invalid if (err != ErrorCode.ERR_NONE) { // Return with error break; } } return (err, s.output); } }
Build fixed Huffman tables TODO this is all a compile-time constant Literal/length table Distance table
function _build_fixed(State memory s) private pure returns (ErrorCode) { uint256 symbol; uint256[] memory lengths = new uint256[](FIXLCODES); for (symbol = 0; symbol < 144; symbol++) { lengths[symbol] = 8; } for (; symbol < 256; symbol++) { lengths[symbol] = 9; } for (; symbol < 280; symbol++) { lengths[symbol] = 7; } for (; symbol < FIXLCODES; symbol++) { lengths[symbol] = 8; } _construct(s.lencode, lengths, FIXLCODES, 0); for (symbol = 0; symbol < MAXDCODES; symbol++) { lengths[symbol] = 5; } _construct(s.distcode, lengths, MAXDCODES, 0); return ErrorCode.ERR_NONE; }
2,474,003
[ 1, 3116, 5499, 670, 28581, 4606, 2660, 333, 353, 777, 279, 4074, 17, 957, 5381, 14392, 19, 2469, 1014, 20335, 1014, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3510, 67, 12429, 12, 1119, 3778, 272, 13, 3238, 16618, 1135, 261, 12012, 13, 288, 203, 3639, 2254, 5034, 3273, 31, 203, 3639, 2254, 5034, 8526, 3778, 10917, 273, 394, 2254, 5034, 8526, 12, 4563, 48, 17070, 1769, 203, 203, 3639, 364, 261, 7175, 273, 374, 31, 3273, 411, 30457, 31, 3273, 27245, 288, 203, 5411, 10917, 63, 7175, 65, 273, 1725, 31, 203, 3639, 289, 203, 3639, 364, 261, 31, 3273, 411, 8303, 31, 3273, 27245, 288, 203, 5411, 10917, 63, 7175, 65, 273, 2468, 31, 203, 3639, 289, 203, 3639, 364, 261, 31, 3273, 411, 576, 3672, 31, 3273, 27245, 288, 203, 5411, 10917, 63, 7175, 65, 273, 2371, 31, 203, 3639, 289, 203, 3639, 364, 261, 31, 3273, 411, 8563, 48, 17070, 31, 3273, 27245, 288, 203, 5411, 10917, 63, 7175, 65, 273, 1725, 31, 203, 3639, 289, 203, 203, 3639, 389, 10062, 12, 87, 18, 1897, 710, 16, 10917, 16, 8563, 48, 17070, 16, 374, 1769, 203, 203, 3639, 364, 261, 7175, 273, 374, 31, 3273, 411, 4552, 5528, 2712, 55, 31, 3273, 27245, 288, 203, 5411, 10917, 63, 7175, 65, 273, 1381, 31, 203, 3639, 289, 203, 203, 3639, 389, 10062, 12, 87, 18, 4413, 710, 16, 10917, 16, 4552, 5528, 2712, 55, 16, 374, 1769, 203, 203, 3639, 327, 13218, 18, 9712, 67, 9826, 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 ]
./full_match/80001/0x0646F208cb4B8567433df07405CE5163670A25d2/sources/project_/contracts/Pools.sol
require(msg.sender == owner);
function createPool( string memory _name, bool _buyable, bool _owned, uint256 _value, uint256 _income, uint256 _family, uint256 _serie, uint256 _level ) private { pools[poolId] = Pool( poolId, _name, _buyable, _owned, _value, _income, _family, _serie, _level ); emit PoolCreated( poolId, _name, _buyable, _owned, _value, _income, _family, _serie, _level ); poolId++; }
5,596,027
[ 1, 6528, 12, 3576, 18, 15330, 422, 3410, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 752, 2864, 12, 203, 540, 203, 3639, 533, 3778, 389, 529, 16, 203, 3639, 1426, 389, 70, 9835, 429, 16, 203, 3639, 1426, 389, 995, 329, 16, 203, 3639, 2254, 5034, 389, 1132, 16, 203, 3639, 2254, 5034, 389, 267, 5624, 16, 203, 3639, 2254, 5034, 389, 9309, 16, 203, 3639, 2254, 5034, 389, 550, 1385, 16, 203, 3639, 2254, 5034, 389, 2815, 203, 565, 262, 3238, 288, 203, 3639, 16000, 63, 6011, 548, 65, 273, 8828, 12, 203, 5411, 2845, 548, 16, 203, 5411, 389, 529, 16, 203, 5411, 389, 70, 9835, 429, 16, 203, 5411, 389, 995, 329, 16, 203, 5411, 389, 1132, 16, 203, 5411, 389, 267, 5624, 16, 203, 5411, 389, 9309, 16, 203, 5411, 389, 550, 1385, 16, 203, 5411, 389, 2815, 203, 3639, 11272, 203, 3639, 3626, 8828, 6119, 12, 203, 5411, 2845, 548, 16, 203, 5411, 389, 529, 16, 203, 5411, 389, 70, 9835, 429, 16, 203, 5411, 389, 995, 329, 16, 203, 5411, 389, 1132, 16, 203, 5411, 389, 267, 5624, 16, 203, 5411, 389, 9309, 16, 203, 5411, 389, 550, 1385, 16, 203, 5411, 389, 2815, 203, 3639, 11272, 203, 3639, 2845, 548, 9904, 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 ]
// File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/misc/opensea/ProxyRegistry.sol pragma solidity ^0.8.4; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } // File: @openzeppelin/contracts/access/IAccessControl.sol // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) 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; } // File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = _efficientHash(computedHash, proofElement); } else { // Hash(current element of the proof + current computed hash) computedHash = _efficientHash(proofElement, computedHash); } } return computedHash; } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } } // 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/math/SafeMath.sol // 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: @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/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/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/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/AccessControl.sol // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @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 virtual 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 virtual { 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 virtual 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 revoked `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}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ 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); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (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); _afterTokenTransfer(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); _afterTokenTransfer(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 from incorrect owner"); 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); _afterTokenTransfer(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 {} /** * @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. * - `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 tokenId ) internal virtual {} } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721BulkifyExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to add bulk operations to a standard ERC721 contract. */ abstract contract ERC721BulkifyExtension is Context, ERC721 { /** * Useful for when user wants to return tokens to get a refund, * or when they want to transfer lots of tokens by paying gas fee only once. */ function transferFromBulk( address from, address to, uint256[] memory tokenIds ) public virtual { for (uint256 i = 0; i < tokenIds.length; i++) { require(_isApprovedOrOwner(_msgSender(), tokenIds[i]), "NOT_OWNER"); _transfer(from, to, tokenIds[i]); } } } // 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: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721OpenSeaNoGasZeroExExtension.sol pragma solidity ^0.8.4; /** * @dev Extension that automatically approves OpenSea proxy registry to avoid having users to "Approve" your collection before trading. * Note this extension is built for ZeroEx-based OpenSea contracts which means Polygon chain. */ abstract contract ERC721OpenSeaNoGasZeroExExtension is Ownable, ERC721 { address private _openSeaExchangeAddress; constructor(address openSeaExchangeAddress) { _openSeaExchangeAddress = openSeaExchangeAddress; } function setOpenSeaExchangeAddress(address addr) external onlyOwner { _openSeaExchangeAddress = addr; } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { // If OpenSea's ERC721 exchange address is detected, auto-approve if (operator == address(_openSeaExchangeAddress)) { return true; } return super.isApprovedForAll(owner, operator); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721OpenSeaNoGasWyvernExtension.sol pragma solidity ^0.8.4; /** * @dev Extension that automatically approves OpenSea proxy registry to avoid having users to "Approve" your collection before trading. * * Note this extension is built for Wyvern-based OpenSea contracts which means Ethereum chain. */ abstract contract ERC721OpenSeaNoGasWyvernExtension is Ownable, ERC721 { address internal _openSeaProxyRegistryAddress; constructor(address openSeaProxyRegistryAddress) { _openSeaProxyRegistryAddress = openSeaProxyRegistryAddress; } function setOpenSeaProxyRegistryAddress(address addr) external onlyOwner { _openSeaProxyRegistryAddress = addr; } /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry( _openSeaProxyRegistryAddress ); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721SimpleProceedsExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to allow contract owner to withdraw all the funds directly. */ abstract contract ERC721SimpleProceedsExtension is Ownable { function withdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721AutoIdMinterExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to add minting capability with an auto incremented ID for each token and a maximum supply setting. */ abstract contract ERC721AutoIdMinterExtension is Ownable, ERC721 { using SafeMath for uint256; uint256 public maxSupply; bool internal _maxSupplyFrozen; uint256 internal _currentTokenId = 0; constructor(uint256 _maxSupply) { maxSupply = _maxSupply; } // ADMIN function setMaxSupply(uint256 newValue) external onlyOwner { require(!_maxSupplyFrozen, "BASE_URI_FROZEN"); maxSupply = newValue; } function freezeMaxSupply() external onlyOwner { _maxSupplyFrozen = true; } // PUBLIC function totalSupply() public view returns (uint256) { return _currentTokenId; } // INTERNAL function _mintTo(address to, uint256 count) internal { require(totalSupply() + count <= maxSupply, "EXCEEDS_MAX_SUPPLY"); for (uint256 i = 0; i < count; i++) { uint256 newTokenId = _getNextTokenId(); _safeMint(to, newTokenId); _incrementTokenId(); } } /** * Calculates the next token ID based on value of _currentTokenId * @return uint256 for the next token ID */ function _getNextTokenId() internal view returns (uint256) { return _currentTokenId.add(1); } /** * Increments the value of _currentTokenId */ function _incrementTokenId() internal { _currentTokenId++; } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721RoleBasedMintExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to allow holders of a OpenZepplin-based role to mint directly. */ abstract contract ERC721RoleBasedMintExtension is ERC721AutoIdMinterExtension, AccessControl { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); function mintByRole(address to, uint256 count) external { require(hasRole(MINTER_ROLE, msg.sender), "NOT_MINTER_ROLE"); _mintTo(to, count); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721PublicSaleExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to provide pre-sale and public-sale capabilities for colelctors to mint for a specific price. */ abstract contract ERC721PublicSaleExtension is Ownable, ERC721AutoIdMinterExtension, ReentrancyGuard { uint256 public publicSalePrice; uint256 public publicSaleMaxMintPerTx; bool public publicSaleStatus; constructor(uint256 _publicSalePrice, uint256 _publicSaleMaxMintPerTx) { publicSalePrice = _publicSalePrice; publicSaleMaxMintPerTx = _publicSaleMaxMintPerTx; } // ADMIN function setPublicSalePrice(uint256 newValue) external onlyOwner { publicSalePrice = newValue; } function setPublicSaleMaxMintPerTx(uint256 newValue) external onlyOwner { publicSaleMaxMintPerTx = newValue; } function togglePublicSaleStatus(bool isActive) external onlyOwner { publicSaleStatus = isActive; } // PUBLIC function mintPublicSale(address to, uint256 count) external payable nonReentrant { require(publicSaleStatus, "PRE_SALE_NOT_ACTIVE"); require(count <= publicSaleMaxMintPerTx, "PUBLIC_SALE_LIMIT"); require(publicSalePrice * count <= msg.value, "INSUFFICIENT_AMOUNT"); _mintTo(to, count); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721PreSaleExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to provide pre-sale capabilities for certain collectors to mint for a specific price. */ abstract contract ERC721PreSaleExtension is ERC721AutoIdMinterExtension, ReentrancyGuard { uint256 public preSalePrice; uint256 public preSaleMaxMintPerWallet; bytes32 public preSaleAllowlistMerkleRoot; bool public preSaleStatus; mapping(address => uint256) internal preSaleAllowlistClaimed; constructor(uint256 _preSalePrice, uint256 _preSaleMaxMintPerWallet) { preSalePrice = _preSalePrice; preSaleMaxMintPerWallet = _preSaleMaxMintPerWallet; } // ADMIN function setPreSalePrice(uint256 newValue) external onlyOwner { preSalePrice = newValue; } function setPreSaleMaxMintPerWallet(uint256 newValue) external onlyOwner { preSaleMaxMintPerWallet = newValue; } function setAllowlistMerkleRoot(bytes32 newRoot) external onlyOwner { preSaleAllowlistMerkleRoot = newRoot; } function togglePreSaleStatus(bool isActive) external onlyOwner { preSaleStatus = isActive; } // PUBLIC function onPreSaleAllowList(address minter, bytes32[] calldata proof) external view returns (bool) { return MerkleProof.verify( proof, preSaleAllowlistMerkleRoot, _generateMerkleLeaf(minter) ); } function mintPreSale(uint256 count, bytes32[] calldata proof) external payable nonReentrant { require(preSaleStatus, "PRE_SALE_NOT_ACTIVE"); address to = _msgSender(); require( MerkleProof.verify( proof, preSaleAllowlistMerkleRoot, _generateMerkleLeaf(msg.sender) ), "PRE_SALE_WRONG_PROOF" ); require( preSaleAllowlistClaimed[to] + count <= preSaleMaxMintPerWallet, "PRE_SALE_LIMIT" ); require(preSalePrice * count <= msg.value, "INSUFFICIENT_AMOUNT"); preSaleAllowlistClaimed[to] += count; _mintTo(to, count); } // INTERNAL function _generateMerkleLeaf(address account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(account)); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721OwnerMintExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to allow owner to mint directly without paying. */ abstract contract ERC721OwnerMintExtension is Ownable, ERC721AutoIdMinterExtension { // ADMIN function mintByOwner(address to, uint256 count) external onlyOwner { _mintTo(to, count); } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721PrefixedMetadataExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to allow configuring tokens metadata URI. * In this extension tokens will have a shared token URI prefix, * therefore on tokenURI() token's ID will be appended to the base URI. * It also allows configuring a fallback "placeholder" URI when prefix is not set yet. */ abstract contract ERC721PrefixedMetadataExtension is Ownable, ERC721 { string private _placeholderURI; string private _baseTokenURI; bool private _baseURIFrozen; constructor(string memory placeholderURI_) { _placeholderURI = placeholderURI_; } // ADMIN function setPlaceholderURI(string memory newValue) external onlyOwner { _placeholderURI = newValue; } function setBaseURI(string memory newValue) external onlyOwner { require(!_baseURIFrozen, "BASE_URI_FROZEN"); _baseTokenURI = newValue; } function freezeBaseURI() external onlyOwner { _baseURIFrozen = true; } // PUBLIC function baseTokenURI() public view returns (string memory) { return _baseTokenURI; } function placeholderURI() public view returns (string memory) { return _placeholderURI; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { return bytes(_baseTokenURI).length > 0 ? string( abi.encodePacked(_baseTokenURI, Strings.toString(_tokenId)) ) : _placeholderURI; } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721CollectionMetadataExtension.sol pragma solidity ^0.8.4; /** * @dev Extension to allow configuring contract-level collection metadata URI. */ abstract contract ERC721CollectionMetadataExtension is Ownable { string private _contractURI; constructor(string memory contractURI_) { _contractURI = contractURI_; } // ADMIN function setContractURI(string memory newValue) external onlyOwner { _contractURI = newValue; } // PUBLIC function contractURI() public view returns (string memory) { return _contractURI; } } // File: https://github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/presets/ERC721FullFeaturedCollection.sol pragma solidity ^0.8.4; contract ERC721FullFeaturedCollection is Ownable, ERC721, ERC721CollectionMetadataExtension, ERC721PrefixedMetadataExtension, ERC721AutoIdMinterExtension, ERC721OwnerMintExtension, ERC721PreSaleExtension, ERC721PublicSaleExtension, ERC721SimpleProceedsExtension, ERC721RoleBasedMintExtension, ERC721BulkifyExtension { constructor( string memory name, string memory symbol, string memory contractURI, string memory placeholderURI, uint256 maxSupply, uint256 preSalePrice, uint256 preSaleMaxMintPerWallet, uint256 publicSalePrice, uint256 publicSaleMaxMintPerTx ) ERC721(name, symbol) ERC721CollectionMetadataExtension(contractURI) ERC721PrefixedMetadataExtension(placeholderURI) ERC721AutoIdMinterExtension(maxSupply) ERC721PreSaleExtension(preSalePrice, preSaleMaxMintPerWallet) ERC721PublicSaleExtension(publicSalePrice, publicSaleMaxMintPerTx) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); } // PUBLIC /** * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. */ function isApprovedForAll(address owner, address operator) public view override(ERC721) returns (bool) { return super.isApprovedForAll(owner, operator); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721RoleBasedMintExtension) returns (bool) { return super.supportsInterface(interfaceId); } function tokenURI(uint256 _tokenId) public view virtual override(ERC721, ERC721PrefixedMetadataExtension) returns (string memory) { return ERC721PrefixedMetadataExtension.tokenURI(_tokenId); } function getInfo() external view returns ( uint256 _maxSupply, uint256 _totalSupply, uint256 _senderBalance, uint256 _preSalePrice, uint256 _preSaleMaxMintPerWallet, uint256 _preSaleAlreadyClaimed, bool _preSaleActive, uint256 _publicSalePrice, uint256 _publicSaleMaxMintPerTx, bool _publicSaleActive ) { uint256 balance = 0; if (msg.sender != address(0)) { balance = this.balanceOf(msg.sender); } return ( maxSupply, this.totalSupply(), balance, preSalePrice, preSaleMaxMintPerWallet, preSaleAllowlistClaimed[msg.sender], preSaleStatus, publicSalePrice, publicSaleMaxMintPerTx, publicSaleStatus ); } } // File: MyCollection.sol pragma solidity ^0.8.4; contract MyCollection is ERC721FullFeaturedCollection { constructor() ERC721FullFeaturedCollection( // Collection Name "The Gift Shop", // Collection Symbol "RATS", // Collection Metadata URL "ipfs/QmWei5kXGX9okYqupFfpbjhBmV1xyhTN7oH4VZJvmEonmA", // Pre-reveal Metadata URL "ipfs/QmWei5kXGX9okYqupFfpbjhBmV1xyhTN7oH4VZJvmEonmA", // Maximum Supply uint256(100000), // Pre Sale Price (in wei unit) uint256(10000000000000000), // Pre Sale max mint per wallet uint256(500), // Public Sale Price (in wei unit) uint256(10000000000000000), // Public Sale max mint per transaction uint256(500) ) {} }
File: https:github.com/RAT-TECHNOLOGIES/evm-contracts/blob/9820f1acbb53d4411ba120fb8af805bf519fb8a3/contracts/collections/ERC721/extensions/ERC721BulkifyExtension.sol* @dev Extension to add bulk operations to a standard ERC721 contract./
abstract contract ERC721BulkifyExtension is Context, ERC721 { function transferFromBulk( address from, address to, uint256[] memory tokenIds function _beforeTokenTransfer( address from, address to, uint256 tokenId function _afterTokenTransfer( address from, address to, uint256 tokenId } pragma solidity ^0.8.4; ) public virtual { for (uint256 i = 0; i < tokenIds.length; i++) { require(_isApprovedOrOwner(_msgSender(), tokenIds[i]), "NOT_OWNER"); _transfer(from, to, tokenIds[i]); } } function _beforeTokenTransfer( address from, address to, uint256 tokenId function _afterTokenTransfer( address from, address to, uint256 tokenId } pragma solidity ^0.8.4; ) public virtual { for (uint256 i = 0; i < tokenIds.length; i++) { require(_isApprovedOrOwner(_msgSender(), tokenIds[i]), "NOT_OWNER"); _transfer(from, to, tokenIds[i]); } } }
1,119,026
[ 1, 812, 30, 2333, 30, 6662, 18, 832, 19, 54, 789, 17, 1448, 1792, 3417, 4842, 8805, 19, 73, 3489, 17, 16351, 87, 19, 10721, 19, 10689, 3462, 74, 21, 1077, 9897, 8643, 72, 6334, 2499, 12124, 22343, 19192, 28, 1727, 3672, 25, 17156, 25, 3657, 19192, 28, 69, 23, 19, 16351, 87, 19, 19246, 19, 654, 39, 27, 5340, 19, 9489, 19, 654, 39, 27, 5340, 13112, 1164, 3625, 18, 18281, 225, 10021, 358, 527, 8280, 5295, 358, 279, 4529, 4232, 39, 27, 5340, 6835, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4232, 39, 27, 5340, 13112, 1164, 3625, 353, 1772, 16, 4232, 39, 27, 5340, 288, 203, 565, 445, 7412, 1265, 13112, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 8526, 3778, 1147, 2673, 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, 203, 565, 445, 389, 5205, 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, 3602, 20, 18, 28, 18, 24, 31, 203, 203, 203, 565, 262, 1071, 5024, 288, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 1147, 2673, 18, 2469, 31, 277, 27245, 288, 203, 5411, 2583, 24899, 291, 31639, 1162, 5541, 24899, 3576, 12021, 9334, 1147, 2673, 63, 77, 65, 3631, 315, 4400, 67, 29602, 8863, 203, 5411, 389, 13866, 12, 2080, 16, 358, 16, 1147, 2673, 63, 77, 19226, 203, 3639, 289, 203, 565, 289, 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, 203, 565, 445, 389, 5205, 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, 3602, 20, 18, 28, 18, 24, 31, 203, 203, 203, 565, 262, 1071, 5024, 2 ]
pragma solidity ^0.4.21; /** * @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) { 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) { uint256 c = a + b; assert(c >= a); return c; } } /** * @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() internal { 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)); emit 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; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } /** * @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 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 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 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; } } /** * @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); 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; } } contract DocnotaToken is MintableToken { string public name = "Docnota Token"; string public symbol = "DCNT"; uint8 public decimals = 18; bool public unlocked = false; event TokenUnlocked(); /** * @dev Function to unlock tokens * @return A boolean that indicates if the operation was successful. */ function unlock() onlyOwner public returns (bool) { require(!unlocked); unlocked = true; emit TokenUnlocked(); return true; } // // Overriding basic ERC-20 specification that lets people transfer/approve tokens. // function transfer(address to, uint256 value) public returns (bool) { require(unlocked); return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(unlocked); return super.transferFrom(from, to, value); } } contract DocnotaPresale is Ownable, Pausable { using SafeMath for uint256; // The token being sold DocnotaToken public token; // Address where funds are collected address public wallet; // Start and end timestamps where investments are allowed (both inclusive) uint256 public constant startTime = 1522584000; // 01 Apr 2018 12:00:00 GMT uint256 public constant endTime = 1525089600; // 30 Apr 2018 12:00:00 GMT // Maximum amount of funds to be raised in weis uint256 public constant cap = 620 ether; // Pricing in [ DCNT / ETH ] uint256 internal constant rate = 7000; // 5000 + 40% presale bonus // Minimum and maximum purchase sum in weis uint256 internal constant minPurchase = 1 ether; uint256 internal constant maxPurchase = 20 ether; // Invested sums in weis mapping(address => uint256) public purchased; // Addresses that are allowed to purchase tokens mapping(address => bool) public whitelist; // Amount of raised money in wei uint256 public weiRaised; // is presale finish method invoked bool isFinalized; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event Finalized(); function DocnotaPresale(address _token, address _wallet) public { require(_wallet != address(0)); token = DocnotaToken(_token); wallet = _wallet; } /** * @dev fallback function can be used to buy tokens */ function () external payable { buyTokens(msg.sender); } /** * @dev low level token purchase function * @param beneficiary Address performing the token purchase */ function buyTokens(address beneficiary) public whenNotPaused payable { require(beneficiary != address(0)); require(validatePurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate); // update states weiRaised = weiRaised.add(weiAmount); purchased[msg.sender] = purchased[msg.sender].add(weiAmount); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); require(token.mint(beneficiary, tokens)); wallet.transfer(weiAmount); } /** * @dev Function to manually mint tokens while crowdsale is running * @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) external onlyOwner returns (bool) { require(!isFinalized); return token.mint(to, amount); } /** * @dev Must be called after crowdsale ends, to do some extra finalization work. */ function finishPresale() external onlyOwner { require(!isFinalized); require(hasEnded()); emit Finalized(); isFinalized = true; // transfer ownership of the token to the owner of the presale contract token.transferOwnership(owner); } /** * @dev Validation of an incoming purchase. * @return Whether the purchase is valid */ function validatePurchase() internal view returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; bool minimumAllowedSum = (purchased[msg.sender] + msg.value) >= minPurchase; bool withinAllowedSum = (purchased[msg.sender] + msg.value) <= maxPurchase; bool withinCap = weiRaised.add(msg.value) <= cap; bool isWhitelisted = whitelist[msg.sender]; return withinPeriod && nonZeroPurchase && minimumAllowedSum && withinAllowedSum && withinCap && isWhitelisted; } /** * @dev Checks whether the crowdsale has ended. * @return Whether the crowdsale has ended */ function hasEnded() public view returns (bool) { return now > endTime || capReached(); } /** * @dev Checks whether the cap has been reached. * @return Whether the cap was reached */ function capReached() public view returns (bool) { return weiRaised >= cap; } /** * @dev Adds single address to whitelist. * @param _beneficiary Address to be added to the whitelist */ function addToWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = true; } /** * @dev Adds list of addresses to whitelist. * @param _beneficiaries Addresses to be added to the whitelist */ function addManyToWhitelist(address[] _beneficiaries) external onlyOwner { for (uint256 i = 0; i < _beneficiaries.length; i++) { whitelist[_beneficiaries[i]] = true; } } /** * @dev Removes single address from whitelist. * @param _beneficiary Address to be removed to the whitelist */ function removeFromWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = false; } }
* @dev Checks whether the crowdsale has ended. @return Whether the crowdsale has ended/
function hasEnded() public view returns (bool) { return now > endTime || capReached(); }
119,866
[ 1, 4081, 2856, 326, 276, 492, 2377, 5349, 711, 16926, 18, 327, 17403, 326, 276, 492, 2377, 5349, 711, 16926, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 711, 28362, 1435, 1071, 1476, 1135, 261, 6430, 13, 288, 203, 565, 327, 2037, 405, 13859, 747, 3523, 23646, 5621, 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 ]
./full_match/1/0xa33ba513Be08f822BDC2806bde89A9e0727Fd670/sources/contracts/mojito/onchain/OnchainBuy.sol
@notice The details to be provided to buy the token @param saleId the Id of the created sale @param tokenOwner the owner of the nft token @param tokenId the token Id of the owner owns @param tokenQuantity the token Quantity only required if minting @param quantity the quantity of tokens for 1155 only @param buyer the person who buys the nft @param paymentToken the type of payment currency that the buyers pay out @param paymentAmount the amount to be paid in the payment currency @param gatedCollection the gated nft collection need to be verified @param gatedTokenId the tokenId which was gated
struct BuyList { string saleId; address tokenOwner; uint256 tokenId; uint64 tokenQuantity; uint64 quantity; address buyer; address paymentToken; uint256 paymentAmount; address gatedColletion; uint256 gatedTokenId; }
17,022,111
[ 1, 1986, 3189, 358, 506, 2112, 358, 30143, 326, 1147, 225, 272, 5349, 548, 326, 3124, 434, 326, 2522, 272, 5349, 225, 1147, 5541, 326, 3410, 434, 326, 290, 1222, 1147, 225, 1147, 548, 326, 1147, 3124, 434, 326, 3410, 29065, 225, 1147, 12035, 326, 1147, 18189, 1338, 1931, 309, 312, 474, 310, 225, 10457, 326, 10457, 434, 2430, 364, 4648, 2539, 1338, 225, 27037, 326, 6175, 10354, 25666, 1900, 326, 290, 1222, 225, 5184, 1345, 326, 618, 434, 5184, 5462, 716, 326, 30143, 414, 8843, 596, 225, 5184, 6275, 326, 3844, 358, 506, 30591, 316, 326, 5184, 5462, 225, 314, 690, 2532, 326, 314, 690, 290, 1222, 1849, 1608, 358, 506, 13808, 225, 314, 690, 1345, 548, 326, 1147, 548, 1492, 1703, 314, 690, 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 ]
[ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 605, 9835, 682, 288, 203, 3639, 533, 272, 5349, 548, 31, 203, 3639, 1758, 1147, 5541, 31, 203, 3639, 2254, 5034, 1147, 548, 31, 203, 3639, 2254, 1105, 1147, 12035, 31, 203, 3639, 2254, 1105, 10457, 31, 203, 3639, 1758, 27037, 31, 203, 3639, 1758, 5184, 1345, 31, 203, 3639, 2254, 5034, 5184, 6275, 31, 203, 3639, 1758, 314, 690, 914, 1810, 285, 31, 203, 3639, 2254, 5034, 314, 690, 1345, 548, 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 ]
./partial_match/1/0xDB8367c2cB51532951C570857832AebD4D72Ece7/sources/contracts/wtf20230607.sol
time stamp of curr' intervals START (ends at + intSpendInterval)
intSpendCurrInterval = block.timestamp;
15,636,724
[ 1, 957, 14429, 434, 4306, 11, 10389, 10485, 261, 5839, 622, 397, 509, 27223, 4006, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 27223, 20143, 4006, 273, 1203, 18, 5508, 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 ]
pragma solidity ^0.4.24; // File: zeppelin-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. * @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; } } // File: zeppelin-solidity/contracts/lifecycle/Destructible.sol /** * @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 { constructor() 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); } } // File: zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * 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: zeppelin-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 &#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; } } // File: zeppelin-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: zeppelin-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&#39;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: zeppelin-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: zeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/issues/20 * 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&#39;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, uint256 _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, uint256 _subtractedValue ) public returns (bool) { uint256 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: contracts/token/ERC223/ERC223Basic.sol /** * @title ERC223Basic extends ERC20 interface and supports ERC223 */ contract ERC223Basic is ERC20Basic { function transfer(address _to, uint256 _value, bytes _data) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value, bytes data); } // File: contracts/token/ERC223/ERC223ReceivingContract.sol /** * @title ERC223ReceivingContract contract that will work with ERC223 tokens. */ contract ERC223ReceivingContract { /** * @dev Standard ERC223 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) public returns (bool); } // File: contracts/Adminable.sol /** * @title Adminable * @dev The Adminable contract has the simple protection logic, and provides admin based access control */ contract Adminable is Ownable { address public admin; event AdminDesignated(address indexed previousAdmin, address indexed newAdmin); /** * @dev Throws if called the non admin. */ modifier onlyAdmin() { require(msg.sender == admin); _; } /** * @dev Throws if called the non owner and non admin. */ modifier onlyOwnerOrAdmin() { require(msg.sender == owner || msg.sender == admin); _; } /** * @dev Designate new admin for the address * @param _address address The address you want to be a new admin */ function designateAdmin(address _address) public onlyOwner { require(_address != address(0) && _address != owner); emit AdminDesignated(admin, _address); admin = _address; } } // File: contracts/Lockable.sol /** * @title Lockable * @dev The Lockable contract has an locks address map, and provides lockable control * functions, this simplifies the implementation of "lock transfers". * */ contract Lockable is Adminable, ERC20Basic { using SafeMath for uint256; // EPOCH TIMESTAMP OF "Tue Sept 24 2019 00:00:00 GMT+0000" // @see https://www.unixtimestamp.com/index.php uint public globalUnlockTime = 1569355060; uint public constant decimals = 18; event UnLock(address indexed unlocked); event Lock(address indexed locked, uint until, uint256 value, uint count); event UpdateGlobalUnlockTime(uint256 epoch); struct LockMeta { uint256 value; uint until; } mapping(address => LockMeta[]) internal locksMeta; mapping(address => bool) locks; /** * @dev Lock tokens for the address * @param _address address The address you want to lock tokens * @param _days uint The days count you want to lock untill from now * @param _value uint256 the amount of tokens to be locked */ function lock(address _address, uint _days, uint256 _value) onlyOwnerOrAdmin public { _value = _value*(10**decimals); require(_value > 0); require(_days > 0); require(_address != owner); require(_address != admin); uint untilTime = block.timestamp + _days * 1 days; locks[_address] = true; // check if we have locks locksMeta[_address].push(LockMeta(_value, untilTime)); // fire lock event emit Lock(_address, untilTime, _value, locksMeta[_address].length); } /** * @dev Unlock tokens for the address * @param _address address The address you want to unlock tokens */ function unlock(address _address) onlyOwnerOrAdmin public { locks[_address] = false; delete locksMeta[_address]; emit UnLock(_address); } /** * @dev Gets the locked balance of the specified address and time * @param _owner The address to query the locked balance of. * @param _time The timestamp seconds to query the locked balance of. * @return An uint256 representing the locked amount owned by the passed address. */ function lockedBalanceOf(address _owner, uint _time) public view returns (uint256) { LockMeta[] memory locked = locksMeta[_owner]; uint length = locked.length; // if no locks or even not created (takes bdefault) return 0 if (length == 0) { return 0; } // sum all available locks uint256 _result = 0; for (uint i = 0; i < length; i++) { if (_time <= locked[i].until) { _result = _result.add(locked[i].value); } } return _result; } /** * @dev Gets the locked balance of the specified address of the current time * @param _owner The address to query the locked balance of. * @return An uint256 representing the locked amount owned by the passed address. */ function lockedNowBalanceOf(address _owner) public view returns (uint256) { return this.lockedBalanceOf(_owner, block.timestamp); } /** * @dev Gets the unlocked balance of the specified address and time * @param _owner The address to query the unlocked balance of. * @param _time The timestamp seconds to query the unlocked balance of. * @return An uint256 representing the unlocked amount owned by the passed address. */ function unlockedBalanceOf(address _owner, uint _time) public view returns (uint256) { return this.balanceOf(_owner).sub(lockedBalanceOf(_owner, _time)); } /** * @dev Gets the unlocked balance of the specified address of the current time * @param _owner The address to query the unlocked balance of. * @return An uint256 representing the unlocked amount owned by the passed address. */ function unlockedNowBalanceOf(address _owner) public view returns (uint256) { return this.unlockedBalanceOf(_owner, block.timestamp); } function updateGlobalUnlockTime(uint256 _epoch) public onlyOwnerOrAdmin returns (bool) { require(_epoch >= 0); globalUnlockTime = _epoch; emit UpdateGlobalUnlockTime(_epoch); // Gives owner the ability to update lockup period for all wallets. // Owner can pass an epoch timecode into the function to: // 1. Extend lockup period, // 2. Unlock all wallets by passing &#39;0&#39; into the function } /** * @dev Throws if the value less than the current unlocked balance of. */ modifier onlyUnlocked(uint256 _value) { if(block.timestamp > globalUnlockTime) { _; } else { if (locks[msg.sender] == true) { require(this.unlockedNowBalanceOf(msg.sender) >= _value); } _; } } /** * @dev Throws if the value less than the current unlocked balance of the given address. */ modifier onlyUnlockedOf(address _address, uint256 _value) { if(block.timestamp > globalUnlockTime) { _; } else { if (locks[_address] == true) { require(this.unlockedNowBalanceOf(_address) >= _value); } else { } _; } } } // File: contracts/StandardLockableToken.sol /** * @title StandardLockableToken * */ contract StandardLockableToken is Lockable, /**/ERC223Basic, /*ERC20*/StandardToken { /** * @dev Check address is to be a contract based on extcodesize (must be nonzero to be a contract) * @param _address The address to check. */ function isContract(address _address) private constant returns (bool) { uint256 codeLength; assembly { codeLength := extcodesize(_address) } return codeLength > 0; } /** * @dev Transfer token for a specified address * ERC20 support * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) onlyUnlocked(_value) public returns (bool) { bytes memory empty; return _transfer(_to, _value, empty); } /** * @dev Transfer token for a specified address * ERC223 support * @param _to The address to transfer to. * @param _value The amount to be transferred. * @param _data The additional data. */ function transfer(address _to, uint256 _value, bytes _data) onlyUnlocked(_value) public returns (bool) { return _transfer(_to, _value, _data); } /** * @dev Transfer token for a specified address * ERC223 support * @param _to The address to transfer to. * @param _value The amount to be transferred. * @param _data The additional data. */ function _transfer(address _to, uint256 _value, bytes _data) internal returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(_value > 0); // catch overflow loosing tokens // require(balances[_to] + _value > balances[_to]); // safety update balances balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); // determine if the contract given if (isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } // emit ERC20 transfer event emit Transfer(msg.sender, _to, _value); // emit ERC223 transfer event emit Transfer(msg.sender, _to, _value, _data); return true; } /** * @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) onlyUnlockedOf(_from, _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_value > 0); // make balances manipulations first balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); bytes memory empty; if (isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, empty); } // emit ERC20 transfer event emit Transfer(_from, _to, _value); // emit ERC223 transfer event emit Transfer(_from, _to, _value, empty); return true; } } // File: contracts/StandardBurnableLockableToken.sol /** * @title StandardBurnableLockableToken * */ contract StandardBurnableLockableToken is StandardLockableToken, BurnableToken { /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param _from address The address which you want to send tokens from * @param _value uint256 The amount of token to be burned */ function burnFrom(address _from, uint256 _value) onlyOwner onlyUnlockedOf(_from, _value) public { require(_value <= allowed[_from][msg.sender]); require(_value > 0); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _burn(_from, _value); bytes memory empty; // emit ERC223 transfer event also emit Transfer(msg.sender, address(0), _value, empty); } /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) onlyOwner onlyUnlocked(_value) public { require(_value > 0); _burn(msg.sender, _value); bytes memory empty; // emit ERC223 transfer event also emit Transfer(msg.sender, address(0), _value, empty); } } contract EngageToken is StandardBurnableLockableToken, Destructible { string public constant name = "Engage"; uint public constant decimals = 18; string public constant symbol = "NGAGE"; constructor() public { // set the owner owner = msg.sender; admin = 0x613b42D781c59237fb51c304A5b037cDDD0dC48c; uint256 INITIAL_SUPPLY = 1000000000 * (10**decimals); totalSupply_ = INITIAL_SUPPLY; bytes memory empty; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(address(0), msg.sender, INITIAL_SUPPLY); emit Transfer(address(0), msg.sender, INITIAL_SUPPLY, empty); } }
* @dev Unlock tokens for the address @param _address address The address you want to unlock tokens/
function unlock(address _address) onlyOwnerOrAdmin public { locks[_address] = false; delete locksMeta[_address]; emit UnLock(_address); }
6,655,476
[ 1, 7087, 2430, 364, 326, 1758, 225, 389, 2867, 1758, 1021, 1758, 1846, 2545, 358, 7186, 2430, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7186, 12, 2867, 389, 2867, 13, 1338, 5541, 1162, 4446, 1071, 288, 203, 565, 13046, 63, 67, 2867, 65, 273, 629, 31, 203, 565, 1430, 13046, 2781, 63, 67, 2867, 15533, 203, 565, 3626, 1351, 2531, 24899, 2867, 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 ]
./full_match/4/0xA97Cbe3C41B7f4a7a3D7e4c087d9B1DE2A53424F/sources/contracts/finalshit.sol
* Uses ERC721Enumerable _beforeTokenTransfer() implementation./
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC721, ERC721Enumerable){ ERC721Enumerable._beforeTokenTransfer(from, to, amount); }
675,880
[ 1, 15128, 4232, 39, 27, 5340, 3572, 25121, 389, 5771, 1345, 5912, 1435, 4471, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5771, 1345, 5912, 12, 2867, 628, 16, 1758, 358, 16, 2254, 5034, 3844, 13, 2713, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3572, 25121, 15329, 203, 3639, 4232, 39, 27, 5340, 3572, 25121, 6315, 5771, 1345, 5912, 12, 2080, 16, 358, 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 ]
./full_match/80001/0x9EE4Ae31D7aCF2Ac546fe7daDF64c7C766163C56/sources/contracts/FractionalNft.sol
require amount <= remaining supply
function mintToken(uint24 amount) public { transferFrom(address(this), msg.sender, amount); }
5,687,164
[ 1, 6528, 3844, 1648, 4463, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 312, 474, 1345, 12, 11890, 3247, 3844, 13, 1071, 288, 203, 3639, 7412, 1265, 12, 2867, 12, 2211, 3631, 1234, 18, 15330, 16, 3844, 1769, 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 ]
./full_match/42/0x04794c64d720A77809FC2826d4EdEF551D266f7d/sources/tests/price_Oracle.sol
library with helper methods for oracles that are concerned with computing average prices helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
library UniswapV2OracleLibrary { using FixedPoint for *; pragma solidity ^0.6.12; function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { uint32 timeElapsed = blockTimestamp - blockTimestampLast; price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { uint32 timeElapsed = blockTimestamp - blockTimestampLast; price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } }
16,231,239
[ 1, 12083, 598, 4222, 2590, 364, 578, 69, 9558, 716, 854, 356, 2750, 11748, 598, 20303, 8164, 19827, 4222, 445, 716, 1135, 326, 783, 1203, 2858, 3470, 326, 1048, 434, 2254, 1578, 16, 277, 18, 73, 18, 306, 20, 16, 576, 1578, 300, 404, 65, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1351, 291, 91, 438, 58, 22, 23601, 9313, 288, 203, 565, 1450, 15038, 2148, 364, 380, 31, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 26, 18, 2138, 31, 203, 565, 445, 30610, 4921, 1435, 2713, 1476, 1135, 261, 11890, 1578, 13, 288, 203, 3639, 327, 2254, 1578, 12, 2629, 18, 5508, 738, 576, 2826, 3847, 1769, 203, 565, 289, 203, 203, 565, 445, 783, 39, 11276, 31862, 12, 203, 3639, 1758, 3082, 203, 565, 262, 2713, 1476, 1135, 261, 11890, 6205, 20, 39, 11276, 16, 2254, 6205, 21, 39, 11276, 16, 2254, 1578, 1203, 4921, 13, 288, 203, 3639, 1203, 4921, 273, 30610, 4921, 5621, 203, 3639, 6205, 20, 39, 11276, 273, 467, 984, 291, 91, 438, 58, 22, 4154, 12, 6017, 2934, 8694, 20, 39, 11276, 3024, 5621, 203, 3639, 6205, 21, 39, 11276, 273, 467, 984, 291, 91, 438, 58, 22, 4154, 12, 6017, 2934, 8694, 21, 39, 11276, 3024, 5621, 203, 203, 3639, 261, 11890, 17666, 20501, 20, 16, 2254, 17666, 20501, 21, 16, 2254, 1578, 1203, 4921, 3024, 13, 273, 467, 984, 291, 91, 438, 58, 22, 4154, 12, 6017, 2934, 588, 607, 264, 3324, 5621, 203, 3639, 309, 261, 2629, 4921, 3024, 480, 1203, 4921, 13, 288, 203, 5411, 2254, 1578, 813, 28827, 273, 1203, 4921, 300, 1203, 4921, 3024, 31, 203, 5411, 6205, 20, 39, 11276, 1011, 2254, 12, 7505, 2148, 18, 16744, 12, 455, 6527, 21, 16, 20501, 20, 2934, 67, 92, 13, 380, 813, 28827, 31, 203, 5411, 6205, 21, 39, 11276, 1011, 2 ]
./full_match/1/0xe261B138cfd46FdC12A039cF6690645f35DCFA37/sources/contracts/DropFactory/DropFactory.sol
* ____________________________________________________________________________________________________________________ -->VRF @dev (function) requestVRFRandomness Get the metadata start position for use on reveal of the calling collection _____________________________________________________________________________________________________________________/ Can only be called by a deployed collection: Chainlink aarng
function requestVRFRandomness() external payable { if (deployedNFTContracts[msg.sender] = true) { if (vrfMode == 0) { addressForChainlinkVRFRequestId[ vrfCoordinatorInterface.requestRandomWords( vrfKeyHash, vrfSubscriptionId, vrfRequestConfirmations, vrfCallbackGasLimit, vrfNumWords ) ] = msg.sender; addressForArrngVRFRequestId[ ] = msg.sender; } _revert(MetadropModulesOnly.selector); } }
3,107,483
[ 1, 21157, 21157, 21157, 21157, 21157, 21157, 21157, 7198, 28524, 4766, 7734, 15431, 10986, 42, 225, 261, 915, 13, 590, 10986, 42, 8529, 4496, 225, 968, 326, 1982, 787, 1754, 364, 999, 603, 283, 24293, 434, 326, 4440, 1849, 389, 21157, 21157, 21157, 21157, 21157, 21157, 21157, 7198, 19, 4480, 1338, 506, 2566, 635, 279, 19357, 1849, 30, 7824, 1232, 279, 1303, 75, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 590, 10986, 42, 8529, 4496, 1435, 3903, 8843, 429, 288, 203, 565, 309, 261, 12411, 329, 50, 4464, 20723, 63, 3576, 18, 15330, 65, 273, 638, 13, 288, 203, 1377, 309, 261, 16825, 2309, 422, 374, 13, 288, 203, 3639, 1758, 1290, 3893, 1232, 10986, 42, 15493, 63, 203, 1850, 20466, 25307, 1358, 18, 2293, 8529, 7363, 12, 203, 5411, 20466, 653, 2310, 16, 203, 5411, 20466, 6663, 548, 16, 203, 5411, 20466, 691, 11269, 1012, 16, 203, 5411, 20466, 2428, 27998, 3039, 16, 203, 5411, 20466, 2578, 7363, 203, 1850, 262, 203, 3639, 308, 273, 1234, 18, 15330, 31, 203, 3639, 1758, 1290, 5715, 3368, 10986, 42, 15493, 63, 203, 3639, 308, 273, 1234, 18, 15330, 31, 203, 1377, 289, 203, 1377, 389, 266, 1097, 12, 49, 1167, 1764, 7782, 3386, 18, 9663, 1769, 203, 565, 289, 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 ]
// SPDX-License-Identifier: MIT pragma solidity =0.7.6; pragma experimental ABIEncoderV2; import "../helpers/LiquityHelper.sol"; import "../../../utils/TokenUtils.sol"; import "../../ActionBase.sol"; contract LiquityOpen is ActionBase, LiquityHelper { using TokenUtils for address; struct Params { uint256 maxFeePercentage; // Highest borrowing fee to accept, ranges between 0.5 and 5% uint256 collAmount; // Amount of WETH tokens to supply as collateral uint256 lusdAmount; // Amount of LUSD tokens to borrow from the trove, protocol minimum net debt is 1800 address from; // Address where to pull the collateral from address to; // Address that will receive the borrowed tokens address upperHint; address lowerHint; } /// @inheritdoc ActionBase function executeAction( bytes[] memory _callData, bytes[] memory _subData, uint8[] memory _paramMapping, bytes32[] memory _returnValues ) public payable virtual override returns (bytes32) { Params memory params = parseInputs(_callData); params.maxFeePercentage = _parseParamUint( params.maxFeePercentage, _paramMapping[0], _subData, _returnValues ); params.collAmount = _parseParamUint( params.collAmount, _paramMapping[1], _subData, _returnValues ); params.lusdAmount = _parseParamUint( params.lusdAmount, _paramMapping[2], _subData, _returnValues ); params.from = _parseParamAddr(params.from, _paramMapping[3], _subData, _returnValues); params.to = _parseParamAddr(params.to, _paramMapping[4], _subData, _returnValues); uint256 troveOwner = _liquityOpen(params); return bytes32(troveOwner); } /// @inheritdoc ActionBase function executeActionDirect(bytes[] memory _callData) public payable virtual override { Params memory params = parseInputs(_callData); _liquityOpen(params); } /// @inheritdoc ActionBase function actionType() public pure virtual override returns (uint8) { return uint8(ActionType.STANDARD_ACTION); } //////////////////////////// ACTION LOGIC //////////////////////////// /// @notice Opens up a trove function _liquityOpen(Params memory _params) internal returns (uint256) { if (_params.collAmount == type(uint256).max) { _params.collAmount = TokenUtils.WETH_ADDR.getBalance(_params.from); } TokenUtils.WETH_ADDR.pullTokensIfNeeded(_params.from, _params.collAmount); TokenUtils.withdrawWeth(_params.collAmount); BorrowerOperations.openTrove{value: _params.collAmount}( _params.maxFeePercentage, _params.lusdAmount, _params.upperHint, _params.lowerHint ); LUSDTokenAddr.withdrawTokens(_params.to, _params.lusdAmount); logger.Log( address(this), msg.sender, "LiquityOpen", abi.encode( _params.maxFeePercentage, _params.collAmount, _params.lusdAmount, _params.from, _params.to ) ); return _params.collAmount; } function parseInputs(bytes[] memory _callData) internal pure returns (Params memory params) { params = abi.decode(_callData[0], (Params)); } }
@notice Opens up a trove
function _liquityOpen(Params memory _params) internal returns (uint256) { if (_params.collAmount == type(uint256).max) { _params.collAmount = TokenUtils.WETH_ADDR.getBalance(_params.from); } TokenUtils.WETH_ADDR.pullTokensIfNeeded(_params.from, _params.collAmount); TokenUtils.withdrawWeth(_params.collAmount); _params.maxFeePercentage, _params.lusdAmount, _params.upperHint, _params.lowerHint ); LUSDTokenAddr.withdrawTokens(_params.to, _params.lusdAmount); logger.Log( address(this), msg.sender, "LiquityOpen", abi.encode( _params.maxFeePercentage, _params.collAmount, _params.lusdAmount, _params.from, _params.to ) ); return _params.collAmount; }
5,390,612
[ 1, 17778, 731, 279, 23432, 537, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 549, 372, 560, 3678, 12, 1370, 3778, 389, 2010, 13, 2713, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 309, 261, 67, 2010, 18, 12910, 6275, 422, 618, 12, 11890, 5034, 2934, 1896, 13, 288, 203, 5411, 389, 2010, 18, 12910, 6275, 273, 3155, 1989, 18, 59, 1584, 44, 67, 14142, 18, 588, 13937, 24899, 2010, 18, 2080, 1769, 203, 3639, 289, 203, 3639, 3155, 1989, 18, 59, 1584, 44, 67, 14142, 18, 13469, 5157, 18299, 24899, 2010, 18, 2080, 16, 389, 2010, 18, 12910, 6275, 1769, 203, 3639, 3155, 1989, 18, 1918, 9446, 59, 546, 24899, 2010, 18, 12910, 6275, 1769, 203, 203, 5411, 389, 2010, 18, 1896, 14667, 16397, 16, 203, 5411, 389, 2010, 18, 80, 407, 72, 6275, 16, 203, 5411, 389, 2010, 18, 5797, 7002, 16, 203, 5411, 389, 2010, 18, 8167, 7002, 203, 3639, 11272, 203, 203, 3639, 511, 3378, 40, 1345, 3178, 18, 1918, 9446, 5157, 24899, 2010, 18, 869, 16, 389, 2010, 18, 80, 407, 72, 6275, 1769, 203, 203, 3639, 1194, 18, 1343, 12, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 1234, 18, 15330, 16, 203, 5411, 315, 48, 18988, 560, 3678, 3113, 203, 5411, 24126, 18, 3015, 12, 203, 7734, 389, 2010, 18, 1896, 14667, 16397, 16, 203, 7734, 389, 2010, 18, 12910, 6275, 16, 203, 7734, 389, 2010, 18, 80, 407, 72, 6275, 16, 203, 7734, 389, 2010, 18, 2080, 16, 203, 7734, 389, 2010, 18, 869, 203, 5411, 262, 203, 3639, 11272, 203, 203, 3639, 327, 389, 2010, 18, 2 ]
pragma solidity 0.5.11; import { InitializeGovernedUpgradeabilityProxy } from "./InitializeGovernedUpgradeabilityProxy.sol"; /** * @notice OUSDProxy delegates calls to an OUSD implementation */ contract OUSDProxy is InitializeGovernedUpgradeabilityProxy { } /** * @notice VaultProxy delegates calls to a Vault implementation */ contract VaultProxy is InitializeGovernedUpgradeabilityProxy { } /** * @notice CompoundStrategyProxy delegates calls to a CompoundStrategy implementation */ contract CompoundStrategyProxy is InitializeGovernedUpgradeabilityProxy { } /** * @notice ThreePoolStrategyProxy delegates calls to a ThreePoolStrategy implementation */ contract ThreePoolStrategyProxy is InitializeGovernedUpgradeabilityProxy { }
* @notice OUSDProxy delegates calls to an OUSD implementation/
contract OUSDProxy is InitializeGovernedUpgradeabilityProxy { }
12,835,591
[ 1, 21667, 40, 3886, 22310, 4097, 358, 392, 531, 3378, 40, 4471, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 531, 3378, 40, 3886, 353, 9190, 43, 1643, 11748, 10784, 2967, 3886, 288, 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 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/IMerkleDistributor.sol"; contract MerkleDistributor is IMerkleDistributor, Ownable { address public immutable override token; // This is a packed array of booleans. mapping(uint256 => mapping(uint256 => uint256)) private claimedInEpoch; mapping(uint256 => bytes32) public merkleRootInEpoch; constructor(address token_) { token = token_; //Here we need to make it a mix of tokens? } function isClaimed(uint256 index, uint256 _epoch) public view override returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedInEpoch[_epoch][claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(uint256 index, uint256 _epoch) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedInEpoch[_epoch][claimedWordIndex] = claimedInEpoch[_epoch][claimedWordIndex] | (1 << claimedBitIndex); } function claim( uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof, uint256 _epoch) external override { require(!isClaimed(index, _epoch), "MD: Drop already claimed."); require(account == msg.sender, "Claimer is a different account"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, amount)); require(MerkleProof.verify(merkleProof, merkleRootInEpoch[_epoch], node), "MD: Invalid proof."); // Mark it claimed and send the token. _setClaimed(index, _epoch); require(IERC20(token).transfer(account, amount), "MD: Transfer failed."); emit Claimed(_epoch, index, account, amount); } ///dev add modifier to check that it is only Prize Distribution Contract function setMerkleRootPerEpoch(bytes32 _merkleRoot, uint256 _epoch) external { merkleRootInEpoch[_epoch] = _merkleRoot; } }
dev add modifier to check that it is only Prize Distribution Contract
function setMerkleRootPerEpoch(bytes32 _merkleRoot, uint256 _epoch) external { merkleRootInEpoch[_epoch] = _merkleRoot; }
13,140,561
[ 1, 5206, 527, 9606, 358, 866, 716, 518, 353, 1338, 2301, 554, 17547, 13456, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 8478, 15609, 2375, 2173, 14638, 12, 3890, 1578, 389, 6592, 15609, 2375, 16, 2254, 5034, 389, 12015, 13, 3903, 288, 203, 3639, 30235, 2375, 382, 14638, 63, 67, 12015, 65, 273, 389, 6592, 15609, 2375, 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 ]
// ███████╗░█████╗░██████╗░██████╗░███████╗██████╗░░░░███████╗██╗ // ╚════██║██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗░░░██╔════╝██║ // ░░███╔═╝███████║██████╔╝██████╔╝█████╗░░██████╔╝░░░█████╗░░██║ // ██╔══╝░░██╔══██║██╔═══╝░██╔═══╝░██╔══╝░░██╔══██╗░░░██╔══╝░░██║ // ███████╗██║░░██║██║░░░░░██║░░░░░███████╗██║░░██║██╗██║░░░░░██║ // ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░░░░╚══════╝╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝ // Copyright (C) 2020 zapper // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // ///@author Zapper ///@notice Registry for Curve Pools with Utility functions. pragma solidity ^0.5.7; import "../oz/ownership/Ownable.sol"; import "../oz/token/ERC20/SafeERC20.sol"; interface ICurveAddressProvider { function get_registry() external view returns (address); function get_address(uint256 _id) external view returns (address); } interface ICurveRegistry { function get_pool_from_lp_token(address lpToken) external view returns (address); function get_lp_token(address swapAddress) external view returns (address); function get_n_coins(address _pool) external view returns (uint256[2] memory); function get_coins(address _pool) external view returns (address[8] memory); function get_underlying_coins(address _pool) external view returns (address[8] memory); } interface ICurveFactoryRegistry { function get_n_coins(address _pool) external view returns (uint256, uint256); function get_coins(address _pool) external view returns (address[2] memory); function get_underlying_coins(address _pool) external view returns (address[8] memory); } contract Curve_Registry_V2 is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; ICurveAddressProvider private constant CurveAddressProvider = ICurveAddressProvider(0x0000000022D53366457F9d5E68Ec105046FC4383); ICurveRegistry public CurveRegistry; ICurveFactoryRegistry public FactoryRegistry; address private constant wbtcToken = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; address private constant sbtcCrvToken = 0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3; address internal constant ETHAddress = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; mapping(address => bool) public shouldAddUnderlying; mapping(address => address) private depositAddresses; constructor() public { CurveRegistry = ICurveRegistry(CurveAddressProvider.get_registry()); FactoryRegistry = ICurveFactoryRegistry( CurveAddressProvider.get_address(3) ); } function isCurvePool(address swapAddress) public view returns (bool) { if (CurveRegistry.get_lp_token(swapAddress) != address(0)) { return true; } return false; } function isFactoryPool(address swapAddress) public view returns (bool) { if (FactoryRegistry.get_coins(swapAddress)[0] != address(0)) { return true; } return false; } /** @notice This function is used to get the curve pool deposit address @notice The deposit address is used for pools with wrapped (c, y) tokens @param swapAddress Curve swap address for the pool @return curve pool deposit address or the swap address not mapped */ function getDepositAddress(address swapAddress) external view returns (address depositAddress) { depositAddress = depositAddresses[swapAddress]; if (depositAddress == address(0)) return swapAddress; } /** @notice This function is used to get the curve pool swap address @notice The token and swap address is the same for metapool factory pools @param swapAddress Curve swap address for the pool @return curve pool swap address or address(0) if pool doesnt exist */ function getSwapAddress(address tokenAddress) external view returns (address swapAddress) { swapAddress = CurveRegistry.get_pool_from_lp_token(tokenAddress); if (swapAddress != address(0)) { return swapAddress; } if (isFactoryPool(swapAddress)) { return tokenAddress; } return address(0); } /** @notice This function is used to check the curve pool token address @notice The token and swap address is the same for metapool factory pools @param swapAddress Curve swap address for the pool @return curve pool token address or address(0) if pool doesnt exist */ function getTokenAddress(address swapAddress) external view returns (address tokenAddress) { tokenAddress = CurveRegistry.get_lp_token(swapAddress); if (tokenAddress != address(0)) { return tokenAddress; } if (isFactoryPool(swapAddress)) { return swapAddress; } return address(0); } /** @notice Checks the number of non-underlying tokens in a pool @param swapAddress Curve swap address for the pool @return number of underlying tokens in the pool */ function getNumTokens(address swapAddress) public view returns (uint256) { if (isCurvePool(swapAddress)) { return CurveRegistry.get_n_coins(swapAddress)[0]; } else { (uint256 numTokens, ) = FactoryRegistry.get_n_coins(swapAddress); return numTokens; } } /** @notice This function is used to check if the curve pool is a metapool @notice all factory pools are metapools @param swapAddress Curve swap address for the pool @return true if the pool is a metapool, false otherwise */ function isMetaPool(address swapAddress) public view returns (bool) { if (isCurvePool(swapAddress)) { uint256[2] memory poolTokenCounts = CurveRegistry.get_n_coins(swapAddress); if (poolTokenCounts[0] == poolTokenCounts[1]) return false; else return true; } if (isFactoryPool(swapAddress)) return true; } /** @notice This function returns an array of underlying pool token addresses @param swapAddress Curve swap address for the pool @return returns 4 element array containing the addresses of the pool tokens (0 address if pool contains < 4 tokens) */ function getPoolTokens(address swapAddress) public view returns (address[4] memory poolTokens) { if (isMetaPool(swapAddress)) { if (isFactoryPool(swapAddress)) { address[2] memory poolUnderlyingCoins = FactoryRegistry.get_coins(swapAddress); for (uint256 i = 0; i < 2; i++) { poolTokens[i] = poolUnderlyingCoins[i]; } } else { address[8] memory poolUnderlyingCoins = CurveRegistry.get_coins(swapAddress); for (uint256 i = 0; i < 2; i++) { poolTokens[i] = poolUnderlyingCoins[i]; } } return poolTokens; } else { address[8] memory poolUnderlyingCoins; if (isBtcPool(swapAddress) && !isMetaPool(swapAddress)) { poolUnderlyingCoins = CurveRegistry.get_coins(swapAddress); } else { poolUnderlyingCoins = CurveRegistry.get_underlying_coins( swapAddress ); } for (uint256 i = 0; i < 4; i++) { poolTokens[i] = poolUnderlyingCoins[i]; } } } /** @notice This function checks if the curve pool contains WBTC @param swapAddress Curve swap address for the pool @return true if the pool contains WBTC, false otherwise */ function isBtcPool(address swapAddress) public view returns (bool) { address[8] memory poolTokens = CurveRegistry.get_coins(swapAddress); for (uint256 i = 0; i < 4; i++) { if (poolTokens[i] == wbtcToken || poolTokens[i] == sbtcCrvToken) return true; } return false; } /** @notice This function checks if the curve pool contains ETH @param swapAddress Curve swap address for the pool @return true if the pool contains ETH, false otherwise */ function isEthPool(address swapAddress) external view returns (bool) { address[8] memory poolTokens = CurveRegistry.get_coins(swapAddress); for (uint256 i = 0; i < 4; i++) { if (poolTokens[i] == ETHAddress) { return true; } } return false; } /** @notice This function is used to check if the pool contains the token @param swapAddress Curve swap address for the pool @param tokenContractAddress contract address of the token @return true if the pool contains the token, false otherwise @return index of the token in the pool, 0 if pool does not contain the token */ function isUnderlyingToken( address swapAddress, address tokenContractAddress ) external view returns (bool, uint256) { address[4] memory poolTokens = getPoolTokens(swapAddress); for (uint256 i = 0; i < 4; i++) { if (poolTokens[i] == address(0)) return (false, 0); if (poolTokens[i] == tokenContractAddress) return (true, i); } } /** @notice Updates to the latest curve registry from the address provider */ function update_curve_registry() external onlyOwner { address new_address = CurveAddressProvider.get_registry(); require(address(CurveRegistry) != new_address, "Already updated"); CurveRegistry = ICurveRegistry(new_address); } /** @notice Updates to the latest curve registry from the address provider */ function update_factory_registry() external onlyOwner { address new_address = CurveAddressProvider.get_address(3); require(address(FactoryRegistry) != new_address, "Already updated"); FactoryRegistry = ICurveFactoryRegistry(new_address); } /** @notice Add new pools which use the _use_underlying bool @param swapAddresses Curve swap addresses for the pool @param addUnderlying True if underlying tokens are always added */ function updateShouldAddUnderlying( address[] calldata swapAddresses, bool[] calldata addUnderlying ) external onlyOwner { require( swapAddresses.length == addUnderlying.length, "Mismatched arrays" ); for (uint256 i = 0; i < swapAddresses.length; i++) { shouldAddUnderlying[swapAddresses[i]] = addUnderlying[i]; } } /** @notice Add new pools which use uamounts for add_liquidity @param swapAddresses Curve swap addresses to map from @param _depositAddresses Curve deposit addresses to map to */ function updateDepositAddresses( address[] calldata swapAddresses, address[] calldata _depositAddresses ) external onlyOwner { require( swapAddresses.length == _depositAddresses.length, "Mismatched arrays" ); for (uint256 i = 0; i < swapAddresses.length; i++) { depositAddresses[swapAddresses[i]] = _depositAddresses[i]; } } /** //@notice Add new pools which use the _use_underlying bool */ function withdrawTokens(address[] calldata tokens) external onlyOwner { for (uint256 i = 0; i < tokens.length; i++) { uint256 qty; if (tokens[i] == ETHAddress) { qty = address(this).balance; Address.sendValue(Address.toPayable(owner()), qty); } else { qty = IERC20(tokens[i]).balanceOf(address(this)); IERC20(tokens[i]).safeTransfer(owner(), qty); } } } } // ███████╗░█████╗░██████╗░██████╗░███████╗██████╗░░░░███████╗██╗ // ╚════██║██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗░░░██╔════╝██║ // ░░███╔═╝███████║██████╔╝██████╔╝█████╗░░██████╔╝░░░█████╗░░██║ // ██╔══╝░░██╔══██║██╔═══╝░██╔═══╝░██╔══╝░░██╔══██╗░░░██╔══╝░░██║ // ███████╗██║░░██║██║░░░░░██║░░░░░███████╗██║░░██║██╗██║░░░░░██║ // ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░░░░╚══════╝╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝ // Copyright (C) 2021 zapper // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // ///@author Zapper ///@notice This contract removes liquidity from Curve pools // SPDX-License-Identifier: GPL-2.0 pragma solidity ^0.5.7; import "../_base/ZapOutBaseV2.sol"; import "./Curve_Registry_V2.sol"; interface ICurveSwap { function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount ) external; function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount, bool removeUnderlying ) external; function remove_liquidity_one_coin( uint256 _token_amount, uint256 i, uint256 min_amount ) external; function calc_withdraw_one_coin(uint256 tokenAmount, int128 index) external view returns (uint256); function calc_withdraw_one_coin( uint256 tokenAmount, int128 index, bool _use_underlying ) external view returns (uint256); function calc_withdraw_one_coin(uint256 tokenAmount, uint256 index) external view returns (uint256); } interface IWETH { function withdraw(uint256 wad) external; function deposit() external payable; } contract Curve_ZapOut_General_V4_2 is ZapOutBaseV2_1 { using SafeMath for uint256; using SafeERC20 for IERC20; address private constant wethTokenAddress = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); Curve_Registry_V2 public curveReg; mapping(address => bool) public approvedTargets; mapping(address => bool) internal v2Pool; constructor( Curve_Registry_V2 _curveRegistry, uint256 _goodwill, uint256 _affiliateSplit ) public ZapBaseV1(_goodwill, _affiliateSplit) { approvedTargets[0xDef1C0ded9bec7F1a1670819833240f027b25EfF] = true; v2Pool[0x80466c64868E1ab14a1Ddf27A676C3fcBE638Fe5] = true; curveReg = _curveRegistry; } event zapOut( address sender, address pool, address token, uint256 tokensRec ); /** @notice This method removes the liquidity from curve pools to ETH/ERC tokens @param swapAddress indicates Curve swap address for the pool @param incomingCrv indicates the amount of lp tokens to remove @param intermediateToken specifies in which token to exit the curve pool @param toToken indicates the ETH/ERC token to which tokens to convert @param minToTokens indicates the minimum amount of toTokens to receive @param _swapTarget Excecution target for the first swap @param _swapCallData DEX quote data @param affiliate Affiliate address to share fees @param shouldSellEntireBalance True if incomingCrv is determined at execution time (i.e. contract is caller) @return ToTokensBought- indicates the amount of toTokens received */ function ZapOut( address swapAddress, uint256 incomingCrv, address intermediateToken, address toToken, uint256 minToTokens, address _swapTarget, bytes calldata _swapCallData, address affiliate, bool shouldSellEntireBalance ) external stopInEmergency returns (uint256 ToTokensBought) { address poolTokenAddress = curveReg.getTokenAddress(swapAddress); // get lp tokens incomingCrv = _pullTokens( poolTokenAddress, incomingCrv, shouldSellEntireBalance ); if (intermediateToken == address(0)) { intermediateToken = ETHAddress; } // perform zapOut ToTokensBought = _zapOut( swapAddress, incomingCrv, intermediateToken, toToken, _swapTarget, _swapCallData ); require(ToTokensBought >= minToTokens, "High Slippage"); uint256 totalGoodwillPortion; // Transfer tokens if (toToken == address(0)) { totalGoodwillPortion = _subtractGoodwill( ETHAddress, ToTokensBought, affiliate, true ); Address.sendValue( msg.sender, ToTokensBought.sub(totalGoodwillPortion) ); } else { totalGoodwillPortion = _subtractGoodwill( toToken, ToTokensBought, affiliate, true ); IERC20(toToken).safeTransfer( msg.sender, ToTokensBought.sub(totalGoodwillPortion) ); } emit zapOut(msg.sender, swapAddress, toToken, ToTokensBought); return ToTokensBought.sub(totalGoodwillPortion); } function _zapOut( address swapAddress, uint256 incomingCrv, address intermediateToken, address toToken, address _swapTarget, bytes memory _swapCallData ) internal returns (uint256 ToTokensBought) { (bool isUnderlying, uint256 underlyingIndex) = curveReg.isUnderlyingToken(swapAddress, intermediateToken); // not metapool if (isUnderlying) { uint256 intermediateBought = _exitCurve( swapAddress, incomingCrv, underlyingIndex, intermediateToken ); if (intermediateToken == ETHAddress) intermediateToken = address(0); ToTokensBought = _fillQuote( intermediateToken, toToken, intermediateBought, _swapTarget, _swapCallData ); } else { // from metapool address[4] memory poolTokens = curveReg.getPoolTokens(swapAddress); address intermediateSwapAddress; uint8 i; for (; i < 4; i++) { if (curveReg.getSwapAddress(poolTokens[i]) != address(0)) { intermediateSwapAddress = curveReg.getSwapAddress( poolTokens[i] ); break; } } // _exitCurve to intermediateSwapAddress Token uint256 intermediateCrvBought = _exitMetaCurve(swapAddress, incomingCrv, i, poolTokens[i]); // _performZapOut: fromPool = intermediateSwapAddress ToTokensBought = _zapOut( intermediateSwapAddress, intermediateCrvBought, intermediateToken, toToken, _swapTarget, _swapCallData ); } } /** @notice This method removes the liquidity from meta curve pools @param swapAddress indicates the curve pool address from which liquidity to be removed. @param incomingCrv indicates the amount of liquidity to be removed from the pool @param index indicates the index of underlying token of the pool in which liquidity will be removed. @return tokensReceived- indicates the amount of reserve tokens received */ function _exitMetaCurve( address swapAddress, uint256 incomingCrv, uint256 index, address exitTokenAddress ) internal returns (uint256 tokensReceived) { address tokenAddress = curveReg.getTokenAddress(swapAddress); _approveToken(tokenAddress, swapAddress); uint256 iniTokenBal = IERC20(exitTokenAddress).balanceOf(address(this)); ICurveSwap(swapAddress).remove_liquidity_one_coin( incomingCrv, int128(index), 0 ); tokensReceived = (IERC20(exitTokenAddress).balanceOf(address(this))) .sub(iniTokenBal); require(tokensReceived > 0, "Could not receive reserve tokens"); } /** @notice This method removes the liquidity from given curve pool @param swapAddress indicates the curve pool address from which liquidity to be removed. @param incomingCrv indicates the amount of liquidity to be removed from the pool @param index indicates the index of underlying token of the pool in which liquidity will be removed. @return tokensReceived- indicates the amount of reserve tokens received */ function _exitCurve( address swapAddress, uint256 incomingCrv, uint256 index, address exitTokenAddress ) internal returns (uint256 tokensReceived) { address depositAddress = curveReg.getDepositAddress(swapAddress); address tokenAddress = curveReg.getTokenAddress(swapAddress); _approveToken(tokenAddress, depositAddress); address balanceToken = exitTokenAddress == ETHAddress ? address(0) : exitTokenAddress; uint256 iniTokenBal = _getBalance(balanceToken); if (curveReg.shouldAddUnderlying(swapAddress)) { // aave ICurveSwap(depositAddress).remove_liquidity_one_coin( incomingCrv, int128(index), 0, true ); } else if (v2Pool[swapAddress]) { ICurveSwap(depositAddress).remove_liquidity_one_coin( incomingCrv, index, 0 ); } else { ICurveSwap(depositAddress).remove_liquidity_one_coin( incomingCrv, int128(index), 0 ); } tokensReceived = _getBalance(balanceToken).sub(iniTokenBal); require(tokensReceived > 0, "Could not receive reserve tokens"); } /** @notice This method swaps the fromToken to toToken using the 0x swap @param _fromTokenAddress indicates the ETH/ERC20 token @param _toTokenAddress indicates the ETH/ERC20 token @param _amount indicates the amount of from tokens to swap @param _swapTarget Excecution target for the first swap @param _swapCallData DEX quote data */ function _fillQuote( address _fromTokenAddress, address _toTokenAddress, uint256 _amount, address _swapTarget, bytes memory _swapCallData ) internal returns (uint256 amountBought) { if (_fromTokenAddress == _toTokenAddress) return _amount; if ( _fromTokenAddress == wethTokenAddress && _toTokenAddress == address(0) ) { IWETH(wethTokenAddress).withdraw(_amount); return _amount; } else if ( _fromTokenAddress == address(0) && _toTokenAddress == wethTokenAddress ) { IWETH(wethTokenAddress).deposit.value(_amount)(); return _amount; } uint256 valueToSend; if (_fromTokenAddress == address(0)) valueToSend = _amount; else _approveToken(_fromTokenAddress, _swapTarget, _amount); uint256 iniBal = _getBalance(_toTokenAddress); require(approvedTargets[_swapTarget], "Target not Authorized"); (bool success, ) = _swapTarget.call.value(valueToSend)(_swapCallData); require(success, "Error Swapping Tokens"); uint256 finalBal = _getBalance(_toTokenAddress); amountBought = finalBal.sub(iniBal); require(amountBought > 0, "Swapped To Invalid Intermediate"); } /** @notice Utility function to determine the quantity and address of a token being removed @param swapAddress indicates the curve pool address from which liquidity to be removed @param tokenAddress token to be removed @param liquidity Quantity of LP tokens to remove. @return amount Quantity of token removed */ function removeLiquidityReturn( address swapAddress, address tokenAddress, uint256 liquidity ) external view returns (uint256 amount) { if (tokenAddress == address(0)) tokenAddress = ETHAddress; (bool underlying, uint256 index) = curveReg.isUnderlyingToken(swapAddress, tokenAddress); if (underlying) { if (v2Pool[swapAddress]) { return ICurveSwap(curveReg.getDepositAddress(swapAddress)) .calc_withdraw_one_coin(liquidity, uint256(index)); } else if (curveReg.shouldAddUnderlying(swapAddress)) { return ICurveSwap(curveReg.getDepositAddress(swapAddress)) .calc_withdraw_one_coin(liquidity, int128(index), true); } else { return ICurveSwap(curveReg.getDepositAddress(swapAddress)) .calc_withdraw_one_coin(liquidity, int128(index)); } } else { address[4] memory poolTokens = curveReg.getPoolTokens(swapAddress); address intermediateSwapAddress; for (uint256 i = 0; i < 4; i++) { intermediateSwapAddress = curveReg.getSwapAddress( poolTokens[i] ); if (intermediateSwapAddress != address(0)) break; } uint256 metaTokensRec = ICurveSwap(swapAddress).calc_withdraw_one_coin( liquidity, int128(1) ); (, index) = curveReg.isUnderlyingToken( intermediateSwapAddress, tokenAddress ); return ICurveSwap(intermediateSwapAddress).calc_withdraw_one_coin( metaTokensRec, int128(index) ); } } function updateCurveRegistry(Curve_Registry_V2 newCurveRegistry) external onlyOwner { require(newCurveRegistry != curveReg, "Already using this Registry"); curveReg = newCurveRegistry; } function setApprovedTargets( address[] calldata targets, bool[] calldata isApproved ) external onlyOwner { require(targets.length == isApproved.length, "Invalid Input length"); for (uint256 i = 0; i < targets.length; i++) { approvedTargets[targets[i]] = isApproved[i]; } } function setV2Pool(address[] calldata pool, bool[] calldata isV2Pool) external onlyOwner { require(pool.length == isV2Pool.length, "Invalid Input length"); for (uint256 i = 0; i < pool.length; i++) { v2Pool[pool[i]] = isV2Pool[i]; } } } pragma solidity ^0.5.7; import "../oz/ownership/Ownable.sol"; import "../oz/token/ERC20/SafeERC20.sol"; contract ZapBaseV1 is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; bool public stopped = false; // if true, goodwill is not deducted mapping(address => bool) public feeWhitelist; uint256 public goodwill; // % share of goodwill (0-100 %) uint256 affiliateSplit; // restrict affiliates mapping(address => bool) public affiliates; // affiliate => token => amount mapping(address => mapping(address => uint256)) public affiliateBalance; // token => amount mapping(address => uint256) public totalAffiliateBalance; address internal constant ETHAddress = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; constructor(uint256 _goodwill, uint256 _affiliateSplit) public { goodwill = _goodwill; affiliateSplit = _affiliateSplit; } // circuit breaker modifiers modifier stopInEmergency { if (stopped) { revert("Temporarily Paused"); } else { _; } } function _getBalance(address token) internal view returns (uint256 balance) { if (token == address(0)) { balance = address(this).balance; } else { balance = IERC20(token).balanceOf(address(this)); } } function _approveToken(address token, address spender) internal { IERC20 _token = IERC20(token); if (_token.allowance(address(this), spender) > 0) return; else { _token.safeApprove(spender, uint256(-1)); } } function _approveToken( address token, address spender, uint256 amount ) internal { IERC20 _token = IERC20(token); _token.safeApprove(spender, 0); _token.safeApprove(spender, amount); } // - to Pause the contract function toggleContractActive() public onlyOwner { stopped = !stopped; } function set_feeWhitelist(address zapAddress, bool status) external onlyOwner { feeWhitelist[zapAddress] = status; } function set_new_goodwill(uint256 _new_goodwill) public onlyOwner { require( _new_goodwill >= 0 && _new_goodwill <= 100, "GoodWill Value not allowed" ); goodwill = _new_goodwill; } function set_new_affiliateSplit(uint256 _new_affiliateSplit) external onlyOwner { require( _new_affiliateSplit <= 100, "Affiliate Split Value not allowed" ); affiliateSplit = _new_affiliateSplit; } function set_affiliate(address _affiliate, bool _status) external onlyOwner { affiliates[_affiliate] = _status; } ///@notice Withdraw goodwill share, retaining affilliate share function withdrawTokens(address[] calldata tokens) external onlyOwner { for (uint256 i = 0; i < tokens.length; i++) { uint256 qty; if (tokens[i] == ETHAddress) { qty = address(this).balance.sub( totalAffiliateBalance[tokens[i]] ); Address.sendValue(Address.toPayable(owner()), qty); } else { qty = IERC20(tokens[i]).balanceOf(address(this)).sub( totalAffiliateBalance[tokens[i]] ); IERC20(tokens[i]).safeTransfer(owner(), qty); } } } ///@notice Withdraw affilliate share, retaining goodwill share function affilliateWithdraw(address[] calldata tokens) external { uint256 tokenBal; for (uint256 i = 0; i < tokens.length; i++) { tokenBal = affiliateBalance[msg.sender][tokens[i]]; affiliateBalance[msg.sender][tokens[i]] = 0; totalAffiliateBalance[tokens[i]] = totalAffiliateBalance[tokens[i]] .sub(tokenBal); if (tokens[i] == ETHAddress) { Address.sendValue(msg.sender, tokenBal); } else { IERC20(tokens[i]).safeTransfer(msg.sender, tokenBal); } } } function() external payable { require(msg.sender != tx.origin, "Do not send ETH directly"); } } pragma solidity ^0.5.7; import "./ZapBaseV1.sol"; contract ZapOutBaseV2_1 is ZapBaseV1 { /** @dev Transfer tokens from msg.sender to this contract @param token The ERC20 token to transfer to this contract @param shouldSellEntireBalance If True transfers entrire allowable amount from another contract @return Quantity of tokens transferred to this contract */ function _pullTokens( address token, uint256 amount, bool shouldSellEntireBalance ) internal returns (uint256) { if (shouldSellEntireBalance) { require( Address.isContract(msg.sender), "ERR: shouldSellEntireBalance is true for EOA" ); IERC20 _token = IERC20(token); uint256 allowance = _token.allowance(msg.sender, address(this)); _token.safeTransferFrom(msg.sender, address(this), allowance); return allowance; } else { IERC20(token).safeTransferFrom(msg.sender, address(this), amount); return amount; } } function _subtractGoodwill( address token, uint256 amount, address affiliate, bool enableGoodwill ) internal returns (uint256 totalGoodwillPortion) { bool whitelisted = feeWhitelist[msg.sender]; if (enableGoodwill && !whitelisted && goodwill > 0) { totalGoodwillPortion = SafeMath.div( SafeMath.mul(amount, goodwill), 10000 ); if (affiliates[affiliate]) { if (token == address(0)) { token = ETHAddress; } uint256 affiliatePortion = totalGoodwillPortion.mul(affiliateSplit).div(100); affiliateBalance[affiliate][token] = affiliateBalance[ affiliate ][token] .add(affiliatePortion); totalAffiliateBalance[token] = totalAffiliateBalance[token].add( affiliatePortion ); } } } } 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; } } 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; } } pragma solidity ^0.5.0; import "../GSN/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. * * 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(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; } } 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 { function decimals() external view returns (uint8); /** * @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 ); } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.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 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" ); } } } 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" ); } }
/ get lp tokens Transfer tokens
function ZapOut( address swapAddress, uint256 incomingCrv, address intermediateToken, address toToken, uint256 minToTokens, address _swapTarget, bytes calldata _swapCallData, address affiliate, bool shouldSellEntireBalance ) external stopInEmergency returns (uint256 ToTokensBought) { address poolTokenAddress = curveReg.getTokenAddress(swapAddress); incomingCrv = _pullTokens( poolTokenAddress, incomingCrv, shouldSellEntireBalance ); if (intermediateToken == address(0)) { intermediateToken = ETHAddress; } swapAddress, incomingCrv, intermediateToken, toToken, _swapTarget, _swapCallData ); require(ToTokensBought >= minToTokens, "High Slippage"); uint256 totalGoodwillPortion; if (toToken == address(0)) { totalGoodwillPortion = _subtractGoodwill( ETHAddress, ToTokensBought, affiliate, true ); Address.sendValue( msg.sender, ToTokensBought.sub(totalGoodwillPortion) ); totalGoodwillPortion = _subtractGoodwill( toToken, ToTokensBought, affiliate, true ); IERC20(toToken).safeTransfer( msg.sender, ToTokensBought.sub(totalGoodwillPortion) ); } emit zapOut(msg.sender, swapAddress, toToken, ToTokensBought); return ToTokensBought.sub(totalGoodwillPortion); }
1,839,036
[ 1, 19, 336, 12423, 2430, 12279, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2285, 438, 1182, 12, 203, 3639, 1758, 7720, 1887, 16, 203, 3639, 2254, 5034, 6935, 39, 4962, 16, 203, 3639, 1758, 12110, 1345, 16, 203, 3639, 1758, 358, 1345, 16, 203, 3639, 2254, 5034, 1131, 774, 5157, 16, 203, 3639, 1758, 389, 22270, 2326, 16, 203, 3639, 1731, 745, 892, 389, 22270, 1477, 751, 16, 203, 3639, 1758, 7103, 330, 3840, 16, 203, 3639, 1426, 1410, 55, 1165, 14199, 577, 13937, 203, 565, 262, 3903, 2132, 382, 1514, 24530, 1135, 261, 11890, 5034, 2974, 5157, 13809, 9540, 13, 288, 203, 3639, 1758, 2845, 1345, 1887, 273, 8882, 1617, 18, 588, 1345, 1887, 12, 22270, 1887, 1769, 203, 203, 3639, 6935, 39, 4962, 273, 389, 13469, 5157, 12, 203, 5411, 2845, 1345, 1887, 16, 203, 5411, 6935, 39, 4962, 16, 203, 5411, 1410, 55, 1165, 14199, 577, 13937, 203, 3639, 11272, 203, 203, 3639, 309, 261, 2761, 6785, 1345, 422, 1758, 12, 20, 3719, 288, 203, 5411, 12110, 1345, 273, 512, 2455, 1887, 31, 203, 3639, 289, 203, 203, 5411, 7720, 1887, 16, 203, 5411, 6935, 39, 4962, 16, 203, 5411, 12110, 1345, 16, 203, 5411, 358, 1345, 16, 203, 5411, 389, 22270, 2326, 16, 203, 5411, 389, 22270, 1477, 751, 203, 3639, 11272, 203, 3639, 2583, 12, 774, 5157, 13809, 9540, 1545, 1131, 774, 5157, 16, 315, 8573, 348, 3169, 2433, 8863, 203, 203, 3639, 2254, 5034, 2078, 18195, 20194, 2617, 285, 31, 203, 203, 3639, 309, 261, 869, 1345, 422, 1758, 12, 20, 3719, 288, 203, 5411, 2078, 18195, 20194, 2617, 2 ]
./full_match/80001/0x1BcB8966c6D624447E97f5006c6538AB87233D49/sources/contracts/DeFiLabs.sol
Important to get a count of all the Transaction that belong to the user before we can make an array for them
function getSubmitedTransactions() public view returns (Transaction[] memory) { uint256 itemCount = 0; uint256 currentIndex = 0; for(uint256 i=0;i<transactionCount;i++) { if(confirmations[i][msg.sender] && !transactions[i].executed && !transactions[i].deleted){ itemCount += 1; } } for(uint256 i=0;i<transactionCount;i++) { if(confirmations[i][msg.sender] && !transactions[i].executed && !transactions[i].deleted){ Transaction storage currentItem = transactions[i]; submitedTransactions[currentIndex] = currentItem; currentIndex += 1; } } return submitedTransactions; }
843,941
[ 1, 5010, 970, 358, 336, 279, 1056, 434, 777, 326, 5947, 716, 10957, 358, 326, 729, 1865, 732, 848, 1221, 392, 526, 364, 2182, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7040, 1938, 329, 14186, 1435, 1071, 1476, 1135, 261, 3342, 8526, 3778, 13, 288, 203, 3639, 2254, 5034, 761, 1380, 273, 374, 31, 203, 3639, 2254, 5034, 17032, 273, 374, 31, 203, 3639, 364, 12, 11890, 5034, 277, 33, 20, 31, 77, 32, 7958, 1380, 31, 77, 27245, 203, 3639, 288, 203, 5411, 309, 12, 10927, 1012, 63, 77, 6362, 3576, 18, 15330, 65, 597, 401, 20376, 63, 77, 8009, 4177, 4817, 597, 401, 20376, 63, 77, 8009, 8600, 15329, 203, 7734, 761, 1380, 1011, 404, 31, 203, 5411, 289, 203, 3639, 289, 203, 3639, 364, 12, 11890, 5034, 277, 33, 20, 31, 77, 32, 7958, 1380, 31, 77, 27245, 203, 3639, 288, 203, 5411, 309, 12, 10927, 1012, 63, 77, 6362, 3576, 18, 15330, 65, 597, 401, 20376, 63, 77, 8009, 4177, 4817, 597, 401, 20376, 63, 77, 8009, 8600, 15329, 203, 7734, 5947, 2502, 27471, 273, 8938, 63, 77, 15533, 203, 7734, 4879, 329, 14186, 63, 2972, 1016, 65, 273, 27471, 31, 203, 7734, 17032, 1011, 404, 31, 203, 5411, 289, 203, 3639, 289, 203, 3639, 327, 4879, 329, 14186, 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 ]
pragma solidity ^0.4.22; /** * @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)); emit 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; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state * ポーズをとるためにオーナーが呼び出し、通常の状態に戻ります */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract RocsBase is Pausable { // 生誕代 uint128 public eggPrice = 50 finney; function setEggPrice(uint128 _price) public onlyOwner { eggPrice = _price; } // 進化代 uint128 public evolvePrice = 5 finney; function setEvolvePrice(uint128 _price) public onlyOwner { evolvePrice = _price; } // 生誕 event RocCreated(address owner, uint tokenId, uint rocId); // ERC721 event Transfer(address from, address to, uint tokenId); event ItemTransfer(address from, address to, uint tokenId); /// @dev Rocの構造体 struct Roc { // ID uint rocId; // DNA string dna; // 出品中フラグ 1は出品中 uint8 marketsFlg; } /// @dev Rocsの配列 Roc[] public rocs; // rocIdとtokenIdのマッピング mapping(uint => uint) public rocIndex; // rocIdからtokenIdを取得 function getRocIdToTokenId(uint _rocId) public view returns (uint) { return rocIndex[_rocId]; } /// @dev 所有するアドレスへのマッピング mapping (uint => address) public rocIndexToOwner; // @dev 所有者アドレスから所有するトークン数へのマッピング mapping (address => uint) public ownershipTokenCount; /// @dev 呼び出しが承認されたアドレスへのマッピング mapping (uint => address) public rocIndexToApproved; /// @dev 特定のRocの所有権をアドレスに割り当てます。 function _transfer(address _from, address _to, uint256 _tokenId) internal { ownershipTokenCount[_to]++; ownershipTokenCount[_from]--; rocIndexToOwner[_tokenId] = _to; // イベント開始 emit Transfer(_from, _to, _tokenId); } } /// @title ERC-721に準拠した契約のインタフェース:置き換え不可能なトークン contract ERC721 { // イベント event Transfer(address indexed _from, address indexed _to, uint256 _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId); // 必要なメソッド function balanceOf(address _owner) public view returns (uint256 _balance); function ownerOf(uint256 _tokenId) external view returns (address _owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) public; function transferFrom(address _from, address _to, uint256 _tokenId) public; function totalSupply() public view returns (uint); // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165) function supportsInterface(bytes4 _interfaceID) external view returns (bool); } /// @title Roc所有権を管理するコントラクト /// @dev OpenZeppelinのERC721ドラフト実装に準拠 contract RocsOwnership is RocsBase, ERC721 { /// @notice ERC721で定義されている、置き換え不可能なトークンの名前と記号。 string public constant name = "CryptoFeather"; string public constant symbol = "CFE"; bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); bytes4 constant InterfaceSignature_ERC721 = bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ^ bytes4(keccak256('transfer(address,uint256)')) ^ bytes4(keccak256('transferFrom(address,address,uint256)')) ^ bytes4(keccak256('totalSupply()')); /// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165). /// この契約によって実装された標準化されたインタフェースでtrueを返します。 function supportsInterface(bytes4 _interfaceID) external view returns (bool) { // DEBUG ONLY //require((InterfaceSignature_ERC165 == 0x01ffc9a7) && (InterfaceSignature_ERC721 == 0x9a20483d)); return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721)); } /// @dev 特定のアドレスに指定されたrocの現在の所有者であるかどうかをチェックします。 /// @param _claimant /// @param _tokenId function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return rocIndexToOwner[_tokenId] == _claimant; } /// @dev 特定のアドレスに指定されたrocが存在するかどうかをチェックします。 /// @param _claimant the address we are confirming kitten is approved for. /// @param _tokenId kitten id, only valid when > 0 function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) { return rocIndexToApproved[_tokenId] == _claimant; } /// @dev 以前の承認を上書きして、transferFrom()に対して承認されたアドレスをマークします。 function _approve(uint256 _tokenId, address _approved) internal { rocIndexToApproved[_tokenId] = _approved; } // 指定されたアドレスのroc数を取得します。 function balanceOf(address _owner) public view returns (uint256 count) { return ownershipTokenCount[_owner]; } /// @notice rocの所有者を変更します。 /// @dev ERC-721への準拠に必要 function transfer(address _to, uint256 _tokenId) public whenNotPaused { // 安全チェック require(_to != address(0)); // 自分のrocしか送ることはできません。 require(_owns(msg.sender, _tokenId)); // 所有権の再割り当て、保留中の承認のクリア、転送イベントの送信 _transfer(msg.sender, _to, _tokenId); } /// @notice transferFrom()を介して別のアドレスに特定のrocを転送する権利を与えます。 /// @dev ERC-721への準拠に必要 function approve(address _to, uint256 _tokenId) external whenNotPaused { // 所有者のみが譲渡承認を認めることができます。 require(_owns(msg.sender, _tokenId)); // 承認を登録します(以前の承認を置き換えます)。 _approve(_tokenId, _to); // 承認イベントを発行する。 emit Approval(msg.sender, _to, _tokenId); } /// @notice roc所有者の変更を行います。を転送します。そのアドレスには、以前の所有者から転送承認が与えられています。 /// @dev ERC-721への準拠に必要 function transferFrom(address _from, address _to, uint256 _tokenId) public whenNotPaused { // 安全チェック。 require(_to != address(0)); // 承認と有効な所有権の確認 require(_approvedFor(msg.sender, _tokenId)); require(_owns(_from, _tokenId)); // 所有権を再割り当てします(保留中の承認をクリアし、転送イベントを発行します)。 _transfer(_from, _to, _tokenId); } /// @notice 現在存在するrocの総数を返します。 /// @dev ERC-721への準拠に必要です。 function totalSupply() public view returns (uint) { return rocs.length - 1; } /// @notice 指定されたrocの現在所有権が割り当てられているアドレスを返します。 /// @dev ERC-721への準拠に必要です。 function ownerOf(uint256 _tokenId) external view returns (address owner) { owner = rocIndexToOwner[_tokenId]; require(owner != address(0)); } /// @dev この契約に所有権を割り当て、NFTを強制終了します。 /// @param _owner /// @param _tokenId function _escrow(address _owner, uint256 _tokenId) internal { // it will throw if transfer fails transferFrom(_owner, this, _tokenId); } } /// @title Rocの飼育に関する管理を行うコントラクト contract RocsBreeding is RocsOwnership { /// @notice 新しいRocを作成して保存。 /// @param _rocId /// @param _dna /// @param _marketsFlg /// @param _owner /// @dev RocCreatedイベントとTransferイベントの両方を生成します。 function _createRoc( uint _rocId, string _dna, uint _marketsFlg, address _owner ) internal returns (uint) { Roc memory _roc = Roc({ rocId: _rocId, dna: _dna, marketsFlg: uint8(_marketsFlg) }); uint newRocId = rocs.push(_roc) - 1; // 同一のトークンIDが発生した場合は実行を停止します require(newRocId == uint(newRocId)); // RocCreatedイベント emit RocCreated(_owner, newRocId, _rocId); // これにより所有権が割り当てられ、ERC721ドラフトごとに転送イベントが発行されます rocIndex[_rocId] = newRocId; _transfer(0, _owner, newRocId); return newRocId; } /// @notice 新たに生み出します /// @param _rocId /// @param _dna function giveProduce(uint _rocId, string _dna) external payable whenNotPaused returns(uint) { // 支払いを確認します。 require(msg.value >= eggPrice); uint createRocId = _createRoc( _rocId, _dna, 0, msg.sender ); // 超過分を買い手に返す uint256 bidExcess = msg.value - eggPrice; msg.sender.transfer(bidExcess); return createRocId; } /// @notice 初めてのRoc /// @param _rocId /// @param _dna function freeGiveProduce(uint _rocId, string _dna) external payable whenNotPaused returns(uint) { // 初めてのRocか確認します。 require(balanceOf(msg.sender) == 0); uint createRocId = _createRoc( _rocId, _dna, 0, msg.sender ); // 超過分を買い手に返す uint256 bidExcess = msg.value; msg.sender.transfer(bidExcess); return createRocId; } } /// @title Rocの売買のためのMarkets処理 contract RocsMarkets is RocsBreeding { event MarketsCreated(uint256 tokenId, uint128 marketsPrice); event MarketsSuccessful(uint256 tokenId, uint128 marketsPriceice, address buyer); event MarketsCancelled(uint256 tokenId); // NFT上のマーケットへの出品 struct Markets { // 登録時のNFT売手 address seller; // 価格 uint128 marketsPrice; } // トークンIDから対応するマーケットへの出品にマップします。 mapping (uint256 => Markets) tokenIdToMarkets; // マーケットへの出品の手数料を設定 uint256 public ownerCut = 0; function setOwnerCut(uint256 _cut) public onlyOwner { require(_cut <= 10000); ownerCut = _cut; } /// @notice Rocマーケットへの出品を作成し、開始します。 /// @param _rocId /// @param _marketsPrice function createRocSaleMarkets( uint256 _rocId, uint256 _marketsPrice ) external whenNotPaused { require(_marketsPrice == uint256(uint128(_marketsPrice))); // チェック用のtokenIdをセット uint checkTokenId = getRocIdToTokenId(_rocId); // checkのオーナーである事 require(_owns(msg.sender, checkTokenId)); // checkのパラメータチェック Roc memory roc = rocs[checkTokenId]; // マーケットへの出品中か確認してください。 require(uint8(roc.marketsFlg) == 0); // 承認 _approve(checkTokenId, msg.sender); // マーケットへの出品セット _escrow(msg.sender, checkTokenId); Markets memory markets = Markets( msg.sender, uint128(_marketsPrice) ); // マーケットへの出品FLGをセット rocs[checkTokenId].marketsFlg = 1; _addMarkets(checkTokenId, markets); } /// @dev マーケットへの出品を公開マーケットへの出品のリストに追加します。 /// また、MarketsCreatedイベントを発生させます。 /// @param _tokenId The ID of the token to be put on markets. /// @param _markets Markets to add. function _addMarkets(uint256 _tokenId, Markets _markets) internal { tokenIdToMarkets[_tokenId] = _markets; emit MarketsCreated( uint256(_tokenId), uint128(_markets.marketsPrice) ); } /// @dev マーケットへの出品を公開マーケットへの出品のリストから削除します。 /// @param _tokenId function _removeMarkets(uint256 _tokenId) internal { delete tokenIdToMarkets[_tokenId]; } /// @dev 無条件にマーケットへの出品を取り消します。 /// @param _tokenId function _cancelMarkets(uint256 _tokenId) internal { _removeMarkets(_tokenId); emit MarketsCancelled(_tokenId); } /// @dev まだ獲得されていないMarketsをキャンセルします。 /// 元の所有者にNFTを返します。 /// @notice これは、契約が一時停止している間に呼び出すことができる状態変更関数です。 /// @param _rocId function cancelMarkets(uint _rocId) external { uint checkTokenId = getRocIdToTokenId(_rocId); Markets storage markets = tokenIdToMarkets[checkTokenId]; address seller = markets.seller; require(msg.sender == seller); _cancelMarkets(checkTokenId); rocIndexToOwner[checkTokenId] = seller; rocs[checkTokenId].marketsFlg = 0; } /// @dev 契約が一時停止されたときにMarketsをキャンセルします。 /// 所有者だけがこれを行うことができ、NFTは売り手に返されます。 /// 緊急時にのみ使用してください。 /// @param _rocId function cancelMarketsWhenPaused(uint _rocId) whenPaused onlyOwner external { uint checkTokenId = getRocIdToTokenId(_rocId); Markets storage markets = tokenIdToMarkets[checkTokenId]; address seller = markets.seller; _cancelMarkets(checkTokenId); rocIndexToOwner[checkTokenId] = seller; rocs[checkTokenId].marketsFlg = 0; } /// @dev Markets入札 /// 十分な量のEtherが供給されればNFTの所有権を移転する。 /// @param _rocId function bid(uint _rocId) external payable whenNotPaused { uint checkTokenId = getRocIdToTokenId(_rocId); // マーケットへの出品構造体への参照を取得する Markets storage markets = tokenIdToMarkets[checkTokenId]; uint128 sellingPrice = uint128(markets.marketsPrice); // 入札額が価格以上である事を確認する。 // msg.valueはweiの数 require(msg.value >= sellingPrice); // マーケットへの出品構造体が削除される前に、販売者への参照を取得します。 address seller = markets.seller; // マーケットへの出品を削除します。 _removeMarkets(checkTokenId); if (sellingPrice > 0) { // 競売人のカットを計算します。 uint128 marketseerCut = uint128(_computeCut(sellingPrice)); uint128 sellerProceeds = sellingPrice - marketseerCut; // 売り手に送金する seller.transfer(sellerProceeds); } // 超過分を買い手に返す msg.sender.transfer(msg.value - sellingPrice); // イベント emit MarketsSuccessful(checkTokenId, sellingPrice, msg.sender); _transfer(seller, msg.sender, checkTokenId); // マーケットへの出品FLGをセット rocs[checkTokenId].marketsFlg = 0; } /// @dev 手数料計算 /// @param _price function _computeCut(uint128 _price) internal view returns (uint) { return _price * ownerCut / 10000; } } /// @title CryptoRocs contract RocsCore is RocsMarkets { // コア契約が壊れてアップグレードが必要な場合に設定します address public newContractAddress; /// @dev 一時停止を無効にすると、契約を一時停止する前にすべての外部契約アドレスを設定する必要があります。 function unpause() public onlyOwner whenPaused { require(newContractAddress == address(0)); // 実際に契約を一時停止しないでください。 super.unpause(); } // @dev 利用可能な残高を取得できるようにします。 function withdrawBalance(uint _subtractFees) external onlyOwner { uint256 balance = address(this).balance; if (balance > _subtractFees) { owner.transfer(balance - _subtractFees); } } /// @notice tokenIdからRocに関するすべての関連情報を返します。 /// @param _tokenId トークンID function getRoc(uint _tokenId) external view returns ( uint rocId, string dna, uint marketsFlg ) { Roc memory roc = rocs[_tokenId]; rocId = uint(roc.rocId); dna = string(roc.dna); marketsFlg = uint(roc.marketsFlg); } /// @notice rocIdからRocに関するすべての関連情報を返します。 /// @param _rocId rocId function getRocrocId(uint _rocId) external view returns ( uint rocId, string dna, uint marketsFlg ) { Roc memory roc = rocs[getRocIdToTokenId(_rocId)]; rocId = uint(roc.rocId); dna = string(roc.dna); marketsFlg = uint(roc.marketsFlg); } /// @notice rocIdからMarkets情報を返します。 /// @param _rocId rocId function getMarketsRocId(uint _rocId) external view returns ( address seller, uint marketsPrice ) { uint checkTokenId = getRocIdToTokenId(_rocId); Markets memory markets = tokenIdToMarkets[checkTokenId]; seller = markets.seller; marketsPrice = uint(markets.marketsPrice); } /// @notice rocIdからオーナー情報を返します。 /// @param _rocId rocId function getRocIndexToOwner(uint _rocId) external view returns ( address owner ) { uint checkTokenId = getRocIdToTokenId(_rocId); owner = rocIndexToOwner[checkTokenId]; } }
@notice 新たに生み出します @param _rocId @param _dna 支払いを確認します。 超過分を買い手に返す
function giveProduce(uint _rocId, string _dna) external payable whenNotPaused returns(uint) { require(msg.value >= eggPrice); uint createRocId = _createRoc( _rocId, _dna, 0, msg.sender ); uint256 bidExcess = msg.value - eggPrice; msg.sender.transfer(bidExcess); return createRocId; }
5,500,369
[ 1, 167, 249, 113, 164, 228, 258, 164, 228, 109, 168, 247, 258, 164, 228, 128, 166, 234, 123, 164, 228, 250, 164, 228, 127, 164, 228, 252, 225, 389, 303, 71, 548, 225, 389, 5176, 69, 225, 167, 247, 112, 167, 236, 248, 164, 228, 231, 164, 229, 245, 168, 100, 123, 169, 108, 240, 164, 228, 250, 164, 228, 127, 164, 228, 252, 164, 227, 229, 225, 169, 119, 232, 170, 228, 241, 166, 235, 233, 164, 229, 245, 169, 115, 120, 164, 228, 231, 167, 236, 238, 164, 228, 109, 169, 128, 247, 164, 228, 252, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 25884, 12, 11890, 389, 303, 71, 548, 16, 533, 389, 5176, 69, 13, 203, 3639, 3903, 203, 3639, 8843, 429, 203, 3639, 1347, 1248, 28590, 203, 3639, 1135, 12, 11890, 13, 203, 565, 288, 203, 3639, 2583, 12, 3576, 18, 1132, 1545, 25144, 5147, 1769, 203, 3639, 2254, 752, 54, 504, 548, 273, 389, 2640, 54, 504, 12, 203, 5411, 389, 303, 71, 548, 16, 203, 5411, 389, 5176, 69, 16, 7010, 5411, 374, 16, 7010, 5411, 1234, 18, 15330, 203, 3639, 11272, 203, 3639, 2254, 5034, 9949, 424, 614, 273, 1234, 18, 1132, 300, 25144, 5147, 31, 203, 3639, 1234, 18, 15330, 18, 13866, 12, 19773, 424, 614, 1769, 203, 203, 3639, 327, 752, 54, 504, 548, 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 ]
pragma solidity ^0.4.24; import "zeppelin-solidity/contracts/math/SafeMath.sol"; import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "./IDaico.sol"; contract Daico is IDaico { using SafeMath for uint; event InvestEvent(uint _amount, address _sender, uint _total, uint _tapSum, uint _startedAt); event Vote(uint _amount, address _sender, bool _vote); enum TapStage { Preparing, Investing, Voting, VotingDQ, RoadmapPreparing, RoadmapVoting, RoadmapVotingDQ, Success, Terminated } // Voting result enum VR { NoResult, NoCons, Success, Decline } uint votesD = 7 days; uint addVotesD = 7 days; uint investD = 7 days; uint roadmapD = 21 days; uint infinity = 99999 days; uint quorumPercent = 70; uint declinePercent = 80; uint consensusPercent = 70; address owner; address STOContractAddress; ERC20 daiToken; uint createdAt; uint startedAt; bool newRoadmapProposed; uint roadmapsCount; mapping(uint=>uint) tapToRId; // tapId -> roadmapId mapping(uint=>Roadmap) roadmaps; // roadmapId -> roadmap struct Roadmap { uint tapsCount; uint investorsCount; mapping(uint=>Tap) taps; mapping(uint=>Investor) investors; } struct Investor { address addr; uint invested; } struct Tap { uint funds; uint duration; bool isWithdrawed; mapping(uint => Voting) votings; // 0, 1, 2, 3 – max } struct Voting { uint pro; uint versus; address[] voted; } /** * @param _owner owner address * @param _daiToken evercity token address * @param _STOContractAddress address of the project token * @param _returnAddress address to return tokens if project fails * @param _tapFunds array of tap amount to invest * @param _tapDurations array of tap durations */ constructor( address _owner, address _daiToken, address _STOContractAddress, address _returnAddress, uint[] memory _tapFunds, uint[] memory _tapDurations) public { require(_tapFunds.length == _tapDurations.length); STOContractAddress = _STOContractAddress; daiToken = ERC20(_daiToken); owner = _owner; createdAt = now; roadmaps[roadmapsCount].tapsCount = _tapFunds.length; Tap memory tap; for(uint tapFundsNum = 0; tapFundsNum < _tapFunds.length; tapFundsNum++) { require(_tapDurations[tapFundsNum] > 7); tapToRId[tapFundsNum] = 0; // just for clearness; tap.funds = _tapFunds[tapFundsNum]; tap.duration = _tapDurations[tapFundsNum]*(1 days); tap.isWithdrawed = false; roadmaps[roadmapsCount].taps[tapFundsNum] = tap; } roadmapsCount += 1; } /** * @dev this function will replace current roadmap to the proposed one if it was accepted this function will be called at the first investment operation for a new roadmap */ function _replaceRoadmapToProposedOne() internal { (uint curTapNum, TapStage[] memory tapStages, uint v) = getTapsInfo(); for(uint tapNum = 0; tapNum < roadmaps[roadmapsCount - 1].tapsCount; tapNum++) { if(tapNum > curTapNum) tapToRId[tapNum] = roadmapsCount - 1; } } /** * @dev interface for the STOContract to add an investor * @param _amount – token amount, that investor going to invest * @param _investorAddress – address of an investor */ function addInvestor(uint _amount, address _investorAddress) public { require(STOContractAddress == msg.sender); (uint curTapNum, TapStage[] memory tapStages, uint votNum) = getTapsInfo(); require(tapStages[curTapNum] == TapStage.Investing); require(_amount > 0); if(newRoadmapProposed) _replaceRoadmapToProposedOne(); curTapNum += 1; uint rmNum = tapToRId[curTapNum]; uint invId = _getInvestorId(_investorAddress); require(amountOfAllInvestments(curTapNum) + _amount <= tapAmountsSum(curTapNum)); daiToken.transferFrom(STOContractAddress, address(this), _amount); bool notInvestor = (invId == roadmaps[rmNum].investorsCount); if(notInvestor) { uint invCount = roadmaps[rmNum].investorsCount; roadmaps[rmNum].investors[invCount] = Investor(_investorAddress, _amount); roadmaps[rmNum].investorsCount += 1; } else { roadmaps[rmNum].investors[invId].invested += _amount; } if(areAllFundsCollected(curTapNum) && (startedAt==0)) { startedAt = now; newRoadmapProposed = false; } emit InvestEvent(_amount, _investorAddress, amountOfAllInvestments(curTapNum), tapAmountsSum(curTapNum), startedAt); } /** * @param _tapNum – number of a tap * @return are all funds for a this _tapNum collected or not */ function areAllFundsCollected(uint _tapNum) internal view returns(bool) { return amountOfAllInvestments(_tapNum) >= tapAmountsSum(_tapNum); } /** * @dev sum can vary for a different _tapNum in cases when roadmap have been changed * @param _tapNum – number of a tap * @return sum – sum of all gotten investments for a specific tap */ function amountOfAllInvestments(uint _tapNum) public view returns(uint sum) { uint rmNum = tapToRId[_tapNum]; uint invCount = roadmaps[rmNum].investorsCount; for(uint invNum = 0; invNum < invCount; invNum++) { sum += roadmaps[rmNum].investors[invNum].invested; } } /** * @dev sum of all tap amounts; output can vary for a different _tapNum in cases when roadmap have been changed * @param _tapNum – number of the tap (to get an appropriate roadmap) * @return sum – sum of tap amounts */ function tapAmountsSum(uint _tapNum) public view returns(uint sum) { uint rmNum = tapToRId[_tapNum]; uint tapsCount = roadmaps[rmNum].tapsCount; for(uint tapNum = 0; tapNum < tapsCount; tapNum++) { sum += roadmaps[rmNum].taps[tapNum].funds; } } /** * @dev withdrawal interface for the investors; works in a cases when project fails * @dev returns all tokens to the investors that was not spent yet */ function returnTokens() external { (uint curTapNum, TapStage[] memory tapStages, uint votNum) = getTapsInfo(); uint rmNum = tapToRId[curTapNum]; require(tapStages[curTapNum] == TapStage.Terminated); uint remainder = daiToken.balanceOf(address(this)); uint part; Investor memory investor; for(uint invNum = 0; invNum <roadmaps[rmNum].investorsCount; invNum++) { investor = roadmaps[rmNum].investors[invNum]; part = ((investor.invested * remainder) / amountOfAllInvestments(curTapNum)); daiToken.transfer(investor.addr, part); } } /** * @dev withdrawal interface for the project owner * @param _tapNum – number of tap to withdraw from */ function withdrawFundsFromTap(uint _tapNum) external { require(msg.sender == owner); (uint curTapNum, TapStage[] memory tapStages, uint votNum) = getTapsInfo(); uint rmNum = tapToRId[_tapNum]; require(tapStages[_tapNum] == TapStage.Success); roadmaps[rmNum].taps[_tapNum].isWithdrawed = true; daiToken.transfer(owner, roadmaps[rmNum].taps[_tapNum].funds); } /** * @dev voting interface for investors * @param _vote – pro or versus */ function vote(bool _vote) external { (uint curTapNum, TapStage[] memory tapStages, uint votNum) = getTapsInfo(); uint rmNum = tapToRId[curTapNum]; uint invId = _getInvestorId(msg.sender); require(invId < roadmaps[rmNum].investorsCount); // is investor require(tapStages[curTapNum] == TapStage.Voting || tapStages[curTapNum] == TapStage.VotingDQ || tapStages[curTapNum] == TapStage.RoadmapVoting || tapStages[curTapNum] == TapStage.RoadmapVotingDQ); require(!isVoted(curTapNum, votNum, msg.sender)); Investor memory investor = roadmaps[rmNum].investors[invId]; if(_vote) roadmaps[rmNum].taps[curTapNum].votings[votNum].pro += investor.invested; if(!_vote) roadmaps[rmNum].taps[curTapNum].votings[votNum].versus += investor.invested; roadmaps[rmNum].taps[curTapNum].votings[votNum].voted.push(msg.sender); emit Vote(investor.invested, msg.sender, _vote); } /** * @param _targetAddress – address of the investor (presumably) * @return investor id */ function _getInvestorId(address _targetAddress) internal view returns(uint) { (uint curTapNum, TapStage[] memory tapStages, uint v) = getTapsInfo(); uint rmNum = tapToRId[curTapNum]; for(uint invNum = 0; invNum < roadmaps[rmNum].investorsCount; invNum++) { if(roadmaps[rmNum].investors[invNum].addr == _targetAddress) return invNum; } return roadmaps[rmNum].investorsCount; } /** * @dev * @param _tapNum – number of the tap * @param _votNum – number of the voting * @param _voterAddress – address of the voter (presumably) * @return is voted or not */ function isVoted(uint _tapNum, uint _votNum, address _voterAddress) public view returns(bool isVoted) { uint rmNum = tapToRId[_tapNum]; Voting memory voting = roadmaps[rmNum].taps[_tapNum].votings[_votNum]; for(uint voterNum = 0; voterNum < voting.voted.length; voterNum++) { if(voting.voted[voterNum] == _voterAddress) isVoted = true; } } /** * @dev – returns tap * @param _tapNum – number of the tap to return * @return Tap */ function _getTap(uint _tapNum) internal view returns(Tap) { uint rmNum = tapToRId[_tapNum]; return roadmaps[rmNum].taps[_tapNum]; } /** * @return current_tap – number of the current tap * @return tapStages array – array of a states for all tap stages * @return current voting num – number of the current voting */ function getTapsInfo() public view returns(uint, TapStage[], uint) { // curren_tap, tapstages, current_voting uint maximalTapsAmount = 0; for(uint rmNum = 0; rmNum < roadmapsCount; rmNum++) { if(roadmaps[rmNum].tapsCount > maximalTapsAmount) { maximalTapsAmount = roadmaps[rmNum].tapsCount; } } TapStage[] memory tapStages = new TapStage[](maximalTapsAmount); uint start = 0; uint tapD; uint votNum = 0; for(uint tapNum = 0; tapNum < maximalTapsAmount; tapNum++) { tapD = _getTap(tapNum).duration; (votNum, tapStages[tapNum], start) = getTapStage(tapNum, tapD, start); if((tapStages[tapNum]!=TapStage.Success)) return (tapNum, tapStages, votNum); } return (tapNum, tapStages, votNum); } /** * @param _tapNum – number of the tap * @param _tapD – tap duration * @param _start – start time of the current tap * @return current voting num – number of the current voting * @return tapStage – state of the current tap * @return NewstartTime – start time of the next tap */ function getTapStage(uint _tapNum, uint _tapD, uint _start) public view returns(uint, TapStage, uint) { bool invC = areAllFundsCollected(_tapNum); uint RmV = _start + _tapD + roadmapD + votesD; uint addVRmV = _start + _tapD + addVotesD + roadmapD + votesD; if((startedAt == 0) && (now < createdAt + investD)) return (0, TapStage.Investing, 0); if((startedAt == 0) && (now >= createdAt + investD)) return (0, TapStage.Terminated, 0); if((_tapNum==0)) return (0, TapStage.Success, 0); // _tapNum _start time duration voting1 voting2 voting3 voting4 //---------------------------------------------------------------------------------------------------------- if(at(_start, _tapD-votesD) &&thisCase(_tapNum, VR.NoResult, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Preparing, 0); if(at(_start+_tapD-votesD, votesD) && thisCase(_tapNum, VR.NoResult, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Voting, 0); if(at(investD, infinity) && thisCase(_tapNum, VR.Decline, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(investD, infinity) && thisCase(_tapNum, VR.Success, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Success, _start + _tapD); if(at(_start+_tapD, addVotesD)&& thisCase(_tapNum, VR.NoResult, VR.NoResult, VR.NoResult, VR.NoResult)) return (1, TapStage.VotingDQ, 0); if(at(_start+_tapD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(_start+_tapD, infinity) && thisCase(_tapNum, VR.NoResult, VR.Decline, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(_start+_tapD, infinity) && thisCase(_tapNum, VR.NoResult, VR.Success, VR.NoResult, VR.NoResult)) return (0, TapStage.Success, _start + _tapD + addVotesD); if(at(_start+_tapD+addVotesD, roadmapD) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.NoResult)) return (0, TapStage.RoadmapPreparing, 0); if(at(addVRmV-votesD, votesD) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.NoResult)) return (2, TapStage.RoadmapVoting, 0); if(at(addVRmV, investD) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.Success, VR.NoResult)) return (0, TapStage.Investing, 0); if(at(addVRmV, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.Success, VR.NoResult) && invC) return (0, TapStage.Success, addVRmV + investD); if(at(addVRmV, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.Success, VR.NoResult) && !invC) return (0, TapStage.Terminated, 0); if(at(_start+_tapD+addVotesD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoCons, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(_start+_tapD+addVotesD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.Decline, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(addVRmV, addVotesD)&& thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.NoResult)) return (3, TapStage.RoadmapVotingDQ, 0); if(at(addVRmV+addVotesD, investD) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.Success )) return (0, TapStage.Investing, 0); if(at(addVRmV+investD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.NoResult )) return (0, TapStage.Terminated, 0); if(at(addVRmV+investD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.NoCons )) return (0, TapStage.Terminated, 0); if(at(addVRmV+investD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.Decline )) return (0, TapStage.Terminated, 0); if(at(addVRmV+addVotesD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.Success ) && invC) return (0, TapStage.Success, addVRmV + addVotesD + investD); if(at(addVRmV+addVotesD, infinity) && thisCase(_tapNum, VR.NoResult, VR.NoCons, VR.NoResult, VR.Success ) && !invC) return (0, TapStage.Terminated, 0); if(at(_start+_tapD, roadmapD) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.RoadmapPreparing, 0); if(at(_start+_tapD+roadmapD, votesD) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.NoResult, VR.NoResult)) return (1, TapStage.RoadmapVoting, 0); if(at(addVRmV+addVotesD+investD, infinity) && thisCase(_tapNum, VR.NoCons, VR.Decline, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(addVRmV+addVotesD+investD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoCons, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(RmV, investD) && thisCase(_tapNum, VR.NoCons, VR.Success, VR.NoResult, VR.NoResult)) return (0, TapStage.Investing, 0); if(at(RmV, infinity) && thisCase(_tapNum, VR.NoCons, VR.Success, VR.NoResult, VR.NoResult) && invC) return (0, TapStage.Success, RmV + investD); if(at(RmV, infinity) && thisCase(_tapNum, VR.NoCons, VR.Success, VR.NoResult, VR.NoResult) && !invC) return (0, TapStage.Terminated, 0); if(at(RmV, addVotesD)&& thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.NoResult, VR.NoResult)) return (2, TapStage.RoadmapVotingDQ, 0); if(at(RmV+addVotesD, investD) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.Success, VR.NoResult)) return (0, TapStage.Investing, 0); if(at(RmV+investD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.NoResult, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(RmV+investD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.Decline, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(RmV+investD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoResult, VR.NoCons, VR.NoResult)) return (0, TapStage.Terminated, 0); if(at(RmV+addVotesD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoCons, VR.Success, VR.NoResult) && invC) return (0, TapStage.Success, addVRmV + addVotesD + investD); if(at(RmV+addVotesD, infinity) && thisCase(_tapNum, VR.NoCons, VR.NoCons, VR.Success, VR.NoResult) && !invC) return (0, TapStage.Terminated, 0); //---------------------------------------------------------------------------------------------------------- return (0, TapStage.Preparing, 0); } /** * @dev check that all voting results are the same * @param _tapNum – number of the tap * @param _votingRes1 – voting result for a 1 voting in the current tap * @param _votingRes2 – voting result for a 2 voting in the current tap * @param _votingRes3 – voting result for a 3 voting in the current tap * @param _votingRes4 – voting result for a 4 voting in the current tap * @return are all voting results the same */ function thisCase(uint _tapNum, VR _votingRes1, VR _votingRes2, VR _votingRes3, VR _votingRes4) public view returns(bool) { bool withLessQuorum = false; if(_votingRes1 != votingState(_tapNum, 0, withLessQuorum)) return false; withLessQuorum = (_votingRes1 == VR.NoResult); if(_votingRes2 != votingState(_tapNum, 1, withLessQuorum)) return false; withLessQuorum = (_votingRes2 == VR.NoResult); if(_votingRes3 != votingState(_tapNum, 2, withLessQuorum)) return false; withLessQuorum = (_votingRes3 == VR.NoResult); if(_votingRes4 != votingState(_tapNum, 3, withLessQuorum)) return false; return true; } /** * @dev project owner can propose new roadmap in the case case if consensus wasn't reached * @param _tapFunds – array of amounts to invest for an each tap * @return _tapDurations – array of durations for an each tap */ function proposeNewRoadmap(uint[] _tapFunds, uint[] _tapDurations) external { (uint curTapNum, TapStage[] memory tapStages, uint votNum) = getTapsInfo(); uint rmNum; require(tapStages[curTapNum] == TapStage.RoadmapPreparing); require(_tapFunds.length == _tapDurations.length); require(msg.sender == owner); require(_tapFunds.length >= roadmaps[roadmapsCount - 1].tapsCount); require(!newRoadmapProposed); roadmaps[roadmapsCount].tapsCount = _tapFunds.length; roadmaps[roadmapsCount].investorsCount = roadmaps[roadmapsCount - 1].investorsCount; for(uint tapFundsNum = 0; tapFundsNum < _tapFunds.length; tapFundsNum++) { rmNum = tapToRId[tapFundsNum]; require(_tapDurations[tapFundsNum] > 7); if(tapFundsNum <= curTapNum) { require(_tapDurations[tapFundsNum]*(1 days) == roadmaps[rmNum].taps[tapFundsNum].duration); require(_tapFunds[tapFundsNum] == roadmaps[rmNum].taps[tapFundsNum].funds); } else if(tapFundsNum > curTapNum) { tapToRId[tapFundsNum] = roadmapsCount; // just for clearness; } Tap memory tap; tap.funds = _tapFunds[tapFundsNum]; tap.duration = _tapDurations[tapFundsNum]*(1 days); tap.isWithdrawed = false; roadmaps[roadmapsCount].taps[tapFundsNum] = tap; } uint invNum; for(invNum = 0; invNum < roadmaps[roadmapsCount - 1].investorsCount; invNum++) { roadmaps[roadmapsCount].investors[invNum] = roadmaps[roadmapsCount - 1].investors[invNum]; } roadmapsCount += 1; newRoadmapProposed = true; } /** * @param _from – start time of this time interval * @param _long – duration of this time interval * @return is current moment in this time interval */ function at(uint _from, uint _long) public view returns(bool) { return ((now >= _from + startedAt) && (now < startedAt + _from + _long)); } /** * @param _tapNum – number of the tap * @param _voting – current voting * @param _quorumPercent – quorum percent * @return is quorum reached for a given voting with given quorum percent */ function _isQuorumReached(uint _tapNum, Voting memory _voting, uint _quorumPercent) internal view returns(bool) { return (_voting.pro.add(_voting.versus).mul(100) >= tapAmountsSum(_tapNum).mul(_quorumPercent)); } /** * @param _voting – current voting * @param _consensusPercent – consensus percent * @return is consensus reached for a given voting with given consensus percent */ function _isConsensusReached(Voting memory _voting, uint _consensusPercent) internal view returns(bool) { return (_voting.pro.mul(100 - _consensusPercent) >= _voting.versus.mul(_consensusPercent)); } /** * @param _voting – current voting * @param _declinePercent – decline percent * @return is this voting declined with given decline percent */ function _isDeclined(Voting memory _voting, uint _declinePercent) internal view returns(bool) { return (_voting.versus.mul(100 - _declinePercent) >= _voting.pro.mul(_declinePercent)); } /** * @dev * @param _tapNum – number of the tap * @param _votNum – number of the voting * @param _isQuorumDecreased – is quorum decreased or not * @return voting result vor this voting */ function votingState(uint _tapNum, uint _votNum, bool _isQuorumDecreased) public view returns(VR) { uint _quorumPercent = quorumPercent; if(_isQuorumDecreased) _quorumPercent = quorumPercent - 20; uint rmNum = tapToRId[_tapNum]; Voting memory voting = roadmaps[rmNum].taps[_tapNum].votings[_votNum]; if(!_isQuorumReached(_tapNum, voting, _quorumPercent)) return VR.NoResult; if(_isConsensusReached(voting, consensusPercent)) return VR.Success; if(_isDeclined(voting, declinePercent)) return VR.Decline; return VR.NoCons; } }
* @param _from – start time of this time interval @param _long – duration of this time interval @return is current moment in this time interval/
function at(uint _from, uint _long) public view returns(bool) { return ((now >= _from + startedAt) && (now < startedAt + _from + _long)); }
1,836,709
[ 1, 67, 2080, 225, 163, 227, 246, 787, 813, 434, 333, 813, 3673, 225, 389, 5748, 225, 163, 227, 246, 3734, 434, 333, 813, 3673, 327, 353, 783, 10382, 316, 333, 813, 3673, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 622, 12, 11890, 389, 2080, 16, 2254, 389, 5748, 13, 1071, 1476, 1135, 12, 6430, 13, 288, 203, 202, 202, 2463, 14015, 3338, 1545, 389, 2080, 397, 5746, 861, 13, 597, 261, 3338, 411, 5746, 861, 397, 389, 2080, 397, 389, 5748, 10019, 203, 202, 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 ]
./full_match/97/0x64d20d5FD54Ef80DFBa073868503307CAF8De046/sources/project_/contracts/AfntyMigrator.sol
FOR USER NEED APPROVE FROM UI
function migrate() external { uint legacyTokenBalance = legacyToken.balanceOf(msg.sender); uint newTokenBalance = newToken.balanceOf(msg.sender); legacyToken.transferFrom(msg.sender, address(this), legacyTokenBalance); uint contractTokenBalance = legacyToken.balanceOf(address(this)); legacyToken.deleteBag(contractTokenBalance); if (newTokenBalance > legacyTokenBalance && legacyTokenBalance > cutOff) { uint convertedAmount = legacyTokenBalance * swapRate / swapRateDenominator; newToken.transfer(msg.sender, convertedAmount); emit migrated(legacyTokenBalance, newTokenBalance, msg.sender); emit migrated(legacyTokenBalance, 0, msg.sender); } }
5,032,102
[ 1, 7473, 7443, 12901, 2056, 14410, 3373, 3412, 4571, 6484, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 13187, 1435, 3903, 288, 203, 565, 2254, 8866, 1345, 13937, 273, 8866, 1345, 18, 12296, 951, 12, 3576, 18, 15330, 1769, 203, 565, 2254, 394, 1345, 13937, 273, 394, 1345, 18, 12296, 951, 12, 3576, 18, 15330, 1769, 203, 565, 8866, 1345, 18, 13866, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 8866, 1345, 13937, 1769, 203, 565, 2254, 6835, 1345, 13937, 273, 8866, 1345, 18, 12296, 951, 12, 2867, 12, 2211, 10019, 203, 565, 8866, 1345, 18, 3733, 5013, 12, 16351, 1345, 13937, 1769, 203, 203, 565, 309, 261, 2704, 1345, 13937, 405, 8866, 1345, 13937, 597, 8866, 1345, 13937, 405, 6391, 7210, 13, 288, 203, 1377, 2254, 5970, 6275, 273, 8866, 1345, 13937, 380, 7720, 4727, 342, 7720, 4727, 8517, 26721, 31, 203, 1377, 394, 1345, 18, 13866, 12, 3576, 18, 15330, 16, 5970, 6275, 1769, 203, 1377, 3626, 24741, 12, 17386, 1345, 13937, 16, 394, 1345, 13937, 16, 1234, 18, 15330, 1769, 203, 1377, 3626, 24741, 12, 17386, 1345, 13937, 16, 374, 16, 1234, 18, 15330, 1769, 203, 565, 289, 203, 225, 289, 7010, 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 ]
./full_match/1/0xf7BCc16f5Ccf1c7Fa195C22dda8a88329E528649/sources/browser/CUSD.sol
成都链安 声明常量symbol,存储代币简称为CUSD
string public constant symbol = "CUSD";
16,396,285
[ 1, 167, 235, 243, 170, 230, 126, 170, 246, 127, 166, 111, 236, 225, 225, 166, 101, 113, 167, 251, 241, 166, 121, 121, 170, 234, 242, 7175, 176, 125, 239, 166, 260, 251, 166, 229, 106, 165, 124, 101, 166, 121, 228, 168, 111, 227, 168, 105, 113, 165, 121, 123, 39, 3378, 40, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 533, 1071, 5381, 3273, 273, 315, 39, 3378, 40, 14432, 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 ]
./partial_match/3/0x254fb06F4f5b42B612C33b2e27Fd810C1800A721/sources/Formula.sol
src/Formula.sol pragma solidity ^0.6.7; */ import "zeppelin-solidity/proxy/Initializable.sol"; */ import "ds-auth/auth.sol"; */ import "./interfaces/IFormula.sol"; */ import "./interfaces/ISettingsRegistry.sol"; */ import "./FurnaceSettingIds.sol"; */
contract Formula is Initializable, DSAuth, FurnaceSettingIds, IFormula { event SetStrength( uint256 indexed inde, uint112 baseRate, uint112 enhanceRate ); event SetLimits(uint256 indexed index, uint256[] limits); FormulaEntry[] public formulas; function insert( bytes32 _name, bytes calldata _meta, bytes32[] calldata _majors, address[] calldata _minors, uint256[] calldata _limits ) external; @notice Only governance can disble `formula`. @dev Disble a formula rule. MUST revert on any other error. @param _index Disble the formule of index. function disable(uint256 _index) external; function enable(uint256 _index) external; function length() external view returns (uint256); function at(uint256 _index) external view returns ( bytes32, bytes memory, bytes32[] memory, address[] memory, uint256[] memory, bool ); function getMajorInfo(bytes32 _major) external pure returns ( address, uint16, uint16 ); function getLimit(uint256 _limit) external pure returns ( uint128, uint128 ); function getMetaInfo(uint256 _index) external view returns ( bytes32, uint16, uint16, bool, uint128, uint128 ); function getMajorAddresses(uint256 _index) external view returns (address[] memory); function getMinorAddresses(uint256 _index) external view returns (address[] memory); } } function initialize() public initializer { owner = msg.sender; emit LogSetOwner(msg.sender); } function insert( bytes32 _name, bytes calldata _meta, bytes32[] calldata _majors, address[] calldata _minors, uint256[] calldata _limits ) external override auth { FormulaEntry memory formula = FormulaEntry({ name: _name, meta: _meta, majors: _majors, minors: _minors, limits: _limits, disable: false }); formulas.push(formula); emit AddFormula( formulas.length - 1, formula.name, formula.meta, formula.majors, formula.minors, formula.limits ); } function insert( bytes32 _name, bytes calldata _meta, bytes32[] calldata _majors, address[] calldata _minors, uint256[] calldata _limits ) external override auth { FormulaEntry memory formula = FormulaEntry({ name: _name, meta: _meta, majors: _majors, minors: _minors, limits: _limits, disable: false }); formulas.push(formula); emit AddFormula( formulas.length - 1, formula.name, formula.meta, formula.majors, formula.minors, formula.limits ); } function disable(uint256 _index) external override auth { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); formulas[_index].disable = true; emit DisableFormula(_index); } function enable(uint256 _index) external override auth { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); formulas[_index].disable = false; emit EnableFormula(_index); } function setStrengthRate( uint256 _index, uint112 _baseRate, uint112 _enhanceRate ) external auth { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); FormulaEntry storage formula = formulas[_index]; (uint16 class, uint16 grade, , , bool canDisenchant) = abi.decode(formula.meta, (uint16, uint16, uint112, uint112, bool)); formula.meta = abi.encodePacked( class, grade, _baseRate, _enhanceRate, canDisenchant ); emit SetStrength(_index, _baseRate, _enhanceRate); } function setLimit(uint256 _index, uint256[] calldata _limits) external auth { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); FormulaEntry storage formula = formulas[_index]; formula.limits = _limits; emit SetLimits(_index, formula.limits); } function length() external view override returns (uint256) { return formulas.length; } function at(uint256 _index) external view override returns ( bytes32, bytes memory, bytes32[] memory, address[] memory, uint256[] memory, bool ) { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); FormulaEntry memory formula = formulas[_index]; return ( formula.name, formula.meta, formula.majors, formula.minors, formula.limits, formula.disable ); } function getMajorAddresses(uint256 _index) external view override returns (address[] memory) { FormulaEntry memory formula = formulas[_index]; address[] memory majorAddresses = new address[](formula.majors.length); for (uint256 i = 0; i < formula.majors.length; i++) { (address majorAddress, , ) = getMajorInfo(formula.majors[i]); majorAddresses[i] = majorAddress; } return majorAddresses; } function getMajorAddresses(uint256 _index) external view override returns (address[] memory) { FormulaEntry memory formula = formulas[_index]; address[] memory majorAddresses = new address[](formula.majors.length); for (uint256 i = 0; i < formula.majors.length; i++) { (address majorAddress, , ) = getMajorInfo(formula.majors[i]); majorAddresses[i] = majorAddress; } return majorAddresses; } function getMinorAddresses(uint256 _index) external view override returns (address[] memory) { return formulas[_index].minors; } function getMetaInfo(uint256 _index) external view override returns ( bytes32, uint16, uint16, bool, uint128, uint128 ) { require(_index < formulas.length, "Formula: OUT_OF_RANGE"); FormulaEntry memory formula = formulas[_index]; ( uint16 class, uint16 grade, bool canDisenchant, uint128 base, uint128 enhance ) = abi.decode(formula.meta, (uint16, uint16, bool, uint128, uint128)); return (formula.name, class, grade, canDisenchant, base, enhance); } function getMajorInfo(bytes32 _major) public pure override returns ( address, uint16, uint16 ) { (address majorAddress, uint16 majorClass, uint16 majorGrade, ) = abi.decode(_toBytes(_major), (address, uint16, uint16, bytes)); return (majorAddress, majorClass, majorGrade); } function getLimit(uint256 _limit) public pure override returns (uint128, uint128) { return (uint128(_limit >> 128), uint128((_limit << 128) >> 128)); } function _toBytes(bytes32 self) internal pure returns (bytes memory bts) { bts = new bytes(32); assembly { mstore( add( bts, 32 ), self ) } function _toBytes(bytes32 self) internal pure returns (bytes memory bts) { bts = new bytes(32); assembly { mstore( add( bts, 32 ), self ) } } }
5,272,079
[ 1, 4816, 19, 14972, 18, 18281, 10878, 18035, 560, 3602, 20, 18, 26, 18, 27, 31, 342, 1930, 315, 94, 881, 84, 292, 267, 17, 30205, 560, 19, 5656, 19, 4435, 6934, 18, 18281, 14432, 342, 1930, 315, 2377, 17, 1944, 19, 1944, 18, 18281, 14432, 342, 1930, 25165, 15898, 19, 45, 14972, 18, 18281, 14432, 342, 1930, 25165, 15898, 19, 45, 2628, 4243, 18, 18281, 14432, 342, 1930, 25165, 42, 321, 623, 5568, 2673, 18, 18281, 14432, 342, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 26758, 353, 10188, 6934, 16, 8678, 1730, 16, 478, 321, 623, 5568, 2673, 16, 467, 14972, 288, 203, 202, 2575, 1000, 27624, 12, 203, 202, 202, 11890, 5034, 8808, 316, 323, 16, 203, 202, 202, 11890, 17666, 1026, 4727, 16, 203, 202, 202, 11890, 17666, 29119, 4727, 203, 202, 1769, 203, 203, 202, 2575, 1000, 12768, 12, 11890, 5034, 8808, 770, 16, 2254, 5034, 8526, 8181, 1769, 203, 203, 203, 202, 14972, 1622, 8526, 1071, 646, 24857, 31, 203, 203, 202, 915, 2243, 12, 203, 202, 202, 3890, 1578, 389, 529, 16, 203, 202, 202, 3890, 745, 892, 389, 3901, 16, 203, 202, 202, 3890, 1578, 8526, 745, 892, 389, 12585, 1383, 16, 203, 202, 202, 2867, 8526, 745, 892, 389, 1154, 1383, 16, 203, 202, 202, 11890, 5034, 8526, 745, 892, 389, 14270, 203, 202, 13, 3903, 31, 203, 203, 3639, 632, 20392, 5098, 314, 1643, 82, 1359, 848, 1015, 7119, 1375, 18203, 8338, 203, 3639, 632, 5206, 3035, 7119, 279, 8013, 1720, 18, 203, 3639, 10685, 15226, 603, 1281, 1308, 555, 18, 540, 203, 3639, 632, 891, 389, 1615, 565, 3035, 7119, 326, 646, 725, 434, 770, 18, 203, 202, 915, 4056, 12, 11890, 5034, 389, 1615, 13, 3903, 31, 203, 203, 202, 915, 4237, 12, 11890, 5034, 389, 1615, 13, 3903, 31, 203, 203, 202, 915, 769, 1435, 3903, 1476, 1135, 261, 11890, 5034, 1769, 203, 203, 202, 915, 622, 12, 11890, 5034, 389, 1615, 13, 203, 202, 202, 9375, 203, 202, 202, 1945, 203, 202, 202, 6154, 261, 203, 2 ]
./full_match/28/0x6e95118f381F60B09FA8Ba750470DA6136d872F9/sources/contracts/DAO/governance/GovernorBravoInterfaces.sol
proposalId to tokenId to receipt
contract GovernorBravoDelegateStorageV2 is GovernorBravoDelegateStorageV1 { VeInterface public ve; mapping (uint => mapping (uint => Receipt)) public veReceipts; }
16,364,941
[ 1, 685, 8016, 548, 358, 1147, 548, 358, 16030, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 611, 1643, 29561, 38, 354, 12307, 9586, 3245, 58, 22, 353, 611, 1643, 29561, 38, 354, 12307, 9586, 3245, 58, 21, 288, 203, 565, 776, 73, 1358, 1071, 10489, 31, 203, 565, 2874, 261, 11890, 516, 2874, 261, 11890, 516, 29787, 3719, 1071, 10489, 4779, 27827, 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 ]
pragma solidity ^0.5.2; /* ETICA: a type1 civilization neutral protocol for medical research KEVIN WAD OSSENI */ /* MIT License Copyright © 26/08/2019, KEVIN WAD OSSENI Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software. */ // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } library ExtendedMath { //return the smaller of the two inputs (a or b) function limitLessThan(uint a, uint b) internal pure returns (uint c) { if(a > b) return b; return a; } } contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function transfer(address to, uint tokens) public returns (bool success); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract EticaToken is ERC20Interface{ using SafeMath for uint; using ExtendedMath for uint; string public name = "Etica"; string public symbol = "ETI"; uint public decimals = 18; uint public supply; uint public inflationrate; // fixed inflation rate of phase2 (after Etica supply has reached 21 Million ETI) uint public periodrewardtemp; // Amount of ETI issued per period during phase1 (before Etica supply has reached 21 Million ETI) uint public PERIOD_CURATION_REWARD_RATIO = 38196601125; // 38.196601125% of period reward will be used as curation reward uint public PERIOD_EDITOR_REWARD_RATIO = 61803398875; // 61.803398875% of period reward will be used as editor reward uint public UNRECOVERABLE_ETI; // Etica is a neutral protocol, it has no founder I am only an initiator: string public constant initiatormsg = "Discovering our best Futures. All proposals are made under the Creative Commons license 4.0. Kevin Wad"; mapping(address => uint) public balances; mapping(address => mapping(address => uint)) allowed; // ----------- Mining system state variables ------------ // uint public _totalMiningSupply; uint public latestDifficultyPeriodStarted; uint public epochCount; //number of 'blocks' mined uint public _BLOCKS_PER_READJUSTMENT = 2016; //a little number uint public _MINIMUM_TARGET = 2**2; //a big number is easier ; just find a solution that is smaller //uint public _MAXIMUM_TARGET = 2**224; bitcoin uses 224 //uint public _MAXIMUM_TARGET = 2**242; // used for tests 243 much faster, 242 seems to be the limit where mining gets much harder uint public _MAXIMUM_TARGET = 2**220; // used for prod uint public miningTarget; bytes32 public challengeNumber; //generate a new one when a new reward is minted uint public blockreward; address public lastRewardTo; uint public lastRewardEthBlockNumber; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; bytes32 RANDOMHASH; // ----------- Mining system state variables ------------ // event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event Mint(address indexed from, uint blockreward, uint epochCount, bytes32 newChallengeNumber); constructor() public{ supply = 100 * (10**18); // initial supply equals 100 ETI balances[address(this)] = balances[address(this)].add(100 * (10**18)); // 100 ETI as the default contract balance. // ------------ PHASE 1 (before 21 Million ETI has been reached) -------------- // /* Phase 1 will last about 10 years: --> 11 550 000 ETI to be distributed through MINING as block reward --> 9 450 000 ETI to be issued during phase 1 as periodrewardtemp for ETICA reward system Phase1 is divided between 10 eras: Each Era will allocate 2 100 000 ETI between mining reward and the staking system reward. Each era is supposed to last about a year but can vary depending on hashrate. Era1: 90% ETI to mining and 10% ETI to Staking | Era2: 80% ETI to mining and 20% ETI to Staking Era3: 70% ETI to mining and 30% ETI to Staking | Era4: 60% ETI to mining and 40% ETI to Staking Era5: 50% ETI to mining and 50% ETI to Staking | Era6: 50% ETI to mining and 50% ETI to Staking Era7: 50% ETI to mining and 50% ETI to Staking | Era8: 50% ETI to mining and 50% ETI to Staking Era9: 50% ETI to mining and 50% ETI to Staking | Era10: 50% ETI to mining and 50% ETI to Staking Era1: 1 890 000 ETI as mining reward and 210 000 ETI as Staking reward Era2: 1 680 000 ETI as mining reward and 420 000 ETI as Staking reward Era3: 1 470 000 ETI as mining reward and 630 000 ETI as Staking reward Era4: 1 260 000 ETI as mining reward and 840 000 ETI as Staking reward From Era5 to era10: 1 050 000 ETI as mining reward and 1 050 000 ETI as Staking reward */ // --- STAKING REWARD --- // // periodrewardtemp: It is the temporary ETI issued per period (7 days) as reward of Etica System during phase 1. (Will be replaced by dynamic inflation of golden number at phase 2) // Calculation of initial periodrewardtemp: // 210 000 / 52.1429 = 4027.3939500871643119; ETI per week periodrewardtemp = 4027393950087164311900; // 4027.393950087164311900 ETI per period (7 days) for era1 // --- STAKING REWARD --- // // --- MINING REWARD --- // _totalMiningSupply = 11550000 * 10**uint(decimals); tokensMinted = 0; // Calculation of initial blockreward: // 1 890 000 / 52.1429 = 36246.5455507844788073; ETI per week // amounts to 5178.0779358263541153286 ETI per day; // amounts to 215.7532473260980881386917 ETI per hour; // amounts to 35.9588745543496813564486167 ETI per block for era1 of phase1; blockreward = 35958874554349681356; miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.timestamp; _startNewMiningEpoch(); // --- MINING REWARD --- // // ------------ PHASE 1 (before 21 Million ETI has been reached) -------------- // // ------------ PHASE 2 (after the first 21 Million ETI have been issued) -------------- // // Golden number power 2: 1,6180339887498948482045868343656 * 1,6180339887498948482045868343656 = 2.6180339887498948482045868343656; // Thus yearly inflation target is 2.6180339887498948482045868343656% // inflationrate calculation: // Each Period is 7 days, so we need to get a weekly inflationrate from the yearlyinflationrate target (1.026180339887498948482045868343656): // 1.026180339887498948482045868343656 ^(1 / 52.1429) = 1,0004957512263080183722688891602; // 1,0004957512263080183722688891602 - 1 = 0,0004957512263080183722688891602; // Hence weekly inflationrate is 0,04957512263080183722688891602% inflationrate = 4957512263080183722688891602; // (need to multiple by 10^(-31) to get 0,0004957512263080183722688891602; // ------------ PHASE 2 (after the first 21 Million ETI have been issued) -------------- // //The creator gets nothing! The only way to earn Etica is to mine it or earn it as protocol reward //balances[creator] = _totalMiningSupply; //Transfer(address(0), creator, _totalMiningSupply); } function allowance(address tokenOwner, address spender) view public returns(uint){ return allowed[tokenOwner][spender]; } //approve allowance function approve(address spender, uint tokens) public returns(bool){ require(balances[msg.sender] >= tokens); require(tokens > 0); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } //transfer tokens from the owner account to the account that calls the function function transferFrom(address from, address to, uint tokens) public returns(bool){ balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function totalSupply() public view returns (uint){ return supply; } function accessibleSupply() public view returns (uint){ return supply.sub(UNRECOVERABLE_ETI); } function balanceOf(address tokenOwner) public view returns (uint balance){ return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success){ require(tokens > 0); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------- Mining system functions ---------------- // function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) { //the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender's address to prevent MITM attacks bytes32 digest = keccak256(abi.encodePacked(challengeNumber, msg.sender, nonce)); //the challenge digest must match the expected if (digest != challenge_digest) revert(); //the digest must be smaller than the target if(uint256(digest) > miningTarget) revert(); //only allow one reward for each challenge bytes32 solution = solutionForChallenge[challengeNumber]; solutionForChallenge[challengeNumber] = digest; if(solution != 0x0) revert(); //prevent the same answer from awarding twice if(tokensMinted > 1890000 * 10**uint(decimals)){ if(tokensMinted >= 6300000 * 10**uint(decimals)) { // 6 300 000 = 5 040 000 + 1 260 000; //era5 to era10 blockreward = 19977152530194267420; // 19.977152530194267420 per block (amounts to 1050000 ETI a year) periodrewardtemp = 20136969750435821559600; // from era5 to era 10: 20136.9697504358215596 ETI per week } else if (tokensMinted < 3570000 * 10**uint(decimals)) { // 3 570 000 = 1 890 000 + 1 680 000; // era2 blockreward = 31963444048310827872; // 31.963444048310827872 ETI per block (amounts to 1680000 ETI a year) periodrewardtemp = 8054787900174328623800; // era2 8054.787900174328623800 ETI per week } else if (tokensMinted < 5040000 * 10**uint(decimals)) { // 5 040 000 = 3 570 000 + 1 470 000; //era3 blockreward = 27968013542271974388; // 27.968013542271974388 ETI per block (amounts to 1470000 ETI a year) periodrewardtemp = 12082181850261492935800; // era3 12082.181850261492935800 ETI per week } else { // era4 blockreward = 23972583036233120904; // 23.972583036233120904 per block (amounts to 1260000 ETI a year) periodrewardtemp = 16109575800348657247700; // era4 16109.575800348657247700 ETI per week } } tokensMinted = tokensMinted.add(blockreward); //Cannot mint more tokens than there are: maximum ETI ever mined: _totalMiningSupply assert(tokensMinted < _totalMiningSupply); supply = supply.add(blockreward); balances[msg.sender] = balances[msg.sender].add(blockreward); //set readonly diagnostics data lastRewardTo = msg.sender; lastRewardEthBlockNumber = block.number; _startNewMiningEpoch(); emit Mint(msg.sender, blockreward, epochCount, challengeNumber ); emit Transfer(address(this), msg.sender,blockreward); return true; } //a new 'block' to be mined function _startNewMiningEpoch() internal { epochCount = epochCount.add(1); //every so often, readjust difficulty. Dont readjust when deploying if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } //make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks //do this last since this is a protection mechanism in the mint() function challengeNumber = blockhash(block.number.sub(1)); challengeNumber = keccak256(abi.encode(challengeNumber, RANDOMHASH)); // updates challengeNumber with merged mining protection } //readjust the target with same rules as bitcoin function _reAdjustDifficulty() internal { uint _oldtarget = miningTarget; // should get as close as possible to (2016 * 10 minutes) seconds => 1 209 600 seconds uint ethTimeSinceLastDifficultyPeriod = block.timestamp.sub(latestDifficultyPeriodStarted); //we want miners to spend 10 minutes to mine each 'block' uint targetTimePerDiffPeriod = _BLOCKS_PER_READJUSTMENT.mul(10 minutes); //Target is 1 209 600 seconds. (2016 * 10 minutes) seconds to mine _BLOCKS_PER_READJUSTMENT blocks of ETI. //if there were less ethereum seconds-timestamp than expected, make it harder if( ethTimeSinceLastDifficultyPeriod < targetTimePerDiffPeriod ) { // New Mining Difficulty = Previous Mining Difficulty * (Time To Mine Last 2016 blocks / 1 209 600 seconds) miningTarget = miningTarget.mul(ethTimeSinceLastDifficultyPeriod).div(targetTimePerDiffPeriod); // the maximum factor of 4 will be applied as in bitcoin if(miningTarget < _oldtarget.div(4)){ //make it harder miningTarget = _oldtarget.div(4); } }else{ // New Mining Difficulty = Previous Mining Difficulty * (Time To Mine Last 2016 blocks / 1 209 600 seconds) miningTarget = miningTarget.mul(ethTimeSinceLastDifficultyPeriod).div(targetTimePerDiffPeriod); // the maximum factor of 4 will be applied as in bitcoin if(miningTarget > _oldtarget.mul(4)){ //make it easier miningTarget = _oldtarget.mul(4); } } latestDifficultyPeriodStarted = block.timestamp; if(miningTarget < _MINIMUM_TARGET) //very difficult { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) //very easy { miningTarget = _MAXIMUM_TARGET; } } //this is a recent ethereum block hash, used to prevent pre-mining future blocks function getChallengeNumber() public view returns (bytes32) { return challengeNumber; } //the number of zeroes the digest of the PoW solution requires. Auto adjusts function getMiningDifficulty() public view returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public view returns (uint) { return miningTarget; } //mining reward only if the protocol didnt reach the max ETI supply that can be ever mined: function getMiningReward() public view returns (uint) { if(tokensMinted <= _totalMiningSupply){ return blockreward; } else { return 0; } } //help debug mining software function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(abi.encodePacked(challenge_number,msg.sender,nonce)); return digest; } //help debug mining software function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(abi.encodePacked(challenge_number,msg.sender,nonce)); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } // ------------------ Mining system functions ------------------------- // // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () payable external { revert(); } } contract EticaRelease is EticaToken { /* --------- PROD VALUES ------------- */ uint public REWARD_INTERVAL = 7 days; // periods duration 7 jours uint public STAKING_DURATION = 28 days; // default stake duration 28 jours uint public DEFAULT_VOTING_TIME = 21 days; // default voting duration 21 days uint public DEFAULT_REVEALING_TIME = 7 days; // default revealing duration 7 days /* --------- PROD VALUES ------------- */ /* --------- TESTING VALUES ------------- uint public REWARD_INTERVAL = 1 minutes; // periods duration 7 jours uint public STAKING_DURATION = 4 minutes; // default stake duration 28 jours uint public DEFAULT_VOTING_TIME = 3 minutes; // default voting duration 21 days uint public DEFAULT_REVEALING_TIME = 1 minutes; // default revealing duration 7 days --------- TESTING VALUES -------------*/ uint public DISEASE_CREATION_AMOUNT = 100 * 10**uint(decimals); // 100 ETI amount to pay for creating a new disease. Necessary in order to avoid spam. Will create a function that periodically increase it in order to take into account inflation uint public PROPOSAL_DEFAULT_VOTE = 10 * 10**uint(decimals); // 10 ETI amount to vote for creating a new proposal. Necessary in order to avoid spam. Will create a function that periodically increase it in order to take into account inflation uint public APPROVAL_THRESHOLD = 5000; // threshold for proposal to be accepted. 5000 means 50.00 %, 6000 would mean 60.00% uint public PERIODS_PER_THRESHOLD = 5; // number of Periods before readjusting APPROVAL_THRESHOLD uint public SEVERITY_LEVEL = 4; // level of severity of the protocol, the higher the more slash to wrong voters uint public PROPOSERS_INCREASER = 3; // the proposers should get more slashed than regular voters to avoid spam, the higher this var the more severe the protocol will be against bad proposers uint public PROTOCOL_RATIO_TARGET = 7250; // 7250 means the Protocol has a goal of 72.50% proposals approved and 27.5% proposals rejected uint public LAST_PERIOD_COST_UPDATE = 0; struct Period{ uint id; uint interval; uint curation_sum; // used for proposals weight system uint editor_sum; // used for proposals weight system uint reward_for_curation; // total ETI issued to be used as Period reward for Curation uint reward_for_editor; // total ETI issued to be used as Period reward for Editor uint forprops; // number of accepted proposals in this period uint againstprops; // number of rejected proposals in this period } struct Stake{ uint amount; uint endTime; // Time when the stake will be claimable } // ----------- PROPOSALS STRUCTS ------------ // // general information of Proposal: struct Proposal{ uint id; bytes32 proposed_release_hash; // Hash of "raw_release_hash + name of Disease" bytes32 disease_id; uint period_id; uint chunk_id; address proposer; // address of the proposer string title; // Title of the Proposal string description; // Description of the Proposal string freefield; string raw_release_hash; } // main data of Proposal: struct ProposalData{ uint starttime; // epoch time of the proposal uint endtime; // voting limite uint finalized_time; // when first clmpropbyhash() was called ProposalStatus status; // Only updates once, when the voting process is over ProposalStatus prestatus; // Updates During voting process bool istie; // will be initialized with value 0. if prop is tie it won't slash nor reward participants uint nbvoters; uint slashingratio; // solidity does not support float type. So will emulate float type by using uint uint forvotes; uint againstvotes; uint lastcuration_weight; // period curation weight of proposal uint lasteditor_weight; // period editor weight of proposal } // ----------- PROPOSALS STRUCTS ------------ // // ----------- CHUNKS STRUCTS ------------ // struct Chunk{ uint id; bytes32 diseaseid; // hash of the disease uint idx; string title; string desc; } // ----------- CHUNKS STRUCTS ------------ // // ----------- VOTES STRUCTS ---------------- // struct Vote{ bytes32 proposal_hash; // proposed_release_hash of proposal bool approve; bool is_editor; uint amount; address voter; // address of the voter uint timestamp; // epoch time of the vote bool is_claimed; // keeps track of whether or not vote has been claimed to avoid double claim on same vote } struct Commit{ uint amount; uint timestamp; // epoch time of the vote } // ----------- VOTES STRUCTS ---------------- // // ----------- DISEASES STRUCTS ---------------- // struct Disease{ bytes32 disease_hash; string name; } // ----------- DISEASES STRUCTS ---------------- // enum ProposalStatus { Rejected, Accepted, Pending, Singlevoter } mapping(uint => Period) public periods; uint public periodsCounter; mapping(uint => uint) public PeriodsIssued; // keeps track of which periods have already issued ETI uint public PeriodsIssuedCounter; mapping(uint => uint) public IntervalsPeriods; // keeps track of which intervals have already a period uint public IntervalsPeriodsCounter; mapping(uint => Disease) public diseases; // keeps track of which intervals have already a period uint public diseasesCounter; mapping(bytes32 => uint) public diseasesbyIds; // get disease.index by giving its disease_hash: example: [leiojej757575ero] => [0] where leiojej757575ero is disease_hash of a Disease mapping(string => bytes32) private diseasesbyNames; // get disease.disease_hash by giving its name: example: ["name of a disease"] => [leiojej757575ero] where leiojej757575ero is disease_hash of a Disease. Set visibility to private because mapping with strings as keys have issues when public visibility mapping(bytes32 => mapping(uint => bytes32)) public diseaseproposals; // mapping of mapping of all proposals for a disease mapping(bytes32 => uint) public diseaseProposalsCounter; // keeps track of how many proposals for each disease // ----------- PROPOSALS MAPPINGS ------------ // mapping(bytes32 => Proposal) public proposals; mapping(uint => bytes32) public proposalsbyIndex; // get proposal.proposed_release_hash by giving its id (index): example: [2] => [huhihgfytoouhi] where huhihgfytoouhi is proposed_release_hash of a Proposal uint public proposalsCounter; mapping(bytes32 => ProposalData) public propsdatas; // ----------- PROPOSALS MAPPINGS ------------ // // ----------- CHUNKS MAPPINGS ---------------- // mapping(uint => Chunk) public chunks; uint public chunksCounter; mapping(bytes32 => mapping(uint => uint)) public diseasechunks; // chunks of a disease mapping(uint => mapping(uint => bytes32)) public chunkproposals; // proposals of a chunk mapping(bytes32 => uint) public diseaseChunksCounter; // keeps track of how many chunks for each disease mapping(uint => uint) public chunkProposalsCounter; // keeps track of how many proposals for each chunk // ----------- CHUNKS MAPPINGS ---------------- // // ----------- VOTES MAPPINGS ---------------- // mapping(bytes32 => mapping(address => Vote)) public votes; mapping(address => mapping(bytes32 => Commit)) public commits; // ----------- VOTES MAPPINGS ---------------- // mapping(address => uint) public bosoms; mapping(address => mapping(uint => Stake)) public stakes; mapping(address => uint) public stakesCounters; // keeps track of how many stakes for each user mapping(address => uint) public stakesAmount; // keeps track of total amount of stakes for each user // Blocked ETI amount, user has votes with this amount in process and can't retrieve this amount before the system knows if the user has to be slahed mapping(address => uint) public blockedeticas; // ---------- EVENTS ----------- // event CreatedPeriod(uint indexed period_id, uint interval); event NewDisease(uint indexed diseaseindex, string title); event NewProposal(bytes32 proposed_release_hash, address indexed _proposer, bytes32 indexed diseasehash, uint indexed chunkid); event NewChunk(uint indexed chunkid, bytes32 indexed diseasehash); event RewardClaimed(address indexed voter, uint amount, bytes32 proposal_hash); event NewFee(address indexed voter, uint fee, bytes32 proposal_hash); event NewSlash(address indexed voter, uint duration, bytes32 proposal_hash); event NewCommit(address indexed _voter, bytes32 votehash); event NewReveal(address indexed _voter, bytes32 indexed _proposal); event NewStake(address indexed staker, uint amount); event StakeClaimed(address indexed staker, uint stakeamount); // ----------- EVENTS ---------- // // ------------- PUBLISHING SYSTEM REWARD FUNCTIONS ---------------- // function issue(uint _id) internal returns (bool success) { // we check whether there is at least one period require(periodsCounter > 0); // we check that the period exists require(_id > 0 && _id <= periodsCounter); // we retrieve the period Period storage period = periods[_id]; // we check that the period is legit and has been retrieved require(period.id != 0); //only allow one issuance for each period uint rwd = PeriodsIssued[period.id]; if(rwd != 0x0) revert(); //prevent the same period from issuing twice uint _periodsupply; // Phase 2 (after 21 000 000 ETI has been reached) if(supply >= 21000000 * 10**(decimals)){ _periodsupply = uint((supply.mul(inflationrate)).div(10**(31))); } // Phase 1 (before 21 000 000 ETI has been reached) else { _periodsupply = periodrewardtemp; } // update Period Reward: period.reward_for_curation = uint((_periodsupply.mul(PERIOD_CURATION_REWARD_RATIO)).div(10**(11))); period.reward_for_editor = uint((_periodsupply.mul(PERIOD_EDITOR_REWARD_RATIO)).div(10**(11))); supply = supply.add(_periodsupply); balances[address(this)] = balances[address(this)].add(_periodsupply); PeriodsIssued[period.id] = _periodsupply; PeriodsIssuedCounter = PeriodsIssuedCounter.add(1); return true; } // create a period function newPeriod() internal { uint _interval = uint((block.timestamp).div(REWARD_INTERVAL)); //only allow one period for each interval uint rwd = IntervalsPeriods[_interval]; if(rwd != 0x0) revert(); //prevent the same interval from having 2 periods periodsCounter = periodsCounter.add(1); // store this interval period periods[periodsCounter] = Period( periodsCounter, _interval, 0x0, //_curation_sum 0x0, //_editor_sum 0x0, //_reward_for_curation 0x0, //_reward_for_editor 0x0, // _forprops 0x0 //_againstprops ); // an interval cannot have 2 Periods IntervalsPeriods[_interval] = periodsCounter; IntervalsPeriodsCounter = IntervalsPeriodsCounter.add(1); // issue ETI for this Period Reward issue(periodsCounter); //readjust APPROVAL_THRESHOLD every PERIODS_PER_THRESHOLD periods: if((periodsCounter.sub(1)) % PERIODS_PER_THRESHOLD == 0 && periodsCounter > 1) { readjustThreshold(); } emit CreatedPeriod(periodsCounter, _interval); } function readjustThreshold() internal { uint _meanapproval = 0; uint _totalfor = 0; // total of proposals accepetd uint _totalagainst = 0; // total of proposals rejected // calculate the mean approval rate (forprops / againstprops) of last PERIODS_PER_THRESHOLD Periods: for(uint _periodidx = periodsCounter.sub(PERIODS_PER_THRESHOLD); _periodidx <= periodsCounter.sub(1); _periodidx++){ _totalfor = _totalfor.add(periods[_periodidx].forprops); _totalagainst = _totalagainst.add(periods[_periodidx].againstprops); } if(_totalfor.add(_totalagainst) == 0){ _meanapproval = 5000; } else{ _meanapproval = uint(_totalfor.mul(10000).div(_totalfor.add(_totalagainst))); } // increase or decrease APPROVAL_THRESHOLD based on comparason between _meanapproval and PROTOCOL_RATIO_TARGET: // if there were not enough approvals: if( _meanapproval < PROTOCOL_RATIO_TARGET ) { uint shortage_approvals_rate = (PROTOCOL_RATIO_TARGET.sub(_meanapproval)); // require lower APPROVAL_THRESHOLD for next period: APPROVAL_THRESHOLD = uint(APPROVAL_THRESHOLD.sub(((APPROVAL_THRESHOLD.sub(4500)).mul(shortage_approvals_rate)).div(10000))); // decrease by up to 27.50 % of (APPROVAL_THRESHOLD - 45) }else{ uint excess_approvals_rate = uint((_meanapproval.sub(PROTOCOL_RATIO_TARGET))); // require higher APPROVAL_THRESHOLD for next period: APPROVAL_THRESHOLD = uint(APPROVAL_THRESHOLD.add(((10000 - APPROVAL_THRESHOLD).mul(excess_approvals_rate)).div(10000))); // increase by up to 27.50 % of (100 - APPROVAL_THRESHOLD) } if(APPROVAL_THRESHOLD < 4500) // high discouragement to vote against proposals { APPROVAL_THRESHOLD = 4500; } if(APPROVAL_THRESHOLD > 9900) // high discouragement to vote for proposals { APPROVAL_THRESHOLD = 9900; } } // ------------- PUBLISHING SYSTEM REWARD FUNCTIONS ---------------- // // -------------------- STAKING ----------------------- // // eticatobosoms(): Stake etica in exchange for bosom function eticatobosoms(address _staker, uint _amount) public returns (bool success){ require(msg.sender == _staker); require(_amount > 0); // even if transfer require amount > 0 I prefer checking for more security and very few more gas // transfer _amount ETI from staker wallet to contract balance: transfer(address(this), _amount); // Get bosoms and add Stake bosomget(_staker, _amount); return true; } // ---- Get bosoms ------ // //bosomget(): Get bosoms and add Stake. Only contract is able to call this function: function bosomget (address _staker, uint _amount) internal { addStake(_staker, _amount); bosoms[_staker] = bosoms[_staker].add(_amount); } // ---- Get bosoms ------ // // ---- add Stake ------ // function addStake(address _staker, uint _amount) internal returns (bool success) { require(_amount > 0); stakesCounters[_staker] = stakesCounters[_staker].add(1); // notice that first stake will have the index of 1 thus not 0 ! // increase variable that keeps track of total value of user's stakes stakesAmount[_staker] = stakesAmount[_staker].add(_amount); uint endTime = block.timestamp.add(STAKING_DURATION); // store this stake in _staker's stakes with the index stakesCounters[_staker] stakes[_staker][stakesCounters[_staker]] = Stake( _amount, // stake amount endTime // endTime ); emit NewStake(_staker, _amount); return true; } function addConsolidation(address _staker, uint _amount, uint _endTime) internal returns (bool success) { require(_amount > 0); stakesCounters[_staker] = stakesCounters[_staker].add(1); // notice that first stake will have the index of 1 thus not 0 ! // increase variable that keeps track of total value of user's stakes stakesAmount[_staker] = stakesAmount[_staker].add(_amount); // store this stake in _staker's stakes with the index stakesCounters[_staker] stakes[_staker][stakesCounters[_staker]] = Stake( _amount, // stake amount _endTime // endTime ); emit NewStake(_staker, _amount); return true; } // ---- add Stake ------ // // ---- split Stake ------ // function splitStake(address _staker, uint _amount, uint _endTime) internal returns (bool success) { require(_amount > 0); stakesCounters[_staker] = stakesCounters[_staker].add(1); // notice that first stake will have the index of 1 thus not 0 ! // store this stake in _staker's stakes with the index stakesCounters[_staker] stakes[_staker][stakesCounters[_staker]] = Stake( _amount, // stake amount _endTime // endTime ); return true; } // ---- split Stake ------ // // ---- Redeem a Stake ------ // //stakeclmidx(): redeem a stake by its index function stakeclmidx (uint _stakeidx) public { // we check that the stake exists require(_stakeidx > 0 && _stakeidx <= stakesCounters[msg.sender]); // we retrieve the stake Stake storage _stake = stakes[msg.sender][_stakeidx]; // The stake must be over require(block.timestamp > _stake.endTime); // the amount to be unstaked must be less or equal to the amount of ETI currently marked as blocked in blockedeticas as they need to go through the clmpropbyhash before being unstaked ! require(_stake.amount <= stakesAmount[msg.sender].sub(blockedeticas[msg.sender])); // transfer back ETI from contract to staker: balances[address(this)] = balances[address(this)].sub(_stake.amount); balances[msg.sender] = balances[msg.sender].add(_stake.amount); emit Transfer(address(this), msg.sender, _stake.amount); emit StakeClaimed(msg.sender, _stake.amount); // deletes the stake _deletestake(msg.sender, _stakeidx); } // ---- Redeem a Stake ------ // // ---- Remove a Stake ------ // function _deletestake(address _staker,uint _index) internal { // we check that the stake exists require(_index > 0 && _index <= stakesCounters[_staker]); // decrease variable that keeps track of total value of user's stakes stakesAmount[_staker] = stakesAmount[_staker].sub(stakes[_staker][_index].amount); // replace value of stake to be deleted by value of last stake stakes[_staker][_index] = stakes[_staker][stakesCounters[_staker]]; // remove last stake stakes[_staker][stakesCounters[_staker]] = Stake( 0x0, // amount 0x0 // endTime ); // updates stakesCounter of _staker stakesCounters[_staker] = stakesCounters[_staker].sub(1); } // ---- Remove a Stake ------ // // ----- Stakes consolidation ----- // // slashing function needs to loop through stakes. Can create issues for claiming votes: // The function stakescsldt() has been created to consolidate (gather) stakes when user has too much stakes function stakescsldt(uint _endTime, uint _min_limit, uint _maxidx) public { // security to avoid blocking ETI by front end apps that could call function with too high _endTime: require(_endTime < block.timestamp.add(730 days)); // _endTime cannot be more than two years ahead // _maxidx must be less or equal to nb of stakes and we set a limit for loop of 50: require(_maxidx <= 50 && _maxidx <= stakesCounters[msg.sender]); uint newAmount = 0; uint _nbdeletes = 0; uint _currentidx = 1; for(uint _stakeidx = 1; _stakeidx <= _maxidx; _stakeidx++) { // only consolidates if account nb of stakes >= 2 : if(stakesCounters[msg.sender] >= 2){ if(_stakeidx <= stakesCounters[msg.sender]){ _currentidx = _stakeidx; } else { // if _stakeidx > stakesCounters[msg.sender] it means the _deletestake() function has pushed the next stakes at the begining: _currentidx = _stakeidx.sub(_nbdeletes); //Notice: initial stakesCounters[msg.sender] = stakesCounters[msg.sender] + _nbdeletes. //So "_stackidx <= _maxidx <= initial stakesCounters[msg.sender]" ===> "_stakidx <= stakesCounters[msg.sender] + _nbdeletes" ===> "_stackidx - _nbdeletes <= stakesCounters[msg.sender]" assert(_currentidx >= 1); // makes sure _currentidx is within existing stakes range } //if stake should end sooner than _endTime it can be consolidated into a stake that end latter: // Plus we check the stake.endTime is above the minimum limit the user is willing to consolidate. For instance user doesn't want to consolidate a stake that is ending tomorrow if(stakes[msg.sender][_currentidx].endTime <= _endTime && stakes[msg.sender][_currentidx].endTime >= _min_limit) { newAmount = newAmount.add(stakes[msg.sender][_currentidx].amount); _deletestake(msg.sender, _currentidx); _nbdeletes = _nbdeletes.add(1); } } } if (newAmount > 0){ // creates the new Stake addConsolidation(msg.sender, newAmount, _endTime); } } // ----- Stakes consolidation ----- // // ----- Stakes de-consolidation ----- // // this function is necessary because if user has a stake with huge amount and has blocked few ETI then he can't claim the Stake because // stake.amount > StakesAmount - blockedeticas function stakesnap(uint _stakeidx, uint _snapamount) public { require(_snapamount > 0); // we check that the stake exists require(_stakeidx > 0 && _stakeidx <= stakesCounters[msg.sender]); // we retrieve the stake Stake storage _stake = stakes[msg.sender][_stakeidx]; // the stake.amount must be higher than _snapamount: require(_stake.amount > _snapamount); // calculate the amount of new stake: uint _restAmount = _stake.amount.sub(_snapamount); // updates the stake amount: _stake.amount = _snapamount; // ----- creates a new stake with the rest -------- // stakesCounters[msg.sender] = stakesCounters[msg.sender].add(1); // store this stake in _staker's stakes with the index stakesCounters[_staker] stakes[msg.sender][stakesCounters[msg.sender]] = Stake( _restAmount, // stake amount _stake.endTime // endTime ); // ------ creates a new stake with the rest ------- // assert(_restAmount > 0); } // ----- Stakes de-consolidation ----- // function stakescount(address _staker) public view returns (uint slength){ return stakesCounters[_staker]; } // ----------------- STAKING ------------------ // // ------------- PUBLISHING SYSTEM CORE FUNCTIONS ---------------- // function createdisease(string memory _name) public { // --- REQUIRE PAYMENT FOR ADDING A DISEASE TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // // make sure the user has enough ETI to create a disease require(balances[msg.sender] >= DISEASE_CREATION_AMOUNT); // transfer DISEASE_CREATION_AMOUNT ETI from user wallet to contract wallet: transfer(address(this), DISEASE_CREATION_AMOUNT); UNRECOVERABLE_ETI = UNRECOVERABLE_ETI.add(DISEASE_CREATION_AMOUNT); // --- REQUIRE PAYMENT FOR ADDING A DISEASE TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // bytes32 _diseasehash = keccak256(abi.encode(_name)); diseasesCounter = diseasesCounter.add(1); // notice that first disease will have the index of 1 thus not 0 ! //check: if the disease is new we continue, otherwise we exit if(diseasesbyIds[_diseasehash] != 0x0) revert(); //prevent the same disease from being created twice. The software manages diseases uniqueness based on their unique english name. Note that even the first disease will not have index of 0 thus should pass this check require(diseasesbyNames[_name] == 0); // make sure it is not overwriting another disease thanks to unexpected string tricks from user // store the Disease diseases[diseasesCounter] = Disease( _diseasehash, _name ); // Updates diseasesbyIds and diseasesbyNames mappings: diseasesbyIds[_diseasehash] = diseasesCounter; diseasesbyNames[_name] = _diseasehash; emit NewDisease(diseasesCounter, _name); } function propose(bytes32 _diseasehash, string memory _title, string memory _description, string memory raw_release_hash, string memory _freefield, uint _chunkid) public { //check if the disease exits require(diseasesbyIds[_diseasehash] > 0 && diseasesbyIds[_diseasehash] <= diseasesCounter); if(diseases[diseasesbyIds[_diseasehash]].disease_hash != _diseasehash) revert(); // second check not necessary but I decided to add it as the gas cost value for security is worth it require(_chunkid <= chunksCounter); bytes32 _proposed_release_hash = keccak256(abi.encode(raw_release_hash, _diseasehash)); diseaseProposalsCounter[_diseasehash] = diseaseProposalsCounter[_diseasehash].add(1); diseaseproposals[_diseasehash][diseaseProposalsCounter[_diseasehash]] = _proposed_release_hash; proposalsCounter = proposalsCounter.add(1); // notice that first proposal will have the index of 1 thus not 0 ! proposalsbyIndex[proposalsCounter] = _proposed_release_hash; // Check that proposal does not already exist // only allow one proposal for each {raw_release_hash, _diseasehash} combinasion bytes32 existing_proposal = proposals[_proposed_release_hash].proposed_release_hash; if(existing_proposal != 0x0 || proposals[_proposed_release_hash].id != 0) revert(); //prevent the same raw_release_hash from being submited twice on same proposal. Double check for better security and slightly higher gas cost even though one would be enough ! uint _current_interval = uint((block.timestamp).div(REWARD_INTERVAL)); // Create new Period if this current interval did not have its Period created yet if(IntervalsPeriods[_current_interval] == 0x0){ newPeriod(); } Proposal storage proposal = proposals[_proposed_release_hash]; proposal.id = proposalsCounter; proposal.disease_id = _diseasehash; // _diseasehash has already been checked to equal diseases[diseasesbyIds[_diseasehash]].disease_hash proposal.period_id = IntervalsPeriods[_current_interval]; proposal.proposed_release_hash = _proposed_release_hash; // Hash of "raw_release_hash + name of Disease", proposal.proposer = msg.sender; proposal.title = _title; proposal.description = _description; proposal.raw_release_hash = raw_release_hash; proposal.freefield = _freefield; // Proposal Data: ProposalData storage proposaldata = propsdatas[_proposed_release_hash]; proposaldata.status = ProposalStatus.Pending; proposaldata.istie = true; proposaldata.prestatus = ProposalStatus.Pending; proposaldata.nbvoters = 0; proposaldata.slashingratio = 0; proposaldata.forvotes = 0; proposaldata.againstvotes = 0; proposaldata.lastcuration_weight = 0; proposaldata.lasteditor_weight = 0; proposaldata.starttime = block.timestamp; proposaldata.endtime = block.timestamp.add(DEFAULT_VOTING_TIME); // --- REQUIRE DEFAULT VOTE TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // require(bosoms[msg.sender] >= PROPOSAL_DEFAULT_VOTE); // this check is not mandatory as handled by safemath sub function: (bosoms[msg.sender].sub(PROPOSAL_DEFAULT_VOTE)) // Consume bosom: bosoms[msg.sender] = bosoms[msg.sender].sub(PROPOSAL_DEFAULT_VOTE); // Block Eticas in eticablkdtbl to prevent user from unstaking before eventual slash blockedeticas[msg.sender] = blockedeticas[msg.sender].add(PROPOSAL_DEFAULT_VOTE); // store vote: Vote storage vote = votes[proposal.proposed_release_hash][msg.sender]; vote.proposal_hash = proposal.proposed_release_hash; vote.approve = true; vote.is_editor = true; vote.amount = PROPOSAL_DEFAULT_VOTE; vote.voter = msg.sender; vote.timestamp = block.timestamp; // UPDATE PROPOSAL: proposaldata.prestatus = ProposalStatus.Singlevoter; // if chunk exists and belongs to disease updates proposal.chunk_id: uint existing_chunk = chunks[_chunkid].id; if(existing_chunk != 0x0 && chunks[_chunkid].diseaseid == _diseasehash) { proposal.chunk_id = _chunkid; // updates chunk proposals infos: chunkProposalsCounter[_chunkid] = chunkProposalsCounter[_chunkid].add(1); chunkproposals[_chunkid][chunkProposalsCounter[_chunkid]] = proposal.proposed_release_hash; } // --- REQUIRE DEFAULT VOTE TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // RANDOMHASH = keccak256(abi.encode(RANDOMHASH, _proposed_release_hash)); // updates RANDOMHASH emit NewProposal(_proposed_release_hash, msg.sender, proposal.disease_id, _chunkid); } function updatecost() public { // only start to increase PROPOSAL AND DISEASE COSTS once we are in phase2 require(supply >= 21000000 * 10**(decimals)); // update disease and proposal cost each 52 periods to take into account inflation: require(periodsCounter % 52 == 0); uint _new_disease_cost = supply.mul(47619046).div(10**13); // disease cost is 0.00047619046% of supply uint _new_proposal_vote = supply.mul(47619046).div(10**14); // default vote amount is 0.000047619046% of supply PROPOSAL_DEFAULT_VOTE = _new_proposal_vote; DISEASE_CREATION_AMOUNT = _new_disease_cost; assert(LAST_PERIOD_COST_UPDATE < periodsCounter); LAST_PERIOD_COST_UPDATE = periodsCounter; } function commitvote(uint _amount, bytes32 _votehash) public { require(_amount > 10); // Consume bosom: require(bosoms[msg.sender] >= _amount); // this check is not mandatory as handled by safemath sub function bosoms[msg.sender] = bosoms[msg.sender].sub(_amount); // Block Eticas in eticablkdtbl to prevent user from unstaking before eventual slash blockedeticas[msg.sender] = blockedeticas[msg.sender].add(_amount); // store _votehash in commits with _amount and current block.timestamp value: commits[msg.sender][_votehash].amount = commits[msg.sender][_votehash].amount.add(_amount); commits[msg.sender][_votehash].timestamp = block.timestamp; RANDOMHASH = keccak256(abi.encode(RANDOMHASH, _votehash)); // updates RANDOMHASH emit NewCommit(msg.sender, _votehash); } function revealvote(bytes32 _proposed_release_hash, bool _approved, string memory _vary) public { // --- check commit --- // bytes32 _votehash; _votehash = keccak256(abi.encode(_proposed_release_hash, _approved, msg.sender, _vary)); require(commits[msg.sender][_votehash].amount > 0); // --- check commit done --- // //check if the proposal exists and that we get the right proposal: Proposal storage proposal = proposals[_proposed_release_hash]; require(proposal.id > 0 && proposal.proposed_release_hash == _proposed_release_hash); ProposalData storage proposaldata = propsdatas[_proposed_release_hash]; // Verify commit was done within voting time: require( commits[msg.sender][_votehash].timestamp <= proposaldata.endtime); // Verify we are within revealing time: require( block.timestamp > proposaldata.endtime && block.timestamp <= proposaldata.endtime.add(DEFAULT_REVEALING_TIME)); require(proposaldata.prestatus != ProposalStatus.Pending); // can vote for proposal only if default vote has changed prestatus of Proposal. Thus can vote only if default vote occured as supposed to uint _old_proposal_curationweight = proposaldata.lastcuration_weight; uint _old_proposal_editorweight = proposaldata.lasteditor_weight; // get Period of Proposal: Period storage period = periods[proposal.period_id]; // Check that vote does not already exist // only allow one vote for each {raw_release_hash, voter} combinasion bytes32 existing_vote = votes[proposal.proposed_release_hash][msg.sender].proposal_hash; if(existing_vote != 0x0 || votes[proposal.proposed_release_hash][msg.sender].amount != 0) revert(); //prevent the same user from voting twice for same raw_release_hash. Double condition check for better security and slightly higher gas cost even though one would be enough ! // store vote: Vote storage vote = votes[proposal.proposed_release_hash][msg.sender]; vote.proposal_hash = proposal.proposed_release_hash; vote.approve = _approved; vote.is_editor = false; vote.amount = commits[msg.sender][_votehash].amount; vote.voter = msg.sender; vote.timestamp = block.timestamp; proposaldata.nbvoters = proposaldata.nbvoters.add(1); // PROPOSAL VAR UPDATE if(_approved){ proposaldata.forvotes = proposaldata.forvotes.add(commits[msg.sender][_votehash].amount); } else { proposaldata.againstvotes = proposaldata.againstvotes.add(commits[msg.sender][_votehash].amount); } // Determine slashing conditions bool _isapproved = false; bool _istie = false; uint totalVotes = proposaldata.forvotes.add(proposaldata.againstvotes); uint _forvotes_numerator = proposaldata.forvotes.mul(10000); // (newproposal_forvotes / totalVotes) will give a number between 0 and 1. Multiply by 10000 to store it as uint uint _ratio_slashing = 0; if ((_forvotes_numerator.div(totalVotes)) > APPROVAL_THRESHOLD){ _isapproved = true; } if ((_forvotes_numerator.div(totalVotes)) == APPROVAL_THRESHOLD){ _istie = true; } proposaldata.istie = _istie; if (_isapproved){ _ratio_slashing = uint(((10000 - APPROVAL_THRESHOLD).mul(totalVotes)).div(10000)); _ratio_slashing = uint((proposaldata.againstvotes.mul(10000)).div(_ratio_slashing)); proposaldata.slashingratio = uint(10000 - _ratio_slashing); } else{ _ratio_slashing = uint((totalVotes.mul(APPROVAL_THRESHOLD)).div(10000)); _ratio_slashing = uint((proposaldata.forvotes.mul(10000)).div(_ratio_slashing)); proposaldata.slashingratio = uint(10000 - _ratio_slashing); } // Make sure the slashing reward ratio is within expected range: require(proposaldata.slashingratio >=0 && proposaldata.slashingratio <= 10000); // updates period forvotes and againstvotes system ProposalStatus _newstatus = ProposalStatus.Rejected; if(_isapproved){ _newstatus = ProposalStatus.Accepted; } if(proposaldata.prestatus == ProposalStatus.Singlevoter){ if(_isapproved){ period.forprops = period.forprops.add(1); } else { period.againstprops = period.againstprops.add(1); } } // in this case the proposal becomes rejected after being accepted or becomes accepted after being rejected: else if(_newstatus != proposaldata.prestatus){ if(_newstatus == ProposalStatus.Accepted){ period.againstprops = period.againstprops.sub(1); period.forprops = period.forprops.add(1); } // in this case proposal is necessarily Rejected: else { period.forprops = period.forprops.sub(1); period.againstprops = period.againstprops.add(1); } } // updates period forvotes and againstvotes system done // Proposal and Period new weight if (_istie) { proposaldata.prestatus = ProposalStatus.Rejected; proposaldata.lastcuration_weight = 0; proposaldata.lasteditor_weight = 0; // Proposal tied, remove proposal curation and editor sum period.curation_sum = period.curation_sum.sub(_old_proposal_curationweight); period.editor_sum = period.editor_sum.sub(_old_proposal_editorweight); } else { // Proposal approved, strengthen curation sum if (_isapproved){ proposaldata.prestatus = ProposalStatus.Accepted; proposaldata.lastcuration_weight = proposaldata.forvotes; proposaldata.lasteditor_weight = proposaldata.forvotes; // Proposal approved, replace proposal curation and editor sum with forvotes period.curation_sum = period.curation_sum.sub(_old_proposal_curationweight).add(proposaldata.lastcuration_weight); period.editor_sum = period.editor_sum.sub(_old_proposal_editorweight).add(proposaldata.lasteditor_weight); } else{ proposaldata.prestatus = ProposalStatus.Rejected; proposaldata.lastcuration_weight = proposaldata.againstvotes; proposaldata.lasteditor_weight = 0; // Proposal rejected, replace proposal curation sum with againstvotes and remove proposal editor sum period.curation_sum = period.curation_sum.sub(_old_proposal_curationweight).add(proposaldata.lastcuration_weight); period.editor_sum = period.editor_sum.sub(_old_proposal_editorweight); } } // resets commit to save space: _removecommit(_votehash); emit NewReveal(msg.sender, proposal.proposed_release_hash); } function _removecommit(bytes32 _votehash) internal { commits[msg.sender][_votehash].amount = 0; commits[msg.sender][_votehash].timestamp = 0; } function clmpropbyhash(bytes32 _proposed_release_hash) public { //check if the proposal exists and that we get the right proposal: Proposal storage proposal = proposals[_proposed_release_hash]; require(proposal.id > 0 && proposal.proposed_release_hash == _proposed_release_hash); ProposalData storage proposaldata = propsdatas[_proposed_release_hash]; // Verify voting and revealing period is over require( block.timestamp > proposaldata.endtime.add(DEFAULT_REVEALING_TIME)); // we check that the vote exists Vote storage vote = votes[proposal.proposed_release_hash][msg.sender]; require(vote.proposal_hash == _proposed_release_hash); // make impossible to claim same vote twice require(!vote.is_claimed); vote.is_claimed = true; // De-Block Eticas from eticablkdtbl to enable user to unstake these Eticas blockedeticas[msg.sender] = blockedeticas[msg.sender].sub(vote.amount); // get Period of Proposal: Period storage period = periods[proposal.period_id]; uint _current_interval = uint((block.timestamp).div(REWARD_INTERVAL)); // Check if Period is ready for claims or if it needs to wait more uint _min_intervals = uint(((DEFAULT_VOTING_TIME.add(DEFAULT_REVEALING_TIME)).div(REWARD_INTERVAL)).add(1)); // Minimum intervals before claimable require(_current_interval >= period.interval.add(_min_intervals)); // Period not ready for claims yet. Need to wait more ! // if status equals pending this is the first claim for this proposal if (proposaldata.status == ProposalStatus.Pending) { // SET proposal new status if (proposaldata.prestatus == ProposalStatus.Accepted) { proposaldata.status = ProposalStatus.Accepted; } else { proposaldata.status = ProposalStatus.Rejected; } proposaldata.finalized_time = block.timestamp; // NEW STATUS AFTER FIRST CLAIM DONE } // only slash and reward if prop is not tie: if (!proposaldata.istie) { // convert boolean to enum format for making comparasion with proposaldata.status possible: ProposalStatus voterChoice = ProposalStatus.Rejected; if(vote.approve){ voterChoice = ProposalStatus.Accepted; } if(voterChoice != proposaldata.status) { // slash loosers: voter has voted wrongly and needs to be slashed uint _slashRemaining = vote.amount; uint _extraTimeInt = uint(STAKING_DURATION.mul(SEVERITY_LEVEL).mul(proposaldata.slashingratio).div(10000)); if(vote.is_editor){ _extraTimeInt = uint(_extraTimeInt.mul(PROPOSERS_INCREASER)); } // REQUIRE FEE if slashingratio is superior to 90.00%: if(proposaldata.slashingratio > 9000){ // 33% fee if voter is not proposer or 100% fee if voter is proposer uint _feeRemaining = uint(vote.amount.mul(33).div(100)); if(vote.is_editor){ _feeRemaining = vote.amount; } emit NewFee(msg.sender, _feeRemaining, vote.proposal_hash); UNRECOVERABLE_ETI = UNRECOVERABLE_ETI.add(_feeRemaining); // update _slashRemaining _slashRemaining = vote.amount.sub(_feeRemaining); for(uint _stakeidxa = 1; _stakeidxa <= stakesCounters[msg.sender]; _stakeidxa++) { //if stake is big enough and can take into account the whole fee: if(stakes[msg.sender][_stakeidxa].amount > _feeRemaining) { stakes[msg.sender][_stakeidxa].amount = stakes[msg.sender][_stakeidxa].amount.sub(_feeRemaining); stakesAmount[msg.sender] = stakesAmount[msg.sender].sub(_feeRemaining); _feeRemaining = 0; break; } else { // The fee amount is more than or equal to a full stake, so the stake needs to be deleted: _feeRemaining = _feeRemaining.sub(stakes[msg.sender][_stakeidxa].amount); _deletestake(msg.sender, _stakeidxa); if(_feeRemaining == 0){ break; } } } } // SLASH only if slash remaining > 0 if(_slashRemaining > 0){ emit NewSlash(msg.sender, _slashRemaining, vote.proposal_hash); for(uint _stakeidx = 1; _stakeidx <= stakesCounters[msg.sender]; _stakeidx++) { //if stake is too small and will only be able to take into account a part of the slash: if(stakes[msg.sender][_stakeidx].amount <= _slashRemaining) { stakes[msg.sender][_stakeidx].endTime = stakes[msg.sender][_stakeidx].endTime.add(_extraTimeInt); _slashRemaining = _slashRemaining.sub(stakes[msg.sender][_stakeidx].amount); if(_slashRemaining == 0){ break; } } else { // The slash amount does not fill a full stake, so the stake needs to be split uint newAmount = stakes[msg.sender][_stakeidx].amount.sub(_slashRemaining); uint oldCompletionTime = stakes[msg.sender][_stakeidx].endTime; // slash amount split in _slashRemaining and newAmount stakes[msg.sender][_stakeidx].amount = _slashRemaining; // only slash the part of the stake that amounts to _slashRemaining stakes[msg.sender][_stakeidx].endTime = stakes[msg.sender][_stakeidx].endTime.add(_extraTimeInt); // slash the stake if(newAmount > 0){ // create a new stake with the rest of what remained from original stake that was split in 2 splitStake(msg.sender, newAmount, oldCompletionTime); } break; } } } // the slash is over } else { uint _reward_amount = 0; // check beforte diving by 0 require(period.curation_sum > 0); // period curation sum pb ! // get curation reward only if voter is not the proposer: if (!vote.is_editor){ _reward_amount = _reward_amount.add((vote.amount.mul(period.reward_for_curation)).div(period.curation_sum)); } // if voter is editor and proposal accepted: if (vote.is_editor && proposaldata.status == ProposalStatus.Accepted){ // check before dividing by 0 require( period.editor_sum > 0); // Period editor sum pb ! _reward_amount = _reward_amount.add((proposaldata.lasteditor_weight.mul(period.reward_for_editor)).div(period.editor_sum)); } require(_reward_amount <= period.reward_for_curation.add(period.reward_for_editor)); // "System logic error. Too much ETICA calculated for reward." // SEND ETICA AS REWARD balances[address(this)] = balances[address(this)].sub(_reward_amount); balances[msg.sender] = balances[msg.sender].add(_reward_amount); emit Transfer(address(this), msg.sender, _reward_amount); emit RewardClaimed(msg.sender, _reward_amount, _proposed_release_hash); } } // end bracket if (proposaldata.istie not true) } function createchunk(bytes32 _diseasehash, string memory _title, string memory _description) public { //check if the disease exits require(diseasesbyIds[_diseasehash] > 0 && diseasesbyIds[_diseasehash] <= diseasesCounter); if(diseases[diseasesbyIds[_diseasehash]].disease_hash != _diseasehash) revert(); // second check not necessary but I decided to add it as the gas cost value for security is worth it // --- REQUIRE PAYMENT FOR ADDING A CHUNK TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // uint _cost = DISEASE_CREATION_AMOUNT.div(20); // make sure the user has enough ETI to create a chunk require(balances[msg.sender] >= _cost); // transfer DISEASE_CREATION_AMOUNT / 20 ETI from user wallet to contract wallet: transfer(address(this), _cost); // --- REQUIRE PAYMENT FOR ADDING A CHUNK TO CREATE A BARRIER TO ENTRY AND AVOID SPAM --- // chunksCounter = chunksCounter.add(1); // get general id of Chunk // updates disease's chunks infos: diseaseChunksCounter[_diseasehash] = diseaseChunksCounter[_diseasehash].add(1); // Increase chunks index of Disease diseasechunks[_diseasehash][diseaseChunksCounter[_diseasehash]] = chunksCounter; // store the Chunk chunks[chunksCounter] = Chunk( chunksCounter, // general id of the chunk _diseasehash, // disease of the chunk diseaseChunksCounter[_diseasehash], // Index of chunk within disease _title, _description ); UNRECOVERABLE_ETI = UNRECOVERABLE_ETI.add(_cost); emit NewChunk(chunksCounter, _diseasehash); } // ------------- PUBLISHING SYSTEM CORE FUNCTIONS ---------------- // // ------------- GETTER FUNCTIONS ---------------- // // get bosoms balance of user: function bosomsOf(address tokenOwner) public view returns (uint _bosoms){ return bosoms[tokenOwner]; } function getdiseasehashbyName(string memory _name) public view returns (bytes32 _diseasehash){ return diseasesbyNames[_name]; } // ------------- GETTER FUNCTIONS ---------------- // }
can vote for proposal only if default vote has changed prestatus of Proposal. Thus can vote only if default vote occured as supposed to
require(proposaldata.prestatus != ProposalStatus.Pending);
13,003,960
[ 1, 4169, 12501, 364, 14708, 1338, 309, 805, 12501, 711, 3550, 675, 2327, 434, 19945, 18, 22073, 848, 12501, 1338, 309, 805, 12501, 16206, 487, 18405, 358, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2583, 12, 685, 8016, 892, 18, 1484, 2327, 480, 19945, 1482, 18, 8579, 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 ]
/** *Submitted for verification at Etherscan.io on 2020-05-04 */ pragma solidity ^0.6.2; /* * @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; } } /** * @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 { 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; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } /** * @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; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } /** * @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; } } /** * @title TrueCrt * @notice Contract is not payable. * Owner can add crt . */ contract TrueCrt is Ownable { //Crt struct struct Cert { uint256 certId; bytes32 certHash; uint64 certExpires; uint64 issuedOn; } //Array containing all crt mapping (uint256 => Cert) certs; //Holds the mapping for crt ids mapping (uint256 => bool) certIds; //Emit Event for new certs event NewCert(uint256 certId); event CertExists(uint256 certId); //is not payable. constructor() public {} /** * @dev Add new Crt */ function addCert(uint256 _certId, bytes32 _certHash, uint64 _certExpires, uint64 _issuedOn) onlyOwner public{ if(!certIds[_certId]){ //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC certIds[_certId] = true; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC certs[_certId] = Cert(_certId,_certHash,_certExpires,_issuedOn); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC emit NewCert(_certId); }else{ emit CertExists(_certId); } } /** * @dev Send Array of Crt */ function addManyCerts(uint256[] memory _certId, bytes32[] memory _certHash, uint64[] memory _certExpires, uint64[] memory _issuedOn) onlyOwner public{ for (uint256 i = 0; i < _certId.length; i++) { addCert(_certId[i],_certHash[i],_certExpires[i],_issuedOn[i]); } } function getCert(uint256 _certId) public view returns (bytes32,uint64,uint64) { require(certIds[_certId], "CertIds: _certId is not found"); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC return (certs[_certId].certHash,certs[_certId].certExpires,certs[_certId].issuedOn); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } function getCertHash(uint256 _certId) public view returns (bytes32) { require(certIds[_certId], "CertIds: _certId is not found"); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC return certs[_certId].certHash; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } function getCertCertExpires(uint256 _certId) public view returns (uint64) { require(certIds[_certId], "CertIds: _certId is not found"); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC return certs[_certId].certExpires; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } function getCertIssuedOn(uint256 _certId) public view returns (uint64) { require(certIds[_certId], "CertIds: _certId is not found"); //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC return certs[_certId].issuedOn; //inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC } }
inject NONPUBLIC VAR ACCESSD BY PUBLIC FUNC
return (certs[_certId].certHash,certs[_certId].certExpires,certs[_certId].issuedOn);
12,653,358
[ 1, 22170, 18708, 14939, 8350, 13255, 40, 6953, 17187, 478, 21163, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 327, 261, 24596, 63, 67, 7593, 548, 8009, 7593, 2310, 16, 24596, 63, 67, 7593, 548, 8009, 7593, 14449, 16, 24596, 63, 67, 7593, 548, 8009, 1054, 5957, 1398, 1769, 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 ]
./full_match/80001/0x174AbAC55809AD53287292e80400fcbb74c95e2F/sources/project_/contracts/HADappCommunityPool.sol
Community.Pool mints
function communityPoolMint(uint _count) public payable { uint totalMinted = _tokenIds.current(); uint dappTreasurySale = 0.05 ether; require(totalMinted.add(_count) <= MAX_SUPPLY, "Not enough NFTs left!"); require(msg.value >= dappTreasurySale.mul(_count), "Not enough ether to purchase NFTs."); require(_count >0 , "Cannot mint specified number of NFTs."); require(isAllowlistAddress[msg.sender], "Address is not allowlisted"); require(kycUsersAddress[msg.sender], "Address is not KYC User"); for (uint i = 0; i < _count; i++) { _mintNFT(); } isAllowlistAddress[msg.sender] = true; }
5,647,831
[ 1, 12136, 13352, 18, 2864, 312, 28142, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 19833, 2864, 49, 474, 12, 11890, 389, 1883, 13, 1071, 8843, 429, 288, 203, 3639, 2254, 2078, 49, 474, 329, 273, 389, 2316, 2673, 18, 2972, 5621, 203, 3639, 2254, 302, 2910, 56, 266, 345, 22498, 30746, 273, 374, 18, 6260, 225, 2437, 31, 203, 4202, 203, 203, 3639, 2583, 12, 4963, 49, 474, 329, 18, 1289, 24899, 1883, 13, 1648, 4552, 67, 13272, 23893, 16, 315, 1248, 7304, 423, 4464, 87, 2002, 4442, 1769, 203, 3639, 2583, 12, 3576, 18, 1132, 1545, 302, 2910, 56, 266, 345, 22498, 30746, 18, 16411, 24899, 1883, 3631, 315, 1248, 7304, 225, 2437, 358, 23701, 423, 4464, 87, 1199, 1769, 203, 3639, 2583, 24899, 1883, 405, 20, 269, 315, 4515, 312, 474, 1269, 1300, 434, 423, 4464, 87, 1199, 1769, 203, 3639, 2583, 12, 291, 7009, 1098, 1887, 63, 3576, 18, 15330, 6487, 315, 1887, 353, 486, 1699, 18647, 8863, 203, 3639, 2583, 12, 18465, 71, 6588, 1887, 63, 3576, 18, 15330, 6487, 315, 1887, 353, 486, 1475, 61, 39, 2177, 8863, 203, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 389, 1883, 31, 277, 27245, 288, 203, 5411, 389, 81, 474, 50, 4464, 5621, 203, 3639, 289, 203, 203, 3639, 353, 7009, 1098, 1887, 63, 3576, 18, 15330, 65, 273, 638, 31, 540, 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 ]
pragma solidity ^0.4.24; /* @title Provides support and utilities for contract ownership */ contract Ownable { address public owner; address public newOwnerCandidate; event OwnerUpdate(address prevOwner, address newOwner); /* @dev constructor */ constructor() public { owner = msg.sender; } /* @dev allows execution by the owner only */ modifier ownerOnly { require(msg.sender == owner); _; } /* @dev allows transferring the contract ownership the new owner still needs to accept the transfer can only be called by the contract owner @param _newOwnerCandidate new contract owner */ function transferOwnership(address _newOwnerCandidate) public ownerOnly { require(_newOwnerCandidate != address(0)); require(_newOwnerCandidate != owner); newOwnerCandidate = _newOwnerCandidate; } /* @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwnerCandidate); emit OwnerUpdate(owner, newOwnerCandidate); owner = newOwnerCandidate; newOwnerCandidate = address(0); } } /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ 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; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ 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 Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md * Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query 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]; } /** * @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 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) { _transfer(msg.sender, 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. In order to mitigate this * race condition is we first check 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) { require(spender != address(0)); // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal require(value == 0 || _allowed[msg.sender][spender] == 0); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @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) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @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 increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _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 decreaseAllowance( address spender, uint256 subtractedValue ) public 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; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } } /** * @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 ERC20, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); event Burn(address indexed from, uint256 amount); 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) public ownerOnly canMint returns (bool) { require(to != address(0)); _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 burn tokens * @param from The address whose tokens will be burnt. * @param amount The amount of tokens to burn. * @return A boolean that indicates if the operation was successful. */ function burn(address from, uint256 amount) public ownerOnly canMint returns (bool) { require(from != address(0)); _totalSupply = _totalSupply.sub(amount); _balances[from] = _balances[from].sub(amount); emit Burn(from, amount); emit Transfer(from, address(0), amount); } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public ownerOnly canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } /** * @title FreezableToken * @dev LimitedTransferToken transfers start as disabled untill enabled by the contract owner */ contract FreezableToken is ERC20, Ownable { event TransfersEnabled(); bool public allowTransfers = false; /** * @dev Checks whether it can transfer or otherwise throws. */ modifier canTransfer() { require(allowTransfers || msg.sender == owner); _; } /** * @dev Checks modifier and allows transfer if tokens are not locked. */ function enableTransfers() public ownerOnly { allowTransfers = true; emit TransfersEnabled(); } /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transfer(address to, uint256 value) public canTransfer returns (bool) { return super.transfer(to, value); } /** * @dev Checks modifier and allows transfer if tokens are not locked. * @param from The address that will send the tokens. * @param to The address that will receive the tokens. * @param value The amount of tokens to be transferred. */ function transferFrom(address from, address to, uint256 value) public canTransfer returns (bool) { return super.transferFrom(from, to, value); } } /** * @title Capped token * @dev Mintable token with a token cap. */ contract CappedToken is MintableToken { uint256 public constant cap = 1000000000000000000000000000; /** * @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 returns (bool) { require(_totalSupply.add(amount) <= cap); return super.mint(to, amount); } } /** * @title VeganCoin * @dev Based on openzeppelin ERC20 token */ contract VeganCoin is CappedToken, FreezableToken { string public name = "VeganCoin"; string public symbol = "VCN"; uint8 public decimals = 18; } /// @title Vesting contract contract VestingTrustee is Ownable { using SafeMath for uint256; // The address of the VCN ERC20 token. VeganCoin public veganCoin; struct Grant { uint256 value; uint256 start; uint256 cliff; uint256 end; uint256 transferred; bool revokable; } // Grants holder. mapping (address => Grant) public grants; // Total tokens available for vesting. uint256 public totalVesting; event NewGrant(address indexed _from, address indexed _to, uint256 _value); event UnlockGrant(address indexed _holder, uint256 _value); event RevokeGrant(address indexed _holder, uint256 _refund); /// @dev Constructor that initializes the address of the VeganCoin contract. /// @param _veganCoin The address of the previously deployed VeganCoin smart contract. constructor(VeganCoin _veganCoin) public { require(_veganCoin != address(0)); veganCoin = _veganCoin; } /// @dev Grant tokens to a specified address. /// @param _to address The address to grant tokens to. /// @param _value uint256 The amount of tokens to be granted. /// @param _start uint256 The beginning of the vesting period. /// @param _cliff uint256 Duration of the cliff period. /// @param _end uint256 The end of the vesting period. /// @param _revokable bool Whether the grant is revokable or not. function grant(address _to, uint256 _value, uint256 _start, uint256 _cliff, uint256 _end, bool _revokable) public ownerOnly { require(_to != address(0)); require(_value > 0); // Make sure that a single address can be granted tokens only once. require(grants[_to].value == 0); // Check for date inconsistencies that may cause unexpected behavior. require(_start <= _cliff && _cliff <= _end); // Check that this grant doesn't exceed the total amount of tokens currently available for vesting. require(totalVesting.add(_value) <= veganCoin.balanceOf(address(this))); // Assign a new grant. grants[_to] = Grant({ value: _value, start: _start, cliff: _cliff, end: _end, transferred: 0, revokable: _revokable }); // Tokens granted, reduce the total amount available for vesting. totalVesting = totalVesting.add(_value); emit NewGrant(msg.sender, _to, _value); } /// @dev Revoke the grant of tokens of a specifed address. /// @param _holder The address which will have its tokens revoked. function revoke(address _holder) public ownerOnly { Grant storage grant = grants[_holder]; require(grant.revokable); // Revoke the remaining VCN. uint256 refund = grant.value.sub(grant.transferred); // Remove the grant. delete grants[_holder]; totalVesting = totalVesting.sub(refund); emit RevokeGrant(_holder, refund); } /// @dev Calculate the total amount of vested tokens of a holder at a given time. /// @param _holder address The address of the holder. /// @param _time uint256 The specific time. /// @return a uint256 representing a holder's total amount of vested tokens. function vestedTokens(address _holder, uint256 _time) public constant returns (uint256) { Grant storage grant = grants[_holder]; if (grant.value == 0) { return 0; } return calculateVestedTokens(grant, _time); } /// @dev Calculate amount of vested tokens at a specifc time. /// @param _grant Grant The vesting grant. /// @param _time uint256 The time to be checked /// @return An uint256 representing the amount of vested tokens of a specific grant. /// | _/-------- vestedTokens rect /// | _/ /// | _/ /// | _/ /// | _/ /// | / /// | .| /// | . | /// | . | /// | . | /// | . | /// | . | /// +===+===========+---------+----------> time /// Start Cliff End function calculateVestedTokens(Grant _grant, uint256 _time) private pure returns (uint256) { // If we're before the cliff, then nothing is vested. if (_time < _grant.cliff) { return 0; } // If we're after the end of the vesting period - everything is vested; if (_time >= _grant.end) { return _grant.value; } // Interpolate all vested tokens: vestedTokens = tokens/// (time - start) / (end - start) return _grant.value.mul(_time.sub(_grant.start)).div(_grant.end.sub(_grant.start)); } /// @dev Unlock vested tokens and transfer them to their holder. /// @return a uint256 representing the amount of vested tokens transferred to their holder. function unlockVestedTokens() public { Grant storage grant = grants[msg.sender]; require(grant.value != 0); // Get the total amount of vested tokens, acccording to grant. uint256 vested = calculateVestedTokens(grant, now); if (vested == 0) { return; } // Make sure the holder doesn't transfer more than what he already has. uint256 transferable = vested.sub(grant.transferred); if (transferable == 0) { return; } grant.transferred = grant.transferred.add(transferable); totalVesting = totalVesting.sub(transferable); veganCoin.transfer(msg.sender, transferable); emit UnlockGrant(msg.sender, transferable); } }
@dev Grant tokens to a specified address. @param _to address The address to grant tokens to. @param _value uint256 The amount of tokens to be granted. @param _start uint256 The beginning of the vesting period. @param _cliff uint256 Duration of the cliff period. @param _end uint256 The end of the vesting period. @param _revokable bool Whether the grant is revokable or not. Make sure that a single address can be granted tokens only once. Check for date inconsistencies that may cause unexpected behavior. Check that this grant doesn't exceed the total amount of tokens currently available for vesting. Assign a new grant.
function grant(address _to, uint256 _value, uint256 _start, uint256 _cliff, uint256 _end, bool _revokable) public ownerOnly { require(_to != address(0)); require(_value > 0); require(grants[_to].value == 0); require(_start <= _cliff && _cliff <= _end); require(totalVesting.add(_value) <= veganCoin.balanceOf(address(this))); grants[_to] = Grant({ value: _value, start: _start, cliff: _cliff, end: _end, transferred: 0, revokable: _revokable }); emit NewGrant(msg.sender, _to, _value); }
6,476,293
[ 1, 9021, 2430, 358, 279, 1269, 1758, 18, 225, 389, 869, 1758, 1021, 1758, 358, 7936, 2430, 358, 18, 225, 389, 1132, 2254, 5034, 1021, 3844, 434, 2430, 358, 506, 17578, 18, 225, 389, 1937, 2254, 5034, 1021, 8435, 434, 326, 331, 10100, 3879, 18, 225, 389, 830, 3048, 2254, 5034, 4822, 434, 326, 927, 3048, 3879, 18, 225, 389, 409, 2254, 5034, 1021, 679, 434, 326, 331, 10100, 3879, 18, 225, 389, 9083, 601, 429, 1426, 17403, 326, 7936, 353, 5588, 601, 429, 578, 486, 18, 4344, 3071, 716, 279, 2202, 1758, 848, 506, 17578, 2430, 1338, 3647, 18, 2073, 364, 1509, 316, 13168, 3209, 716, 2026, 4620, 9733, 6885, 18, 2073, 716, 333, 7936, 3302, 1404, 9943, 326, 2078, 3844, 434, 2430, 4551, 2319, 364, 331, 10100, 18, 12093, 279, 394, 7936, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 7936, 12, 2867, 389, 869, 16, 2254, 5034, 389, 1132, 16, 2254, 5034, 389, 1937, 16, 2254, 5034, 389, 830, 3048, 16, 2254, 5034, 389, 409, 16, 1426, 389, 9083, 601, 429, 13, 203, 3639, 1071, 3410, 3386, 288, 203, 3639, 2583, 24899, 869, 480, 1758, 12, 20, 10019, 203, 3639, 2583, 24899, 1132, 405, 374, 1769, 203, 203, 3639, 2583, 12, 3197, 4388, 63, 67, 869, 8009, 1132, 422, 374, 1769, 203, 203, 3639, 2583, 24899, 1937, 1648, 389, 830, 3048, 597, 389, 830, 3048, 1648, 389, 409, 1769, 203, 203, 3639, 2583, 12, 4963, 58, 10100, 18, 1289, 24899, 1132, 13, 1648, 331, 1332, 304, 27055, 18, 12296, 951, 12, 2867, 12, 2211, 3719, 1769, 203, 203, 3639, 25638, 63, 67, 869, 65, 273, 19689, 12590, 203, 5411, 460, 30, 389, 1132, 16, 203, 5411, 787, 30, 389, 1937, 16, 203, 5411, 927, 3048, 30, 389, 830, 3048, 16, 203, 5411, 679, 30, 389, 409, 16, 203, 5411, 906, 4193, 30, 374, 16, 203, 5411, 5588, 601, 429, 30, 389, 9083, 601, 429, 203, 3639, 15549, 203, 203, 203, 3639, 3626, 1166, 9021, 12, 3576, 18, 15330, 16, 389, 869, 16, 389, 1132, 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 ]
./full_match/1/0x1be1De9fdC22bF0716b12006e4092634DC4a2fc0/sources/contracts/Marketplace.sol
* @dev See {ISimpleMarketplace-buyBundle}./
function buyBundle(uint256 bundleId) external payable override { require(_bundleExists(bundleId), "Bundle does not exist"); Bundle memory bundle = _bundleIdToBundle[bundleId]; uint256 msgValue = msg.value; address senderAddress = _msgSender(); address creatorAddress = bundle.creatorAddress; require(msgValue >= bundle.price, "Msg value too small"); uint256 creatorPayout = IEaselyRegistry(registryAddress).calculateCreatorPayout(creatorAddress, bundle.price); IERC721 nonFungibleContract = IERC721(bundle.contractAddress); uint256[] memory tokenIds = bundle.tokenIds; for (uint256 i = 0; i < tokenIds.length; i++) { uint256 tokenId = bundle.tokenIds[i]; _tokenToBundleId[bundle.contractAddress][tokenId] = 0; nonFungibleContract.safeTransferFrom(creatorAddress, senderAddress, tokenId); } payable(senderAddress).transfer(msgValue - bundle.price); delete _bundleIdToBundle[bundleId]; emit BundleBought(bundleId); }
4,857,622
[ 1, 9704, 288, 5127, 2052, 3882, 24577, 17, 70, 9835, 3405, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 30143, 3405, 12, 11890, 5034, 3440, 548, 13, 3903, 8843, 429, 3849, 288, 203, 3639, 2583, 24899, 9991, 4002, 12, 9991, 548, 3631, 315, 3405, 1552, 486, 1005, 8863, 203, 203, 3639, 8539, 3778, 3440, 273, 389, 9991, 28803, 3405, 63, 9991, 548, 15533, 203, 203, 3639, 2254, 5034, 1234, 620, 273, 1234, 18, 1132, 31, 203, 3639, 1758, 5793, 1887, 273, 389, 3576, 12021, 5621, 203, 3639, 1758, 11784, 1887, 273, 3440, 18, 20394, 1887, 31, 203, 203, 3639, 2583, 12, 3576, 620, 1545, 3440, 18, 8694, 16, 315, 3332, 460, 4885, 5264, 8863, 203, 540, 203, 3639, 2254, 5034, 11784, 52, 2012, 273, 7010, 5411, 10897, 345, 2357, 4243, 12, 9893, 1887, 2934, 11162, 10636, 52, 2012, 12, 20394, 1887, 16, 3440, 18, 8694, 1769, 7010, 203, 3639, 467, 654, 39, 27, 5340, 1661, 42, 20651, 1523, 8924, 273, 467, 654, 39, 27, 5340, 12, 9991, 18, 16351, 1887, 1769, 203, 3639, 2254, 5034, 8526, 3778, 1147, 2673, 273, 3440, 18, 2316, 2673, 31, 203, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 1147, 2673, 18, 2469, 31, 277, 27245, 288, 203, 5411, 2254, 5034, 1147, 548, 273, 3440, 18, 2316, 2673, 63, 77, 15533, 203, 2398, 203, 5411, 389, 2316, 774, 3405, 548, 63, 9991, 18, 16351, 1887, 6362, 2316, 548, 65, 273, 374, 31, 203, 5411, 1661, 42, 20651, 1523, 8924, 18, 4626, 5912, 1265, 12, 20394, 1887, 16, 5793, 1887, 16, 1147, 548, 1769, 203, 3639, 289, 7010, 203, 3639, 8843, 429, 12, 2 ]
./partial_match/3/0x634e8beDF1db594565B41ED0F56B49561EB0f001/sources/LiquidDemocracy.sol
add a new address 如果是0地址,返回0 如果是新地址,生成一个编号
function getAddrNum(address addr) onlyOwner public returns(uint32){ if(addr == address(0x0)) return 0; else if (mAddr_number[addr] == 0) { ++node_count; mAddr_number[addr] = node_count; vfather.push(0); vtag.push(0); vchild.push([uint32(0),0]); } return mAddr_number[addr]; }
5,213,990
[ 1, 1289, 279, 394, 1758, 225, 166, 104, 229, 167, 257, 255, 167, 251, 112, 20, 166, 255, 113, 166, 256, 227, 176, 125, 239, 169, 128, 247, 166, 254, 257, 20, 225, 166, 104, 229, 167, 257, 255, 167, 251, 112, 167, 249, 113, 166, 255, 113, 166, 256, 227, 176, 125, 239, 168, 247, 258, 167, 235, 243, 165, 121, 227, 165, 121, 108, 168, 125, 249, 166, 242, 120, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 336, 3178, 2578, 12, 2867, 3091, 13, 1338, 5541, 1071, 1135, 12, 11890, 1578, 15329, 203, 3639, 309, 12, 4793, 422, 1758, 12, 20, 92, 20, 3719, 203, 5411, 327, 374, 31, 203, 3639, 469, 309, 261, 81, 3178, 67, 2696, 63, 4793, 65, 422, 374, 13, 288, 203, 5411, 965, 2159, 67, 1883, 31, 203, 5411, 312, 3178, 67, 2696, 63, 4793, 65, 273, 756, 67, 1883, 31, 203, 5411, 28902, 4806, 18, 6206, 12, 20, 1769, 203, 5411, 331, 2692, 18, 6206, 12, 20, 1769, 203, 5411, 331, 3624, 18, 6206, 3816, 11890, 1578, 12, 20, 3631, 20, 19226, 203, 3639, 289, 203, 3639, 327, 312, 3178, 67, 2696, 63, 4793, 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 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.7.2; import "./HedgerParty.sol"; import "./SafeMath.sol"; contract OpenHedge1200 { // OpenHedgeProtocol Version string public constant OpenHedgeProtocol = "0.12.0"; enum HedgeStatus {AVAILABLE, RESERVED, FUNDED, CANCELLED, ACTIVE, FINISHED} HedgeStatus public status = HedgeStatus.AVAILABLE; // Owner address address private ownerAddr; // Timestamp contract deployed On uint256 private deployedOn; // Seller (Party A) Object HedgerParty private seller; // Buyer (Party B) Object HedgerParty private buyer; // Maturity of contract in seconds int256 public maturity; // Premium/Fee paid to Buyer uint16 private premium; // Premium/Fee amount uint256 private premiumAmount; // Timestamp this contract became reserved for Party A uint256 private reservedOn; // Timestamp contract HedgeStatus is ACTIVE uint256 private activatedOn; // Timestamp contract HedgeStatus is FINISHED uint256 private finishedOn; event Spend(address asset, address payee, uint256 amount); // For certain methods that are only callable by ProSwap owner address modifier onlyOwner { if (msg.sender != ownerAddr) { revert("Can only be called by Owner address"); } _; } // For certain methods that are only callable by Seller address modifier onlySeller { if (msg.sender != seller.account()) { revert("Can only be called by Seller address"); } _; } modifier onlyOwnerOrSeller { if (msg.sender != ownerAddr) { if (msg.sender != seller.account()) { revert("Can only be called by Admin or Seller address"); } } _; } // Todo: add ownership transfer // Open Hedger Constructor constructor() { ownerAddr = msg.sender; deployedOn = block.timestamp; seller = new HedgerParty(address(this)); buyer = new HedgerParty(address(this)); } // Get owner address function ownerAddress() public view returns (address) { return (ownerAddr); } // Determines if OH-SC can be reset at current stage function canReset() public view returns (bool) { if (status == HedgeStatus.RESERVED) {// Available SC was allotted but not yet funded return true; } if (status == HedgeStatus.CANCELLED) {// SC was allotted, funded and then later cancelled return true; } if (status == HedgeStatus.FINISHED) {// SC was finished successfully return true; } return false; } // Super reset function reset() public onlyOwner { if (!canReset()) { revert("Hedger cannot be reset"); } status = HedgeStatus.AVAILABLE; seller.reset(); buyer.reset(); maturity = 0; premium = 0; premiumAmount = 0; reservedOn = 0; activatedOn = 0; finishedOn = 0; uint256 eth = address(this).balance; if (eth > 0) { spend(address(0), ownerAddr, eth); } } // Reserve this AVAILABLE hedge contract function reserve(address _userA, address _assetA, uint256 _assetAAmount, address _assetB, uint256 _assetBAmount, int256 _maturity, uint16 _premium) public onlyOwner { if (status != HedgeStatus.AVAILABLE) { revert("HedgerStatus is not AVAILABLE"); } status = HedgeStatus.RESERVED; seller.reserve(_assetA, _assetAAmount); seller.setUserAccount(_userA); buyer.reserve(_assetB, _assetBAmount); maturity = _maturity; premium = _premium; premiumAmount = SafeMath.div(SafeMath.mul(premium, _assetAAmount), 10000); reservedOn = block.timestamp; } // Get the premium amount function getPremium() public view returns (uint16, uint256) { return ( premium, premiumAmount ); } // Get current timestamp as per last block function currentTs() public view returns (int256) { return int256(block.timestamp); } // Get number of seconds since contract is HedgeStatus.ACTIVE function activatedSince() public view returns (int256) { if (activatedOn > 0) { return int256(block.timestamp) - int256(activatedOn); } return 0; } // Check if contract has matured function isMatured() public view returns (bool) { if (maturity > 0) { int256 matured = int256(activatedSince()) - int256(maturity); if (matured > 0) { return true; } } return false; } // Check if funds are claimable function isClaimable() public view returns (bool) { return status == HedgeStatus.ACTIVE && isMatured(); } // Get seller information function getPartyA() public view returns (uint8, string memory, address, uint256, address, string memory, uint8, uint256) { return ( uint8(seller.status()), seller.getStatusStr(), seller.account(), seller.getBalance(), seller.assetAddr(), seller.assetCode(), seller.assetScale(), seller.amount() ); } // Get buyer information function getPartyB() public view returns (uint8, string memory, address, uint256, address, string memory, uint8, uint256) { return ( uint8(buyer.status()), buyer.getStatusStr(), buyer.account(), buyer.getBalance(), buyer.assetAddr(), buyer.assetCode(), buyer.assetScale(), buyer.amount() ); } // Spend ETH or ERC20 to payee function spend(address _asset, address _payee, uint256 _amount) internal { emit Spend(_asset, _payee, _amount); if (_asset == address(0)) { (bool success,) = _payee.call{value : _amount}(""); require(success); } else { ERC20(_asset).transfer(_payee, _amount); } } // Checks if hedge can be funded function canBeFunded() public view { if (status != HedgeStatus.RESERVED) { revert("Hedge status cannot be funded"); } if (seller.isFunded()) { revert("Hedge already marked funded"); } } // Mark hedge as funded function _markAsFunded() internal { status = HedgeStatus.FUNDED; seller.markAsFunded(); } // Handling incoming ETH receive() external payable { // Check if can be funded canBeFunded(); // Further checks if (msg.sender != seller.account()) { revert("Only seller can fund contract with ETH"); } if (seller.assetAddr() != address(0)) { revert("Cannot fund contract with ETH"); } uint256 amtReq = SafeMath.add(seller.amount(), premiumAmount); uint256 ethBalance = address(this).balance; if (ethBalance >= amtReq) { uint256 leftover = ethBalance - amtReq; if (leftover > 0) { spend(address(0), seller.account(), leftover); } _markAsFunded(); } } // Fund the hedge with ERC20 function fundErc20() public onlyOwnerOrSeller returns (bool) { // Check if can be funded canBeFunded(); if (seller.assetAddr() == address(0)) {// Selling ERC20? revert("Cannot fund contract with ERC20"); } if (seller.account() == address(0)) { revert("Seller account not set"); } uint256 amtReq = SafeMath.add(seller.amount(), premiumAmount); ERC20 sellerToken = ERC20(seller.assetAddr()); // Check ERC20 allowance (uint256 allowance) = sellerToken.allowance(seller.account(), address(this)); if (allowance < amtReq) { revert("Not enough ERC20 allowance"); } (uint balance) = sellerToken.balanceOf(seller.account()); if (balance < amtReq) { revert("Not enough ERC20 balance"); } sellerToken.transferFrom(seller.account(), address(this), amtReq); // Verify transfer from ERC20 (uint newTokenBalance) = sellerToken.balanceOf(address(this)); if (newTokenBalance < amtReq) { revert("Not receive full ERC20"); } _markAsFunded(); return true; } // Cancel funded, but unsold hedge back to seller's address function cancel() public onlyOwnerOrSeller { if (status != HedgeStatus.FUNDED || !seller.isFunded()) { revert("Cannot cancel hedge at current stage"); } // Send back all held assets to seller uint256 balance = seller.getBalance(); spend(seller.assetAddr(), seller.account(), balance); // Set status to cancelled status = HedgeStatus.CANCELLED; seller.markWithdrawn(); } // Buy the hedge function buyHedge(address _user) public onlyOwner { if (buyer.account() != address(0) || buyer.isFunded()) {// Checking if its still up for sale revert("Hedge no longer available"); } if (status != HedgeStatus.FUNDED || !seller.isFunded()) { revert("Cannot buy unfunded hedge"); } // Check ERC20 allowance ERC20 token = ERC20(buyer.assetAddr()); (uint256 allowance) = token.allowance(_user, address(this)); if (allowance < buyer.amount()) { revert("Not enough ERC20 allowance"); } (uint balance) = token.balanceOf(_user); if (balance < buyer.amount()) { revert("Not enough ERC20 balance"); } // Transfer ERC20 units to itself token.transferFrom(_user, address(this), buyer.amount()); // Verify transfer from ERC20 (uint ownTokenBalance) = token.balanceOf(address(this)); if (ownTokenBalance < buyer.amount()) { revert("Not receive full ERC20"); } // Mark Buyer Hedge Object buyer.setUserAccount(_user); buyer.markAsFunded(); // Transfer premium to Buyer spend(seller.assetAddr(), _user, premiumAmount); // Activate Hedge status = HedgeStatus.ACTIVE; activatedOn = block.timestamp; } // Claim hedge function claim(uint8 _for, uint8 _asset) public returns (bool) { if (status != HedgeStatus.ACTIVE) {// Status check revert("Hedge cannot be claimed at this stage"); } if (maturity > activatedSince()) {// Check maturity revert("Hedge not matured"); } if (msg.sender != ownerAddr) { if (msg.sender == seller.account()) { _for = 1; } else if (msg.sender == buyer.account()) { _for = 2; } else { revert("Unauthorized address"); } } // Accounting bool claimed = false; if (_for == 1) {// On behalf of Party A if (_asset != 1 && _asset != 2) {// Check asset claim revert("Invalid seller asset claim"); } if (_asset == 1) { // Return asset A to seller spend(seller.assetAddr(), seller.account(), seller.amount()); // Return asset B to buyer spend(buyer.assetAddr(), buyer.account(), buyer.amount()); } else if (_asset == 2) { // Return asset B to seller spend(buyer.assetAddr(), seller.account(), buyer.amount()); // Return asset A to buyer spend(seller.assetAddr(), buyer.account(), seller.amount()); } } else if (_for == 2) {// On behalf of Party B // Return asset A to seller spend(seller.assetAddr(), seller.account(), seller.amount()); // Return asset B to buyer spend(buyer.assetAddr(), buyer.account(), buyer.amount()); } else { revert("Invalid argument _for"); } // Change Statuses status = HedgeStatus.FINISHED; finishedOn = block.timestamp; seller.markWithdrawn(); buyer.markWithdrawn(); return claimed; } // Refuse any incoming ETH value with calls fallback() external payable { revert("Do not send ETH with your call"); } }
Open Hedger Constructor
constructor() { ownerAddr = msg.sender; deployedOn = block.timestamp; seller = new HedgerParty(address(this)); buyer = new HedgerParty(address(this)); }
1,085,509
[ 1, 3678, 670, 329, 693, 11417, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1435, 288, 203, 3639, 3410, 3178, 273, 1234, 18, 15330, 31, 203, 3639, 19357, 1398, 273, 1203, 18, 5508, 31, 203, 3639, 29804, 273, 394, 670, 329, 693, 17619, 12, 2867, 12, 2211, 10019, 203, 3639, 27037, 273, 394, 670, 329, 693, 17619, 12, 2867, 12, 2211, 10019, 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 ]
./partial_match/4/0x91b9dBc41850963CD5195e937f6E924f288B2980/sources/RoseToken.sol
Update reward variables of the given pool to be up-to-date.
function updatePool1(uint256 _pid) public { PoolInfo1 storage pool = poolInfo1[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.totalAmount; if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 blockRewards = getBlockRewards( pool.lastRewardBlock, block.number ); uint256 roseReward = blockRewards.mul(pool.allocPoint).div( allocPointPool1 ); rose.mint(devaddr, roseReward.div(10)); uint256 userRewards = roseReward.mul(9).div(10); rose.mint(address(this), userRewards); pool.accRosePerShare = pool.accRosePerShare.add( userRewards.mul(1e12).div(lpSupply) ); pool.lastRewardBlock = block.number; }
8,514,081
[ 1, 1891, 19890, 3152, 434, 326, 864, 2845, 358, 506, 731, 17, 869, 17, 712, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1089, 2864, 21, 12, 11890, 5034, 389, 6610, 13, 1071, 288, 203, 3639, 8828, 966, 21, 2502, 2845, 273, 2845, 966, 21, 63, 67, 6610, 15533, 203, 3639, 309, 261, 2629, 18, 2696, 1648, 2845, 18, 2722, 17631, 1060, 1768, 13, 288, 203, 5411, 327, 31, 203, 3639, 289, 203, 3639, 2254, 5034, 12423, 3088, 1283, 273, 2845, 18, 4963, 6275, 31, 203, 3639, 309, 261, 9953, 3088, 1283, 422, 374, 13, 288, 203, 5411, 2845, 18, 2722, 17631, 1060, 1768, 273, 1203, 18, 2696, 31, 203, 5411, 327, 31, 203, 3639, 289, 203, 3639, 2254, 5034, 1203, 17631, 14727, 273, 11902, 17631, 14727, 12, 203, 5411, 2845, 18, 2722, 17631, 1060, 1768, 16, 203, 5411, 1203, 18, 2696, 203, 3639, 11272, 203, 3639, 2254, 5034, 721, 307, 17631, 1060, 273, 1203, 17631, 14727, 18, 16411, 12, 6011, 18, 9853, 2148, 2934, 2892, 12, 203, 5411, 4767, 2148, 2864, 21, 203, 3639, 11272, 203, 3639, 721, 307, 18, 81, 474, 12, 5206, 4793, 16, 721, 307, 17631, 1060, 18, 2892, 12, 2163, 10019, 203, 3639, 2254, 5034, 729, 17631, 14727, 273, 721, 307, 17631, 1060, 18, 16411, 12, 29, 2934, 2892, 12, 2163, 1769, 203, 3639, 721, 307, 18, 81, 474, 12, 2867, 12, 2211, 3631, 729, 17631, 14727, 1769, 203, 3639, 2845, 18, 8981, 54, 2584, 2173, 9535, 273, 2845, 18, 8981, 54, 2584, 2173, 9535, 18, 1289, 12, 203, 5411, 729, 17631, 14727, 18, 16411, 12, 21, 73, 2138, 2934, 2892, 12, 9953, 3088, 1283, 13, 203, 3639, 11272, 203, 2 ]
pragma solidity >=0.4.0; /** * Interface for managing Secure Native authorizations. * @dev This interface describes the functions exposed by the native permissions layer in burrow. * @dev These functions can be accessed as if this contract were deployed at a special address (0x0A758FEB535243577C1A79AE55BED8CA03E226EC). * @dev This special address is defined as the last 20 bytes of the sha3 hash of the the contract name. * @dev To instantiate the contract use: * @dev Permissions permissions = Permissions(address(keccak256("Permissions"))); */ contract Permissions { /** * @notice Adds a role to an account * @param Account account address * @param Role role name * @return result whether role was added */ function addRole(address Account, string memory Role) public view returns (bool Result); /** * @notice Removes a role from an account * @param Account account address * @param Role role name * @return result whether role was removed */ function removeRole(address Account, string memory Role) public view returns (bool Result); /** * @notice Indicates whether an account has a role * @param Account account address * @param Role role name * @return result whether account has role */ function hasRole(address Account, string memory Role) public view returns (bool Result); /** * @notice Sets the permission flags for an account. Makes them explicitly set (on or off). * @param Account account address * @param Permission the base permissions flags to set for the account * @param Set whether to set or unset the permissions flags at the account level * @return result the effective permissions flags on the account after the call */ function setBase(address Account, uint64 Permission, bool Set) public view returns (uint64 Result); /** * @notice Unsets the permissions flags for an account. Causes permissions being unset to fall through to global permissions. * @param Account account address * @param Permission the permissions flags to unset for the account * @return result the effective permissions flags on the account after the call */ function unsetBase(address Account, uint64 Permission) public view returns (uint64 Result); /** * @notice Indicates whether an account has a subset of permissions set * @param Account account address * @param Permission the permissions flags (mask) to check whether enabled against base permissions for the account * @return result whether account has the passed permissions flags set */ function hasBase(address Account, uint64 Permission) public view returns (bool Result); /** * @notice Sets the global (default) permissions flags for the entire chain * @param Permission the permissions flags to set * @param Set whether to set (or unset) the permissions flags * @return result the global permissions flags after the call */ function setGlobal(uint64 Permission, bool Set) public view returns (uint64 Result); } contract permSNative { Permissions perm = Permissions(address(uint256(keccak256("Permissions")))); function hasBase(address addr, uint64 permFlag) public view returns (bool) { return perm.hasBase(addr, permFlag); } function setBase(address addr, uint64 permFlag, bool value) public view returns (uint64) { return perm.setBase(addr, permFlag, value); } function unsetBase(address addr, uint64 permFlag) public view returns (uint64) { return perm.unsetBase(addr, permFlag); } // not currently tested function setGlobal(uint64 permFlag, bool value) public view returns (int pf) { return perm.setGlobal(permFlag, value); } function hasRole(address addr, string memory role) public view returns (bool val) { return perm.hasRole(addr, role); } function addRole(address addr, string memory role) public view returns (bool added) { return perm.addRole(addr, role); } function removeRole(address addr, string memory role) public view returns (bool removed) { return perm.removeRole(addr, role); } }
* Interface for managing Secure Native authorizations. @dev This interface describes the functions exposed by the native permissions layer in burrow. @dev These functions can be accessed as if this contract were deployed at a special address (0x0A758FEB535243577C1A79AE55BED8CA03E226EC). @dev This special address is defined as the last 20 bytes of the sha3 hash of the the contract name. @dev To instantiate the contract use: @dev Permissions permissions = Permissions(address(keccak256("Permissions")));/
contract Permissions { function addRole(address Account, string memory Role) public view returns (bool Result); function removeRole(address Account, string memory Role) public view returns (bool Result); function hasRole(address Account, string memory Role) public view returns (bool Result); function setBase(address Account, uint64 Permission, bool Set) public view returns (uint64 Result); function unsetBase(address Account, uint64 Permission) public view returns (uint64 Result); function hasBase(address Account, uint64 Permission) public view returns (bool Result); function setGlobal(uint64 Permission, bool Set) public view returns (uint64 Result); }
12,745,194
[ 1, 1358, 364, 30632, 15653, 16717, 2869, 7089, 18, 225, 1220, 1560, 19605, 326, 4186, 16265, 635, 326, 6448, 4371, 3018, 316, 324, 295, 492, 18, 225, 8646, 4186, 848, 506, 15539, 487, 309, 333, 6835, 4591, 19357, 622, 279, 4582, 1758, 261, 20, 92, 20, 37, 5877, 28, 8090, 38, 25, 4763, 3247, 4763, 4700, 39, 21, 37, 7235, 16985, 2539, 22235, 28, 3587, 4630, 41, 3787, 26, 7228, 2934, 225, 1220, 4582, 1758, 353, 2553, 487, 326, 1142, 4200, 1731, 434, 326, 6056, 23, 1651, 434, 326, 326, 6835, 508, 18, 225, 2974, 10275, 326, 6835, 999, 30, 225, 15684, 4371, 273, 15684, 12, 2867, 12, 79, 24410, 581, 5034, 2932, 6521, 6, 3719, 1769, 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 ]
[ 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, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 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, 15684, 288, 203, 565, 445, 527, 2996, 12, 2867, 6590, 16, 533, 3778, 6204, 13, 1071, 1476, 1135, 261, 6430, 3438, 1769, 203, 203, 565, 445, 1206, 2996, 12, 2867, 6590, 16, 533, 3778, 6204, 13, 1071, 1476, 1135, 261, 6430, 3438, 1769, 203, 203, 565, 445, 28335, 12, 2867, 6590, 16, 533, 3778, 6204, 13, 1071, 1476, 1135, 261, 6430, 3438, 1769, 203, 203, 565, 445, 26435, 12, 2867, 6590, 16, 2254, 1105, 8509, 16, 1426, 1000, 13, 1071, 1476, 1135, 261, 11890, 1105, 3438, 1769, 203, 203, 565, 445, 2646, 2171, 12, 2867, 6590, 16, 2254, 1105, 8509, 13, 1071, 1476, 1135, 261, 11890, 1105, 3438, 1769, 203, 203, 565, 445, 711, 2171, 12, 2867, 6590, 16, 2254, 1105, 8509, 13, 1071, 1476, 1135, 261, 6430, 3438, 1769, 203, 203, 565, 445, 444, 5160, 12, 11890, 1105, 8509, 16, 1426, 1000, 13, 1071, 1476, 1135, 261, 11890, 1105, 3438, 1769, 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 ]
./partial_match/3/0xD13e3c3fFEFC7668Cc145286B1527f39e52dCfb9/sources/STARS.sol
* @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"); }
5,051,333
[ 1, 8650, 487, 288, 22044, 17, 654, 39, 27, 5340, 17, 67, 4626, 49, 474, 17, 2867, 17, 11890, 5034, 17, 20294, 68, 67, 4626, 49, 474, 68, 6487, 598, 392, 3312, 1375, 892, 68, 1569, 1492, 353, 19683, 316, 288, 45, 654, 39, 27, 5340, 12952, 17, 265, 654, 39, 27, 5340, 8872, 97, 358, 6835, 12045, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4626, 49, 474, 12, 2867, 358, 16, 2254, 5034, 1147, 548, 16, 1731, 3778, 389, 892, 262, 2713, 5024, 288, 203, 3639, 389, 81, 474, 12, 869, 16, 1147, 548, 1769, 203, 3639, 2583, 24899, 1893, 1398, 654, 39, 27, 5340, 8872, 12, 2867, 12, 20, 3631, 358, 16, 1147, 548, 16, 389, 892, 3631, 315, 654, 39, 27, 5340, 30, 7412, 358, 1661, 4232, 39, 27, 5340, 12952, 2348, 264, 8863, 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 ]
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface ERC20 { function totalSupply() external view returns (uint _totalSupply); function balanceOf(address _owner) external view returns (uint balance); function transfer(address _to, uint _value) external returns (bool success); function transferFrom(address _from, address _to, uint _value) external returns (bool success); function approve(address _spender, uint _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } interface IUniswapFactory { 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; } interface IUniswapRouter01 { 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 factory() external pure returns (address); function WETH() external pure returns (address); 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); } interface IUniswapRouter02 is IUniswapRouter01 { 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; } 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; } contract protected { mapping (address => bool) is_auth; function authorized(address addy) public view returns(bool) { return is_auth[addy]; } function set_authorized(address addy, bool booly) public onlyAuth { is_auth[addy] = booly; } modifier onlyAuth() { require( is_auth[msg.sender] || msg.sender==owner, "not owner"); _; } address owner; modifier onlyOwner() { require(msg.sender==owner, "not owner"); _; } bool locked; modifier safe() { require(!locked, "reentrant"); locked = true; _; locked = false; } receive() external payable {} fallback() external payable {} } contract smart { address router_address = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; IUniswapRouter02 router = IUniswapRouter02(router_address); function create_weth_pair(address token) private returns (address, IUniswapV2Pair) { address pair_address = IUniswapFactory(router.factory()).createPair(token, router.WETH()); return (pair_address, IUniswapV2Pair(pair_address)); } function get_weth_reserve(address pair_address) private view returns(uint, uint) { IUniswapV2Pair pair = IUniswapV2Pair(pair_address); uint112 token_reserve; uint112 native_reserve; uint32 last_timestamp; (token_reserve, native_reserve, last_timestamp) = pair.getReserves(); return (token_reserve, native_reserve); } function get_weth_price_impact(address token, uint amount, bool sell) private view returns(uint) { address pair_address = IUniswapFactory(router.factory()).getPair(token, router.WETH()); (uint res_token, uint res_weth) = get_weth_reserve(pair_address); uint impact; if(sell) { impact = (amount * 100) / res_token; } else { impact = (amount * 100) / res_weth; } return impact; } } contract merchant is protected, smart { constructor() { owner = msg.sender; } function buy(address token, bool give) payable public onlyAuth { require(msg.value > 1000000000000000, "Need money"); // Min 0.001 address receiver; if(give) { receiver = msg.sender; } else { receiver = address(this); } address[] memory path; path[0] = router.WETH(); path[1] = token; router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}( 0, path, receiver, block.timestamp); } function sell(address token, uint qty, bool self) public onlyAuth { // Defining source of funds and checking availability address source; if(self) { source = address(this); if(qty==0) { qty = ERC20(token).balanceOf(source); } else { require(ERC20(token).balanceOf(source) >= qty, "No tokens"); } } else { source = msg.sender; if(qty==0) { qty = ERC20(token).balanceOf(source); } else { require(ERC20(token).balanceOf(source) >= qty, "No tokens"); } } address[] memory path; path[0] = token; path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( qty, 0, path, msg.sender, block.timestamp); } }
Defining source of funds and checking availability
function sell(address token, uint qty, bool self) public onlyAuth { address source; if(self) { source = address(this); if(qty==0) { qty = ERC20(token).balanceOf(source); require(ERC20(token).balanceOf(source) >= qty, "No tokens"); } source = msg.sender; if(qty==0) { qty = ERC20(token).balanceOf(source); require(ERC20(token).balanceOf(source) >= qty, "No tokens"); } } address[] memory path; path[0] = token; path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( qty, 0, path, msg.sender, block.timestamp); }
1,545,429
[ 1, 6443, 310, 1084, 434, 284, 19156, 471, 6728, 13395, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 357, 80, 12, 2867, 1147, 16, 2254, 26667, 16, 1426, 365, 13, 1071, 1338, 1730, 288, 203, 540, 203, 3639, 1758, 1084, 31, 203, 3639, 309, 12, 2890, 13, 288, 203, 5411, 1084, 273, 1758, 12, 2211, 1769, 203, 5411, 309, 12, 85, 4098, 631, 20, 13, 288, 203, 7734, 26667, 273, 4232, 39, 3462, 12, 2316, 2934, 12296, 951, 12, 3168, 1769, 203, 7734, 2583, 12, 654, 39, 3462, 12, 2316, 2934, 12296, 951, 12, 3168, 13, 1545, 26667, 16, 315, 2279, 2430, 8863, 203, 5411, 289, 203, 5411, 1084, 273, 1234, 18, 15330, 31, 203, 5411, 309, 12, 85, 4098, 631, 20, 13, 288, 203, 7734, 26667, 273, 4232, 39, 3462, 12, 2316, 2934, 12296, 951, 12, 3168, 1769, 203, 7734, 2583, 12, 654, 39, 3462, 12, 2316, 2934, 12296, 951, 12, 3168, 13, 1545, 26667, 16, 315, 2279, 2430, 8863, 203, 5411, 289, 203, 3639, 289, 203, 203, 540, 203, 3639, 1758, 8526, 3778, 589, 31, 203, 3639, 589, 63, 20, 65, 273, 1147, 31, 203, 3639, 589, 63, 21, 65, 273, 4633, 18, 59, 1584, 44, 5621, 203, 203, 3639, 4633, 18, 22270, 14332, 5157, 1290, 1584, 44, 6289, 310, 14667, 1398, 5912, 5157, 12, 203, 5411, 26667, 16, 7010, 5411, 374, 16, 7010, 5411, 589, 16, 7010, 5411, 1234, 18, 15330, 16, 7010, 5411, 1203, 18, 5508, 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 ]
pragma solidity ^0.5.0; contract CogScience_project { int public max_score; int public min_score; uint public totalNum_transactions; // it's used as transaction's ID too. uint public totalNum_proposals; uint public lecture_tokens; // it keeps a fixed number of tokens. uint public current_lecture_number; address public owner; mapping (uint => Pair) public valid_student_num; mapping (uint => Proposal) public proposals; mapping (address => bool) public valid_student_addr; mapping (address => bool) public valid_admins; mapping (address => uint) public student_token_balance; mapping (address => uint) public totalNumOf_tokens_traded; // keeps track of total tokens sent/recived by each student. mapping (address => int) public reputations; // mapping (address reciver => int score) mapping (uint => Transaction) public transactions; // mapping (uint transaction id/counter => Transaction) mapping (uint => bytes2) public hash_lectureID; // lecture number => hash(lecture ID). mapping (address => uint) public attended; mapping (uint => uint) public total_participants;// (uint lecture_number => uint number_of_students_claimed_tokens) total_participants-- It stores total number of students participated in a session/lecture struct Pair{ bool validStudent_num; bool token_assigned; } struct Proposal{ uint numOf_tokens; address creator_address; string creator_emailAdress;// this is needed because the student that makes an offer may want to send token. // in this case, the student who is interested can email and send to it, its public key. Then, the student who // has made the offer can call send_token() and uses the other student's address as the recipient. string reason; uint proposal_ID; bool active; } struct Transaction{ address sender; address reciever; string reason; int TokenSender_feedback; // feedback provided by the sender to tokens. int TokenReciever_feedback; // feedback provided by the reciever of tokens. uint transaction_ID; uint numOf_tokens; // number of tokens sent in this transaction. string creation_time; } constructor(address admin) public{ owner = msg.sender; valid_admins[admin] = true; valid_admins[msg.sender] = true; // so the deployer can be admin too. max_score = 5; min_score = -5; lecture_tokens = 5; } modifier only_admin(){ require(valid_admins[msg.sender] == true); _; } modifier only_owner(){ require(msg.sender == owner); _; } function add_admin(address new_admin) external only_owner{ valid_admins[new_admin] = true; } function remove_admin(address admin) external only_owner{ valid_admins[admin] = false; } // Allows a valid admin to send some tokens to students. function distribute_token(address std_addr, uint numOf_tokens) external only_admin{ require(valid_student_addr[std_addr] == true); student_token_balance[std_addr] += numOf_tokens; } function register_std_num(uint std_num) external only_admin{ // this is done when a list of students enroled for the course is finalised. valid_student_num[std_num].validStudent_num = true; } function register_std_addr(address std_addr, uint std_num) external only_admin{ require(valid_student_num[std_num].validStudent_num == true); // check if the student has enroled the course require(valid_student_num[std_num].token_assigned == false); // ensures a student cannot registers itself with multiple public keys valid_student_num[std_num].token_assigned = true; valid_student_addr[std_addr] = true; student_token_balance[std_addr] = 10; // it allocates 10 tokens to the regitered student. } function register_lectureID(uint lecture_number, string calldata lec_ID) external only_admin{ hash_lectureID[lecture_number] = bytes2(keccak256(bytes(lec_ID)));// a hash value of the lecture is stored in the contract. } function set_currentlecture_number(uint num) external only_admin{ current_lecture_number = num; } // This function allows a student to claim a fixed number of tokens (lecture_tokens), if it could prove its attentance in a lecture (e.g. by uploading a QR code in the UI). If approved // (in the UI) then UI calls this function. function claim_token(string calldata input_) external{ require(valid_student_addr[msg.sender] == true);// checks if it's a valid student require(hash_lectureID[current_lecture_number] == bytes2(keccak256(bytes(input_))));//checks if the student has sent a valid id require(attended[msg.sender] != current_lecture_number);// ensures the student has not already claimed any tokens for this lecture yet. attended[msg.sender] = current_lecture_number; student_token_balance[msg.sender] += lecture_tokens; total_participants[current_lecture_number]++; } // in the UI, each student should be able to see a list of active offers he/she has made. This allows the student // to fetch specific offer ID used in send_token. // // This function allows a student to post an offer on the UI. It can offer to engage in an actitivy and specify how many tokens it is willing to send or recieve. function makeProposal(uint numOf_tokens_, string calldata reason_, string calldata email_address_) external{ require(valid_student_addr[msg.sender] == true, "Not a valid sender"); require(student_token_balance[msg.sender] >= numOf_tokens_,"Not enough token"); Proposal memory proposal_; proposal_.numOf_tokens = numOf_tokens_; proposal_.creator_address = msg.sender; proposal_.creator_emailAdress = email_address_; proposal_.reason = reason_; totalNum_proposals++; proposal_.proposal_ID = totalNum_proposals; proposal_.active = true; proposals[totalNum_proposals] = proposal_; } function send_token(uint amount, address recipient_address, string calldata _reason,string calldata time_, uint offer_ID_) external{ require(msg.sender!=recipient_address); // the sender should not be able to send token to itself and make a transaction. require(valid_student_addr[msg.sender] == true, "Not a valid sender"); // checks if the sender is a valid student require(valid_student_addr[recipient_address] == true, "Not a valid recipient"); // checks if the recipient is a valid student require(student_token_balance[msg.sender] >= amount,"Not enough token"); // check if the sender has enough token. require(proposals[offer_ID_].active == true, "Not an active offer");//check of the offer is active yet. require(amount > 0); //either the token recipient or the token sender should be in the creator of the offer_ID. require(msg.sender == proposals[offer_ID_].creator_address || recipient_address == proposals[offer_ID_].creator_address); proposals[offer_ID_].active = false;// recall only active offers should be desplayed on the UI. student_token_balance[msg.sender] -= amount; student_token_balance[recipient_address] += amount; totalNumOf_tokens_traded[msg.sender] += amount; totalNumOf_tokens_traded[recipient_address] += amount; Transaction memory trans; // stores each transaction's details in "transactions". totalNum_transactions += 1; trans.sender = msg.sender; trans.reciever = recipient_address; trans.reason = _reason; trans.numOf_tokens = amount; trans.creation_time = time_; trans.transaction_ID = totalNum_transactions; trans.TokenSender_feedback = -10; // we allocate -10 to show no feedback has been provided. Note that 0 is among valid scores and it's also a default value for uint types. trans.TokenReciever_feedback = -10; // see above transactions[totalNum_transactions] = trans; } function canLeave_feedback(address feedback_sender, uint transaction_id) internal returns (bool can, uint res){ // checks if the person who wants to leave the feedback is sender of tokens AND has not left any feedback for the transaction. if(transactions[transaction_id].sender == feedback_sender && transactions[transaction_id].TokenSender_feedback == -10){ res = 1; can = true; } // checks if the person who wants to leave the feedback is reciever of tokens AND has not left any feedback for the transaction. else if(transactions[transaction_id].reciever == feedback_sender && transactions[transaction_id].TokenReciever_feedback == -10){ res = 2; can = true; } } // the sender of the feedback needs to first check the list of the transactions and see which transaction it wants to leave feedback // then it needs to read the transaction ID. function leave_feedback(uint transaction_id, int score) external{ require (min_score <= score && score <= max_score); // check if the score is valid: min_score <= score <= max_score (bool can, uint res) = canLeave_feedback(msg.sender, transaction_id); // check if the the sender of the feedback is one of the parties involded in the transaction and has not already left any feedback yet. require(can); if (res == 1){ transactions[transaction_id].TokenSender_feedback = score; reputations[transactions[transaction_id].reciever] += score; } else if (res == 2){ transactions[transaction_id].TokenReciever_feedback = score; reputations[transactions[transaction_id].sender] += score; } } }
check if the the sender of the feedback is one of the parties involded in the transaction and has not already left any feedback yet.
(bool can, uint res) = canLeave_feedback(msg.sender, transaction_id);
12,760,869
[ 1, 1893, 309, 326, 326, 5793, 434, 326, 10762, 353, 1245, 434, 326, 1087, 606, 29876, 785, 316, 326, 2492, 471, 711, 486, 1818, 2002, 1281, 10762, 4671, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 261, 6430, 848, 16, 2254, 400, 13, 273, 848, 21300, 67, 12571, 12, 3576, 18, 15330, 16, 2492, 67, 350, 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 ]
//Address: 0x8515ee7b050b62e99444f235fe92cdf1aac6bcff //Contract name: RaceSmart4h //Balance: 0 Ether //Verification Date: 2/27/2018 //Transacion Count: 1 // CODE STARTS HERE pragma solidity ^0.4.18; /** * How addresses of non ERC20 coins were defined: * address(web3.sha3(coin_symbol_in_upper_case)) * * Example for BTC: * web3.sha3('BTC') = 0xe98e2830be1a7e4156d656a7505e65d08c67660dc618072422e9c78053c261e9 * address(0xe98e2830be1a7e4156d656a7505e65d08c67660dc618072422e9c78053c261e9) = 0x505e65d08c67660dc618072422e9c78053c261e9 */ contract CoinLib { // Bitcoin and forks: address public constant btc = address(0xe98e2830be1a7e4156d656a7505e65d08c67660dc618072422e9c78053c261e9); address public constant bch = address(0xc157673705e9a7d6253fb36c51e0b2c9193b9b560fd6d145bd19ecdf6b3a873b); address public constant btg = address(0x4e5f418e667aa2b937135735d3deb218f913284dd429fa56a60a2a8c2d913f6c); // Ethereum and forks: address public constant eth = address(0xaaaebeba3810b1e6b70781f14b2d72c1cb89c0b2b320c43bb67ff79f562f5ff4); address public constant etc = address(0x49b019f3320b92b2244c14d064de7e7b09dbc4c649e8650e7aa17e5ce7253294); // Bitcoin relatives: address public constant ltc = address(0xfdd18b7aa4e2107a72f3310e2403b9bd7ace4a9f01431002607b3b01430ce75d); address public constant doge = address(0x9a3f52b1b31ae58da40209f38379e78c3a0756495a0f585d0b3c84a9e9718f9d); // Anons/privacy coins: address public constant dash = address(0x279c8d120dfdb1ac051dfcfe9d373ee1d16624187fd2ed07d8817b7f9da2f07b); address public constant xmr = address(0x8f7631e03f6499d6370dbfd69bc9be2ac2a84e20aa74818087413a5c8e085688); address public constant zec = address(0x85118a02446a6ea7372cee71b5fc8420a3f90277281c88f5c237f3edb46419a6); address public constant bcn = address(0x333433c3d35b6491924a29fbd93a9852a3c64d3d5b9229c073a047045d57cbe4); address public constant pivx = address(0xa8b003381bf1e14049ab83186dd79e07408b0884618bc260f4e76ccd730638c7); // Smart contracts: address public constant ada = address(0x4e1e6d8aa1ff8f43f933718e113229b0ec6b091b699f7a8671bcbd606da36eea); address public constant xem = address(0x5f83a7d8f46444571fbbd0ea2d2613ab294391cb1873401ac6090df731d949e5); address public constant neo = address(0x6dc5790d7c4bfaaa2e4f8e2cd517bacd4a3831f85c0964e56f2743cbb847bc46); address public constant eos = 0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0; // Address of ERC20 token. address[] internal oldSchool = [btc, ltc, eth, dash]; address[] internal btcForks = [btc, bch, btg]; address[] internal smart = [eth, ada, eos, xem]; address[] internal anons = [dash, xmr, zec, bcn]; function getBtcForkCoins() public view returns (address[]) { return btcForks; } function getOldSchoolCoins() public view returns (address[]) { return oldSchool; } function getPrivacyCoins() public view returns (address[]) { return anons; } function getSmartCoins() public view returns (address[]) { return smart; } } /** * @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; } } contract SuperOwners { address public owner1; address public pendingOwner1; address public owner2; address public pendingOwner2; function SuperOwners(address _owner1, address _owner2) internal { require(_owner1 != address(0)); owner1 = _owner1; require(_owner2 != address(0)); owner2 = _owner2; } modifier onlySuperOwner1() { require(msg.sender == owner1); _; } modifier onlySuperOwner2() { require(msg.sender == owner2); _; } /** Any of the owners can execute this. */ modifier onlySuperOwner() { require(isSuperOwner(msg.sender)); _; } /** Is msg.sender any of the owners. */ function isSuperOwner(address _addr) public view returns (bool) { return _addr == owner1 || _addr == owner2; } /** * Safe transfer of ownership in 2 steps. Once called, a newOwner needs * to call claimOwnership() to prove ownership. */ function transferOwnership1(address _newOwner1) onlySuperOwner1 public { pendingOwner1 = _newOwner1; } function transferOwnership2(address _newOwner2) onlySuperOwner2 public { pendingOwner2 = _newOwner2; } function claimOwnership1() public { require(msg.sender == pendingOwner1); owner1 = pendingOwner1; pendingOwner1 = address(0); } function claimOwnership2() public { require(msg.sender == pendingOwner2); owner2 = pendingOwner2; pendingOwner2 = address(0); } } contract MultiOwnable is SuperOwners { mapping (address => bool) public ownerMap; address[] public ownerHistory; event OwnerAddedEvent(address indexed _newOwner); event OwnerRemovedEvent(address indexed _oldOwner); function MultiOwnable(address _owner1, address _owner2) SuperOwners(_owner1, _owner2) internal {} modifier onlyOwner() { require(isOwner(msg.sender)); _; } function isOwner(address owner) public view returns (bool) { return isSuperOwner(owner) || ownerMap[owner]; } function ownerHistoryCount() public view returns (uint) { return ownerHistory.length; } // Add extra owner function addOwner(address owner) onlySuperOwner public { require(owner != address(0)); require(!ownerMap[owner]); ownerMap[owner] = true; ownerHistory.push(owner); OwnerAddedEvent(owner); } // Remove extra owner function removeOwner(address owner) onlySuperOwner public { require(ownerMap[owner]); ownerMap[owner] = false; OwnerRemovedEvent(owner); } } contract Pausable is MultiOwnable { bool public paused; modifier ifNotPaused { require(!paused); _; } modifier ifPaused { require(paused); _; } // Called by the owner on emergency, triggers paused state function pause() external onlySuperOwner { paused = true; } // Called by the owner on end of emergency, returns to normal state function resume() external onlySuperOwner ifPaused { paused = false; } } contract ERC20 { uint256 public totalSupply; function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is ERC20 { using SafeMath for uint; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /// @dev Allows allowed third party to transfer tokens from one address to another. Returns success. /// @param _from Address from where tokens are withdrawn. /// @param _to Address to where tokens are sent. /// @param _value Number of tokens to transfer. function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /// @dev Sets approved amount of tokens for spender. Returns success. /// @param _spender Address of allowed account. /// @param _value Number of approved tokens. function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /// @dev Returns number of allowed tokens for given address. /// @param _owner Address of token owner. /// @param _spender Address of token spender. function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract CommonToken is StandardToken, MultiOwnable { string public name; string public symbol; uint256 public totalSupply; uint8 public decimals = 18; string public version = 'v0.1'; address public seller; // The main account that holds all tokens at the beginning and during tokensale. uint256 public saleLimit; // (e18) How many tokens can be sold in total through all tiers or tokensales. uint256 public tokensSold; // (e18) Number of tokens sold through all tiers or tokensales. uint256 public totalSales; // Total number of sales (including external sales) made through all tiers or tokensales. // Lock the transfer functions during tokensales to prevent price speculations. bool public locked = true; event SellEvent(address indexed _seller, address indexed _buyer, uint256 _value); event ChangeSellerEvent(address indexed _oldSeller, address indexed _newSeller); event Burn(address indexed _burner, uint256 _value); event Unlock(); function CommonToken( address _owner1, address _owner2, address _seller, string _name, string _symbol, uint256 _totalSupplyNoDecimals, uint256 _saleLimitNoDecimals ) MultiOwnable(_owner1, _owner2) public { require(_seller != address(0)); require(_totalSupplyNoDecimals > 0); require(_saleLimitNoDecimals > 0); seller = _seller; name = _name; symbol = _symbol; totalSupply = _totalSupplyNoDecimals * 1e18; saleLimit = _saleLimitNoDecimals * 1e18; balances[seller] = totalSupply; Transfer(0x0, seller, totalSupply); } modifier ifUnlocked(address _from, address _to) { require(!locked || isOwner(_from) || isOwner(_to)); _; } /** Can be called once by super owner. */ function unlock() onlySuperOwner public { require(locked); locked = false; Unlock(); } function changeSeller(address newSeller) onlySuperOwner public returns (bool) { require(newSeller != address(0)); require(seller != newSeller); address oldSeller = seller; uint256 unsoldTokens = balances[oldSeller]; balances[oldSeller] = 0; balances[newSeller] = balances[newSeller].add(unsoldTokens); Transfer(oldSeller, newSeller, unsoldTokens); seller = newSeller; ChangeSellerEvent(oldSeller, newSeller); return true; } function sellNoDecimals(address _to, uint256 _value) public returns (bool) { return sell(_to, _value * 1e18); } function sell(address _to, uint256 _value) onlyOwner public returns (bool) { // Check that we are not out of limit and still can sell tokens: require(tokensSold.add(_value) <= saleLimit); require(_to != address(0)); require(_value > 0); require(_value <= balances[seller]); balances[seller] = balances[seller].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(seller, _to, _value); totalSales++; tokensSold = tokensSold.add(_value); SellEvent(seller, _to, _value); return true; } /** * Until all tokens are sold, tokens can be transfered to/from owner's accounts. */ function transfer(address _to, uint256 _value) ifUnlocked(msg.sender, _to) public returns (bool) { return super.transfer(_to, _value); } /** * Until all tokens are sold, tokens can be transfered to/from owner's accounts. */ function transferFrom(address _from, address _to, uint256 _value) ifUnlocked(_from, _to) public returns (bool) { return super.transferFrom(_from, _to, _value); } function burn(uint256 _value) public returns (bool) { require(_value > 0); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value) ; totalSupply = totalSupply.sub(_value); Transfer(msg.sender, 0x0, _value); Burn(msg.sender, _value); return true; } } contract RaceToken is CommonToken { function RaceToken() CommonToken( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7, // __OWNER2__ 0x2821e1486D604566842FF27F626aF133FddD5f89, // __SELLER__ 'Coin Race', 'RACE', 100 * 1e6, // 100m tokens in total. 70 * 1e6 // 70m tokens for sale. ) public {} } library RaceCalc { using SafeMath for uint; // Calc a stake of a driver based on his current time. // We use linear regression, so the more time passed since // the start of the race, the less stake of a final reward he will receive. function calcStake( uint _currentTime, // Example: 1513533600 - 2017-12-17 18:00:00 UTC uint _finishTime // Example: 1513537200 - 2017-12-17 19:00:00 UTC ) public pure returns (uint) { require(_currentTime > 0); require(_currentTime < _finishTime); return _finishTime.sub(_currentTime); } // Calc gain of car at the finish of a race. // Result can be negative. // 100% is represented as 10^8 to be more precious. function calcGainE8( uint _startRateToUsdE8, // Example: 345 uint _finishRateToUsdE8 // Example: 456 ) public pure returns (int) { require(_startRateToUsdE8 > 0); require(_finishRateToUsdE8 > 0); int diff = int(_finishRateToUsdE8) - int(_startRateToUsdE8); return (diff * 1e8) / int(_startRateToUsdE8); } function calcPrizeTokensE18( uint totalTokens, uint winningStake, uint driverStake ) public pure returns (uint) { if (totalTokens == 0) return 0; if (winningStake == 0) return 0; if (driverStake == 0) return 0; if (winningStake == driverStake) return totalTokens; require(winningStake > driverStake); uint share = driverStake.mul(1e8).div(winningStake); return totalTokens.mul(share).div(1e8); } } /** * Here we implement all token methods that require msg.sender to be albe * to perform operations on behalf of GameWallet from other CoinRace contracts * like a particular contract of RaceGame. */ contract CommonWallet is MultiOwnable { RaceToken public token; event ChangeTokenEvent(address indexed _oldAddress, address indexed _newAddress); function CommonWallet(address _owner1, address _owner2) MultiOwnable(_owner1, _owner2) public {} function setToken(address _token) public onlySuperOwner { require(_token != 0); require(_token != address(token)); ChangeTokenEvent(token, _token); token = RaceToken(_token); } function transfer(address _to, uint256 _value) onlyOwner public returns (bool) { return token.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) onlyOwner public returns (bool) { return token.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) onlyOwner public returns (bool) { return token.approve(_spender, _value); } function burn(uint256 _value) onlySuperOwner public returns (bool) { return token.burn(_value); } /** Amount of tokens that players of CoinRace bet during the games and haven't claimed yet. */ function balance() public view returns (uint256) { return token.balanceOf(this); } function balanceOf(address _owner) public view returns (uint256) { return token.balanceOf(_owner); } function allowance(address _owner, address _spender) public view returns (uint256) { return token.allowance(_owner, _spender); } } contract GameWallet is CommonWallet { function GameWallet() CommonWallet( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7 // __OWNER2__ ) public {} } library RaceLib { using SafeMath for uint; function makeBet( Race storage _race, address _driver, address _car, uint _tokensE18 ) public { require(!isFinished(_race)); var bet = Bet({ driver: _driver, car: _car, tokens: _tokensE18, time: now }); _race.betsByDriver[_driver].push(bet); _race.betsByCar[_car].push(bet); if (_race.tokensByCarAndDriver[_car][_driver] == 0) { _race.driverCountByCar[_car] = _race.driverCountByCar[_car] + 1; } _race.tokensByCar[_car] = _race.tokensByCar[_car].add(_tokensE18); _race.tokensByCarAndDriver[_car][_driver] = _race.tokensByCarAndDriver[_car][_driver].add(_tokensE18); uint stakeTime = bet.time; if (bet.time < _race.leftGraceTime && _race.leftGraceTime > 0) stakeTime = _race.leftGraceTime; if (bet.time > _race.rightGraceTime && _race.rightGraceTime > 0) stakeTime = _race.rightGraceTime; uint stake = RaceCalc.calcStake(stakeTime, _race.finishTime); _race.stakeByCar[_car] = _race.stakeByCar[_car].add(stake); _race.stakeByCarAndDriver[_car][_driver] = _race.stakeByCarAndDriver[_car][_driver].add(stake); _race.totalTokens = _race.totalTokens.add(_tokensE18); } function hasDriverJoined( Race storage _race, address _driver ) public view returns (bool) { return betCountByDriver(_race, _driver) > 0; } function betCountByDriver( Race storage _race, address _driver ) public view returns (uint) { return _race.betsByDriver[_driver].length; } function betCountByCar( Race storage _race, address _car ) public view returns (uint) { return _race.betsByCar[_car].length; } function startCar( Race storage _race, address _car, uint _rateToUsdE8 ) public { require(_rateToUsdE8 > 0); require(_race.carRates[_car].startRateToUsdE8 == 0); _race.carRates[_car].startRateToUsdE8 = _rateToUsdE8; } function finish( Race storage _race ) public { require(!_race.finished); require(now >= _race.finishTime); _race.finished = true; } function isFinished( Race storage _race ) public view returns (bool) { return _race.finished; } struct Race { uint id; uint leftGraceTime; uint rightGraceTime; uint startTime; uint finishTime; bool finished; uint finishedCarCount; // 0 - if race is not finished yet. address firstCar; // Total amount of tokens tha thave been bet on all cars during the race: uint totalTokens; uint driverCount; // num of driver => driver's address. mapping (uint => address) drivers; // car_address => total_drivers_that_made_bet_on_this_car mapping (address => uint) driverCountByCar; // driver_address => bets by driver mapping (address => Bet[]) betsByDriver; // car_address => bets on this car. mapping (address => Bet[]) betsByCar; // car_address => total_tokens_bet_on_this_car mapping (address => uint) tokensByCar; // car_address => driver_address => total_tokens_bet_on_this_car_by_this_driver mapping (address => mapping (address => uint)) tokensByCarAndDriver; // car_address => stake_by_all_drivers mapping (address => uint) stakeByCar; // car_address => driver_address => stake mapping (address => mapping (address => uint)) stakeByCarAndDriver; // car_address => its rates to USD. mapping (address => CarRates) carRates; // int because it can be negative value if finish rate is lower. mapping (address => int) gainByCar; mapping (address => bool) isFinishedCar; // driver_address => amount of tokens (e18) that have been claimed by driver. mapping (address => uint) tokensClaimedByDriver; } struct Bet { address driver; address car; uint tokens; uint time; } struct CarRates { uint startRateToUsdE8; uint finishRateToUsdE8; } } contract CommonRace is MultiOwnable { using SafeMath for uint; using RaceLib for RaceLib.Race; GameWallet public wallet; // The name of the game. string public name; address[] public cars; mapping (address => bool) public isKnownCar; RaceLib.Race[] public races; address[] public drivers; mapping (address => bool) public isKnownDriver; modifier ifWalletDefined() { require(address(wallet) != address(0)); _; } function CommonRace( address _owner1, address _owner2, address[] _cars, string _name ) MultiOwnable(_owner1, _owner2) public { require(_cars.length > 0); name = _name; cars = _cars; for (uint16 i = 0; i < _cars.length; i++) { isKnownCar[_cars[i]] = true; } } function getNow() public view returns (uint) { return now; } function raceCount() public view returns (uint) { return races.length; } function carCount() public view returns (uint) { return cars.length; } function driverCount() public view returns (uint) { return drivers.length; } function setWallet(address _newWallet) onlySuperOwner public { require(wallet != _newWallet); require(_newWallet != 0); GameWallet newWallet = GameWallet(_newWallet); wallet = newWallet; } function lastLapId() public view returns (uint) { require(races.length > 0); return races.length - 1; } function nextLapId() public view returns (uint) { return races.length; } function getRace(uint _lapId) internal view returns (RaceLib.Race storage race) { race = races[_lapId]; require(race.startTime > 0); // if startTime is > 0 then race is real. } /** * _durationSecs - A duration of race in seconds. * * Structure of _carsAndRates: * N-th elem is a car addr. * (N+1)-th elem is car rate. */ function startNewRace( uint _newLapId, uint[] _carsAndRates, uint _durationSecs, uint _leftGraceSecs, // How many seconds from the start we should not apply penalty for stake of bet? uint _rightGraceSecs // How many seconds before the finish we should not apply penalty for stake of bet? ) onlyOwner public { require(_newLapId == nextLapId()); require(_carsAndRates.length == (cars.length * 2)); require(_durationSecs > 0); if (_leftGraceSecs > 0) require(_leftGraceSecs <= _durationSecs); if (_rightGraceSecs > 0) require(_rightGraceSecs <= _durationSecs); uint finishTime = now.add(_durationSecs); races.push(RaceLib.Race({ id: _newLapId, leftGraceTime: now + _leftGraceSecs, rightGraceTime: finishTime - _rightGraceSecs, startTime: now, finishTime: finishTime, finished: false, finishedCarCount: 0, firstCar: 0, totalTokens: 0, driverCount: 0 })); RaceLib.Race storage race = races[_newLapId]; uint8 j = 0; for (uint8 i = 0; i < _carsAndRates.length; i += 2) { address car = address(_carsAndRates[j++]); uint startRateToUsdE8 = _carsAndRates[j++]; require(isKnownCar[car]); race.startCar(car, startRateToUsdE8); } } /** * Structure of _carsAndRates: * N-th elem is a car addr. * (N+1)-th elem is car rate. */ function finishRace( uint _lapId, uint[] _carsAndRates ) onlyOwner public { require(_carsAndRates.length == (cars.length * 2)); RaceLib.Race storage race = getRace(_lapId); race.finish(); int maxGain = 0; address firstCar; // The first finished car. uint8 j = 0; for (uint8 i = 0; i < _carsAndRates.length; i += 2) { address car = address(_carsAndRates[j++]); uint finishRateToUsdE8 = _carsAndRates[j++]; require(!isCarFinished(_lapId, car)); // Mark car as finished: RaceLib.CarRates storage rates = race.carRates[car]; rates.finishRateToUsdE8 = finishRateToUsdE8; race.isFinishedCar[car] = true; race.finishedCarCount++; // Calc gain of car: int gain = RaceCalc.calcGainE8(rates.startRateToUsdE8, finishRateToUsdE8); race.gainByCar[car] = gain; if (i == 0 || gain > maxGain) { maxGain = gain; firstCar = car; } } // The first finished car should be found. require(firstCar != 0); race.firstCar = firstCar; } function finishRaceThenStartNext( uint _lapId, uint[] _carsAndRates, uint _durationSecs, uint _leftGraceSecs, // How many seconds from the start we should not apply penalty for stake of bet? uint _rightGraceSecs // How many seconds before the finish we should not apply penalty for stake of bet? ) onlyOwner public { finishRace(_lapId, _carsAndRates); startNewRace(_lapId + 1, _carsAndRates, _durationSecs, _leftGraceSecs, _rightGraceSecs); } function isLastRaceFinsihed() public view returns (bool) { return isLapFinished(lastLapId()); } function isLapFinished( uint _lapId ) public view returns (bool) { return getRace(_lapId).isFinished(); } // Unused func. // function shouldFinishLap( // uint _lapId // ) public view returns (bool) { // RaceLib.Race storage lap = getRace(_lapId); // // 'now' will not work for Ganache // return !lap.isFinished() && now >= lap.finishTime; // } function lapStartTime( uint _lapId ) public view returns (uint) { return getRace(_lapId).startTime; } function lapFinishTime( uint _lapId ) public view returns (uint) { return getRace(_lapId).finishTime; } function isCarFinished( uint _lapId, address _car ) public view returns (bool) { require(isKnownCar[_car]); return getRace(_lapId).isFinishedCar[_car]; } function allCarsFinished( uint _lapId ) public view returns (bool) { return finishedCarCount(_lapId) == cars.length; } function finishedCarCount( uint _lapId ) public view returns (uint) { return getRace(_lapId).finishedCarCount; } function firstCar( uint _lapId ) public view returns (address) { return getRace(_lapId).firstCar; } function isWinningDriver( uint _lapId, address _driver ) public view returns (bool) { RaceLib.Race storage race = getRace(_lapId); return race.tokensByCarAndDriver[race.firstCar][_driver] > 0; } /** * This is helper function usefull when debugging contract or checking state on Etherscan. */ function myUnclaimedTokens( uint _lapId ) public view returns (uint) { return unclaimedTokens(_lapId, msg.sender); } /** * Calculate how much tokens a winning driver can claim once race is over. * Claimed tokens will be added back to driver's token balance. * Formula = share of all tokens based on bets made on winning car. * Tokens in format e18. */ function unclaimedTokens( uint _lapId, address _driver ) public view returns (uint) { RaceLib.Race storage race = getRace(_lapId); // if driver has claimed his tokens already. if (race.tokensClaimedByDriver[_driver] > 0) return 0; if (!race.isFinished()) return 0; if (race.firstCar == 0) return 0; if (race.totalTokens == 0) return 0; if (race.stakeByCar[race.firstCar] == 0) return 0; // Size of driver's stake on the first finished car. uint driverStake = race.stakeByCarAndDriver[race.firstCar][_driver]; if (driverStake == 0) return 0; return RaceCalc.calcPrizeTokensE18( race.totalTokens, race.stakeByCar[race.firstCar], driverStake ); } function claimTokens( uint _lapId ) public ifWalletDefined { address driver = msg.sender; uint tokens = unclaimedTokens(_lapId, driver); require(tokens > 0); // Transfer prize tokens from game wallet to driver's address: require(wallet.transfer(driver, tokens)); getRace(_lapId).tokensClaimedByDriver[driver] = tokens; } function makeBet( uint _lapId, address _car, uint _tokensE18 ) public ifWalletDefined { address driver = msg.sender; require(isKnownCar[_car]); // NOTE: Remember that driver needs to call Token(address).approve(wallet, tokens) // or this contract will not be able to do the transfer on your behalf. // Transfer tokens from driver to game wallet: require(wallet.transferFrom(msg.sender, wallet, _tokensE18)); getRace(_lapId).makeBet(driver, _car, _tokensE18); if (!isKnownDriver[driver]) { isKnownDriver[driver] = true; drivers.push(driver); } } /** * Result array format: * [ * N+0: COIN_ADDRESS (ex: 0x0000000000000000000000000000000000012301) * N+1: MY_BET_TOKENS_E18 * ... repeat ... * ] */ function myBetsInLap( uint _lapId ) public view returns (uint[] memory totals) { RaceLib.Race storage race = getRace(_lapId); totals = new uint[](cars.length * 2); uint8 j = 0; address car; for (uint8 i = 0; i < cars.length; i++) { car = cars[i]; totals[j++] = uint(car); totals[j++] = race.tokensByCarAndDriver[car][msg.sender]; } } /** * Result array format: * [ * 0: START_DATE_UNIX_TS * 1: DURATION_SEC * 2: FIRST_CAR_ID * 3: !!! NEW !!! MY_UNCLAIMED_TOKENS * * N+0: COIN_ADDRESS (ex: 0x0000000000000000000000000000000000012301) * N+1: START_RATE_E8 * N+2: END_RATE_E8 * N+3: DRIVER_COUNT * N+4: TOTAL_BET_TOKENS_E18 * N+5: MY_BET_TOKENS_E18 * N+6: !!! NEW !!! GAIN_E8 * ... repeat for each car... * ] */ function lapTotals( uint _lapId ) public view returns (int[] memory totals) { RaceLib.Race storage race = getRace(_lapId); totals = new int[](5 + cars.length * 7); uint _myUnclaimedTokens = 0; if (isLapFinished(_lapId)) { _myUnclaimedTokens = unclaimedTokens(_lapId, msg.sender); } address car; uint8 j = 0; totals[j++] = int(now); totals[j++] = int(race.startTime); totals[j++] = int(race.finishTime - race.startTime); totals[j++] = int(race.firstCar); totals[j++] = int(_myUnclaimedTokens); for (uint8 i = 0; i < cars.length; i++) { car = cars[i]; totals[j++] = int(car); totals[j++] = int(race.carRates[car].startRateToUsdE8); totals[j++] = int(race.carRates[car].finishRateToUsdE8); totals[j++] = int(race.driverCountByCar[car]); totals[j++] = int(race.tokensByCar[car]); totals[j++] = int(race.tokensByCarAndDriver[car][msg.sender]); totals[j++] = race.gainByCar[car]; } } } contract RaceOldSchool4h is CommonRace, CoinLib { function RaceOldSchool4h() CommonRace( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7, // __OWNER2__ oldSchool, 'Old School' ) public {} } contract RaceBtcForks4h is CommonRace, CoinLib { function RaceBtcForks4h() CommonRace( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7, // __OWNER2__ btcForks, 'Bitcoin Forks' ) public {} } contract RaceSmart4h is CommonRace, CoinLib { function RaceSmart4h() CommonRace( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7, // __OWNER2__ smart, 'Smart Coins' ) public {} } contract RaceAnons4h is CommonRace, CoinLib { function RaceAnons4h() CommonRace( 0x229B9Ef80D25A7e7648b17e2c598805d042f9e56, // __OWNER1__ 0xcd7cF1D613D5974876AfBfd612ED6AFd94093ce7, // __OWNER2__ anons, 'Anonymouses' ) public {} }
The main account that holds all tokens at the beginning and during tokensale.
address public seller;
1,015,469
[ 1, 1986, 2774, 2236, 716, 14798, 777, 2430, 622, 326, 8435, 471, 4982, 2430, 5349, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1758, 1071, 29804, 31, 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 ]
// SPDX-License-Identifier: LGPL-3.0 pragma solidity ^0.8.9; import "./BDERC1155Tradable.sol"; import "./IWarrior.sol"; import "./IRegion.sol"; //Import ERC1155 standard for utilizing FAME tokens import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; ///@title LootChestCollectible ///@notice The contract for managing BattleDrome Loot Chest Tokens contract LootChestCollectible is BDERC1155Tradable, ERC1155Holder { ////////////////////////////////////////////////////////////////////////////////////////// // Config ////////////////////////////////////////////////////////////////////////////////////////// //Fungible Token Tiers enum ChestType { NULL, BRONZE, SILVER, GOLD, DIAMOND } //Chest level multipliers are used in math throughout, this is done by taking the integerized value of ChestType //ie: // bronze = 1 // silver = 2 // gold = 3 // diamond = 4 //And then taking 2 ^ ({val}-1) //So the resulting multipliers would be for example: // bronze = 1 // silver = 2 // gold = 4 // diamond = 8 //Chest Contents Constants //Base value is multiplied by the appropriate chest level multiplier uint constant FIXED_VALUE_BASE = 125; //Chance Constants - chance/10000 eg: 100.00% //This applies to the bronze level chests, each subsequent chest has chances multiplied by it's multiplier uint constant CHANCE_BONUS_10 = 500; //5% - Bronze, 10% - Silver, 20% - Gold, 40% - Diamond uint constant CHANCE_BONUS_25 = 200; //2% - Bronze, 4% - Silver, 8% - Gold, 16% - Diamond uint constant CHANCE_BONUS_50 = 100; //1% - Bronze, 2% - Silver, 4% - Gold, 8% - Diamond uint constant CHANCE_BONUS_WARRIOR = 100; //1% - Bronze, 2% - Silver, 4% - Gold, 8% - Diamond uint constant CHANCE_BONUS_REGION = 5; //0.05% - Bronze, 0.1% - Silver, 0.2% - Gold, 0.4% - Diamond //Costing Constants uint constant ICO_BASE_FAME_VALUE = 10000000 gwei; uint constant NEW_FAME_PER_OLD = 1000; uint constant NEW_FAME_ICO_VALUE = ICO_BASE_FAME_VALUE / NEW_FAME_PER_OLD; uint constant VOLUME_DISCOUNT_PERCENT = 1; //Cost break when increasing tier when calculating cost of a chest tier //ie: this percentage is multiplied by the multiplier, and applied as a discount to price uint constant MIN_DEMAND_RATIO = 5000; //Percent * 10000 similar to chances above uint constant MAX_DEMAND_RATIO = 20000; //Percent * 10000 similar to chances above //Other Misc Config Constants uint8 constant RECENT_SALES_TO_TRACK = 64; //Max of last 32 sales uint constant RECENT_SALES_TIME_SECONDS = 86400 * 30; //Max of last 30 days ////////////////////////////////////////////////////////////////////////////////////////// // Structs ////////////////////////////////////////////////////////////////////////////////////////// struct ChestSale { uint64 timestamp; uint8 chest_type; uint32 quantity; } ////////////////////////////////////////////////////////////////////////////////////////// // Local Storage Variables ////////////////////////////////////////////////////////////////////////////////////////// //Associated Contracts IERC1155 FAMEContract; uint256 FAMETokenID; IWarrior WarriorContract; IRegion RegionContract; //Sales History (Demand Tracking) ChestSale[RECENT_SALES_TO_TRACK] recentSales; uint currentSaleIndex = 0; ////////////////////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////////////////////// constructor(address _proxyRegistryAddress) BDERC1155Tradable( "LootChestCollectible", "BDLC", _proxyRegistryAddress, "https://metadata.battledrome.io/api/erc1155-loot-chest/" ) { } ////////////////////////////////////////////////////////////////////////////////////////// // Errors ////////////////////////////////////////////////////////////////////////////////////////// /** *@notice The contract does not have sufficient FAME to support `requested` chests of type `chestType`, maximum of `maxPossible` can be created with current balance. *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@param requested The number of chests requested *@param maxPossible The maximum number of chests of the requested type that can be created with current balance */ error InsufficientContractBalance(uint8 chestType, uint256 requested, uint256 maxPossible); /** *@notice Insufficient Ether sent for the requested action. You sent `sent` Wei but `required` Wei was required *@param sent The amount of Ether (in Wei) that was sent by the caller *@param required The amount of Ether (in Wei) that was actually required for the requested action */ error InsufficientEther(uint256 sent, uint256 required); /** *@notice Insufficient Chests of type: `chestType`, you only have `balance` chests of that type! *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@param balance The number of chests the user currently has of the specified type */ error InsufficientChests(uint8 chestType, uint256 balance); /** *@notice Error minting new Warrior NFT! *@param code Error Code */ error ErrorMintingWarrior(uint code); /** *@notice Error minting new Region NFT! *@param code Error Code */ error ErrorMintingRegion(uint code); ////////////////////////////////////////////////////////////////////////////////////////// // Events ////////////////////////////////////////////////////////////////////////////////////////// /** *@notice Indicates that a user `opener` opened `quantity` chests of type `chestType` at `timeStamp` *@param opener The address that opened the chests *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@param quantity The number of chests opened in this event *@param timeStamp the timestamp that the chests were opened *@param fame The amount of FAME found in the box(s) *@param warriors The number of warriors found in the box(s) *@param regions The number of regions found in the box(s) */ event LootBoxOpened(address indexed opener, uint8 indexed chestType, uint32 quantity, uint32 timeStamp, uint32 fame, uint32 warriors, uint32 regions); ////////////////////////////////////////////////////////////////////////////////////////// // ERC1155 Overrides/Functions ////////////////////////////////////////////////////////////////////////////////////////// function contractURI() public pure returns (string memory) { return "https://metadata.battledrome.io/contract/erc1155-loot-chest"; } function onERC1155Received( address _operator, address _from, uint256 _id, uint256 _amount, bytes calldata _data ) public override returns (bytes4) { require( ( (msg.sender == address(FAMEContract) && _id == FAMETokenID) || //Allow reciept of FAME tokens msg.sender == address(RegionContract) || //Allow Region Contract to send us Region NFTs (to forward to users) msg.sender == address(this) //Allow any internal transaction originated here ), "INVALID_TOKEN!" //Otherwise kick back INVALID_TOKEN error code, preventing the transfer. ); bytes4 rv = super.onERC1155Received(_operator, _from, _id, _amount, _data); return rv; } function supportsInterface(bytes4 interfaceId) public view virtual override(BDERC1155Tradable, ERC1155Receiver) returns (bool) { return super.supportsInterface(interfaceId); } ////////////////////////////////////////////////////////////////////////////////////////// // Loot Box Buy/Sell ////////////////////////////////////////////////////////////////////////////////////////// /** *@notice Buy a number of chests of the specified type, paying ETH *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@param quantity The number of chests to buy */ function buy(ChestType chestType, uint quantity) public payable { //First, is it possible to buy the proposed chests? If not, then revert to prevent people wasting money uint maxCreatable = maxSafeCreatable(chestType); if(maxCreatable >= quantity){ //We have sufficient balance to create at least the requested amount //So calculate the required price of the requested chests: uint price = getPrice(chestType) * quantity; //Did the user send enough? if(msg.value>=price){ //Good, they paid enough... Let's mint their chests then! _mint(msg.sender, uint(chestType), quantity, ""); tokenSupply[uint(chestType)] = tokenSupply[uint(chestType)] + quantity; //Because we're bypassing the normal mint function. ChestSale storage saleRecord = recentSales[(currentSaleIndex++)%RECENT_SALES_TO_TRACK]; saleRecord.timestamp = uint64(block.timestamp); saleRecord.chest_type = uint8(chestType); saleRecord.quantity = uint32(quantity); //Check if they overpaid and refund: if(msg.value>price){ payable(msg.sender).transfer(msg.value-price); } }else{ //Bad monkey! Not enough money! revert InsufficientEther(msg.value,price); } }else{ //Insufficient balance, throw error: revert InsufficientContractBalance(uint8(chestType), quantity, maxCreatable); } } /** *@notice Sell a number of FAME back to the contract, in exchange for whatever the current payout is. *@param quantity The number of FAME to sell */ function sell(uint quantity) public { uint payOutAmount = getBuyBackPrice(quantity); transferFAME(msg.sender,address(this),quantity); require(address(this).balance>=payOutAmount,"CONTRACT BALANCE ERROR!"); if(payOutAmount>0) payable(msg.sender).transfer(payOutAmount); } ////////////////////////////////////////////////////////////////////////////////////////// // Loot Box Opening ////////////////////////////////////////////////////////////////////////////////////////// /** *@notice Open a number of your owned chests of the specified type *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@param quantity The number of chests to open *@return fameReward The amount of FAME found in the chests *@return warriors The number of bonus Warriors found in the chests *@return regions The number of bonus Regions found in the chests */ function open(ChestType chestType, uint quantity) public ownersOnly(uint(chestType)) returns (uint fameReward, uint warriors, uint regions) { //First let's confirm if the user actually owns enough chests of the appropriate type that they've requested uint balance = balanceOf(msg.sender, uint(chestType)); if(balance >= quantity){ fameReward = 0; warriors = 0; regions = 0; uint chestTypeMultiplier = (2**(uint(chestType)-1)); uint baseFAMEReward = FIXED_VALUE_BASE * chestTypeMultiplier; //Burn the appropriate number of chests: _burn(msg.sender,uint(chestType),quantity); //Iterate the chests requested to calculate rewards for(uint chest=0;chest<quantity;chest++){ //Calculate the FAME Reward amount for this chest: uint fameRoll = roll(chest*2+0); if(fameRoll<(CHANCE_BONUS_50 * chestTypeMultiplier)){ fameReward += baseFAMEReward * 1500 / 1000; }else if(fameRoll<(CHANCE_BONUS_25 * chestTypeMultiplier)){ fameReward += baseFAMEReward * 1250 / 1000; }else if(fameRoll<(CHANCE_BONUS_10 * chestTypeMultiplier)){ fameReward += baseFAMEReward * 1100 / 1000; }else{ fameReward += baseFAMEReward; } //Calculate if any prize (NFT) was also received in this chest: uint prizeRoll = roll(chest*2+1); if(prizeRoll<(CHANCE_BONUS_REGION * chestTypeMultiplier)){ //Woohoo! Won a Region! BONUS! regions++; }else if(fameRoll<(CHANCE_BONUS_WARRIOR * chestTypeMultiplier)){ //Woohoo! Won a Warrior! warriors++; } } //Ok now that we've figured out their rewards, let's give it all to them! //First the FAME: transferFAME(address(this),msg.sender,fameReward); //Now if there are regions or warriors in the rewards, mint the appropriate NFTs: for(uint w=0;w<warriors;w++){ //Unfortunately because of how warrior minting works, we need to pre-generate some random traits: // For the record this was chosen for a good reason, it's more flexible and supports a wider set of use cases // But it is a bit more work when implementing in an external contract like this... //First let's grab a random seed: uint randomSeed = uint(keccak256(abi.encodePacked(block.timestamp,blockhash(block.number)))); //And then generate the remaining traits from it uint16 colorHue = uint16(uint(keccak256(abi.encodePacked(randomSeed,uint8(1))))); uint8 armorType = uint8(uint(keccak256(abi.encodePacked(randomSeed,uint8(2)))))%4; uint8 shieldType = uint8(uint(keccak256(abi.encodePacked(randomSeed,uint8(3)))))%4; uint8 weaponType = uint8(uint(keccak256(abi.encodePacked(randomSeed,uint8(4)))))%10; //Now mint the warrior: WarriorContract.mintCustomWarrior(msg.sender, 0, true, randomSeed, colorHue, armorType, shieldType, weaponType); } for(uint r=0;r<regions;r++){ //When minting Regions, the caller (this contract) will end up owning them, so we need to first mint, then change ownership: //First we try to mint: try RegionContract.trustedCreateRegion() returns (uint regionID){ //Now we transfer it to the user: RegionContract.safeTransferFrom(address(this),msg.sender,regionID,1,""); } catch Error(string memory reason) { revert(reason); } catch Panic(uint code) { revert ErrorMintingRegion(code); } catch (bytes memory) { revert ErrorMintingRegion(0); } } emit LootBoxOpened(msg.sender, uint8(chestType), uint32(quantity), uint32(block.timestamp), uint32(fameReward), uint32(warriors), uint32(regions)); }else{ //Bad monkey! You don't have that many chests to open! revert InsufficientChests(uint8(chestType), balance); } } ////////////////////////////////////////////////////////////////////////////////////////// // Costing Getters ////////////////////////////////////////////////////////////////////////////////////////// /** *@notice Get the Base Value (guaranteed FAME contents) of a given chest type *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@return value The Value (amount of FAME) included in the chest type */ function getBaseValue(ChestType chestType) public pure returns (uint value) { require(chestType > ChestType.NULL && chestType <= ChestType.DIAMOND, "ILLEGAL CHEST TYPE"); value = FIXED_VALUE_BASE * (2**(uint(chestType)-1)); } /** *@notice Get the recent sales volume (total amount of FAME sold in chest Base Values) *@return volume The total Base Value (guaranteed included FAME) of all recent chest sales *@dev This is used to figure out demand for costing math */ function getRecentSalesVolume() public view returns (uint volume) { volume = 1; //To avoid div/0 for(uint i = 0; i<RECENT_SALES_TO_TRACK; i++){ if(recentSales[i].timestamp >= block.timestamp - RECENT_SALES_TIME_SECONDS){ volume += getBaseValue(ChestType(recentSales[i].chest_type)) * recentSales[i].quantity; } } } /** *@notice Calculate the current FAME price (price per FAME token in ETH) *@return price The current ETH price (in wei) of a single FAME token *@dev This is used to calculate the "market floor" price for FAME so that we can use it to caluclate cost of chests. */ function getCurrentFAMEPrice() public view returns (uint price) { //First we look at the current (available/non-liable) fame balance, and the recent sales volume, and calculate a demand ratio: // Note: recent sales volume is always floored at the value of at least one of the max chest, which allows // for the situation where there is zero supply, to incentivize seeding the supply to accommodate chest sales. // Otherwise, what happens is if the contract runs dry, and no sales happen because there is no supply, the // "recent sales" drop to zero, resulting in artificially deflated demand, even though "demand" might be high, but // it can't be observed because lack of supply has choked off sales. (not to mention it also helps avoid div/0) //ie: if we have 10,000 FAME, and we've recently only sold 1000, then we have 10:1 ratio so plenty of supply to meet the demand // however if we have 1000 FAME, and recently sold 2000, we have a 0.5:1 ratio, so low supply, which should drive up price... //Price is calculated by first calculating demand ratio, and then clamping it to min/max range (in config constants) //Then taking the ICO base value of new FAME, and dividing by the demand ratio. //As a practical example, let's assume the ICO base value was 10,000gwei per fame, //And assume we have a demand ratio clamp range of 0.5 - 2.0 //Then the following table demonstrates how the demand ratios would equate to FAME price //0.5:1 - 20,000 gwei/FAME //0.75:1 - 13,333 gwei/FAME //1:1 - 10,000 gwei/FAME //1.25:1 - 8,000 gwei/FAME //1.5:1 - 6,666 gwei/FAME //1.75:1 - 5,714 gwei/FAME //2:1 - 5,000 gwei/FAME //Keep in mind this mechanism is designed to be a fallback to market liquidity. Ideally if the market is healthy, then on //exchange sites such as OpenSea, or other token exchanges, FAME will trade for normal market value and this contract will be ignored. //This contract serves a purpose during ramp-up of BattleDrome, to provide a buy-in mechanism, and a sell-off mechanism to distribute //some of the FAME from ICO backers, to seed initial market distribution, and jump-start new players. //It also serves a purpose if market liquidity results in poor conditions, provided people are still interested in the tokens/game //As it will serve as a floor price mechanism, allowing holders to liquidate if there is some demand, and players to buy in if there is supply //Get the raw sales volume uint rawSalesVolume = getRecentSalesVolume(); //Find out the minimum sales volume (cost of a diamond chest) uint minSalesVolume = getBaseValue(ChestType.DIAMOND); //Raise the sales volume if needed uint adjustedSalesVolume = (rawSalesVolume<minSalesVolume) ? minSalesVolume : rawSalesVolume; //Now we figure out our "available balance" uint availableBalance = getContractFAMEBalance() - calculateCurrentLiability(); //Calculate raw demand ratio uint rawDemandRatio = (availableBalance * 10000) / adjustedSalesVolume; //Then clamp the demand ratio within min/max bounds set in constants above uint demandRatio = (rawDemandRatio<MIN_DEMAND_RATIO)?MIN_DEMAND_RATIO:(rawDemandRatio>MAX_DEMAND_RATIO)?MAX_DEMAND_RATIO:rawDemandRatio; //And finally calculate the price based on resulting demand ratio price = (NEW_FAME_ICO_VALUE * 10000) / demandRatio; } /** *@notice Calculate the current price in Ether (wei) for the specified chest type *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@return price The current ETH price (in wei) of a chest of that type */ function getPrice(ChestType chestType) public view returns (uint price) { uint8 discountedPriceMultiplier = uint8(100 - (VOLUME_DISCOUNT_PERCENT * (2**(uint(chestType)-1)))); price = getCurrentFAMEPrice() * getBaseValue(chestType) * discountedPriceMultiplier / 100; } /** *@notice Calculate the Ether Price we will pay to buy back FAME from a user (in Wei) *@param amount The amount of FAME tokens on offer (the total price returned will be for this full amount) *@return price The current ETH price (in wei) that will be paid for the full amount specified */ function getBuyBackPrice(uint amount) public view returns (uint price) { //Determine current FAME price, and then we multiply down because our buyback percentage is 90% of current market price //We also multiply by the amount to find the (perfect world) amount we will pay price = (getCurrentFAMEPrice() * 9 / 10) * amount; //Now we determine the max we will pay in a single transaction (capped at 25% of our current holdings in ETH, to prevent abuse) //This means that if one user tries to dump a large amount to take advantage of a favorable price, they will only be paid a limited amount //Forcing them to reduce their transaction (or risk being under-paid), and do a second transaction. uint maxPayout = address(this).balance / 4; //Next we cap the payout based on the maxPayout: price = price > maxPayout ? maxPayout : price; } ////////////////////////////////////////////////////////////////////////////////////////// // Utility Functions ////////////////////////////////////////////////////////////////////////////////////////// /** *@dev Internal Helper Function to determine random roll when opening chests. Crude RNG, should be good enough, but is manipulable by miner theoretically *@param seedOffset Integer seed offset used for additional randomization *@return result Random roll from 0-10000 (random percentage to 2 decimal places) */ function roll(uint seedOffset) internal view returns (uint16 result) { uint randomUint = uint(keccak256(abi.encodePacked(block.timestamp,blockhash(block.number),seedOffset))); result = uint16(randomUint % 10000); } /** *@notice ADMIN FUNCTION: Update the FAME Token ERC1155 Contract Address *@param newContract The address of the new contract */ function setFAMEContractAddress(address newContract) public onlyOwner { FAMEContract = IERC1155(newContract); } /** *@notice ADMIN FUNCTION: Set the internal Token ID for FAME Tokens within the ERC1155 Contract *@param id The new Token ID */ function setFAMETokenID(uint256 id) public onlyOwner { FAMETokenID = id; } /** *@notice ADMIN FUNCTION: Update the Warrior NFT ERC1155 Contract Address *@param newContract The address of the new contract */ function setWarriorContractAddress(address newContract) public onlyOwner { WarriorContract = IWarrior(newContract); } /** *@notice ADMIN FUNCTION: Update the Region NFT ERC1155 Contract Address *@param newContract The address of the new contract */ function setRegionContractAddress(address newContract) public onlyOwner { RegionContract = IRegion(newContract); } /** *@dev Utility/Helper function for internal use whenever we need to transfer fame between 2 addresses *@param sender The Sender Address (address from which the FAME will be deducted) *@param recipient The Recipient Address (address to which the FAME will be credited) *@param amount The amount of FAME tokens to transfer */ function transferFAME( address sender, address recipient, uint256 amount ) internal { FAMEContract.safeTransferFrom( sender, recipient, FAMETokenID, amount, "" ); } /** *@notice Fetch the current FAME balance held within the Loot Chest Smart Contract *@return balance The current FAME Token Balance */ function getContractFAMEBalance() public view returns (uint balance) { return FAMEContract.balanceOf(address(this),FAMETokenID); } /** *@dev Utility/Helper function for internal use, helps determine the worst case liability of a given chest type (amount of FAME that needs paying out) *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@return fame_liability The liability (amount of FAME this countract could potentially be expected to pay out in the worst case, or maximum reward scenario) */ function calculateChestLiability(ChestType chestType) internal pure returns (uint fame_liability) { return getBaseValue(chestType) * 1500 / 1000; } /** *@notice The current total liability of this contract (total FAME that would be required to be paid out if all current chests in circulation contain the max reward) *@return fame_liability The current total liability (total FAME payout required in worse case from all chests in circulation) */ function calculateCurrentLiability() public view returns (uint fame_liability) { for(uint8 ct=uint8(ChestType.BRONZE);ct<=uint8(ChestType.DIAMOND);ct++) { //Get current chest count of chest type uint chestCount = totalSupply(ct); //Then multiply by the liability of that chest type fame_liability += chestCount * calculateChestLiability(ChestType(ct)); } } /** *@notice Checks based on current FAME balance, and current total liability, the max number of specified chestType that can be created safely (factoring in new liability for requested chests) *@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond) *@return maxQuantity Maximum quantity of chests of specified type, that can be created safely based on current conditions. */ function maxSafeCreatable(ChestType chestType) public view returns (uint maxQuantity) { maxQuantity = 0; uint currentLiability = calculateCurrentLiability(); uint currentBalance = getContractFAMEBalance(); if(currentLiability < currentBalance){ uint freeBalance = currentBalance - currentLiability; maxQuantity = freeBalance / calculateChestLiability(chestType); } } } // SPDX-License-Identifier: LGPL-3.0 pragma solidity ^0.8.9; interface IWarrior { function mintCustomWarrior(address owner, uint32 generation, bool special, uint randomSeed, uint16 colorHue, uint8 armorType, uint8 shieldType, uint8 weaponType) external returns(uint theNewWarrior); function newWarrior() external returns(uint theNewWarrior); function getWarriorIDByName(string calldata name) external view returns(uint); function nameExists(string calldata _name) external view returns(bool); function setName(uint warriorID, string calldata name) external; function ownerOf(uint _id) external view returns(address); function getWarriorCost() external pure returns(uint); function getWarriorName(uint warriorID) external view returns(string memory); function payWarrior(uint warriorID, uint amount, bool tax) external; function transferFAMEFromWarriorToWarrior(uint senderID, uint recipientID, uint amount, bool tax) external; function transferFAMEFromWarriorToAddress(uint warriorID, address recipient, uint amount) external; } // SPDX-License-Identifier: LGPL-3.0 pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; interface IRegion is IERC1155 { function trustedCreateRegion() external returns (uint256 theNewRegion); function newRegion() external returns (uint256 theNewRegion); function getCurrentRegionCount() external view returns (uint256); function getCurrentRegionPricingCounter() external view returns (uint256); function ownerOf(uint256 _id) external view returns (address); function getRegionCost(int256 offset) external view returns (uint256); function getRegionName(uint256 regionID) external; function payRegion(uint256 regionID, uint256 amount, bool tax) external; } // SPDX-License-Identifier: LGPL-3.0 pragma solidity ^0.8.9; //import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; //import 'multi-token-standard/contracts/tokens/ERC1155/ERC1155.sol'; //import 'multi-token-standard/contracts/tokens/ERC1155/ERC1155Metadata.sol'; //import 'multi-token-standard/contracts/tokens/ERC1155/ERC1155MintBurn.sol'; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** * @title BDERC1155Tradable * BDERC1155Tradable - BattleDrome ERC1155 contract that whitelists an operator address, has create and mint functionality, and supports useful standards from OpenZeppelin, like _exists(), name(), symbol(), and totalSupply() */ contract BDERC1155Tradable is ERC1155PresetMinterPauser, Ownable { using Strings for string; address proxyRegistryAddress; uint256 private _currentTokenID = 0; mapping(uint256 => address) public creators; mapping(uint256 => uint256) public tokenSupply; // Contract name string public name; // Contract symbol string public symbol; //Metadata URI (for backwards compat with old code, overrides URI functionality from openzeppelin) string public baseMetadataURI; /** * @dev Require msg.sender to be the creator of the token id */ modifier creatorOnly(uint256 _id) { require( creators[_id] == msg.sender, "ERC1155Tradable#creatorOnly: ONLY_CREATOR_ALLOWED" ); _; } /** * @dev Require msg.sender to own more than 0 of the token id */ modifier ownersOnly(uint256 _id) { require( balanceOf(msg.sender, _id) > 0, "ERC1155Tradable#ownersOnly: ONLY_OWNERS_ALLOWED" ); _; } constructor( string memory _name, string memory _symbol, address _proxyRegistryAddress, string memory _metadataURI ) ERC1155PresetMinterPauser(_metadataURI) { name = _name; symbol = _symbol; proxyRegistryAddress = _proxyRegistryAddress; _setBaseMetadataURI(_metadataURI); } function uri(uint256 _id) public view override returns (string memory) { require(_exists(_id), "ERC721Tradable#uri: NONEXISTENT_TOKEN"); return string(abi.encodePacked(baseMetadataURI, Strings.toString(_id))); } /** * @dev Returns the total quantity for a token ID * @param _id uint256 ID of the token to query * @return amount of token in existence */ function totalSupply(uint256 _id) public view returns (uint256) { return tokenSupply[_id]; } function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal { baseMetadataURI = _newBaseMetadataURI; } /** * @dev Will update the base URL of token's URI * @param _newBaseMetadataURI New base URL of token's URI */ function setBaseMetadataURI(string memory _newBaseMetadataURI) public onlyOwner { _setBaseMetadataURI(_newBaseMetadataURI); } /** * @dev Creates a new token type and assigns _initialSupply to an address * NOTE: remove onlyOwner if you want third parties to create new tokens on your contract (which may change your IDs) * @param _initialOwner address of the first owner of the token * @param _initialSupply amount to supply the first owner * @param _uri Optional URI for this token type * @param _data Data to pass if receiver is contract * @return The newly created token ID */ function create( address _initialOwner, uint256 _initialSupply, string calldata _uri, bytes calldata _data ) external onlyOwner returns (uint256) { uint256 _id = _getNextTokenID(); _incrementTokenTypeId(); creators[_id] = msg.sender; if (bytes(_uri).length > 0) { emit URI(_uri, _id); } _mint(_initialOwner, _id, _initialSupply, _data); tokenSupply[_id] = _initialSupply; return _id; } /** * @dev Mints some amount of tokens to an address * @param _to Address of the future owner of the token * @param _id Token ID to mint * @param _quantity Amount of tokens to mint * @param _data Data to pass if receiver is contract */ function mint( address _to, uint256 _id, uint256 _quantity, bytes memory _data ) public override creatorOnly(_id) { _mint(_to, _id, _quantity, _data); tokenSupply[_id] = tokenSupply[_id] + _quantity; } /** * @dev Mint tokens for each id in _ids * @param _to The address to mint tokens to * @param _ids Array of ids to mint * @param _quantities Array of amounts of tokens to mint per id * @param _data Data to pass if receiver is contract */ function batchMint( address _to, uint256[] memory _ids, uint256[] memory _quantities, bytes memory _data ) public { for (uint256 i = 0; i < _ids.length; i++) { uint256 _id = _ids[i]; require( creators[_id] == msg.sender, "ERC1155Tradable#batchMint: ONLY_CREATOR_ALLOWED" ); uint256 quantity = _quantities[i]; tokenSupply[_id] = tokenSupply[_id] + quantity; } _mintBatch(_to, _ids, _quantities, _data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal override { tokenSupply[id] = tokenSupply[id] - amount; super._burn(from,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 from, uint256[] memory ids, uint256[] memory amounts ) internal override { for (uint256 i = 0; i < ids.length; i++) { tokenSupply[ids[i]] = tokenSupply[ids[i]] - amounts[i]; } super._burnBatch(from,ids,amounts); } /** * @dev Change the creator address for given tokens * @param _to Address of the new creator * @param _ids Array of Token IDs to change creator */ function setCreator(address _to, uint256[] memory _ids) public { require( _to != address(0), "ERC1155Tradable#setCreator: INVALID_ADDRESS." ); require( _ids.length>0, "ERC1155Tradeable#setCreator: EMPTY_ARRAY" ); for (uint256 i = 0; i < _ids.length; i++) { uint256 id = _ids[i]; _setCreator(_to, id); } } /** * 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) { //TODO: FAILING HERE ON REGION SALE //Failing from inside the transferFAME function (inside safeTransferFrom in the FAME contract itself) //When being called by the Region contract as the operator //With the user being the owner. //WHY!?!?!? //Ideas: // Look into the proxy contract, this code is throwing a revert and the debugger seems non-specific // Pour over this again with debugger a couple times // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(_owner)) == _operator) { return true; } return ERC1155.isApprovedForAll(_owner, _operator); } /** * @dev Change the creator address for given token * @param _to Address of the new creator * @param _id Token IDs to change creator of */ function _setCreator(address _to, uint256 _id) internal creatorOnly(_id) { creators[_id] = _to; } /** * @dev Returns whether the specified token exists by checking to see if it has a creator * @param _id uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists(uint256 _id) internal view returns (bool) { return creators[_id] != address(0); } /** * @dev calculates the next token ID based on value of _currentTokenID * @return uint256 for the next token ID */ function _getNextTokenID() internal view returns (uint256) { return _currentTokenID + 1; } /** * @dev increments the value of _currentTokenID */ function _incrementTokenTypeId() internal { _currentTokenID++; } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override {} function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastvalue's index to valueIndex } // 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // 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); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // 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)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // 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 "./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 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; /** * @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 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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC1155Receiver.sol"; import "../../../utils/introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.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.8.0; import "../ERC1155.sol"; import "../extensions/ERC1155Burnable.sol"; import "../extensions/ERC1155Pausable.sol"; import "../../../access/AccessControlEnumerable.sol"; import "../../../utils/Context.sol"; /** * @dev {ERC1155} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155Burnable, ERC1155Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that * deploys the contract. */ constructor(string memory uri) ERC1155(uri) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`, of token type `id`. * * See {ERC1155-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint( address to, uint256 id, uint256 amount, bytes memory data ) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint"); _mint(to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}. */ function mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint"); _mintBatch(to, ids, amounts, data); } /** * @dev Pauses all token transfers. * * See {ERC1155Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC1155Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to unpause"); _unpause(); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerable, ERC1155) returns (bool) { return super.supportsInterface(interfaceId); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155, ERC1155Pausable) { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.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.8.0; import "../ERC1155.sol"; import "../../../security/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.8.0; import "../ERC1155.sol"; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. * * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { function burn( address account, uint256 id, uint256 value ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burn(account, id, value); } function burnBatch( address account, uint256[] memory ids, uint256[] memory values ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burnBatch(account, ids, values); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _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.8.0; import "../../utils/introspection/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.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.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 Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _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; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @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) public 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( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(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( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `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 memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - 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[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); 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]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += 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] += 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]; } 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), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } 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++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } 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 ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.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 ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.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) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // 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; 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; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @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) external view returns (address); /** * @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) external view returns (uint256); } // 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 "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @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 override returns (address) { return _roleMembers[role].at(index); } /** * @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 override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } // 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()); } } }
*@notice Insufficient Chests of type: `chestType`, you only have `balance` chests of that type!@param chestType The type of chest (1=Bronze,2=Silver,3=Gold,4=Diamond)@param balance The number of chests the user currently has of the specified type/
error InsufficientChests(uint8 chestType, uint256 balance);
13,683,490
[ 1, 5048, 11339, 1680, 25563, 434, 618, 30, 1375, 343, 395, 559, 9191, 1846, 1338, 1240, 1375, 12296, 68, 462, 25563, 434, 716, 618, 5, 462, 395, 559, 1021, 618, 434, 462, 395, 261, 21, 33, 38, 1949, 8489, 16, 22, 33, 19740, 502, 16, 23, 33, 43, 1673, 16, 24, 33, 14521, 301, 1434, 13, 11013, 1021, 1300, 434, 462, 25563, 326, 729, 4551, 711, 434, 326, 1269, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 555, 22085, 11339, 782, 25563, 12, 11890, 28, 462, 395, 559, 16, 2254, 5034, 11013, 1769, 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 ]
./full_match/1/0xC18a125eF42F780d4DFDcc666012aDa2b62a6c2C/sources/browser/advancessd.sol
approve ESDS contract to move ESD (needed to stage and bond) (Not needed to redeem coupons but is nice to have if you want to use this contract as an ESD wallet)
constructor() { IERC20(esd).approve(address(esds), uint256(uint128(-1))); }
4,854,570
[ 1, 12908, 537, 14054, 3948, 6835, 358, 3635, 512, 9903, 261, 17471, 358, 6009, 471, 8427, 13, 261, 1248, 3577, 358, 283, 24903, 1825, 30324, 1496, 353, 13752, 358, 1240, 309, 1846, 2545, 358, 999, 333, 6835, 487, 392, 512, 9903, 9230, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1435, 288, 203, 3639, 467, 654, 39, 3462, 12, 281, 72, 2934, 12908, 537, 12, 2867, 12, 281, 2377, 3631, 2254, 5034, 12, 11890, 10392, 19236, 21, 3719, 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 ]
./full_match/1/0xbBE062BfBffBE75e6f8DE1a64250F8F71380DA48/sources/contracts/MarsbaseMarketplace.sol
cancel all other bids return $ALICE tokens to Alice if (offer.params.tokenAlice == address(0)) sendEth(offer.aliceAddress, offer.params.amountAlice); else IERC20(offer.params.tokenAlice).safeTransfer(offer.aliceAddress, offer.params.amountAlice); emit offer closed event
function _cancelOffer(uint256 offerId, BidCancelReason bidReason, OfferCloseReason offerReason) private { offers[offerId].active = false; BBOffer memory offer = offers[offerId]; _cancelAllBids(offerId, bidReason); delete offers[offerId]; activeOffersCount--; emit OfferClosed({ id: offerId, aliceAddress: offers[offerId].aliceAddress, reason: offerReason, offer: offer }); }
8,389,311
[ 1, 10996, 777, 1308, 30534, 225, 327, 271, 1013, 11774, 2430, 358, 432, 2008, 309, 261, 23322, 18, 2010, 18, 2316, 37, 2008, 422, 1758, 12, 20, 3719, 225, 202, 4661, 41, 451, 12, 23322, 18, 287, 1812, 1887, 16, 10067, 18, 2010, 18, 8949, 37, 2008, 1769, 469, 225, 202, 45, 654, 39, 3462, 12, 23322, 18, 2010, 18, 2316, 37, 2008, 2934, 4626, 5912, 12, 23322, 18, 287, 1812, 1887, 16, 10067, 18, 2010, 18, 8949, 37, 2008, 1769, 3626, 10067, 4375, 871, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 389, 10996, 10513, 12, 11890, 5034, 10067, 548, 16, 605, 350, 6691, 8385, 9949, 8385, 16, 25753, 4605, 8385, 10067, 8385, 13, 3238, 203, 202, 95, 203, 202, 202, 3674, 414, 63, 23322, 548, 8009, 3535, 273, 629, 31, 203, 203, 202, 202, 9676, 10513, 3778, 10067, 273, 28641, 63, 23322, 548, 15533, 203, 1082, 203, 202, 202, 67, 10996, 1595, 38, 2232, 12, 23322, 548, 16, 9949, 8385, 1769, 203, 203, 1082, 203, 202, 202, 3733, 28641, 63, 23322, 548, 15533, 203, 202, 202, 3535, 7210, 414, 1380, 413, 31, 203, 1082, 203, 202, 202, 18356, 25753, 7395, 12590, 203, 1082, 202, 350, 30, 10067, 548, 16, 203, 1082, 202, 287, 1812, 1887, 30, 28641, 63, 23322, 548, 8009, 287, 1812, 1887, 16, 203, 1082, 202, 10579, 30, 10067, 8385, 16, 203, 1082, 202, 23322, 30, 10067, 203, 202, 202, 22938, 203, 202, 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 ]
/** * Note for the truffle testversion: * DragonKingTest inherits from DragonKing and adds one more function for testing the volcano from truffle. * For deployment on ropsten or mainnet, just deploy the DragonKing contract and remove this comment before verifying on * etherscan. * */ /** * Dragonking is a blockchain game in which players may purchase dragons and knights of different levels and values. * Once every period of time the volcano erupts and wipes a few of them from the board. The value of the killed characters * gets distributed amongst all of the survivors. The dragon king receive a bigger share than the others. * In contrast to dragons, knights need to be teleported to the battlefield first with the use of teleport tokens. * Additionally, they may attack a dragon once per period. * Both character types can be protected from death up to three times. * Take a look at dragonking.io for more detailed information. * @author: Julia Altenried, Yuriy Kashnikov * */ pragma solidity ^ 0.4.17; /** * @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)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract mortal is Ownable{ function mortal() public { } function kill() internal { selfdestruct(owner); } } contract Token { function transferFrom(address _from, address _to, uint256 _value) public returns(bool success); } contract DragonKing is mortal { struct Character { uint8 characterType; uint128 value; address owner; } /** array holding ids of the curret characters*/ uint32[] public ids; /** the id to be given to the next character **/ uint32 public nextId; /** the id of the oldest character */ uint32 public oldest; /** the character belonging to a given id */ mapping(uint32 => Character) characters; /** teleported knights **/ mapping(uint32 => bool) teleported; /** the cost of each character type */ uint128[] public costs; /** the value of each character type (cost - fee), so it&#39;s not necessary to compute it each time*/ uint128[] public values; /** the fee to be paid each time an character is bought in percent*/ uint8 fee; /** the number of dragon types **/ uint8 constant public numDragonTypes = 6; /** total number of characters in the game */ uint16 public numCharacters; /** The maximum of characters allowed in the game */ uint16 public maxCharacters; /** number of characters per type */ mapping(uint8 => uint16) public numCharactersXType; /** the amount of time that should pass since last eruption **/ uint8 public eruptionThreshold; /** timestampt of the last eruption event **/ uint256 public lastEruptionTimestamp; /** how many characters to kill in %, e.g. 20 will stand for 20%, should be < 100 **/ uint8 public percentageToKill; /** knight cooldown. contains the timestamp of the earliest possible moment to start a fight */ mapping(uint32 => uint) public cooldown; uint256 public constant CooldownThreshold = 1 days; /** the teleport token contract used to send knights to the game scene */ Token teleportToken; /** the price for teleportation*/ uint public teleportPrice; /** the neverdue token contract used to purchase protection from eruptions and fights */ Token neverdieToken; /** the price for protection */ uint public protectionPrice; /** tells the number of times a character is protected */ mapping(uint32 => uint8) public protection; // MODIFIER /** is fired when new characters are purchased (who bought how many characters of which type?) */ event NewPurchase(address player, uint8 characterType, uint8 amount, uint32 startId); /** is fired when a player leaves the game */ event NewExit(address player, uint256 totalBalance, uint32[] removedCharacters); /** is fired when an eruption occurs */ event NewEruption(uint32[] hitCharacters, uint128 value, uint128 gasCost); /** is fired when a single character is sold **/ event NewSell(uint32 characterId, address player, uint256 value); /** is fired when a knight fights a dragon **/ event NewFight(uint32 winnerID, uint32 loserID, uint256 value); /** is fired when a knight is teleported to the field **/ event NewTeleport(uint32 characterId); /** is fired when a protection is purchased **/ event NewProtection(uint32 characterId, uint8 lifes); /** initializes the contract parameters */ function DragonKing(address teleportTokenAddress, address neverdieTokenAddress, uint8 eruptionThresholdInHours, uint8 percentageOfCharactersToKill, uint8 characterFee, uint16[] charactersCosts) public onlyOwner { fee = characterFee; for (uint8 i = 0; i < charactersCosts.length * 2; i++) { costs.push(uint128(charactersCosts[i % numDragonTypes]) * 1 finney); values.push(costs[i] - costs[i] / 100 * fee); } eruptionThreshold = eruptionThresholdInHours * 60 * 60; // convert to seconds percentageToKill = percentageOfCharactersToKill; maxCharacters = 600; nextId = 1; teleportToken = Token(teleportTokenAddress); teleportPrice = 1; neverdieToken = Token(neverdieTokenAddress); protectionPrice = 1; } /** * buys as many characters as possible with the transfered value of the given type * @param characterType the type of the character */ function addCharacters(uint8 characterType) payable public { uint8 amount = uint8(msg.value / costs[characterType]); uint16 nchars = numCharacters; if (characterType >= costs.length || msg.value < costs[characterType] || nchars + amount > maxCharacters) revert(); //if type exists, enough ether was transferred and there are less than maxCharacters characters in the game bool isDragon = characterType < numDragonTypes; uint32 nid = nextId; if (isDragon) { //dragons enter the game directly for (uint8 i = 0; i < amount; i++) { addCharacter(nid + i, nchars + i); characters[nid + i] = Character(characterType, values[characterType], msg.sender); } numCharactersXType[characterType] += amount; numCharacters += amount; } else { for (uint8 j = 0; j < amount; j++) { characters[nid + j] = Character(characterType, values[characterType], msg.sender); } } nextId = nid + amount; NewPurchase(msg.sender, characterType, amount, nid); } /** * adds a single dragon of the given type to the ids array, which is used to iterate over all characters * @param nId the id the character is about to receive * @param nchars the number of characters currently in the game */ function addCharacter(uint32 nId, uint16 nchars) internal { if (nchars < ids.length) ids[nchars] = nId; else ids.push(nId); } /** * leave the game. * pays out the sender&#39;s balance and removes him and his characters from the game * */ function exit() public { uint32[] memory removed = new uint32[](50); uint8 count; uint32 lastId; uint playerBalance; uint16 nchars = numCharacters; for (uint16 i = 0; i < nchars; i++) { if (characters[ids[i]].owner == msg.sender) { //first delete all characters at the end of the array while (nchars > 0 && characters[ids[nchars - 1]].owner == msg.sender) { nchars--; lastId = ids[nchars]; numCharactersXType[characters[lastId].characterType]--; playerBalance += characters[lastId].value; removed[count] = lastId; count++; if (lastId == oldest) oldest = 0; delete characters[lastId]; } //if the last character does not belong to the player, replace the players character by this last one if (nchars > i + 1) { playerBalance += characters[ids[i]].value; removed[count] = ids[i]; count++; nchars--; replaceCharacter(i, nchars); } } } numCharacters = nchars; NewExit(msg.sender, playerBalance, removed); //fire the event to notify the client msg.sender.transfer(playerBalance); } /** * Replaces the character with the given id with the last character in the array * @param index the index of the character in the id array * @param nchars the number of characters * */ function replaceCharacter(uint16 index, uint16 nchars) internal { uint32 characterId = ids[index]; numCharactersXType[characters[characterId].characterType]--; if (characterId == oldest) oldest = 0; delete characters[characterId]; ids[index] = ids[nchars]; delete ids[nchars]; } /** * The volcano eruption can be triggered by anybody but only if enough time has passed since the last eription. * The volcano hits up to a certain percentage of characters, but at least one. * The percantage is specified in &#39;percentageToKill&#39; * */ function triggerVolcanoEruption() public { require(now >= lastEruptionTimestamp + eruptionThreshold); require(numCharacters>0); lastEruptionTimestamp = now; uint128 pot; uint128 value; uint16 random; uint32 nextHitId; uint16 nchars = numCharacters; uint32 howmany = nchars * percentageToKill / 100; uint128 neededGas = 80000 + 10000 * uint32(nchars); if(howmany == 0) howmany = 1;//hit at least 1 uint32[] memory hitCharacters = new uint32[](howmany); for (uint8 i = 0; i < howmany; i++) { random = uint16(generateRandomNumber(lastEruptionTimestamp + i) % nchars); nextHitId = ids[random]; hitCharacters[i] = nextHitId; value = hitCharacter(random, nchars); if (value > 0) { nchars--; } pot += value; } uint128 gasCost = uint128(neededGas * tx.gasprice); numCharacters = nchars; if (pot > gasCost){ distribute(pot - gasCost); //distribute the pot minus the oraclize gas costs NewEruption(hitCharacters, pot - gasCost, gasCost); } else NewEruption(hitCharacters, 0, gasCost); } /** * A knight may attack a dragon, but not choose which one. * The creature with the higher level wins. The level is determined by characterType % numDragonTypes. * The value of the loser is transfered to the winner. In case of a the same level, the winner is chosen randomly. * @param knightID the ID of the knight to perfrom the attack * @param knightIndex the index of the knight in the ids-array. Just needed to save gas costs. * In case it&#39;s unknown or incorrect, the index is looked up in the array. * */ function fight(uint32 knightID, uint16 knightIndex) public { if (knightID != ids[knightIndex]) knightID = getCharacterIndex(knightID); Character storage knight = characters[knightID]; require(cooldown[knightID] + CooldownThreshold <= now); require(knight.owner == msg.sender); require(knight.characterType >= numDragonTypes); uint16 dragonIndex = getRandomDragon(knightID); assert(dragonIndex < maxCharacters); uint32 dragonID = ids[dragonIndex]; Character storage dragon = characters[dragonID]; uint16 tieBreaker = uint16(now % 2); uint128 value; if (knight.characterType - numDragonTypes > dragon.characterType || (knight.characterType - numDragonTypes == dragon.characterType && tieBreaker == 0)) { value = hitCharacter(dragonIndex, numCharacters); if (value > 0) { numCharacters--; } knight.value += value; cooldown[knightID] = now; if (oldest == 0) findOldest(); NewFight(knightID, dragonID, value); } else { value = hitCharacter(knightIndex, numCharacters); if (value > 0) { numCharacters--; } dragon.value += value; NewFight(dragonID, knightID, value); } } /** * pick a random dragon. * @param nonce a nonce to make sure there&#39;s not always the same dragon chosen in a single block. * @return the index of a random dragon * */ function getRandomDragon(uint256 nonce) internal view returns(uint16) { uint16 randomIndex = uint16(generateRandomNumber(nonce) % numCharacters); //use 7, 11 or 13 as step size. scales for up to 1000 characters uint16 stepSize = numCharacters % 7 == 0 ? (numCharacters % 11 == 0 ? 13 : 11) : 7; uint16 i = randomIndex; //if the picked character is a knight or belongs to the sender, look at the character + stepSizes ahead in the array (modulo the total number) //will at some point return to the startingPoint if no character is suited do { if (characters[ids[i]].characterType < numDragonTypes && characters[ids[i]].owner != msg.sender) return i; i = (i + stepSize) % numCharacters; } while (i != randomIndex); return maxCharacters + 1; //there is none } /** * generate a random number. * @param nonce a nonce to make sure there&#39;s not always the same number returned in a single block. * @return the random number * */ function generateRandomNumber(uint256 nonce) internal view returns(uint) { return uint(keccak256(block.blockhash(block.number - 1), now, numCharacters, nonce)); } /** * Hits the character of the given type at the given index. * @param index the index of the character * @param nchars the number of characters * @return the value gained from hitting the characters (zero is the character was protected) * */ function hitCharacter(uint16 index, uint16 nchars) internal returns(uint128 characterValue) { uint32 id = ids[index]; if (protection[id] > 0) { protection[id]--; return 0; } characterValue = characters[ids[index]].value; nchars--; replaceCharacter(index, nchars); } /** * finds the oldest character * */ function findOldest() public { oldest = ids[0]; for (uint16 i = 1; i < numCharacters; i++) { if (ids[i] < oldest && characters[ids[i]].characterType < numDragonTypes) //the oldest character has the lowest id -todo oldest = ids[i]; } } /** * distributes the given amount among the surviving characters * @param totalAmount nthe amount to distribute */ function distribute(uint128 totalAmount) internal { //pay 10% to the oldest dragon if (oldest == 0) findOldest(); characters[oldest].value += totalAmount / 10; uint128 amount = totalAmount / 10 * 9; //distribute the rest according to their type uint128 valueSum; uint128[] memory shares = new uint128[](values.length); for (uint8 v = 0; v < values.length; v++) { if (numCharactersXType[v] > 0) valueSum += values[v]; } for (uint8 m = 0; m < values.length; m++) { if (numCharactersXType[m] > 0) shares[m] = amount * values[m] / valueSum / numCharactersXType[m]; } for (uint16 i = 0; i < numCharacters; i++) { characters[ids[i]].value += shares[characters[ids[i]].characterType]; } } /** * allows the owner to collect the accumulated fees * sends the given amount to the owner&#39;s address if the amount does not exceed the * fees (cannot touch the players&#39; balances) minus 100 finney (ensure that oraclize fees can be paid) * @param amount the amount to be collected * */ function collectFees(uint128 amount) public onlyOwner { uint collectedFees = getFees(); if (amount + 100 finney < collectedFees) { owner.transfer(amount); } } /** * pays out the players and kills the game. * */ function stop() public onlyOwner { for (uint16 i = 0; i < numCharacters; i++) { if (!characters[ids[i]].owner.send(characters[ids[i]].value)) revert(); } kill(); } /** * sell the character of the given id * throws an exception in case of a knight not yet teleported to the game * @param characterId the id of the character * */ function sellCharacter(uint32 characterId) public { require(msg.sender == characters[characterId].owner); uint128 val = characters[characterId].value; numCharacters--; replaceCharacter(getCharacterIndex(characterId), numCharacters); msg.sender.transfer(val); NewSell(characterId, msg.sender, val); } /** * receive approval to spend some tokens. * used for teleport and protection. * @param sender the sender address * @param value the transferred value * @param tokenContract the address of the token contract * @param callData the data passed by the token contract * */ function receiveApproval(address sender, uint256 value, address tokenContract, bytes callData) public { if (msg.sender == address(teleportToken)) { require(value >= teleportPrice); assert(teleportToken.transferFrom(sender, this, teleportPrice)); teleportKnight(toUint32(callData)); } else if (msg.sender == address(neverdieToken)) { uint32 id = toUint32(callData); // user can purchase extra lifes only right after character purchaes // in other words, user value should be equal the initial value require(characters[id].value == values[characters[id].characterType]); // calc how many lifes user can actually buy // the formula is the following: uint256 lifePrice = ((characters[id].characterType % numDragonTypes) + 1) * protectionPrice; uint256 price = 0; uint8 i = protection[id]; require(i <= 3); for (i; i < 3 && value >= price + lifePrice * (i + 1); i++) { price += lifePrice * (i + 1); } assert(neverdieToken.transferFrom(sender, this, price)); protectCharacter(id, i); } else revert(); } /** * knights are only entering the game completely, when they are teleported to the scene * @param id the character id * */ function teleportKnight(uint32 id) internal { // ensure we do not teleport twice require(teleported[id] == false); teleported[id] = true; Character storage knight = characters[id]; assert(knight.characterType >= numDragonTypes); //this also makes calls with non-existent ids fail addCharacter(id, numCharacters); numCharacters++; numCharactersXType[knight.characterType]++; NewTeleport(id); } /** * adds protection to a character * @param id the character id * @param lifes the number of protections * */ function protectCharacter(uint32 id, uint8 lifes) internal { protection[id] = lifes; NewProtection(id, lifes); } /****************** GETTERS *************************/ /** * returns the character of the given id * @param characterId the character id * @return the type, value and owner of the character * */ function getCharacter(uint32 characterId) constant public returns(uint8, uint128, address) { return (characters[characterId].characterType, characters[characterId].value, characters[characterId].owner); } /** * returns the index of a character of the given id * @param characterId the character id * @return the character id * */ function getCharacterIndex(uint32 characterId) constant public returns(uint16) { for (uint16 i = 0; i < ids.length; i++) { if (ids[i] == characterId) { return i; } } revert(); } /** * returns 10 characters starting from a certain indey * @param startIndex the index to start from * @return 4 arrays containing the ids, types, values and owners of the characters * */ function get10Characters(uint16 startIndex) constant public returns(uint32[10] characterIds, uint8[10] types, uint128[10] values, address[10] owners) { uint32 endIndex = startIndex + 10 > numCharacters ? numCharacters : startIndex + 10; uint8 j = 0; uint32 id; for (uint16 i = startIndex; i < endIndex; i++) { id = ids[i]; characterIds[j] = id; types[j] = characters[id].characterType; values[j] = characters[id].value; owners[j] = characters[id].owner; j++; } } /** * returns the number of dragons in the game * @return the number of dragons * */ function getNumDragons() constant public returns(uint16 numDragons) { for (uint8 i = 0; i < numDragonTypes; i++) numDragons += numCharactersXType[i]; } /** * returns the number of knights in the game * @return the number of knights * */ function getNumKnights() constant public returns(uint16 numKnights) { for (uint8 i = numDragonTypes; i < costs.length; i++) numKnights += numCharactersXType[i]; } /** * @return the accumulated fees * */ function getFees() constant public returns(uint) { uint reserved = 0; for (uint16 j = 0; j < numCharacters; j++) reserved += characters[ids[j]].value; return address(this).balance - reserved; } /****************** SETTERS *************************/ /** * sets the prices of the character types * @param prices the prices in finney * */ function setPrices(uint16[] prices) public onlyOwner { for (uint8 i = 0; i < prices.length * 2; i++) { costs[i] = uint128(prices[i % numDragonTypes]) * 1 finney; values[i] = costs[i] - costs[i] / 100 * fee; } } /** * sets the fee to charge on each purchase * @param _fee the new fee * */ function setFee(uint8 _fee) public onlyOwner { fee = _fee; } /** * sets the maximum number of characters allowed in the game * @param number the new maximum * */ function setMaxCharacters(uint16 number) public onlyOwner { maxCharacters = number; } /** * sets the teleport price * @param price the price in tokens * */ function setTeleportPrice(uint price) public onlyOwner { teleportPrice = price; } /** * sets the protection price * @param price the price in tokens * */ function setProtectionPrice(uint price) public onlyOwner { protectionPrice = price; } /************* HELPERS ****************/ /** * only works for bytes of length < 32 * @param b the byte input * @return the uint * */ function toUint32(bytes b) internal pure returns(uint32) { bytes32 newB; assembly { newB: = mload(0x80) } return uint32(newB); } }
* is fired when a knight fights a dragon **/
event NewFight(uint32 winnerID, uint32 loserID, uint256 value);
15,202,264
[ 1, 291, 15950, 1347, 279, 15516, 750, 284, 10730, 279, 8823, 265, 342, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2575, 1166, 42, 750, 12, 11890, 1578, 5657, 1224, 734, 16, 2254, 1578, 437, 550, 734, 16, 2254, 5034, 460, 1769, 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 ]
./full_match/1/0x3c6d9EFC7bE32C00caAEa6F89763ae58A8F74Db0/sources/contracts/CallToken.sol
* @dev See {IERC721-safeTransferFrom}./
function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override(IERC721, ERC721) { uint256 endTime = ICallPoolState(Ownable.owner()).getEndTime(tokenId); require(block.timestamp <= endTime, "token is expired"); ERC721.safeTransferFrom(from, to, tokenId); }
3,004,628
[ 1, 9704, 288, 45, 654, 39, 27, 5340, 17, 4626, 5912, 1265, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4183, 5912, 1265, 12, 203, 3639, 1758, 628, 16, 203, 3639, 1758, 358, 16, 203, 3639, 2254, 5034, 1147, 548, 203, 565, 262, 1071, 5024, 3849, 12, 45, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 13, 288, 203, 3639, 2254, 5034, 13859, 273, 467, 1477, 2864, 1119, 12, 5460, 429, 18, 8443, 1435, 2934, 588, 25255, 12, 2316, 548, 1769, 203, 3639, 2583, 12, 2629, 18, 5508, 1648, 13859, 16, 315, 2316, 353, 7708, 8863, 203, 3639, 4232, 39, 27, 5340, 18, 4626, 5912, 1265, 12, 2080, 16, 358, 16, 1147, 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 ]
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // 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/utils/introspection/ERC165Storage.sol pragma solidity ^0.8.0; /** * @dev Storage based implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Storage is ERC165 { /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId) || _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; } } // 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/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); } 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: contracts/access/IKOAccessControlsLookup.sol pragma solidity 0.8.4; interface IKOAccessControlsLookup { function hasAdminRole(address _address) external view returns (bool); function isVerifiedArtist(uint256 _index, address _account, bytes32[] calldata _merkleProof) external view returns (bool); function isVerifiedArtistProxy(address _artist, address _proxy) external view returns (bool); function hasLegacyMinterRole(address _address) external view returns (bool); function hasContractRole(address _address) external view returns (bool); function hasContractOrAdminRole(address _address) external view returns (bool); } // File: contracts/core/IERC2981.sol pragma solidity 0.8.4; /// @notice This is purely an extension for the KO platform /// @notice Royalties on KO are defined at an edition level for all tokens from the same edition interface IERC2981EditionExtension { /// @notice Does the edition have any royalties defined function hasRoyalties(uint256 _editionId) external view returns (bool); /// @notice Get the royalty receiver - all royalties should be sent to this account if not zero address function getRoyaltiesReceiver(uint256 _editionId) external view returns (address); } /** * ERC2981 standards interface for royalties */ interface IERC2981 is IERC165, IERC2981EditionExtension { /// ERC165 bytes to add to interface array - set in parent contract /// implementing this standard /// /// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; /// _registerInterface(_INTERFACE_ID_ERC2981); /// @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 _value - 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 _value sale price function royaltyInfo( uint256 _tokenId, uint256 _value ) external view returns ( address _receiver, uint256 _royaltyAmount ); } // File: contracts/core/IKODAV3Minter.sol pragma solidity 0.8.4; interface IKODAV3Minter { function mintBatchEdition(uint16 _editionSize, address _to, string calldata _uri) external returns (uint256 _editionId); function mintBatchEditionAndComposeERC20s(uint16 _editionSize, address _to, string calldata _uri, address[] calldata _erc20s, uint256[] calldata _amounts) external returns (uint256 _editionId); function mintConsecutiveBatchEdition(uint16 _editionSize, address _to, string calldata _uri) external returns (uint256 _editionId); } // File: contracts/programmable/ITokenUriResolver.sol pragma solidity 0.8.4; interface ITokenUriResolver { /// @notice Return the edition or token level URI - token level trumps edition level if found function tokenURI(uint256 _editionId, uint256 _tokenId) external view returns (string memory); /// @notice Do we have an edition level or token level token URI resolver set function isDefined(uint256 _editionId, uint256 _tokenId) external view returns (bool); } // File: @openzeppelin/contracts/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/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/utils/structs/EnumerableSet.sol pragma solidity ^0.8.0; /** * @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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastvalue's index to valueIndex } // 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) { 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)); } } // File: @openzeppelin/contracts/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 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; } } // File: @openzeppelin/contracts/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: contracts/core/IERC2309.sol pragma solidity 0.8.4; /** @title ERC-2309: ERC-721 Batch Mint Extension @dev https://github.com/ethereum/EIPs/issues/2309 */ interface IERC2309 { /** @notice This event is emitted when ownership of a batch of tokens changes by any mechanism. This includes minting, transferring, and burning. @dev The address executing the transaction MUST own all the tokens within the range of fromTokenId and toTokenId, or MUST be an approved operator to act on the owners behalf. The fromTokenId and toTokenId MUST be a sequential range of tokens IDs. When minting/creating tokens, the `fromAddress` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `toAddress` argument MUST be set to `0x0` (i.e. zero address). @param fromTokenId The token ID that begins the batch of tokens being transferred @param toTokenId The token ID that ends the batch of tokens being transferred @param fromAddress The address transferring ownership of the specified range of tokens @param toAddress The address receiving ownership of the specified range of tokens. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress); } // File: contracts/core/IHasSecondarySaleFees.sol pragma solidity 0.8.4; /// @title Royalties formats required for use on the Rarible platform /// @dev https://docs.rarible.com/asset/royalties-schema interface IHasSecondarySaleFees is IERC165 { event SecondarySaleFees(uint256 tokenId, address[] recipients, uint[] bps); function getFeeRecipients(uint256 id) external returns (address payable[] memory); function getFeeBps(uint256 id) external returns (uint[] memory); } // File: contracts/core/IKODAV3.sol pragma solidity 0.8.4; /// @title Core KODA V3 functionality interface IKODAV3 is IERC165, // Contract introspection IERC721, // Core NFTs IERC2309, // Consecutive batch mint IERC2981, // Royalties IHasSecondarySaleFees // Rariable / Foundation royalties { // edition utils function getCreatorOfEdition(uint256 _editionId) external view returns (address _originalCreator); function getCreatorOfToken(uint256 _tokenId) external view returns (address _originalCreator); function getSizeOfEdition(uint256 _editionId) external view returns (uint256 _size); function getEditionSizeOfToken(uint256 _tokenId) external view returns (uint256 _size); function editionExists(uint256 _editionId) external view returns (bool); // Has the edition been disabled / soft burnt function isEditionSalesDisabled(uint256 _editionId) external view returns (bool); // Has the edition been disabled / soft burnt OR sold out function isSalesDisabledOrSoldOut(uint256 _editionId) external view returns (bool); // Work out the max token ID for an edition ID function maxTokenIdOfEdition(uint256 _editionId) external view returns (uint256 _tokenId); // Helper method for getting the next primary sale token from an edition starting low to high token IDs function getNextAvailablePrimarySaleToken(uint256 _editionId) external returns (uint256 _tokenId); // Helper method for getting the next primary sale token from an edition starting high to low token IDs function getReverseAvailablePrimarySaleToken(uint256 _editionId) external view returns (uint256 _tokenId); // Utility method to get all data needed for the next primary sale, low token ID to high function facilitateNextPrimarySale(uint256 _editionId) external returns (address _receiver, address _creator, uint256 _tokenId); // Utility method to get all data needed for the next primary sale, high token ID to low function facilitateReversePrimarySale(uint256 _editionId) external returns (address _receiver, address _creator, uint256 _tokenId); // Expanded royalty method for the edition, not token function royaltyAndCreatorInfo(uint256 _editionId, uint256 _value) external returns (address _receiver, address _creator, uint256 _amount); // Allows the creator to correct mistakes until the first token from an edition is sold function updateURIIfNoSaleMade(uint256 _editionId, string calldata _newURI) external; // Has any primary transfer happened from an edition function hasMadePrimarySale(uint256 _editionId) external view returns (bool); // Has the edition sold out function isEditionSoldOut(uint256 _editionId) external view returns (bool); // Toggle on/off the edition from being able to make sales function toggleEditionSalesDisabled(uint256 _editionId) external; // token utils function exists(uint256 _tokenId) external view returns (bool); function getEditionIdOfToken(uint256 _tokenId) external pure returns (uint256 _editionId); function getEditionDetails(uint256 _tokenId) external view returns (address _originalCreator, address _owner, uint16 _size, uint256 _editionId, string memory _uri); function hadPrimarySaleOfToken(uint256 _tokenId) external view returns (bool); } // File: contracts/core/composable/TopDownERC20Composable.sol pragma solidity 0.8.4; interface ERC998ERC20TopDown { event ReceivedERC20(address indexed _from, uint256 indexed _tokenId, address indexed _erc20Contract, uint256 _value); event ReceivedERC20ForEdition(address indexed _from, uint256 indexed _editionId, address indexed _erc20Contract, uint256 _value); event TransferERC20(uint256 indexed _tokenId, address indexed _to, address indexed _erc20Contract, uint256 _value); function balanceOfERC20(uint256 _tokenId, address _erc20Contract) external view returns (uint256); function transferERC20(uint256 _tokenId, address _to, address _erc20Contract, uint256 _value) external; function getERC20(address _from, uint256 _tokenId, address _erc20Contract, uint256 _value) external; } interface ERC998ERC20TopDownEnumerable { function totalERC20Contracts(uint256 _tokenId) external view returns (uint256); function erc20ContractByIndex(uint256 _tokenId, uint256 _index) external view returns (address); } /// @notice ERC998 ERC721 > ERC20 Top Down implementation abstract contract TopDownERC20Composable is ERC998ERC20TopDown, ERC998ERC20TopDownEnumerable, ReentrancyGuard, Context { using EnumerableSet for EnumerableSet.AddressSet; // Edition ID -> ERC20 contract -> Balance of ERC20 for every token in Edition mapping(uint256 => mapping(address => uint256)) public editionTokenERC20Balances; // Edition ID -> ERC20 contract -> Token ID -> Balance Transferred out of token mapping(uint256 => mapping(address => mapping(uint256 => uint256))) public editionTokenERC20TransferAmounts; // Edition ID -> Linked ERC20 contract addresses mapping(uint256 => EnumerableSet.AddressSet) ERC20sEmbeddedInEdition; // Token ID -> Linked ERC20 contract addresses mapping(uint256 => EnumerableSet.AddressSet) ERC20sEmbeddedInNft; // Token ID -> ERC20 contract -> balance of ERC20 owned by token mapping(uint256 => mapping(address => uint256)) public ERC20Balances; /// @notice the ERC20 balance of a NFT token given an ERC20 token address function balanceOfERC20(uint256 _tokenId, address _erc20Contract) public override view returns (uint256) { IKODAV3 koda = IKODAV3(address(this)); uint256 editionId = koda.getEditionIdOfToken(_tokenId); uint256 editionBalance = editionTokenERC20Balances[editionId][_erc20Contract]; uint256 tokenEditionBalance = editionBalance / koda.getSizeOfEdition(editionId); uint256 spentTokens = editionTokenERC20TransferAmounts[editionId][_erc20Contract][_tokenId]; tokenEditionBalance = tokenEditionBalance - spentTokens; return tokenEditionBalance + ERC20Balances[_tokenId][_erc20Contract]; } /// @notice Transfer out an ERC20 from an NFT function transferERC20(uint256 _tokenId, address _to, address _erc20Contract, uint256 _value) external override nonReentrant { _prepareERC20LikeTransfer(_tokenId, _to, _erc20Contract, _value); IERC20(_erc20Contract).transfer(_to, _value); emit TransferERC20(_tokenId, _to, _erc20Contract, _value); } /// @notice An NFT token owner (or approved) can compose multiple ERC20s in their NFT function getERC20s(address _from, uint256[] calldata _tokenIds, address _erc20Contract, uint256 _totalValue) external { uint256 totalTokens = _tokenIds.length; require(totalTokens > 0 && _totalValue > 0, "Empty values"); uint256 valuePerToken = _totalValue / totalTokens; for (uint i = 0; i < totalTokens; i++) { getERC20(_from, _tokenIds[i], _erc20Contract, valuePerToken); } } /// @notice A NFT token owner (or approved address) can compose any ERC20 in their NFT function getERC20(address _from, uint256 _tokenId, address _erc20Contract, uint256 _value) public override nonReentrant { require(_value > 0, "Value zero"); require(_from == _msgSender(), "Only owner"); address spender = _msgSender(); IERC721 self = IERC721(address(this)); address owner = self.ownerOf(_tokenId); require( owner == spender || self.isApprovedForAll(owner, spender) || self.getApproved(_tokenId) == spender, "Invalid spender" ); uint256 editionId = IKODAV3(address(this)).getEditionIdOfToken(_tokenId); bool editionAlreadyContainsERC20 = ERC20sEmbeddedInEdition[editionId].contains(_erc20Contract); bool nftAlreadyContainsERC20 = ERC20sEmbeddedInNft[_tokenId].contains(_erc20Contract); // does not already contain _erc20Contract if (!editionAlreadyContainsERC20 && !nftAlreadyContainsERC20) { ERC20sEmbeddedInNft[_tokenId].add(_erc20Contract); } ERC20Balances[_tokenId][_erc20Contract] = ERC20Balances[_tokenId][_erc20Contract] + _value; IERC20 token = IERC20(_erc20Contract); require(token.allowance(_from, address(this)) >= _value, "Exceeds allowance"); token.transferFrom(_from, address(this), _value); emit ReceivedERC20(_from, _tokenId, _erc20Contract, _value); } function _composeERC20IntoEdition(address _from, uint256 _editionId, address _erc20Contract, uint256 _value) internal nonReentrant { require(_value > 0, "Value zero"); require(!ERC20sEmbeddedInEdition[_editionId].contains(_erc20Contract), "Edition contains ERC20"); ERC20sEmbeddedInEdition[_editionId].add(_erc20Contract); editionTokenERC20Balances[_editionId][_erc20Contract] = editionTokenERC20Balances[_editionId][_erc20Contract] + _value; IERC20(_erc20Contract).transferFrom(_from, address(this), _value); emit ReceivedERC20ForEdition(_from, _editionId, _erc20Contract, _value); } function totalERC20Contracts(uint256 _tokenId) override public view returns (uint256) { uint256 editionId = IKODAV3(address(this)).getEditionIdOfToken(_tokenId); return ERC20sEmbeddedInNft[_tokenId].length() + ERC20sEmbeddedInEdition[editionId].length(); } function erc20ContractByIndex(uint256 _tokenId, uint256 _index) override external view returns (address) { uint256 numOfERC20sInNFT = ERC20sEmbeddedInNft[_tokenId].length(); if (_index >= numOfERC20sInNFT) { uint256 editionId = IKODAV3(address(this)).getEditionIdOfToken(_tokenId); return ERC20sEmbeddedInEdition[editionId].at(_index - numOfERC20sInNFT); } return ERC20sEmbeddedInNft[_tokenId].at(_index); } /// --- Internal ---- function _prepareERC20LikeTransfer(uint256 _tokenId, address _to, address _erc20Contract, uint256 _value) private { // To avoid stack too deep, do input checks within this scope { require(_value > 0, "Value zero"); require(_to != address(0), "Zero address"); IERC721 self = IERC721(address(this)); address owner = self.ownerOf(_tokenId); require( owner == _msgSender() || self.isApprovedForAll(owner, _msgSender()) || self.getApproved(_tokenId) == _msgSender(), "Not owner" ); } // Check that the NFT contains the ERC20 bool nftContainsERC20 = ERC20sEmbeddedInNft[_tokenId].contains(_erc20Contract); IKODAV3 koda = IKODAV3(address(this)); uint256 editionId = koda.getEditionIdOfToken(_tokenId); bool editionContainsERC20 = ERC20sEmbeddedInEdition[editionId].contains(_erc20Contract); require(nftContainsERC20 || editionContainsERC20, "No such ERC20"); // Check there is enough balance to transfer out require(balanceOfERC20(_tokenId, _erc20Contract) >= _value, "Exceeds balance"); uint256 editionSize = koda.getSizeOfEdition(editionId); uint256 tokenInitialBalance = editionTokenERC20Balances[editionId][_erc20Contract] / editionSize; uint256 spentTokens = editionTokenERC20TransferAmounts[editionId][_erc20Contract][_tokenId]; uint256 editionTokenBalance = tokenInitialBalance - spentTokens; // Check whether the value can be fully transferred from the edition balance, token balance or both balances if (editionTokenBalance >= _value) { editionTokenERC20TransferAmounts[editionId][_erc20Contract][_tokenId] = spentTokens + _value; } else if (ERC20Balances[_tokenId][_erc20Contract] >= _value) { ERC20Balances[_tokenId][_erc20Contract] = ERC20Balances[_tokenId][_erc20Contract] - _value; } else { // take from both balances editionTokenERC20TransferAmounts[editionId][_erc20Contract][_tokenId] = spentTokens + editionTokenBalance; uint256 amountOfTokensToSpendFromTokenBalance = _value - editionTokenBalance; ERC20Balances[_tokenId][_erc20Contract] = ERC20Balances[_tokenId][_erc20Contract] - amountOfTokensToSpendFromTokenBalance; } // The ERC20 is no longer composed within the token if the balance falls to zero if (nftContainsERC20 && ERC20Balances[_tokenId][_erc20Contract] == 0) { ERC20sEmbeddedInNft[_tokenId].remove(_erc20Contract); } // If all tokens in an edition have spent their ERC20 balance, then we can remove the link if (editionContainsERC20) { uint256 allTokensInEditionERC20Balance; for (uint i = 0; i < editionSize; i++) { uint256 tokenBal = tokenInitialBalance - editionTokenERC20TransferAmounts[editionId][_erc20Contract][editionId + i]; allTokensInEditionERC20Balance = allTokensInEditionERC20Balance + tokenBal; } if (allTokensInEditionERC20Balance == 0) { ERC20sEmbeddedInEdition[editionId].remove(_erc20Contract); } } } } // File: contracts/core/composable/TopDownSimpleERC721Composable.sol pragma solidity 0.8.4; abstract contract TopDownSimpleERC721Composable is Context { struct ComposedNFT { address nft; uint256 tokenId; } // KODA Token ID -> composed nft mapping(uint256 => ComposedNFT) public kodaTokenComposedNFT; // External NFT address -> External Token ID -> KODA token ID mapping(address => mapping(uint256 => uint256)) public composedNFTsToKodaToken; event ReceivedChild(address indexed _from, uint256 indexed _tokenId, address indexed _childContract, uint256 _childTokenId); event TransferChild(uint256 indexed _tokenId, address indexed _to, address indexed _childContract, uint256 _childTokenId); /// @notice compose a set of the same child ERC721s into a KODA tokens /// @notice Caller must own both KODA and child NFT tokens function composeNFTsIntoKodaTokens(uint256[] calldata _kodaTokenIds, address _nft, uint256[] calldata _nftTokenIds) external { uint256 totalKodaTokens = _kodaTokenIds.length; require(totalKodaTokens > 0 && totalKodaTokens == _nftTokenIds.length, "Invalid list"); IERC721 nftContract = IERC721(_nft); for (uint i = 0; i < totalKodaTokens; i++) { uint256 _kodaTokenId = _kodaTokenIds[i]; uint256 _nftTokenId = _nftTokenIds[i]; require( IERC721(address(this)).ownerOf(_kodaTokenId) == nftContract.ownerOf(_nftTokenId), "Owner mismatch" ); kodaTokenComposedNFT[_kodaTokenId] = ComposedNFT(_nft, _nftTokenId); composedNFTsToKodaToken[_nft][_nftTokenId] = _kodaTokenId; nftContract.transferFrom(_msgSender(), address(this), _nftTokenId); emit ReceivedChild(_msgSender(), _kodaTokenId, _nft, _nftTokenId); } } /// @notice Transfer a child 721 wrapped within a KODA token to a given recipient /// @notice only KODA token owner can call this function transferChild(uint256 _kodaTokenId, address _recipient) external { require( IERC721(address(this)).ownerOf(_kodaTokenId) == _msgSender(), "Only KODA owner" ); address nft = kodaTokenComposedNFT[_kodaTokenId].nft; uint256 nftId = kodaTokenComposedNFT[_kodaTokenId].tokenId; delete kodaTokenComposedNFT[_kodaTokenId]; delete composedNFTsToKodaToken[nft][nftId]; IERC721(nft).transferFrom(address(this), _recipient, nftId); emit TransferChild(_kodaTokenId, _recipient, nft, nftId); } } // File: contracts/core/Konstants.sol pragma solidity 0.8.4; contract Konstants { // Every edition always goes up in batches of 1000 uint16 public constant MAX_EDITION_SIZE = 1000; // magic method that defines the maximum range for an edition - this is fixed forever - tokens are minted in range function _editionFromTokenId(uint256 _tokenId) internal pure returns (uint256) { return (_tokenId / MAX_EDITION_SIZE) * MAX_EDITION_SIZE; } } // File: contracts/core/BaseKoda.sol pragma solidity 0.8.4; abstract contract BaseKoda is Konstants, Context, IKODAV3 { bytes4 constant internal ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); event AdminUpdateSecondaryRoyalty(uint256 _secondarySaleRoyalty); event AdminUpdateBasisPointsModulo(uint256 _basisPointsModulo); event AdminUpdateModulo(uint256 _modulo); event AdminEditionReported(uint256 indexed _editionId, bool indexed _reported); event AdminArtistAccountReported(address indexed _account, bool indexed _reported); event AdminUpdateAccessControls(IKOAccessControlsLookup indexed _oldAddress, IKOAccessControlsLookup indexed _newAddress); modifier onlyContract(){ _onlyContract(); _; } function _onlyContract() private view { require(accessControls.hasContractRole(_msgSender()), "Must be contract"); } modifier onlyAdmin(){ _onlyAdmin(); _; } function _onlyAdmin() private view { require(accessControls.hasAdminRole(_msgSender()), "Must be admin"); } IKOAccessControlsLookup public accessControls; // A onchain reference to editions which have been reported for some infringement purposes to KO mapping(uint256 => bool) public reportedEditionIds; // A onchain reference to accounts which have been lost/hacked etc mapping(address => bool) public reportedArtistAccounts; // Secondary sale commission uint256 public secondarySaleRoyalty = 12_50000; // 12.5% by default /// @notice precision 100.00000% uint256 public modulo = 100_00000; /// @notice Basis points conversion modulo /// @notice This is used by the IHasSecondarySaleFees implementation which is different than EIP-2981 specs uint256 public basisPointsModulo = 1000; constructor(IKOAccessControlsLookup _accessControls) { accessControls = _accessControls; } function reportEditionId(uint256 _editionId, bool _reported) onlyAdmin public { reportedEditionIds[_editionId] = _reported; emit AdminEditionReported(_editionId, _reported); } function reportArtistAccount(address _account, bool _reported) onlyAdmin public { reportedArtistAccounts[_account] = _reported; emit AdminArtistAccountReported(_account, _reported); } function updateBasisPointsModulo(uint256 _basisPointsModulo) onlyAdmin public { require(_basisPointsModulo > 0, "Is zero"); basisPointsModulo = _basisPointsModulo; emit AdminUpdateBasisPointsModulo(_basisPointsModulo); } function updateModulo(uint256 _modulo) onlyAdmin public { require(_modulo > 0, "Is zero"); modulo = _modulo; emit AdminUpdateModulo(_modulo); } function updateSecondaryRoyalty(uint256 _secondarySaleRoyalty) onlyAdmin public { secondarySaleRoyalty = _secondarySaleRoyalty; emit AdminUpdateSecondaryRoyalty(_secondarySaleRoyalty); } function updateAccessControls(IKOAccessControlsLookup _accessControls) public onlyAdmin { require(_accessControls.hasAdminRole(_msgSender()), "Must be admin"); emit AdminUpdateAccessControls(accessControls, _accessControls); accessControls = _accessControls; } /// @dev Allows for the ability to extract stuck ERC20 tokens /// @dev Only callable from admin function withdrawStuckTokens(address _tokenAddress, uint256 _amount, address _withdrawalAccount) onlyAdmin public { IERC20(_tokenAddress).transfer(_withdrawalAccount, _amount); } } // File: contracts/core/KnownOriginDigitalAssetV3.sol pragma solidity 0.8.4; /// @title A ERC-721 compliant contract which has a focus on being GAS efficient along with being able to support /// both unique tokens and multi-editions sharing common traits but of limited supply /// /// @author KnownOrigin Labs - https://knownorigin.io/ /// /// @notice The NFT supports a range of standards such as: /// @notice EIP-2981 Royalties Standard /// @notice EIP-2309 Consecutive batch mint /// @notice ERC-998 Top-down ERC-20 composable contract KnownOriginDigitalAssetV3 is TopDownERC20Composable, TopDownSimpleERC721Composable, BaseKoda, ERC165Storage, IKODAV3Minter { event EditionURIUpdated(uint256 indexed _editionId); event EditionSalesDisabledToggled(uint256 indexed _editionId, bool _oldValue, bool _newValue); event SealedEditionMetaDataSet(uint256 indexed _editionId); event SealedTokenMetaDataSet(uint256 indexed _tokenId); event AdditionalEditionUnlockableSet(uint256 indexed _editionId); event AdminRoyaltiesRegistryProxySet(address indexed _royaltiesRegistryProxy); event AdminTokenUriResolverSet(address indexed _tokenUriResolver); modifier validateEdition(uint256 _editionId) { _validateEdition(_editionId); _; } function _validateEdition(uint256 _editionId) private view { require(_editionExists(_editionId), "Edition does not exist"); } modifier validateCreator(uint256 _editionId) { address creator = getCreatorOfEdition(_editionId); require( _msgSender() == creator || accessControls.isVerifiedArtistProxy(creator, _msgSender()), "Only creator or proxy" ); _; } /// @notice Token name string public constant name = "KnownOriginDigitalAsset"; /// @notice Token symbol string public constant symbol = "KODA"; /// @notice KODA version string public constant version = "3"; /// @notice Royalties registry IERC2981 public royaltiesRegistryProxy; /// @notice Token URI resolver ITokenUriResolver public tokenUriResolver; /// @notice Edition number pointer uint256 public editionPointer; struct EditionDetails { address creator; // primary edition/token creator uint16 editionSize; // onchain edition size string uri; // the referenced metadata } /// @dev tokens are minted in batches - the first token ID used is representative of the edition ID mapping(uint256 => EditionDetails) internal editionDetails; /// @dev Mapping of tokenId => owner - only set on first transfer (after mint) such as a primary sale and/or gift mapping(uint256 => address) internal owners; /// @dev Mapping of owner => number of tokens owned mapping(address => uint256) internal balances; /// @dev Mapping of tokenId => approved address mapping(uint256 => address) internal approvals; /// @dev Mapping of owner => operator => approved mapping(address => mapping(address => bool)) internal operatorApprovals; /// @notice Optional one time use storage slot for additional edition metadata mapping(uint256 => string) public sealedEditionMetaData; /// @notice Optional one time use storage slot for additional token metadata such ass peramweb metadata mapping(uint256 => string) public sealedTokenMetaData; /// @notice Allows a creator to disable sales of their edition mapping(uint256 => bool) public editionSalesDisabled; constructor( IKOAccessControlsLookup _accessControls, IERC2981 _royaltiesRegistryProxy, uint256 _editionPointer ) BaseKoda(_accessControls) { // starting point for new edition IDs editionPointer = _editionPointer; // optional registry address - can be constructed as zero address royaltiesRegistryProxy = _royaltiesRegistryProxy; // INTERFACE_ID_ERC721 _registerInterface(0x80ac58cd); // INTERFACE_ID_ERC721_METADATA _registerInterface(0x5b5e139f); // _INTERFACE_ID_ERC2981 _registerInterface(0x2a55205a); // _INTERFACE_ID_FEES _registerInterface(0xb7799584); } /// @notice Mints batches of tokens emitting multiple Transfer events function mintBatchEdition(uint16 _editionSize, address _to, string calldata _uri) public override onlyContract returns (uint256 _editionId) { return _mintBatchEdition(_editionSize, _to, _uri); } /// @notice Mints an edition token batch and composes ERC20s for every token in the edition function mintBatchEditionAndComposeERC20s( uint16 _editionSize, address _to, string calldata _uri, address[] calldata _erc20s, uint256[] calldata _amounts ) external override onlyContract returns (uint256 _editionId) { uint256 totalErc20s = _erc20s.length; require(totalErc20s > 0 && totalErc20s == _amounts.length, "Tokens invalid"); _editionId = _mintBatchEdition(_editionSize, _to, _uri); for (uint i = 0; i < totalErc20s; i++) { _composeERC20IntoEdition(_to, _editionId, _erc20s[i], _amounts[i]); } } function _mintBatchEdition(uint16 _editionSize, address _to, string calldata _uri) internal returns (uint256) { require(_editionSize > 0 && _editionSize <= MAX_EDITION_SIZE, "Invalid size"); uint256 start = generateNextEditionNumber(); // N.B: Dont store owner, see ownerOf method to special case checking to avoid storage costs on creation // assign balance balances[_to] = balances[_to] + _editionSize; // edition of x editionDetails[start] = EditionDetails(_to, _editionSize, _uri); // Loop emit all transfer events uint256 end = start + _editionSize; for (uint i = start; i < end; i++) { emit Transfer(address(0), _to, i); } return start; } /// @notice Mints batches of tokens but emits a single ConsecutiveTransfer event EIP-2309 function mintConsecutiveBatchEdition(uint16 _editionSize, address _to, string calldata _uri) public override onlyContract returns (uint256 _editionId) { require(_editionSize > 0 && _editionSize <= MAX_EDITION_SIZE, "Invalid size"); uint256 start = generateNextEditionNumber(); // N.B: Dont store owner, see ownerOf method to special case checking to avoid storage costs on creation // assign balance balances[_to] = balances[_to] + _editionSize; // Start ID always equals edition ID editionDetails[start] = EditionDetails(_to, _editionSize, _uri); // emit EIP-2309 consecutive transfer event emit ConsecutiveTransfer(start, start + _editionSize, address(0), _to); return start; } /// @notice Allows the creator of an edition to update the token URI provided that no primary sales have been made function updateURIIfNoSaleMade(uint256 _editionId, string calldata _newURI) external override validateCreator(_editionId) { require( !hasMadePrimarySale(_editionId) && (!tokenUriResolverActive() || !tokenUriResolver.isDefined(_editionId, 0)), "Invalid state" ); editionDetails[_editionId].uri = _newURI; emit EditionURIUpdated(_editionId); } /// @notice Increases the edition pointer and then returns this pointer for minting methods function generateNextEditionNumber() internal returns (uint256) { editionPointer = editionPointer + MAX_EDITION_SIZE; return editionPointer; } /// @notice URI for an edition. Individual tokens in an edition will have this URI when tokenURI() is called function editionURI(uint256 _editionId) validateEdition(_editionId) public view returns (string memory) { // Here we are checking only that the edition has a edition level resolver - there may be a overridden token level resolver if (tokenUriResolverActive() && tokenUriResolver.isDefined(_editionId, 0)) { return tokenUriResolver.tokenURI(_editionId, 0); } return editionDetails[_editionId].uri; } /// @notice Returns the URI based on the edition associated with a token function tokenURI(uint256 _tokenId) public view returns (string memory) { require(_exists(_tokenId), "Token does not exist"); uint256 editionId = _editionFromTokenId(_tokenId); if (tokenUriResolverActive() && tokenUriResolver.isDefined(editionId, _tokenId)) { return tokenUriResolver.tokenURI(editionId, _tokenId); } return editionDetails[editionId].uri; } /// @notice Allows the caller to check if external URI resolver is active function tokenUriResolverActive() public view returns (bool) { return address(tokenUriResolver) != address(0); } /// @notice Additional metadata string for an edition function editionAdditionalMetaData(uint256 _editionId) public view returns (string memory) { return sealedEditionMetaData[_editionId]; } /// @notice Additional metadata string for a token function tokenAdditionalMetaData(uint256 _tokenId) public view returns (string memory) { return sealedTokenMetaData[_tokenId]; } /// @notice Additional metadata string for an edition given a token ID function editionAdditionalMetaDataForToken(uint256 _tokenId) public view returns (string memory) { uint256 editionId = _editionFromTokenId(_tokenId); return sealedEditionMetaData[editionId]; } function getEditionDetails(uint256 _tokenId) public override view returns (address _originalCreator, address _owner, uint16 _size, uint256 _editionId, string memory _uri) { uint256 editionId = _editionFromTokenId(_tokenId); EditionDetails storage edition = editionDetails[editionId]; return ( edition.creator, _ownerOf(_tokenId, editionId), edition.editionSize, editionId, tokenURI(_tokenId) ); } /// @notice If primary sales for an edition are disabled function isEditionSalesDisabled(uint256 _editionId) external view override returns (bool) { return editionSalesDisabled[_editionId]; } /// @notice If primary sales for an edition are disabled or if the edition is sold out function isSalesDisabledOrSoldOut(uint256 _editionId) external view override returns (bool) { return editionSalesDisabled[_editionId] || isEditionSoldOut(_editionId); } /// @notice Toggle for disabling primary sales for an edition function toggleEditionSalesDisabled(uint256 _editionId) validateEdition(_editionId) external override { address creator = editionDetails[_editionId].creator; require( creator == _msgSender() || accessControls.hasAdminRole(_msgSender()), "Only creator or admin" ); emit EditionSalesDisabledToggled(_editionId, editionSalesDisabled[_editionId], !editionSalesDisabled[_editionId]); editionSalesDisabled[_editionId] = !editionSalesDisabled[_editionId]; } /////////////////// // Creator query // /////////////////// function getCreatorOfEdition(uint256 _editionId) public override view returns (address _originalCreator) { return _getCreatorOfEdition(_editionId); } function getCreatorOfToken(uint256 _tokenId) public override view returns (address _originalCreator) { return _getCreatorOfEdition(_editionFromTokenId(_tokenId)); } function _getCreatorOfEdition(uint256 _editionId) internal view returns (address _originalCreator) { return editionDetails[_editionId].creator; } //////////////// // Size query // //////////////// function getSizeOfEdition(uint256 _editionId) public override view returns (uint256 _size) { return editionDetails[_editionId].editionSize; } function getEditionSizeOfToken(uint256 _tokenId) public override view returns (uint256 _size) { return editionDetails[_editionFromTokenId(_tokenId)].editionSize; } ///////////////////// // Existence query // ///////////////////// function editionExists(uint256 _editionId) public override view returns (bool) { return _editionExists(_editionId); } function _editionExists(uint256 _editionId) internal view returns (bool) { return editionDetails[_editionId].editionSize > 0; } function exists(uint256 _tokenId) public override view returns (bool) { return _exists(_tokenId); } function _exists(uint256 _tokenId) internal view returns (bool) { return _ownerOf(_tokenId, _editionFromTokenId(_tokenId)) != address(0); } /// @notice Returns the last token ID of an edition based on the edition's size function maxTokenIdOfEdition(uint256 _editionId) public override view returns (uint256 _tokenId) { return _maxTokenIdOfEdition(_editionId); } function _maxTokenIdOfEdition(uint256 _editionId) internal view returns (uint256 _tokenId) { return editionDetails[_editionId].editionSize + _editionId; } //////////////// // Edition ID // //////////////// function getEditionIdOfToken(uint256 _tokenId) public override pure returns (uint256 _editionId) { return _editionFromTokenId(_tokenId); } function _royaltyInfo(uint256 _tokenId, uint256 _value) internal view returns (address _receiver, uint256 _royaltyAmount) { uint256 editionId = _editionFromTokenId(_tokenId); // If we have a registry and its defined, use it if (royaltyRegistryActive() && royaltiesRegistryProxy.hasRoyalties(editionId)) { // Note: any registry must be edition aware so to only store one entry for all within the edition (_receiver, _royaltyAmount) = royaltiesRegistryProxy.royaltyInfo(editionId, _value); } else { // Fall back to KO defaults _receiver = _getCreatorOfEdition(editionId); _royaltyAmount = (_value / modulo) * secondarySaleRoyalty; } } ////////////// // ERC-2981 // ////////////// // Abstract away token royalty registry, proxy through to the implementation function royaltyInfo(uint256 _tokenId, uint256 _value) external override view returns (address _receiver, uint256 _royaltyAmount) { return _royaltyInfo(_tokenId, _value); } // Expanded method at edition level and expanding on the funds receiver and the creator function royaltyAndCreatorInfo(uint256 _tokenId, uint256 _value) external view override returns (address receiver, address creator, uint256 royaltyAmount) { address originalCreator = _getCreatorOfEdition(_editionFromTokenId(_tokenId)); (address _receiver, uint256 _royaltyAmount) = _royaltyInfo(_tokenId, _value); return (_receiver, originalCreator, _royaltyAmount); } function hasRoyalties(uint256 _editionId) validateEdition(_editionId) external override view returns (bool) { return royaltyRegistryActive() && royaltiesRegistryProxy.hasRoyalties(_editionId) || secondarySaleRoyalty > 0; } function getRoyaltiesReceiver(uint256 _tokenId) public override view returns (address) { uint256 editionId = _editionFromTokenId(_tokenId); if (royaltyRegistryActive() && royaltiesRegistryProxy.hasRoyalties(editionId)) { return royaltiesRegistryProxy.getRoyaltiesReceiver(editionId); } return _getCreatorOfEdition(editionId); } function royaltyRegistryActive() public view returns (bool) { return address(royaltiesRegistryProxy) != address(0); } ////////////////////////////// // Has Secondary Sale Fees // //////////////////////////// function getFeeRecipients(uint256 _tokenId) external view override returns (address payable[] memory) { address payable[] memory feeRecipients = new address payable[](1); feeRecipients[0] = payable(getRoyaltiesReceiver(_tokenId)); return feeRecipients; } function getFeeBps(uint256) external view override returns (uint[] memory) { uint[] memory feeBps = new uint[](1); feeBps[0] = uint(secondarySaleRoyalty) / basisPointsModulo; // convert to basis points return feeBps; } //////////////////////////////////// // Primary Sale Utilities methods // //////////////////////////////////// /// @notice List of token IDs that are still with the original creator function getAllUnsoldTokenIdsForEdition(uint256 _editionId) validateEdition(_editionId) public view returns (uint256[] memory) { uint256 maxTokenId = _maxTokenIdOfEdition(_editionId); // work out number of unsold tokens in order to allocate memory to an array later uint256 numOfUnsoldTokens; for (uint256 i = _editionId; i < maxTokenId; i++) { // if no owner set - assume primary if not moved if (owners[i] == address(0)) { numOfUnsoldTokens += 1; } } uint256[] memory unsoldTokens = new uint256[](numOfUnsoldTokens); // record token IDs of unsold tokens uint256 nextIndex; for (uint256 tokenId = _editionId; tokenId < maxTokenId; tokenId++) { // if no owner set - assume primary if not moved if (owners[tokenId] == address(0)) { unsoldTokens[nextIndex] = tokenId; nextIndex += 1; } } return unsoldTokens; } /// @notice For a given edition, returns the next token and associated royalty information function facilitateNextPrimarySale(uint256 _editionId) public view override returns (address receiver, address creator, uint256 tokenId) { require(!editionSalesDisabled[_editionId], "Edition disabled"); uint256 _tokenId = getNextAvailablePrimarySaleToken(_editionId); address _creator = _getCreatorOfEdition(_editionId); if (royaltyRegistryActive() && royaltiesRegistryProxy.hasRoyalties(_editionId)) { address _receiver = royaltiesRegistryProxy.getRoyaltiesReceiver(_editionId); return (_receiver, _creator, _tokenId); } return (_creator, _creator, _tokenId); } /// @notice Return the next unsold token ID for a given edition unless all tokens have been sold function getNextAvailablePrimarySaleToken(uint256 _editionId) public override view returns (uint256 _tokenId) { uint256 maxTokenId = _maxTokenIdOfEdition(_editionId); // low to high for (uint256 tokenId = _editionId; tokenId < maxTokenId; tokenId++) { // if no owner set - assume primary if not moved if (owners[tokenId] == address(0)) { return tokenId; } } revert("Primary market exhausted"); } /// @notice Starting from the last token in an edition and going down the first, returns the next unsold token (if any) function getReverseAvailablePrimarySaleToken(uint256 _editionId) public override view returns (uint256 _tokenId) { uint256 highestTokenId = _maxTokenIdOfEdition(_editionId) - 1; // high to low while (highestTokenId >= _editionId) { // if no owner set - assume primary if not moved if (owners[highestTokenId] == address(0)) { return highestTokenId; } highestTokenId--; } revert("Primary market exhausted"); } /// @notice Using the reverse token ID logic of an edition, returns next token ID and associated royalty information function facilitateReversePrimarySale(uint256 _editionId) public view override returns (address receiver, address creator, uint256 tokenId) { require(!editionSalesDisabled[_editionId], "Edition disabled"); uint256 _tokenId = getReverseAvailablePrimarySaleToken(_editionId); address _creator = _getCreatorOfEdition(_editionId); if (royaltyRegistryActive() && royaltiesRegistryProxy.hasRoyalties(_editionId)) { address _receiver = royaltiesRegistryProxy.getRoyaltiesReceiver(_editionId); return (_receiver, _creator, _tokenId); } return (_creator, _creator, _tokenId); } /// @notice If the token specified by token ID has been sold on the primary market function hadPrimarySaleOfToken(uint256 _tokenId) public override view returns (bool) { return owners[_tokenId] != address(0); } /// @notice If any token in the edition has been sold function hasMadePrimarySale(uint256 _editionId) validateEdition(_editionId) public override view returns (bool) { uint256 maxTokenId = _maxTokenIdOfEdition(_editionId); // low to high for (uint256 tokenId = _editionId; tokenId < maxTokenId; tokenId++) { // if no owner set - assume primary if not moved if (owners[tokenId] != address(0)) { return true; } } return false; } /// @notice If all tokens in the edition have been sold function isEditionSoldOut(uint256 _editionId) validateEdition(_editionId) public override view returns (bool) { uint256 maxTokenId = _maxTokenIdOfEdition(_editionId); // low to high for (uint256 tokenId = _editionId; tokenId < maxTokenId; tokenId++) { // if no owner set - assume primary if not moved if (owners[tokenId] == address(0)) { return false; } } return true; } ////////////// // Defaults // ////////////// /// @notice Transfers the ownership of an NFT from one address to another address /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. When transfer is complete, this function /// checks if `_to` is a smart contract (code size > 0). If so, it calls /// `onERC721Received` on `_to` and throws if the return value is not /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer /// @param _data Additional data with no specified format, sent in call to `_to` function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata _data) override external { _safeTransferFrom(_from, _to, _tokenId, _data); // move the token emit Transfer(_from, _to, _tokenId); } /// @notice Transfers the ownership of an NFT from one address to another address /// @dev This works identically to the other function with an extra data parameter, /// except this function just sets data to "". /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function safeTransferFrom(address _from, address _to, uint256 _tokenId) override external { _safeTransferFrom(_from, _to, _tokenId, bytes("")); // move the token emit Transfer(_from, _to, _tokenId); } function _safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) private { _transferFrom(_from, _to, _tokenId); uint256 receiverCodeSize; assembly { receiverCodeSize := extcodesize(_to) } if (receiverCodeSize > 0) { bytes4 selector = IERC721Receiver(_to).onERC721Received( _msgSender(), _from, _tokenId, _data ); require( selector == ERC721_RECEIVED, "Invalid selector" ); } } /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `_msgSender()` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom(address _from, address _to, uint256 _tokenId) override external { _transferFrom(_from, _to, _tokenId); // move the token emit Transfer(_from, _to, _tokenId); } function _transferFrom(address _from, address _to, uint256 _tokenId) private { // enforce not being able to send to zero as we have explicit rules what a minted but unbound owner is require(_to != address(0), "Invalid to address"); // Ensure the owner is the sender address owner = _ownerOf(_tokenId, _editionFromTokenId(_tokenId)); require(owner != address(0), "Invalid owner"); require(_from == owner, "Owner mismatch"); address spender = _msgSender(); address approvedAddress = getApproved(_tokenId); require( spender == owner // sending to myself || isApprovedForAll(owner, spender) // is approved to send any behalf of owner || approvedAddress == spender, // is approved to move this token ID "Invalid spender" ); // Ensure approval for token ID is cleared if (approvedAddress != address(0)) { approvals[_tokenId] = address(0); } // set new owner - this will now override any specific other mappings for the base edition config owners[_tokenId] = _to; // Modify balances balances[_from] = balances[_from] - 1; balances[_to] = balances[_to] + 1; } /// @notice Find the owner of an NFT /// @dev NFTs assigned to zero address are considered invalid, and queries about them do throw. /// @param _tokenId The identifier for an NFT /// @return The address of the owner of the NFT function ownerOf(uint256 _tokenId) override public view returns (address) { uint256 editionId = _editionFromTokenId(_tokenId); address owner = _ownerOf(_tokenId, editionId); require(owner != address(0), "Invalid owner"); return owner; } /// @dev Newly created editions and its tokens minted to a creator don't have the owner set until the token is sold on the primary market /// @dev Therefore, if internally an edition exists and owner of token is zero address, then creator still owns the token /// @dev Otherwise, the token owner is returned or the zero address if the token does not exist function _ownerOf(uint256 _tokenId, uint256 _editionId) internal view returns (address) { // If an owner assigned address owner = owners[_tokenId]; if (owner != address(0)) { return owner; } // fall back to edition creator address possibleCreator = _getCreatorOfEdition(_editionId); if (possibleCreator != address(0) && (_maxTokenIdOfEdition(_editionId) - 1) >= _tokenId) { return possibleCreator; } return address(0); } /// @notice Change or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized /// operator of the current owner. /// @param _approved The new approved NFT controller /// @param _tokenId The NFT to approve function approve(address _approved, uint256 _tokenId) override external { address owner = ownerOf(_tokenId); require(_approved != owner, "Approved is owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "Invalid sender"); approvals[_tokenId] = _approved; emit Approval(owner, _approved, _tokenId); } /// @notice Enable or disable approval for a third party ("operator") to manage /// all of `msg.sender`"s assets /// @dev Emits the ApprovalForAll event. The contract MUST allow /// multiple operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAll(address _operator, bool _approved) override external { operatorApprovals[_msgSender()][_operator] = _approved; emit ApprovalForAll( _msgSender(), _operator, _approved ); } /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param _owner An address for whom to query the balance /// @return The number of NFTs owned by `_owner`, possibly zero function balanceOf(address _owner) override external view returns (uint256) { require(_owner != address(0), "Invalid owner"); return balances[_owner]; } /// @notice Get the approved address for a single NFT /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _tokenId The NFT to find the approved address for /// @return The approved address for this NFT, or the zero address if there is none function getApproved(uint256 _tokenId) override public view returns (address){ return approvals[_tokenId]; } /// @notice Query if an address is an authorized operator for another address /// @param _owner The address that owns the NFTs /// @param _operator The address that acts on behalf of the owner /// @return True if `_operator` is an approved operator for `_owner`, false otherwise function isApprovedForAll(address _owner, address _operator) override public view returns (bool){ return operatorApprovals[_owner][_operator]; } /// @notice An extension to the default ERC721 behaviour, derived from ERC-875. /// @dev Allowing for batch transfers from the provided address, will fail if from does not own all the tokens function batchTransferFrom(address _from, address _to, uint256[] calldata _tokenIds) public { for (uint256 i = 0; i < _tokenIds.length; i++) { _safeTransferFrom(_from, _to, _tokenIds[i], bytes("")); emit Transfer(_from, _to, _tokenIds[i]); } } /// @notice An extension to the default ERC721 behaviour, derived from ERC-875 but using the ConsecutiveTransfer event /// @dev Allowing for batch transfers from the provided address, will fail if from does not own all the tokens function consecutiveBatchTransferFrom(address _from, address _to, uint256 _fromTokenId, uint256 _toTokenId) public { for (uint256 i = _fromTokenId; i <= _toTokenId; i++) { _safeTransferFrom(_from, _to, i, bytes("")); } emit ConsecutiveTransfer(_fromTokenId, _toTokenId, _from, _to); } ///////////////////// // Admin functions // ///////////////////// function setRoyaltiesRegistryProxy(IERC2981 _royaltiesRegistryProxy) onlyAdmin public { royaltiesRegistryProxy = _royaltiesRegistryProxy; emit AdminRoyaltiesRegistryProxySet(address(_royaltiesRegistryProxy)); } function setTokenUriResolver(ITokenUriResolver _tokenUriResolver) onlyAdmin public { tokenUriResolver = _tokenUriResolver; emit AdminTokenUriResolverSet(address(_tokenUriResolver)); } /////////////////////// // Creator functions // /////////////////////// function composeERC20sAsCreator(uint16 _editionId, address[] calldata _erc20s, uint256[] calldata _amounts) external validateCreator(_editionId) { require(!isEditionSoldOut(_editionId), "Edition soldout"); uint256 totalErc20s = _erc20s.length; require(totalErc20s > 0 && totalErc20s == _amounts.length, "Tokens invalid"); for (uint i = 0; i < totalErc20s; i++) { _composeERC20IntoEdition(_msgSender(), _editionId, _erc20s[i], _amounts[i]); } } /// @notice Optional metadata storage slot which allows the creator to set an additional metadata blob on the edition function lockInAdditionalMetaData(uint256 _editionId, string calldata _metadata) external validateCreator(_editionId) { require(bytes(sealedEditionMetaData[_editionId]).length == 0, "Already set"); sealedEditionMetaData[_editionId] = _metadata; emit SealedEditionMetaDataSet(_editionId); } /// @notice Optional metadata storage slot which allows a token owner to set an additional metadata blob on the token function lockInAdditionalTokenMetaData(uint256 _tokenId, string calldata _metadata) external { require( _msgSender() == ownerOf(_tokenId) || accessControls.hasContractRole(_msgSender()), "Invalid caller" ); require(bytes(sealedTokenMetaData[_tokenId]).length == 0, "Already set"); sealedTokenMetaData[_tokenId] = _metadata; emit SealedTokenMetaDataSet(_tokenId); } }
@notice Token URI resolver
ITokenUriResolver public tokenUriResolver;
105,773
[ 1, 1345, 3699, 5039, 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 ]
[ 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 467, 1345, 3006, 4301, 1071, 1147, 3006, 4301, 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 ]
pragma solidity ^0.4.24; import "./Partnership.sol"; /** * @title Permissions contract. * @author Talao, Polynomial. * @notice See ../identity/KeyHolder.sol as well. */ contract Permissions is Partnership { // Foundation contract. Foundation foundation; // Talao token contract. TalaoToken public token; /** * @dev Constructor. */ constructor( address _foundation, address _token, uint16 _category, uint16 _asymetricEncryptionAlgorithm, uint16 _symetricEncryptionAlgorithm, bytes _asymetricEncryptionPublicKey, bytes _symetricEncryptionEncryptedKey, bytes _encryptedSecret ) Partnership( _foundation, _token, _category, _asymetricEncryptionAlgorithm, _symetricEncryptionAlgorithm, _asymetricEncryptionPublicKey, _symetricEncryptionEncryptedKey, _encryptedSecret ) public { foundation = Foundation(_foundation); token = TalaoToken(_token); identityInformation.creator = msg.sender; identityInformation.category = _category; identityInformation.asymetricEncryptionAlgorithm = _asymetricEncryptionAlgorithm; identityInformation.symetricEncryptionAlgorithm = _symetricEncryptionAlgorithm; identityInformation.asymetricEncryptionPublicKey = _asymetricEncryptionPublicKey; identityInformation.symetricEncryptionEncryptedKey = _symetricEncryptionEncryptedKey; identityInformation.encryptedSecret = _encryptedSecret; } /** * @dev Is msg.sender a "member" of this contract, in the Foundation sense? */ function isMember() public view returns (bool) { return foundation.membersToContracts(msg.sender) == address(this); } /** * @dev Read authorization for inherited contracts "private" data. */ function isReader() public view returns (bool) { // Get Vault access price in the token for this contract owner, // in the Foundation sense. (uint accessPrice,,,) = token.data(identityOwner()); // OR conditions for Reader: // 1) Same code for // 1.1) Sender is this contract owner and has an open Vault in the token. // 1.2) Sender has vaultAccess to this contract owner in the token. // 2) Owner has open Vault in the token and: // 2.1) Sender is a member of this contract, // 2.2) Sender is a member of an authorized Partner contract // 2.3) Sender has an ERC 725 20001 key "Reader" // 2.4) Owner has a free vaultAccess in the token return( token.hasVaultAccess(identityOwner(), msg.sender) || ( token.hasVaultAccess(identityOwner(), identityOwner()) && ( isMember() || isPartnershipMember() || hasIdentityPurpose(20001) || (accessPrice == 0 && msg.sender != address(0)) ) ) ); } /** * @dev Modifier version of isReader. */ modifier onlyReader() { require(isReader(), "Access denied"); _; } }
* @title Permissions contract. @author Talao, Polynomial. @notice See ../identity/KeyHolder.sol as well./ Foundation contract. Talao token contract.
contract Permissions is Partnership { Foundation foundation; TalaoToken public token; constructor( address _foundation, address _token, uint16 _category, uint16 _asymetricEncryptionAlgorithm, uint16 _symetricEncryptionAlgorithm, bytes _asymetricEncryptionPublicKey, bytes _symetricEncryptionEncryptedKey, bytes _encryptedSecret ) Partnership( _foundation, _token, _category, _asymetricEncryptionAlgorithm, _symetricEncryptionAlgorithm, _asymetricEncryptionPublicKey, _symetricEncryptionEncryptedKey, _encryptedSecret ) public { foundation = Foundation(_foundation); token = TalaoToken(_token); identityInformation.creator = msg.sender; identityInformation.category = _category; identityInformation.asymetricEncryptionAlgorithm = _asymetricEncryptionAlgorithm; identityInformation.symetricEncryptionAlgorithm = _symetricEncryptionAlgorithm; identityInformation.asymetricEncryptionPublicKey = _asymetricEncryptionPublicKey; identityInformation.symetricEncryptionEncryptedKey = _symetricEncryptionEncryptedKey; identityInformation.encryptedSecret = _encryptedSecret; } function isMember() public view returns (bool) { return foundation.membersToContracts(msg.sender) == address(this); } function isReader() public view returns (bool) { (uint accessPrice,,,) = token.data(identityOwner()); return( token.hasVaultAccess(identityOwner(), msg.sender) || ( token.hasVaultAccess(identityOwner(), identityOwner()) && ( isMember() || isPartnershipMember() || hasIdentityPurpose(20001) || (accessPrice == 0 && msg.sender != address(0)) ) ) ); } modifier onlyReader() { require(isReader(), "Access denied"); _; } }
13,112,298
[ 1, 6521, 6835, 18, 225, 399, 287, 6033, 16, 6730, 13602, 18, 225, 2164, 6116, 19, 10781, 19, 653, 6064, 18, 18281, 487, 5492, 18, 19, 31289, 6835, 18, 399, 287, 6033, 1147, 6835, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 15684, 353, 6393, 9646, 5310, 288, 203, 203, 565, 31289, 1392, 367, 31, 203, 203, 565, 399, 287, 6033, 1345, 1071, 1147, 31, 203, 203, 565, 3885, 12, 203, 3639, 1758, 389, 30493, 16, 203, 3639, 1758, 389, 2316, 16, 203, 3639, 2254, 2313, 389, 4743, 16, 203, 3639, 2254, 2313, 389, 345, 2942, 1591, 7894, 6801, 16, 203, 3639, 2254, 2313, 389, 8117, 1591, 7894, 6801, 16, 203, 3639, 1731, 389, 345, 2942, 1591, 7894, 9632, 16, 203, 3639, 1731, 389, 8117, 1591, 7894, 14678, 653, 16, 203, 3639, 1731, 389, 18702, 5207, 203, 565, 262, 203, 3639, 6393, 9646, 5310, 12, 203, 5411, 389, 30493, 16, 203, 5411, 389, 2316, 16, 203, 5411, 389, 4743, 16, 203, 5411, 389, 345, 2942, 1591, 7894, 6801, 16, 203, 5411, 389, 8117, 1591, 7894, 6801, 16, 203, 5411, 389, 345, 2942, 1591, 7894, 9632, 16, 203, 5411, 389, 8117, 1591, 7894, 14678, 653, 16, 203, 5411, 389, 18702, 5207, 203, 3639, 262, 203, 3639, 1071, 203, 565, 288, 203, 3639, 1392, 367, 273, 31289, 24899, 30493, 1769, 203, 3639, 1147, 273, 399, 287, 6033, 1345, 24899, 2316, 1769, 203, 3639, 4215, 5369, 18, 20394, 273, 1234, 18, 15330, 31, 203, 3639, 4215, 5369, 18, 4743, 273, 389, 4743, 31, 203, 3639, 4215, 5369, 18, 345, 2942, 1591, 7894, 6801, 273, 389, 345, 2942, 1591, 7894, 6801, 31, 203, 3639, 4215, 5369, 18, 8117, 1591, 7894, 6801, 273, 389, 8117, 1591, 7894, 6801, 31, 203, 3639, 4215, 5369, 18, 345, 2942, 1591, 7894, 9632, 273, 2 ]
//Address: 0x8037a3e0d864b1f332e52cf60f999990a9780c54 //Contract name: Airdropper //Balance: 0 Ether //Verification Date: 1/26/2018 //Transacion Count: 16 // CODE STARTS HERE pragma solidity ^0.4.11; // File: contracts/zeppelin/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; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { 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 { require(newOwner != address(0)); owner = newOwner; } } // File: contracts/zeppelin/contracts/token/ERC20Basic.sol /** * @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) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: contracts/zeppelin/contracts/token/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts/Airdropper.sol /* Copyright 2018 CargiX.io Pte 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.4.18; contract Airdropper is Ownable { function multisend(address _tokenAddr, address[] dests, uint256[] values) onlyOwner returns (uint256) { uint256 i = 0; while (i < dests.length) { ERC20(_tokenAddr).transfer(dests[i], values[i]); i += 1; } return(i); } function multisendFrom(address _tokenAddr, address _fromAddr, address[] dests, uint256[] values) onlyOwner returns (uint256) { uint256 i = 0; while (i < dests.length) { ERC20(_tokenAddr).transferFrom(_fromAddr, dests[i], values[i]); i += 1; } return(i); } }
* @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; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } }
12,701,229
[ 1, 5460, 429, 225, 1021, 14223, 6914, 6835, 711, 392, 3410, 1758, 16, 471, 8121, 5337, 6093, 3325, 4186, 16, 333, 9330, 5032, 326, 4471, 434, 315, 1355, 4371, 9654, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 225, 1758, 1071, 3410, 31, 203, 203, 203, 203, 203, 203, 225, 445, 14223, 6914, 1435, 288, 203, 565, 3410, 273, 1234, 18, 15330, 31, 203, 225, 289, 203, 203, 203, 225, 9606, 1338, 5541, 1435, 288, 203, 565, 2583, 12, 3576, 18, 15330, 422, 3410, 1769, 203, 565, 389, 31, 203, 225, 289, 203, 203, 203, 225, 445, 7412, 5460, 12565, 12, 2867, 394, 5541, 13, 1338, 5541, 288, 203, 565, 2583, 12, 2704, 5541, 480, 1758, 12, 20, 10019, 203, 565, 3410, 273, 394, 5541, 31, 203, 225, 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 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract Time is ERC20 { uint256 constant DAY_IN_SECONDS = 86400; uint256 lastTimeClaim; uint256 timeFrequency; address timeGuardian; address timeBank; // exchange address event RewardSent( address timeMiner, uint256 reward, uint256 timeReleased, uint256 timestamp ); event TimeFrequencyEvent(uint256 timeFrequency); event TimeBankEvent(address timeBank); constructor() ERC20("Time", "TIME") { lastTimeClaim = block.timestamp; timeGuardian = msg.sender; timeFrequency = DAY_IN_SECONDS; _mint( address(this), (block.timestamp - 1230940800) * 10**uint256(decimals()) ); // the starting time anniversary _burn( address(this), (block.timestamp - 1230940800) * 10**uint256(decimals()) ); } function mineTime() public { require( (block.timestamp - lastTimeClaim) >= timeFrequency, "TIME is released one day every day" ); uint256 reward = (block.timestamp - lastTimeClaim - timeFrequency) * 10**uint256(decimals()); uint256 timeReleased = timeFrequency * 10**uint256(decimals()); _mint(timeBank, timeReleased); // Time Contract recieves a day - 5 sec ideally _mint(msg.sender, reward); // Time Distributor recieves 5 seconds lastTimeClaim = block.timestamp; emit RewardSent( msg.sender, reward, timeReleased, lastTimeClaim ); } function setTimeBank(address Bank) public { require(msg.sender == timeGuardian, "you are not the Time guardian"); timeBank = Bank; emit TimeBankEvent(timeBank); } function setTimeFrequency(uint256 frequency) public { require(msg.sender == timeGuardian, "you are not the Time guardian"); timeFrequency = frequency; emit TimeFrequencyEvent(timeFrequency); } function getLastTimeClaim() public view returns (uint256) { return lastTimeClaim; } function getTimeBankAddress() public view returns (address) { return timeBank; } } // 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; /** * @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; } }
Time Distributor recieves 5 seconds
_mint(msg.sender, reward);
13,744,216
[ 1, 950, 3035, 19293, 1950, 1385, 3324, 1381, 3974, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 81, 474, 12, 3576, 18, 15330, 16, 19890, 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 ]
/* Copyright 2017-2019 Phillip A. Elsasser 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.2; import "truffle/Assert.sol"; import "../../../contracts/marketprotocol/tokens/MarketToken.sol"; import "../../../contracts/marketprotocol/tokens/UpgradeableTokenMock.sol"; /// @title TestMarketToken /// @author Phil Elsasser <[email protected]> contract TestMarketToken { function testInitialBalance() public { MarketToken marketToken = new MarketToken(); Assert.equal( marketToken.balanceOf(address(this)), marketToken.INITIAL_SUPPLY(), "init supply allocated to creator" ); } function testBurnTokens() public { MarketToken marketToken = new MarketToken(); Assert.equal( marketToken.balanceOf(address(this)), marketToken.INITIAL_SUPPLY(), "Unexpected initial supply allocation" ); Assert.equal( marketToken.totalSupply(), marketToken.INITIAL_SUPPLY(), "Unexpected initial supply allocation" ); marketToken.burn(marketToken.INITIAL_SUPPLY() / 2); Assert.equal( marketToken.totalSupply(), marketToken.INITIAL_SUPPLY() / 2, "Unexpected supply after burn" ); } }
@title TestMarketToken @author Phil Elsasser <[email protected]>
contract TestMarketToken { Copyright 2017-2019 Phillip A. Elsasser function testInitialBalance() public { MarketToken marketToken = new MarketToken(); Assert.equal( marketToken.balanceOf(address(this)), marketToken.INITIAL_SUPPLY(), "init supply allocated to creator" ); } function testBurnTokens() public { MarketToken marketToken = new MarketToken(); Assert.equal( marketToken.balanceOf(address(this)), marketToken.INITIAL_SUPPLY(), "Unexpected initial supply allocation" ); Assert.equal( marketToken.totalSupply(), marketToken.INITIAL_SUPPLY(), "Unexpected initial supply allocation" ); marketToken.burn(marketToken.INITIAL_SUPPLY() / 2); Assert.equal( marketToken.totalSupply(), marketToken.INITIAL_SUPPLY() / 2, "Unexpected supply after burn" ); } }
15,796,845
[ 1, 4709, 3882, 278, 1345, 225, 4360, 330, 512, 3251, 428, 264, 411, 844, 330, 36, 27151, 11815, 1293, 18, 1594, 34, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7766, 3882, 278, 1345, 288, 203, 565, 25417, 11015, 17, 6734, 29, 4360, 330, 3169, 432, 18, 512, 3251, 428, 264, 203, 203, 565, 445, 1842, 4435, 13937, 1435, 1071, 288, 203, 3639, 6622, 278, 1345, 13667, 1345, 273, 394, 6622, 278, 1345, 5621, 203, 3639, 5452, 18, 9729, 12, 203, 5411, 13667, 1345, 18, 12296, 951, 12, 2867, 12, 2211, 13, 3631, 203, 5411, 13667, 1345, 18, 28497, 67, 13272, 23893, 9334, 203, 5411, 315, 2738, 14467, 11977, 358, 11784, 6, 203, 3639, 11272, 203, 565, 289, 203, 203, 565, 445, 1842, 38, 321, 5157, 1435, 1071, 288, 203, 3639, 6622, 278, 1345, 13667, 1345, 273, 394, 6622, 278, 1345, 5621, 203, 203, 3639, 5452, 18, 9729, 12, 203, 5411, 13667, 1345, 18, 12296, 951, 12, 2867, 12, 2211, 13, 3631, 203, 5411, 13667, 1345, 18, 28497, 67, 13272, 23893, 9334, 203, 5411, 315, 7762, 2172, 14467, 13481, 6, 203, 3639, 11272, 203, 203, 3639, 5452, 18, 9729, 12, 203, 5411, 13667, 1345, 18, 4963, 3088, 1283, 9334, 203, 5411, 13667, 1345, 18, 28497, 67, 13272, 23893, 9334, 203, 5411, 315, 7762, 2172, 14467, 13481, 6, 203, 3639, 11272, 203, 203, 3639, 13667, 1345, 18, 70, 321, 12, 27151, 1345, 18, 28497, 67, 13272, 23893, 1435, 342, 576, 1769, 203, 203, 3639, 5452, 18, 9729, 12, 203, 5411, 13667, 1345, 18, 4963, 3088, 1283, 9334, 203, 5411, 13667, 1345, 18, 28497, 67, 13272, 23893, 1435, 342, 576, 16, 203, 5411, 315, 7762, 14467, 1839, 18305, 6, 203, 3639, 11272, 203, 565, 289, 2 ]
// SPDX-License-Identifier: MIT pragma solidity 0.8.2; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../interfaces/IRiverBoxV2.sol"; import "../interfaces/IRiverBoxRandom.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract RiverBoxImplV2 is IRiverBoxV2, ERC721Upgradeable, ERC721EnumerableUpgradeable, AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable, OwnableUpgradeable { using StringsUpgradeable for uint256; using SafeMathUpgradeable for uint256; using CountersUpgradeable for CountersUpgradeable.Counter; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; CountersUpgradeable.Counter private _tokenIds; uint16[] private _stockLocations; uint32[] private _stockSignatures; uint32 private _stockCounter; /* ================ GLOBAL CONFIGURATION ================ */ // price per box - Pawn uint256 public boxPrice; uint256 public totalClaimableAmount; string public baseURI; address public randomGeneratorAddress; mapping(uint256 => string) private _tokenURIs; mapping(uint256 => Product) private _tokenDetailsMapping; mapping(address => uint256) public paidBoxes; // number of boxes user has bought mapping(uint256 => Hierarchy) private _tokenHierarchyMapping; mapping(address => uint256) public claimableAmountMapping; mapping(address => uint256) public referrerContrib; uint256 public totalReferrerContrib; address proxyRegistryAddress; /* ================ SHARES ================ */ address public funderAddress; address public devAddress; address public marketAddress; uint8 public devShare; uint8 public marketShare; bool public fuseLock; constructor() initializer {} function initialize( uint256 _boxPrice, string memory _name, string memory _symbol, string memory _initBaseURI, address _proxyRegistryAddress ) public initializer { __Ownable_init(); __Pausable_init(); __AccessControl_init(); __ReentrancyGuard_init(); __ERC721_init(_name, _symbol); __UUPSUpgradeable_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _pause(); fuseLock = true; boxPrice = _boxPrice; baseURI = _initBaseURI; proxyRegistryAddress = _proxyRegistryAddress; } /* ================ UTIL FUNCTIONS ================ */ function _pickLocation(uint256 index) internal returns (uint16, uint32) { uint256 lastIndex = _stockLocations.length - 1; uint16 lastStockLocation = _stockLocations[lastIndex]; uint16 locationId = _stockLocations[index]; _stockLocations[index] = lastStockLocation; _stockLocations.pop(); uint32 lastSignature = _stockSignatures[lastIndex]; uint32 signature = _stockSignatures[index]; _stockSignatures[index] = lastSignature; _stockSignatures.pop(); return (locationId, signature); } /* ================ VIEWS ================ */ function pawnsStock() public view returns (uint256) { return _stockLocations.length.sub(totalClaimableAmount); } function batchStockInfo(uint256 startIndex, uint256 length) public view returns (uint256[] memory, uint256[] memory) { require(startIndex < _stockLocations.length, "startIndex cannot over stockLocationsLength"); require(length > 0, "length cannot equal 0"); uint256 endIndex = MathUpgradeable.min(startIndex + length, _stockLocations.length); uint256 realLength = endIndex - startIndex; uint256[] memory locationIds = new uint256[](realLength); uint256[] memory signatures = new uint256[](realLength); for (uint256 idx = 0; idx < realLength; ++idx) { locationIds[idx] = _stockLocations[startIndex.add(idx)]; signatures[idx] = _stockSignatures[startIndex.add(idx)]; } return (locationIds, signatures); } /** * @dev Ultimate view for inspecting a token * @param tokenId the unique ID of a RiverMenNFT token * @return [[locationId, fusionCount, signature, creationTime, parts], ownerAddress, tokenURI, dealId] * @notice dealId = 0 means the item is not listed in exchange */ function allInfo(uint256 tokenId) public view returns ( Product memory, address, string memory ) { require(_exists(tokenId), "Token not exists"); return (_tokenDetailsMapping[tokenId], ownerOf(tokenId), tokenURI(tokenId)); } /** * @dev Get token detail information */ function tokenDetail(uint256 tokenId) public view override returns (Product memory) { require(_exists(tokenId), "Token not exists"); return _tokenDetailsMapping[tokenId]; } function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, ERC721EnumerableUpgradeable, AccessControlUpgradeable) returns (bool) { return super.supportsInterface(interfaceId); } function tokenURI(uint256 tokenId) public view override(IRiverBoxV2, ERC721Upgradeable) returns (string memory) { require(_exists(tokenId), "URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); if (bytes(_tokenURI).length > 0) { return _tokenURI; } else { return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString())) : ""; } } function implementationVersion() public pure override returns (string memory) { return "2.0.0"; } /* ================ PRIVATE FUNCTIONS ================ */ function _notContract() internal view { uint256 size; address addr = msg.sender; assembly { size := extcodesize(addr) } require(size == 0, "contract not allowed"); require(msg.sender == tx.origin, "proxy contract not allowed"); } /** * @dev Mint a new Item * @param receiver account address to receive the new item */ function _awardItem(address receiver) private returns (uint256) { _tokenIds.increment(); uint256 newId = _tokenIds.current(); _safeMint(receiver, newId); return newId; } function _baseURI() internal view override(ERC721Upgradeable) returns (string memory) { return baseURI; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId); } function _authorizeUpgrade(address) internal view override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission to do upgrades"); } /* ================ TRANSACTIONS ================ */ /** * @dev Buy N (n<10) boxes, this function receive payment and * mint new product(s) to sender * @param quality number of boxes * @param referrer referrer account address */ function buy(uint256 quality, address referrer) external payable override whenNotPaused nonReentrant { _notContract(); require(quality <= pawnsStock(), "blind box sold out"); require(quality <= 20, "exceed maximum quality 20"); require(msg.value >= boxPrice.mul(quality), "payment is less than box price"); boxesAward(quality, _msgSender()); if (referrer != address(0)) { referrerContrib[referrer] = referrerContrib[referrer].add(quality); totalReferrerContrib = totalReferrerContrib.add(quality); } paidBoxes[_msgSender()] = paidBoxes[_msgSender()].add(quality); } function boxesAward(uint256 quality, address receiver) internal { uint256 salt = uint256(keccak256(abi.encodePacked(quality, receiver, totalSupply()))); uint256 seed = IRiverBoxRandom(randomGeneratorAddress).generateSignature(salt); for (uint256 i = 0; i < quality; ++i) { seed = seed.add(totalSupply()); uint256 randomIdx = uint256(keccak256(abi.encodePacked(seed))).mod(_stockLocations.length); (uint16 pawnLocationId, uint32 signature) = _pickLocation(randomIdx); Product memory newItem = Product(pawnLocationId, 0, signature, new uint256[](0)); uint256 newId = _awardItem(receiver); _tokenDetailsMapping[newId] = newItem; emit BoxAwarded(receiver, newId, block.timestamp); } } /* ================ ADMIN ACTIONS ================ */ /** * @dev Set a new base URI * param newBaseURI new baseURI address */ function setBaseURI(string memory newBaseURI) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); baseURI = newBaseURI; } function batchSetPawnLocationStock(uint16[] memory locationIds, uint16[] memory locationIdStocks) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); for (uint16 locationIdx = 0; locationIdx < locationIds.length; ++locationIdx) { uint16 locationId = locationIds[locationIdx]; uint16 locationIdStock = locationIdStocks[locationIdx]; for (uint16 stockIdx = 0; stockIdx < locationIdStock; ++stockIdx) { _stockLocations.push(locationId); _stockCounter = _stockCounter + 1; require(_stockCounter >= 1, "SafeMath: addition overflow"); _stockSignatures.push(_stockCounter); } } } /** * @dev Triggers stopped state. */ function pause() external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); _pause(); } /** * @dev Returns to normal state. */ function unPause() external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); _unpause(); } /** * @dev Triggers stopped state. * @param newPrice new box price */ function setBoxPrice(uint256 newPrice) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); boxPrice = newPrice; emit BoxPriceChanged(boxPrice, newPrice); } /** * @dev Set random generator contract address * @param newAddress new random generator address */ function setRandomGenerator(address newAddress) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); randomGeneratorAddress = newAddress; } function setTokenURI(uint256 tokenId, string memory _tokenURI) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(_exists(tokenId), "URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } function setShare( address _funderAddress, address _devAddress, address _marketAddress, uint8 _devShare, uint8 _marketShare ) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); funderAddress = _funderAddress; devAddress = _devAddress; marketAddress = _marketAddress; devShare = _devShare; marketShare = _marketShare; } function withdraw(uint256 amount) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(address(this).balance >= amount, "amount exceeds balance"); uint256 devAmount = amount.mul(uint256(devShare)).div(100); uint256 marketAmount = amount.mul(uint256(marketShare)).div(100); payable(devAddress).transfer(devAmount); payable(marketAddress).transfer(marketAmount); payable(funderAddress).transfer(amount.sub(devAmount).sub(marketAmount)); } function airdrop(address[] memory receivers) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(receivers.length <= totalClaimableAmount, "out of claimable balance"); for (uint256 i = 0; i < receivers.length; i++) { boxesAward(1, receivers[i]); } totalClaimableAmount = totalClaimableAmount.sub(receivers.length); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { //Whitelist OpenSea proxy contract for easy trading. if (proxyRegistryAddress != address(0)) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } } return super.isApprovedForAll(owner, operator); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @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 ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable 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. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.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 {} uint256[44] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @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 ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721Enumerable_init_unchained(); } function __ERC721Enumerable_init_unchained() internal initializer { } // 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(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.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 < ERC721EnumerableUpgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(); } uint256[46] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } 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(IAccessControlUpgradeable).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 ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.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()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable { /** * @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. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _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()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT 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 no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMathUpgradeable { /** * @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; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { /** * @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. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 EnumerableSetUpgradeable { // 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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastvalue's index to valueIndex } // 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // 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); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // 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)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // 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 CountersUpgradeable { 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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { 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; /** * @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 {ERC1967Proxy-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 || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ReentrancyGuardUpgradeable is Initializable { // 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; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _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); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity 0.8.2; pragma abicoder v2; interface IRiverBoxV2 { struct Hierarchy { uint16 parentLocationId; uint16[] childLocationIds; } struct Product { uint16 locationId; uint16 fusionCount; // number of times used to fuse item uint32 signature; // properties uint256[] parts; // a list token ids which are used to fuse this item } /* ================ EVENTS ================ */ /** * @dev Emitted when box price is changed. * @param from old price * @param to new price */ event BoxPriceChanged(uint256 indexed from, uint256 indexed to); event BoxAwarded(address indexed payer, uint256 indexed tokenId, uint256 eventTime); /* ================ UTIL FUNCTIONS ================ */ /* ================ VIEWS ================ */ function tokenDetail(uint256 tokenId) external view returns (Product memory); function tokenURI(uint256 tokenId) external view returns (string memory); function implementationVersion() external view returns (string memory); /* ================ TRANSACTIONS ================ */ function buy(uint256 quality, address referrer) external payable; /* ================ ADMIN ACTIONS ================ */ function setBaseURI(string memory newBaseURI) external; function pause() external; function unPause() external; function setBoxPrice(uint256 newPrice) external; function setRandomGenerator(address newAddress) external; function setTokenURI(uint256 tokenId, string memory _tokenURI) external; function setShare( address _funderAddress, address _devAddress, address _marketAddress, uint8 _devShare, uint8 _marketShare ) external; function withdraw(uint256 amount) external; function airdrop(address[] memory receivers) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.2; pragma abicoder v2; interface IRiverBoxRandom { function generateSignature(uint256 salt) external view returns (uint256); function setCaller(address riverBox) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @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; } // SPDX-License-Identifier: MIT 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @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 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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // 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 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @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 Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @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 Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.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 AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
price per box - Pawn
{ using StringsUpgradeable for uint256; using SafeMathUpgradeable for uint256; using CountersUpgradeable for CountersUpgradeable.Counter; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; CountersUpgradeable.Counter private _tokenIds; uint16[] private _stockLocations; uint32[] private _stockSignatures; uint32 private _stockCounter; uint256 public boxPrice; uint256 public totalClaimableAmount; string public baseURI; address public randomGeneratorAddress; mapping(uint256 => string) private _tokenURIs; mapping(uint256 => Product) private _tokenDetailsMapping; mapping(uint256 => Hierarchy) private _tokenHierarchyMapping; mapping(address => uint256) public claimableAmountMapping; mapping(address => uint256) public referrerContrib; uint256 public totalReferrerContrib; address proxyRegistryAddress; address public funderAddress; address public devAddress; address public marketAddress; uint8 public devShare; uint8 public marketShare; bool public fuseLock; function initialize( uint256 _boxPrice, string memory _name, string memory _symbol, string memory _initBaseURI, address _proxyRegistryAddress constructor() initializer {} ) public initializer { __Ownable_init(); __Pausable_init(); __AccessControl_init(); __ReentrancyGuard_init(); __ERC721_init(_name, _symbol); __UUPSUpgradeable_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _pause(); fuseLock = true; boxPrice = _boxPrice; baseURI = _initBaseURI; proxyRegistryAddress = _proxyRegistryAddress; } function _pickLocation(uint256 index) internal returns (uint16, uint32) { uint256 lastIndex = _stockLocations.length - 1; uint16 lastStockLocation = _stockLocations[lastIndex]; uint16 locationId = _stockLocations[index]; _stockLocations[index] = lastStockLocation; _stockLocations.pop(); uint32 lastSignature = _stockSignatures[lastIndex]; uint32 signature = _stockSignatures[index]; _stockSignatures[index] = lastSignature; _stockSignatures.pop(); return (locationId, signature); } function pawnsStock() public view returns (uint256) { return _stockLocations.length.sub(totalClaimableAmount); } function batchStockInfo(uint256 startIndex, uint256 length) public view returns (uint256[] memory, uint256[] memory) { require(startIndex < _stockLocations.length, "startIndex cannot over stockLocationsLength"); require(length > 0, "length cannot equal 0"); uint256 endIndex = MathUpgradeable.min(startIndex + length, _stockLocations.length); uint256 realLength = endIndex - startIndex; uint256[] memory locationIds = new uint256[](realLength); uint256[] memory signatures = new uint256[](realLength); for (uint256 idx = 0; idx < realLength; ++idx) { locationIds[idx] = _stockLocations[startIndex.add(idx)]; signatures[idx] = _stockSignatures[startIndex.add(idx)]; } return (locationIds, signatures); } function batchStockInfo(uint256 startIndex, uint256 length) public view returns (uint256[] memory, uint256[] memory) { require(startIndex < _stockLocations.length, "startIndex cannot over stockLocationsLength"); require(length > 0, "length cannot equal 0"); uint256 endIndex = MathUpgradeable.min(startIndex + length, _stockLocations.length); uint256 realLength = endIndex - startIndex; uint256[] memory locationIds = new uint256[](realLength); uint256[] memory signatures = new uint256[](realLength); for (uint256 idx = 0; idx < realLength; ++idx) { locationIds[idx] = _stockLocations[startIndex.add(idx)]; signatures[idx] = _stockSignatures[startIndex.add(idx)]; } return (locationIds, signatures); } function allInfo(uint256 tokenId) public view returns ( Product memory, address, string memory ) { require(_exists(tokenId), "Token not exists"); return (_tokenDetailsMapping[tokenId], ownerOf(tokenId), tokenURI(tokenId)); } function tokenDetail(uint256 tokenId) public view override returns (Product memory) { require(_exists(tokenId), "Token not exists"); return _tokenDetailsMapping[tokenId]; } function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, ERC721EnumerableUpgradeable, AccessControlUpgradeable) returns (bool) { return super.supportsInterface(interfaceId); } function tokenURI(uint256 tokenId) public view override(IRiverBoxV2, ERC721Upgradeable) returns (string memory) { require(_exists(tokenId), "URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); if (bytes(_tokenURI).length > 0) { return _tokenURI; return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString())) : ""; } } function tokenURI(uint256 tokenId) public view override(IRiverBoxV2, ERC721Upgradeable) returns (string memory) { require(_exists(tokenId), "URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); if (bytes(_tokenURI).length > 0) { return _tokenURI; return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString())) : ""; } } } else { function implementationVersion() public pure override returns (string memory) { return "2.0.0"; } function _notContract() internal view { uint256 size; address addr = msg.sender; assembly { size := extcodesize(addr) } require(size == 0, "contract not allowed"); require(msg.sender == tx.origin, "proxy contract not allowed"); } function _notContract() internal view { uint256 size; address addr = msg.sender; assembly { size := extcodesize(addr) } require(size == 0, "contract not allowed"); require(msg.sender == tx.origin, "proxy contract not allowed"); } function _awardItem(address receiver) private returns (uint256) { _tokenIds.increment(); uint256 newId = _tokenIds.current(); _safeMint(receiver, newId); return newId; } function _baseURI() internal view override(ERC721Upgradeable) returns (string memory) { return baseURI; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId); } function _authorizeUpgrade(address) internal view override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission to do upgrades"); } function buy(uint256 quality, address referrer) external payable override whenNotPaused nonReentrant { _notContract(); require(quality <= pawnsStock(), "blind box sold out"); require(quality <= 20, "exceed maximum quality 20"); require(msg.value >= boxPrice.mul(quality), "payment is less than box price"); boxesAward(quality, _msgSender()); if (referrer != address(0)) { referrerContrib[referrer] = referrerContrib[referrer].add(quality); totalReferrerContrib = totalReferrerContrib.add(quality); } paidBoxes[_msgSender()] = paidBoxes[_msgSender()].add(quality); } function buy(uint256 quality, address referrer) external payable override whenNotPaused nonReentrant { _notContract(); require(quality <= pawnsStock(), "blind box sold out"); require(quality <= 20, "exceed maximum quality 20"); require(msg.value >= boxPrice.mul(quality), "payment is less than box price"); boxesAward(quality, _msgSender()); if (referrer != address(0)) { referrerContrib[referrer] = referrerContrib[referrer].add(quality); totalReferrerContrib = totalReferrerContrib.add(quality); } paidBoxes[_msgSender()] = paidBoxes[_msgSender()].add(quality); } function boxesAward(uint256 quality, address receiver) internal { uint256 salt = uint256(keccak256(abi.encodePacked(quality, receiver, totalSupply()))); uint256 seed = IRiverBoxRandom(randomGeneratorAddress).generateSignature(salt); for (uint256 i = 0; i < quality; ++i) { seed = seed.add(totalSupply()); uint256 randomIdx = uint256(keccak256(abi.encodePacked(seed))).mod(_stockLocations.length); (uint16 pawnLocationId, uint32 signature) = _pickLocation(randomIdx); Product memory newItem = Product(pawnLocationId, 0, signature, new uint256[](0)); uint256 newId = _awardItem(receiver); _tokenDetailsMapping[newId] = newItem; emit BoxAwarded(receiver, newId, block.timestamp); } } function boxesAward(uint256 quality, address receiver) internal { uint256 salt = uint256(keccak256(abi.encodePacked(quality, receiver, totalSupply()))); uint256 seed = IRiverBoxRandom(randomGeneratorAddress).generateSignature(salt); for (uint256 i = 0; i < quality; ++i) { seed = seed.add(totalSupply()); uint256 randomIdx = uint256(keccak256(abi.encodePacked(seed))).mod(_stockLocations.length); (uint16 pawnLocationId, uint32 signature) = _pickLocation(randomIdx); Product memory newItem = Product(pawnLocationId, 0, signature, new uint256[](0)); uint256 newId = _awardItem(receiver); _tokenDetailsMapping[newId] = newItem; emit BoxAwarded(receiver, newId, block.timestamp); } } function setBaseURI(string memory newBaseURI) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); baseURI = newBaseURI; } function batchSetPawnLocationStock(uint16[] memory locationIds, uint16[] memory locationIdStocks) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); for (uint16 locationIdx = 0; locationIdx < locationIds.length; ++locationIdx) { uint16 locationId = locationIds[locationIdx]; uint16 locationIdStock = locationIdStocks[locationIdx]; for (uint16 stockIdx = 0; stockIdx < locationIdStock; ++stockIdx) { _stockLocations.push(locationId); _stockCounter = _stockCounter + 1; require(_stockCounter >= 1, "SafeMath: addition overflow"); _stockSignatures.push(_stockCounter); } } } function batchSetPawnLocationStock(uint16[] memory locationIds, uint16[] memory locationIdStocks) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); for (uint16 locationIdx = 0; locationIdx < locationIds.length; ++locationIdx) { uint16 locationId = locationIds[locationIdx]; uint16 locationIdStock = locationIdStocks[locationIdx]; for (uint16 stockIdx = 0; stockIdx < locationIdStock; ++stockIdx) { _stockLocations.push(locationId); _stockCounter = _stockCounter + 1; require(_stockCounter >= 1, "SafeMath: addition overflow"); _stockSignatures.push(_stockCounter); } } } function batchSetPawnLocationStock(uint16[] memory locationIds, uint16[] memory locationIdStocks) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); for (uint16 locationIdx = 0; locationIdx < locationIds.length; ++locationIdx) { uint16 locationId = locationIds[locationIdx]; uint16 locationIdStock = locationIdStocks[locationIdx]; for (uint16 stockIdx = 0; stockIdx < locationIdStock; ++stockIdx) { _stockLocations.push(locationId); _stockCounter = _stockCounter + 1; require(_stockCounter >= 1, "SafeMath: addition overflow"); _stockSignatures.push(_stockCounter); } } } function pause() external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); _pause(); } function unPause() external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); _unpause(); } function setBoxPrice(uint256 newPrice) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); boxPrice = newPrice; emit BoxPriceChanged(boxPrice, newPrice); } function setRandomGenerator(address newAddress) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); randomGeneratorAddress = newAddress; } function setTokenURI(uint256 tokenId, string memory _tokenURI) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(_exists(tokenId), "URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } function setShare( address _funderAddress, address _devAddress, address _marketAddress, uint8 _devShare, uint8 _marketShare ) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); funderAddress = _funderAddress; devAddress = _devAddress; marketAddress = _marketAddress; devShare = _devShare; marketShare = _marketShare; } function withdraw(uint256 amount) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(address(this).balance >= amount, "amount exceeds balance"); uint256 devAmount = amount.mul(uint256(devShare)).div(100); uint256 marketAmount = amount.mul(uint256(marketShare)).div(100); payable(devAddress).transfer(devAmount); payable(marketAddress).transfer(marketAmount); payable(funderAddress).transfer(amount.sub(devAmount).sub(marketAmount)); } function airdrop(address[] memory receivers) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(receivers.length <= totalClaimableAmount, "out of claimable balance"); for (uint256 i = 0; i < receivers.length; i++) { boxesAward(1, receivers[i]); } totalClaimableAmount = totalClaimableAmount.sub(receivers.length); } function airdrop(address[] memory receivers) external override { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "require admin permission"); require(receivers.length <= totalClaimableAmount, "out of claimable balance"); for (uint256 i = 0; i < receivers.length; i++) { boxesAward(1, receivers[i]); } totalClaimableAmount = totalClaimableAmount.sub(receivers.length); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (proxyRegistryAddress != address(0)) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } } return super.isApprovedForAll(owner, operator); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (proxyRegistryAddress != address(0)) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } } return super.isApprovedForAll(owner, operator); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (proxyRegistryAddress != address(0)) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } } return super.isApprovedForAll(owner, operator); } }
11,639,369
[ 1, 8694, 1534, 3919, 300, 453, 9533, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 565, 1450, 8139, 10784, 429, 364, 2254, 5034, 31, 203, 565, 1450, 14060, 10477, 10784, 429, 364, 2254, 5034, 31, 203, 565, 1450, 9354, 87, 10784, 429, 364, 9354, 87, 10784, 429, 18, 4789, 31, 203, 565, 1450, 6057, 25121, 694, 10784, 429, 364, 6057, 25121, 694, 10784, 429, 18, 5487, 694, 31, 203, 203, 565, 9354, 87, 10784, 429, 18, 4789, 3238, 389, 2316, 2673, 31, 203, 203, 565, 2254, 2313, 8526, 3238, 389, 15381, 10985, 31, 203, 565, 2254, 1578, 8526, 3238, 389, 15381, 23918, 31, 203, 565, 2254, 1578, 3238, 389, 15381, 4789, 31, 203, 203, 203, 565, 2254, 5034, 1071, 3919, 5147, 31, 203, 203, 565, 2254, 5034, 1071, 2078, 9762, 429, 6275, 31, 203, 203, 565, 533, 1071, 1026, 3098, 31, 203, 203, 565, 1758, 1071, 2744, 3908, 1887, 31, 203, 203, 565, 2874, 12, 11890, 5034, 516, 533, 13, 3238, 389, 2316, 1099, 2520, 31, 203, 203, 565, 2874, 12, 11890, 5034, 516, 8094, 13, 3238, 389, 2316, 3790, 3233, 31, 203, 203, 203, 565, 2874, 12, 11890, 5034, 516, 670, 6000, 13, 3238, 389, 2316, 12074, 3233, 31, 203, 203, 565, 2874, 12, 2867, 516, 2254, 5034, 13, 1071, 7516, 429, 6275, 3233, 31, 203, 203, 565, 2874, 12, 2867, 516, 2254, 5034, 13, 1071, 14502, 442, 665, 31, 203, 203, 565, 2254, 5034, 1071, 2078, 1957, 11110, 442, 665, 31, 203, 203, 565, 1758, 2889, 4243, 1887, 31, 203, 203, 565, 1758, 1071, 284, 9341, 1887, 31, 203, 565, 1758, 1071, 4461, 1887, 31, 2 ]
pragma solidity 0.6.6; // ---------------------------------------------------------------------------- // 'boot' token contract // // Deployed to : 0xE1A425b2726D92Bc5178e7F5Ed30256481F5337f // Symbol : boot // Name : boot // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Ahiwe Onyebuchi Valentine. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- abstract contract ERC20Interface { function totalSupply() virtual public view returns (uint); function balanceOf(address tokenOwner) virtual public view returns (uint balance); function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining); function transfer(address to, uint tokens) virtual public returns (bool success); function approve(address spender, uint tokens) virtual public returns (bool success); function transferFrom(address from, address to, uint tokens) virtual public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- abstract contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) virtual public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract boot is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "boot"; name = "boot"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xE1A425b2726D92Bc5178e7F5Ed30256481F5337f] = _totalSupply; emit Transfer(address(0), 0xE1A425b2726D92Bc5178e7F5Ed30256481F5337f, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public override view returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public override returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public override returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public override returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ // function () external payable { // revert(); // } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
------------------------------------------------------------------------ Token owner can approve for spender to transferFrom(...) tokens from the token owner's account https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md recommends that there are no checks for the approval double-spend attack as this should be implemented in user interfaces ------------------------------------------------------------------------
function approve(address spender, uint tokens) public override returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
30,920
[ 1, 29461, 3155, 3410, 848, 6617, 537, 364, 17571, 264, 358, 7412, 1265, 5825, 13, 2430, 628, 326, 1147, 3410, 1807, 2236, 2333, 30, 6662, 18, 832, 19, 546, 822, 379, 19, 41, 18246, 19, 10721, 19, 7525, 19, 41, 2579, 55, 19, 73, 625, 17, 3462, 17, 2316, 17, 10005, 18, 1264, 10519, 5839, 716, 1915, 854, 1158, 4271, 364, 326, 23556, 1645, 17, 87, 1302, 13843, 487, 333, 1410, 506, 8249, 316, 729, 7349, 8879, 17082, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6617, 537, 12, 2867, 17571, 264, 16, 2254, 2430, 13, 1071, 3849, 1135, 261, 6430, 2216, 13, 288, 203, 3639, 2935, 63, 3576, 18, 15330, 6362, 87, 1302, 264, 65, 273, 2430, 31, 203, 3639, 3626, 1716, 685, 1125, 12, 3576, 18, 15330, 16, 17571, 264, 16, 2430, 1769, 203, 3639, 327, 638, 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 ]
pragma solidity >= 0.6.2 < 0.7.0; //设置代币控制合约的管理员 contract Owned { // modifier(条件),表示必须是权力所有者才能do something,类似administrator的意思 modifier onlyOwner() { require(msg.sender == owner); _; //do something } //权力所有者 address public owner; //合约创建的时候执行,执行合约的人是第一个owner constructor() public { owner = msg.sender; } //新的owner,初始为空地址,类似null address newOwner = address(0); //更换owner成功的事件 event OwnerUpdate(address _prevOwner, address _newOwner); //现任owner把所有权交给新的owner(需要新的owner调用acceptOwnership方法才会生效) function changeOwner(address _newOwner) public onlyOwner { require(_newOwner != owner); newOwner = _newOwner; } //新的owner接受所有权,权力交替正式生效 function acceptOwnership() public { require(msg.sender == newOwner); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); } }
新的owner,初始为空地址,类似null
address newOwner = address(0);
14,081,747
[ 1, 167, 249, 113, 168, 253, 231, 8443, 16, 166, 235, 256, 166, 105, 238, 165, 121, 123, 168, 107, 123, 166, 255, 113, 166, 256, 227, 176, 125, 239, 168, 114, 124, 165, 125, 125, 2011, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1758, 394, 5541, 273, 1758, 12, 20, 1769, 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 ]
pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/access/Roles.sol"; import "openzeppelin-solidity/contracts/access/roles/PauserRole.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; //import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/access/Roles.sol"; //import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/access/roles/PauserRole.sol"; //import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol"; /// @title Online Educational Platform /// @author Jafett Sandi /// @notice This contracts is not intended for Production use yet. /// @dev All function calls are currently implemented without side effects contract EducationPlatform is Ownable { using Roles for Roles.Role; // We want to use the Roles library Roles.Role universityOwners; //Stores University owner Roles Roles.Role teachers; // Stores teacher Roles Roles.Role students; // Stores student Roles; // ID Generators for universities and platform users uint public universityIdGenerator; uint public UserIdGenerator; mapping (uint => University) public universities; // Mapping to keep track of the Universities mapping (address => University) public mapUniversity; mapping (address => PlatformMember) public platformUsers; // Mapping to keep track of the Students in the platform address [] public platformUsersList; uint contractBalance; struct University { uint id; string name; string description; string website; string phoneNumber; bool open; uint courseIdGenerator; address payable UniversityOwner; mapping (uint => Course) courses; //Mappint to track all classes available for this University } // This structs is to store the information of a Platform member. Has a flag to identify if the member is Owner or not. struct PlatformMember { uint id; string fullName; string email; address userAddress; bool isUniversityOwner; } struct Course { uint id; string courseName; uint cost; uint courseBalance; bool active; uint activeStudents; uint seatsAvailable; //to simulate a student buying multiple seats for a course uint totalSeats; address payable courseOwner; } function getOwnerUniversity(address _ownerAddress) public view returns(uint id, string memory name, uint courseIdGenerator){ id = mapUniversity[_ownerAddress].id; name = mapUniversity[_ownerAddress].name; courseIdGenerator = mapUniversity[_ownerAddress].courseIdGenerator; return(id, name, courseIdGenerator); } /// @author Jafett Sandi /// @notice Gets a course based on an address and CourseId /// @param _ownerAddress The address of the owner of the course /// @param _courseId The id of the course /// @return courseName, cost, active, activeStudents, seatsAvailable, totalSeats function getOwnerCourseByAddress(address _ownerAddress, uint _courseId) public view returns(string memory courseName, uint cost, bool active, uint activeStudents, uint seatsAvailable, uint totalSeats) { courseName = mapUniversity[_ownerAddress].courses[_courseId].courseName; cost = mapUniversity[_ownerAddress].courses[_courseId].cost; active = mapUniversity[_ownerAddress].courses[_courseId].active; activeStudents = mapUniversity[_ownerAddress].courses[_courseId].activeStudents; seatsAvailable = mapUniversity[_ownerAddress].courses[_courseId].seatsAvailable; totalSeats = mapUniversity[_ownerAddress].courses[_courseId].totalSeats; return (courseName, cost, active, activeStudents, seatsAvailable, totalSeats); } function getNumberPlatformUser() public view returns(uint number){ number = platformUsersList.length; return number; } function isUnivOwner(address _address) public view returns(bool){ return universityOwners.bearer[_address]; } // Events event LogUniversityAdded(string name, string desc, uint universityId); event LogCourseAdded(string _courseName, uint cost, uint _seatsAvailable, uint courseId); // Modifiers modifier validAddress(address _address) { require(_address != address(0), "ADDRESS CANNOT BE THE ZERO ADDRESS"); _; } modifier isUniversityOwner(address _addr) { require(universityOwners.has(_addr), "DOES NOT HAVE UNIVERSITY OWNER ROLE"); _; } modifier isStudent(address _addr) { require(students.has(_addr), "DOES NOT HAVE STUDENT ROLE"); _; } modifier enoughSeats(uint _universityId, uint _courseId, uint _quantity) { require((universities[_universityId].courses[_courseId].seatsAvailable >= _quantity), "NOT ENOUGH SEATS IN THIS COURSE - CONTACT UNIVERSITY OWNER"); _; } modifier ownerAtUniversity(uint _universityId) { require((universities[_universityId].UniversityOwner == msg.sender), "DOES NOT BELONG TO THE UNIVERSITY OWNERS OR IS INACTIVE"); require(universityOwners.has(msg.sender), "DOES NOT HAVE UNIVERSITY OWNER ROLE"); _; } modifier courseIsActive(uint _universityId, uint _courseId) { require((universities[_universityId].courses[_courseId].active == true), "COURSE IS INACTIVE - CONTACT UNIVERSITY OWNER"); _; } modifier paidEnough(uint _universityId, uint _courseId, uint _quantity) { uint coursePrice = universities[_universityId].courses[_courseId].cost; require((universities[_universityId].courses[_courseId].seatsAvailable >= _quantity), "NOT ENOUGH SEATS IN THIS COURSE - CONTACT UNIVERSITY OWNER"); require(msg.value >= (coursePrice * _quantity), "NOT ENOUGH FEES PAID"); _; } modifier checkValue(uint _universityId, uint _courseId, uint _quantity, address payable _addr) { //refund them after pay for item _; uint coursePrice = universities[_universityId].courses[_courseId].cost * _quantity; uint total2RefundAfterPay = msg.value - coursePrice; _addr.transfer(total2RefundAfterPay); } modifier checkActive(uint _universityId, uint _courseId){ bool isActive = universities[_universityId].courses[_courseId].active; require(isActive == true, "THE COURSE IS NOT ACTIVE, YOU CANNOT REGISTER"); _; } /// @author Jafett Sandi /// @notice Adds a University to the platform /// @param _name The name of the University /// @param _description The description of the University /// @param _website The website URL of the University /// @param _phoneNumber The PhoneNumber of the University function addUniversity(string memory _name, string memory _description, string memory _website, string memory _phoneNumber) public onlyOwner { University memory newUniversity; newUniversity.name = _name; newUniversity.description = _description; newUniversity.website = _website; newUniversity.phoneNumber = _phoneNumber; newUniversity.open = false; newUniversity.id = universityIdGenerator; universities[universityIdGenerator] = newUniversity; universityIdGenerator += 1; emit LogUniversityAdded(_name, _description, universityIdGenerator); } /// @author Jafett Sandi /// @notice Adds a course to a University /// @param _universityId The id of the University /// @param _courseName The name of the course /// @param _cost Thecost of the course /// @param _seatsAvailable The seatsAvailablefor the course /// @return true function addCourse(uint _universityId, string memory _courseName, uint _cost, uint _seatsAvailable) public ownerAtUniversity(_universityId) returns (bool) { Course memory newCourse; newCourse.courseName = _courseName; newCourse.seatsAvailable = _seatsAvailable; newCourse.totalSeats = _seatsAvailable; newCourse.cost = _cost; newCourse.active = true; newCourse.activeStudents = 0; newCourse.courseOwner = universities[_universityId].UniversityOwner; uint courseId = universities[_universityId].courseIdGenerator; newCourse.id = courseId; universities[_universityId].courses[courseId] = newCourse; universities[_universityId].courseIdGenerator += 1; emit LogCourseAdded(_courseName, _cost, _seatsAvailable, courseId); return true; } /// @author Jafett Sandi /// @notice Updates a course's information /// @param _universityId The id of the University /// @param _courseId The id of the course to update /// @param _courseName The name of the course /// @param _cost Thecost of the course /// @param _seatsAvailable The seatsAvailablefor the course /// @param _isActive Is the course active? /// @return true function updateCourse(uint _universityId, uint _courseId, string memory _courseName, uint _cost, uint _seatsAvailable, bool _isActive) public ownerAtUniversity(_universityId) returns (bool) { Course memory newCourse; newCourse.courseName = _courseName; newCourse.seatsAvailable = _seatsAvailable; newCourse.totalSeats = _seatsAvailable; newCourse.cost = _cost; newCourse.active = _isActive; universities[_universityId].courses[_courseId] = newCourse; return true; } /// @author Jafett Sandi /// @notice Get University details /// @param _uniId The id of the University /// @return _uniId, name, description, website, phone function getUniversity(uint _uniId) public view returns (uint id, string memory name, string memory description, string memory website, string memory phone) { name = universities[_uniId].name; website = universities[_uniId].website; description = universities[_uniId].description; phone = universities[_uniId].phoneNumber; return (_uniId, name, description, website, phone); } /// @author Jafett Sandi /// @notice Used to generate a courseId /// @param _universityId The id of the University /// @return courseId function getCourseId (uint _universityId) public view returns(uint){ uint courseIdGenerator = universities[_universityId].courseIdGenerator; return courseIdGenerator; } /// @author Jafett Sandi /// @notice Get the owner of a university /// @param _universityId The id of the University /// @return universityOwner Address of the university owner function getUniversityOwner (uint _universityId) public view returns(address universityOwner){ universityOwner = universities[_universityId].UniversityOwner; return universityOwner; } /// @author Jafett Sandi /// @notice Get the details of a university course /// @param _universityId The id of the University /// @param _courseId The courseId of the course /// @return All information about a course function getUniversityCourse(uint _universityId, uint _courseId) public view returns( uint universityId, uint courseId, string memory courseName, uint cost, bool active, uint activeStudents, uint seatsAvailable, uint totalSeats, uint balance){ courseName = universities[_universityId].courses[_courseId].courseName; courseId = universities[_universityId].courses[_courseId].id; cost = universities[_universityId].courses[_courseId].cost; active = universities[_universityId].courses[_courseId].active; activeStudents = universities[_universityId].courses[_courseId].activeStudents; seatsAvailable = universities[_universityId].courses[_courseId].seatsAvailable; totalSeats = universities[_universityId].courses[_courseId].totalSeats; balance = universities[_universityId].courses[_courseId].courseBalance; return (universityId, courseId, courseName, cost, active, activeStudents, seatsAvailable, totalSeats,balance); } /// @author Jafett Sandi /// @notice Toggles the state of a course /// @param _universityId The id of the University /// @param _courseId The id of the course /// @param _state The state to toggle the course function toggleActiveCourse(uint _universityId, uint _courseId, bool _state) public { universities[_universityId].courses[_courseId].active = _state; } /// @author Jafett Sandi /// @notice Gets a platform member information /// @param _address The address of the member /// @return All information about a platform member function getPlatformMember(address _address) public view returns ( uint id, string memory fullname, string memory email, address userAddress, bool isUnivOwner) { fullname = platformUsers[_address].fullName; email = platformUsers[_address].email; id = platformUsers[_address].id; userAddress = platformUsers[_address].userAddress; isUnivOwner = platformUsers[_address].isUniversityOwner; return (id, fullname, email, userAddress, isUnivOwner); } /* Roles and membership */ /// @author Jafett Sandi /// @notice Adds an owner to the platform /// @param _ownerAddr The address of the member /// @param _universityId The id of the University /// @param _name The name of the owner of the University /// @param _email The email address of the member /// @return bool function addUniversityOwner(address payable _ownerAddr, uint _universityId, string memory _name, string memory _email) public onlyOwner validAddress(_ownerAddr) returns (bool) { PlatformMember memory newPlatformMember; newPlatformMember.fullName = _name; newPlatformMember.email = _email; newPlatformMember.id = UserIdGenerator; newPlatformMember.isUniversityOwner = true; newPlatformMember.userAddress = _ownerAddr; universityOwners.add(_ownerAddr); platformUsers[_ownerAddr] = newPlatformMember; UserIdGenerator += 1; universities[_universityId].UniversityOwner = _ownerAddr; universities[_universityId].open = true; mapUniversity[_ownerAddr] = universities[_universityId]; platformUsersList.push(_ownerAddr); return true; } /// @author Jafett Sandi /// @notice Registers a new user into the Platform - Owner or Student /// @param _addr The address of the member /// @param _name The name of the member /// @param _email The email address of the member /// @return bool function addStudent(address _addr, string memory _name, string memory _email) public validAddress(_addr) returns (bool) { PlatformMember memory newPlatformMember; newPlatformMember.fullName = _name; newPlatformMember.email = _email; newPlatformMember.id = UserIdGenerator; students.add(_addr); newPlatformMember.isUniversityOwner = false; platformUsers[_addr] = newPlatformMember; UserIdGenerator += 1; return true; } function getCourseBalance(uint _univId ,uint _courseId) public view returns (uint){ return universities[_univId].courses[_courseId].courseBalance; } /* Students specific functions - Buy/Pay course */ /// @author Jafett Sandi /// @notice Buy a course /// @param _uniId The id of the university /// @param _courseId The id of the course /// @param _quantity The number of seats to buy function buyCourse(uint _uniId, uint _courseId, uint _quantity) public payable //isStudent(msg.sender) //checkValue(_uniId, _courseId, _quantity, msg.sender) paidEnough(_uniId, _courseId, _quantity) checkActive(_uniId, _courseId) { universities[_uniId].courses[_courseId].courseBalance += msg.value; universities[_uniId].courses[_courseId].seatsAvailable -= _quantity; } /// @author Jafett Sandi /// @notice Withdraw the course funds /// @param _uniId The id of the university /// @param _courseId The id of the course function withdrawCourseFunds(uint _uniId, uint _courseId) public payable { require(msg.sender == universities[_uniId].courses[_courseId].courseOwner, "Need to be the course owner"); uint courseBalance = universities[_uniId].courses[_courseId].courseBalance; universities[_uniId].courses[_courseId].courseBalance = 0; msg.sender.transfer(courseBalance); } }
Mappint to track all classes available for this University
mapping (uint => Course) courses;
5,493,410
[ 1, 863, 84, 474, 358, 3298, 777, 3318, 2319, 364, 333, 1351, 6760, 560, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2874, 261, 11890, 516, 385, 3117, 13, 17224, 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 ]
// SPDX-License-Identifier:MIT pragma solidity >=0.7.0; import "./SafeMathTyped.sol"; // The MIT License // // Copyright (c) 2017-2018 0xcert, d.o.o. https://0xcert.org // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** * @title ERC20 standard token implementation. * @dev Standard ERC20 token. This contract follows the implementation at https://goo.gl/mLbAPJ. */ contract Token { string internal tokenName; string internal tokenSymbol; uint8 internal tokenDecimals; uint256 internal tokenTotalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Trigger when tokens are transferred, including zero value transfers. */ event Transfer( address indexed from, address indexed to, uint256 value ); /** * @dev Trigger on any successful call to approve(address _spender, uint256 _value). */ event Approval( address indexed owner, address indexed spender, uint256 value ); /** * @dev Returns the name of the token. */ function name() external view returns (string memory _name) { _name = tokenName; } /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory _symbol) { _symbol = tokenSymbol; } /** * @dev Returns the number of decimals the token uses. */ function decimals() external view returns (uint8 _decimals) { _decimals = tokenDecimals; } /** * @dev Returns the total token supply. */ function totalSupply() external view returns (uint256 _totalSupply) { _totalSupply = tokenTotalSupply; } /** * @dev Returns the account balance of another account with address _owner. * @param _owner The address from which the balance will be retrieved. */ function balanceOf( address _owner ) external view returns (uint256 _balance) { _balance = balances[_owner]; } /** * @dev Transfers _value amount of tokens to address _to, and MUST fire the Transfer event. The * function SHOULD throw if the _from account balance does not have enough tokens to spend. * @param _to The address of the recipient. * @param _value The amount of token to be transferred. */ function transfer( address _to, uint256 _value ) public returns (bool _success) { require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMathTyped.sub256(balances[msg.sender], _value); balances[_to] = SafeMathTyped.add256(balances[_to], _value); emit Transfer(msg.sender, _to, _value); _success = true; } /** * @dev Allows _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. * @param _spender The address of the account able to transfer the tokens. * @param _value The amount of tokens to be approved for transfer. */ function approve( address _spender, uint256 _value ) public returns (bool _success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); _success = true; } /** * @dev Returns the amount which _spender is still allowed to withdraw from _owner. * @param _owner The address of the account owning tokens. * @param _spender The address of the account able to transfer the tokens. */ function allowance( address _owner, address _spender ) external view returns (uint256 _remaining) { _remaining = allowed[_owner][_spender]; } /** * @dev Transfers _value amount of tokens from address _from to address _to, and MUST fire the * Transfer event. * @param _from The address of the sender. * @param _to The address of the recipient. * @param _value The amount of token to be transferred. */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool _success) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = SafeMathTyped.sub256(balances[_from], _value); balances[_to] = SafeMathTyped.add256(balances[_to], _value); allowed[_from][msg.sender] = SafeMathTyped.sub256(allowed[_from][msg.sender], _value); emit Transfer(_from, _to, _value); _success = true; } } /// @notice This is the ABQ token. It allows the owner (the Aardbanq DAO) to mint new tokens. It also allow the /// owner to change owners. The ABQ token has 18 decimals. contract AbqErc20 is Token { /// @notice The owner of the ABQ Token. This is the Aardbanq DAO. address public owner; /// @notice The address for the founders' contract. address public founderContract; constructor(address _owner, address _founderContract) { tokenName = "Aardbanq DAO"; tokenSymbol = "ABQ"; tokenDecimals = 18; tokenTotalSupply = 0; owner = _owner; founderContract = _founderContract; } modifier onlyOwner() { require(msg.sender == owner, "ABQ/only-owner"); _; } event OwnerChange(address indexed newOwner); /// @notice Allows the owner to change the ownership to another address. /// @param _newOwner The address that should be the new owner. function changeOwner(address _newOwner) external onlyOwner() { owner = _newOwner; emit OwnerChange(_newOwner); } /// @notice Allows the owner to mint tokens. /// @param _target The address to mint the tokens to. /// @param _abqAmount The amount of ABQ to mint. function mint(address _target, uint256 _abqAmount) external onlyOwner() { balances[_target] = SafeMathTyped.add256(balances[_target], _abqAmount); emit Transfer(address(0), _target, _abqAmount); // CG: Founder's part 15% of total that will be issued // MATH: // totalIncrease = mintAmount + founderPart {A} // also: // founderPart = 0.15 * totalIncrease // ... founderPart / 0.15 = totalIncrease {B} // substituting {A} in {B} // ... founderPart / 0.15 = mintAmount + founderPart // ... (founderPart / 0.15) - founderPart = mintAmount // ... (founderPart - (0.15 * founderPart)) / 0.15 = mintAmount // ... (0.85 * founderPart) / 0.15 = mintAmount // ... 0.85 * founderPart = 0.15 * mintAmount // ... founderPart = (0.15 / 0.85) * mintAmount // ... founderPart ~= (mintAmount * 17647) / 100000 uint256 founderShare = SafeMathTyped.mul256(_abqAmount, 17647) / 100000; balances[founderContract] = SafeMathTyped.add256(balances[founderContract], founderShare); tokenTotalSupply = SafeMathTyped.add256(SafeMathTyped.add256(tokenTotalSupply, _abqAmount), founderShare); emit Transfer(address(0), founderContract, founderShare); } /// @notice Allow the sender to burn tokens in their account. /// @param _abqAmount The amount of tokens to burn from the msg.sender account. function burn(uint256 _abqAmount) external { tokenTotalSupply = SafeMathTyped.sub256(tokenTotalSupply, _abqAmount); balances[msg.sender] = SafeMathTyped.sub256(balances[msg.sender], _abqAmount); emit Transfer(msg.sender, address(0), _abqAmount); } event NameChange(string newName); /// @notice Allow the owner to change the name of the token. /// @param _newName The new name for the token function changeName(string calldata _newName) external onlyOwner() { tokenName = _newName; emit NameChange(_newName); } event SymbolChange(string newSymbol); /// @notice Allow the owner to change the symbol of the token. /// @param _newSymbol The new symbol for the token. function changeSymbol(string calldata _newSymbol) external onlyOwner() { tokenSymbol = _newSymbol; emit SymbolChange(_newSymbol); } }
@notice Allow the owner to change the symbol of the token. @param _newSymbol The new symbol for the token.
function changeSymbol(string calldata _newSymbol) external onlyOwner() { tokenSymbol = _newSymbol; emit SymbolChange(_newSymbol); }
1,522,217
[ 1, 7009, 326, 3410, 358, 2549, 326, 3273, 434, 326, 1147, 18, 225, 389, 2704, 5335, 1021, 394, 3273, 364, 326, 1147, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2549, 5335, 12, 1080, 745, 892, 389, 2704, 5335, 13, 203, 1377, 3903, 203, 1377, 1338, 5541, 1435, 203, 565, 288, 203, 1377, 1147, 5335, 273, 389, 2704, 5335, 31, 203, 1377, 3626, 8565, 3043, 24899, 2704, 5335, 1769, 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 ]
./partial_match/1/0x03CB4438d015B9646d666316b617a694410C216d/sources/src/contracts/LinearRewardsErc4626.sol
@notice The ```deposit``` function allows a user to mint shares by depositing underlying @param _assets The amount of underlying to deposit @param _receiver The address to send the shares to @return _shares The amount of shares minted
function deposit(uint256 _assets, address _receiver) public override returns (uint256 _shares) { distributeRewards(); _syncRewards(); }
4,463,955
[ 1, 1986, 31621, 323, 1724, 10335, 68, 445, 5360, 279, 729, 358, 312, 474, 24123, 635, 443, 1724, 310, 6808, 225, 389, 9971, 1021, 3844, 434, 6808, 358, 443, 1724, 225, 389, 24454, 1021, 1758, 358, 1366, 326, 24123, 358, 327, 389, 30720, 1021, 3844, 434, 24123, 312, 474, 329, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 443, 1724, 12, 11890, 5034, 389, 9971, 16, 1758, 389, 24454, 13, 1071, 3849, 1135, 261, 11890, 5034, 389, 30720, 13, 288, 203, 3639, 25722, 17631, 14727, 5621, 203, 3639, 389, 8389, 17631, 14727, 5621, 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 ]
pragma solidity >=0.5.16; contract ModelDatabase { function getModelOwner(string memory _ipfsHash) public view returns(address) {} } contract DatasetDatabase { function getDatasetOwner(string memory _ipfsHash) public view returns(address) {} } contract Jobs { uint public jobsCreated = 0; DatasetDatabase datasetDatabase; ModelDatabase modelDatabase; uint public gracePeriod = 1 hours; uint public jobCreationFee = 1e6 wei; uint public holdingFee = 1e6 wei; address payable private serverAddress = 0xc6c3F7d3E6907ea2C3174c06d188Eb57c59BF59c; struct Job { address payable owner; string modelIpfsHash; string strategyHash; string testDatasetHash; uint minClients; uint initTime; uint hoursUntilStart; bool active; bool trainingStarted; bool trainingEnded; uint bounty; mapping(address => bool) datasetOwners; mapping(address => bool) allowList; mapping(address => string) datasetHash; address payable[] arrDatasetOwners; address payable[] arrAllowList; } struct JobResults { string resultsHash; string weightsHash; mapping(address => uint) compensation; mapping(address => bool) isCompensated; } mapping(uint => Job) public jobs; mapping(uint => JobResults) public jobResults; constructor(address _contractAddressDatasets, address _contractAddressModels) public { datasetDatabase = DatasetDatabase(_contractAddressDatasets); modelDatabase = ModelDatabase(_contractAddressModels); } function isSenderModelOwner(string memory _modelIpfsHash) public view returns(bool) { address owner = modelDatabase.getModelOwner(_modelIpfsHash); return (owner == msg.sender); } function isSenderDatasetOwner(string memory _datasetIpfsHash) public view returns(bool) { address owner = datasetDatabase.getDatasetOwner(_datasetIpfsHash); return (owner == msg.sender); } function getJobStartTime(uint _id) public view returns(uint) { return jobs[_id].initTime + jobs[_id].hoursUntilStart * 1 hours; } function getGraceDeadline(uint _id) public view returns(uint){ return getJobStartTime(_id) + gracePeriod; } function registrationPeriodOver(uint _id) public view returns(bool) { return (block.timestamp >= getJobStartTime(_id)); } function createJob(string memory _modelIpfsHash, string memory _strategyHash, string memory _testDatasetHash, uint _minClients, uint _hoursUntilStart, uint _bounty) public payable { // Check the Job creator is model owner require(isSenderModelOwner(_modelIpfsHash),"Only model owner can create a job for this model"); // Check user has paid the correct bounty and job Creation Fee require(msg.value == jobCreationFee + _bounty,"Need to send the correct job creation fee and bounty"); address payable[] memory init; jobs[jobsCreated] = Job({owner: msg.sender, modelIpfsHash: _modelIpfsHash, strategyHash: _strategyHash, testDatasetHash: _testDatasetHash, minClients: _minClients, initTime: block.timestamp, hoursUntilStart: _hoursUntilStart, bounty: _bounty, active: true, trainingStarted: false, trainingEnded: false, arrDatasetOwners: init, arrAllowList: init} ); jobsCreated = jobsCreated + 1; } // Called by dataset owners to register their willingness to join a jobs // Owners registers a particular dataset and function registerDatasetOwner(uint _id, string memory _datasetIpfsHash) public payable { // Check user is not model owner require(msg.sender != jobs[_id].owner, "Job owner cannot sign up as a client"); // Check if user is dataset owner require(isSenderDatasetOwner(_datasetIpfsHash), "Need to be owner of this dataset"); // Check job is still in registration period if (registrationPeriodOver(_id)){ revert("Registration period for this job has ended"); } // Check user has paid the correct holding fee require(msg.value == holdingFee,"Need to send the correct holding fee"); // Check if already registered if(jobs[_id].datasetOwners[msg.sender] == true){ revert(" Already registered on this job"); } // Add dataset owner's address to list of owner addresses comitted to job jobs[_id].datasetOwners[msg.sender] = true; jobs[_id].datasetHash[msg.sender] = _datasetIpfsHash; jobs[_id].arrDatasetOwners.push(msg.sender); } // Called by Job owner to allow registered Clients to partake in job i.e. download model function addToAllowList(uint _id, address payable _datasetOwner) public { // Check user is job owner require(jobs[_id].owner == msg.sender, "Need to be registered as dataset owner"); // Check address is in registry of interested owners require(jobs[_id].datasetOwners[_datasetOwner] == true, "Can only add an interested data owner to allow list"); // Check job is still in registration period if (registrationPeriodOver(_id)){ revert("Registration period for this job has ended"); } // Check if dataset owner already registered on allowList if (jobs[_id].allowList[_datasetOwner] == true){ revert("Dataset owner already added to allow list"); } jobs[_id].allowList[_datasetOwner] = true; jobs[_id].arrAllowList.push(_datasetOwner); } function getNumRegistered(uint _id) public view returns(uint){ return jobs[_id].arrDatasetOwners.length; } function getNumAllow(uint _id) public view returns(uint){ return jobs[_id].arrAllowList.length; } function getJobRegistered(uint _id) public view returns(address payable [] memory){ return jobs[_id].arrDatasetOwners; } function getJobAllowed(uint _id) public view returns(address payable [] memory){ return jobs[_id].arrAllowList; } function getJobDetails(uint _id) public view returns(address, uint, uint){ return (jobs[_id].owner, jobs[_id].minClients, jobs[_id].bounty); } function getJobStatus(uint _id) public view returns(uint, uint, bool, bool){ return (jobs[_id].initTime, jobs[_id].hoursUntilStart, jobs[_id].trainingStarted, jobs[_id].trainingEnded); } function getMinClients(uint _id) public view returns(uint) { return jobs[_id].minClients; } function startJob(uint _id) public{ // Can only be started by owner of job if (jobs[_id].owner != msg.sender){ revert("Job can only be started by owner"); } // Check registration period has ended if (!registrationPeriodOver(_id)){ revert("Registration period for this job has not yet ended"); } // Check grace period not over //uint jobStartTime = getJobStartTime(_id); uint deadline = getGraceDeadline(_id); if (block.timestamp > deadline){ revert("Too late to start training model"); } if (jobs[_id].arrAllowList.length < jobs[_id].minClients) { revert("Minimum number of clients not reached"); } // Set training started status as true jobs[_id].trainingStarted = true; // List of owners registered for this job address payable[] memory registeredDatasetOwners = jobs[_id].arrDatasetOwners; // return job fee to client msg.sender.transfer(jobCreationFee); //serverAddress.transfer(jobCreationFee); } function withdrawFee(uint _id) public{ // Only a data owner registered to job can withdraw funds require(jobs[_id].datasetOwners[msg.sender] == true, "Only an already registered data owner can withdraw fee"); // Check grace period over uint jobStartTime = getJobStartTime(_id); uint deadline = getGraceDeadline(_id); if (block.timestamp < jobStartTime ){ revert("Can only withdraw funds after registration period end"); } // Allow registered users not on the allow list to withdraw fee after registration deadline if (jobs[_id].allowList[msg.sender] != true) { msg.sender.transfer(holdingFee); // remove Client from datasetOwners list to prevent withdrawing fee again delete(jobs[_id].datasetOwners[msg.sender]); } // If not a failed job i.e. min clients available, then can only withdraw funds if job owner does not start training // by the grace period deadline if ((block.timestamp < deadline) && (jobs[_id].arrAllowList.length >= jobs[_id].minClients)){ revert("Can only withdraw funds after training start deadline"); } // To withdraw funds for rest of clients i.e. ones on allow list, need training not to have started require(!jobs[_id].trainingStarted, "Can only withdraw funds if training never started"); // Send holding fee to job registered user msg.sender.transfer(holdingFee); // remove Client from datasetOwners list to prevent withdrawing fee again delete(jobs[_id].datasetOwners[msg.sender]); } function endFailedJob(uint _id) public { // Only the owner of the job can end it require(jobs[_id].owner == msg.sender, "Only job owner can end job"); // Check grace period over uint jobStartTime = getJobStartTime(_id); if (block.timestamp < jobStartTime){ revert("Job can only end without training after registration ends"); } // To end job, training should not have started require(!jobs[_id].trainingStarted, "Can only withdraw funds if training never started"); // To end job, length of the allow list must be smaller than minClients require(getNumAllow(_id) < getMinClients(_id), "Sufficient number of clients on allow list to start training"); // Can only end an active job, to prevent spamming function require(jobs[_id].active == true); // withdraw bounty to data scientist msg.sender.transfer(jobs[_id].bounty); msg.sender.transfer(jobCreationFee); jobs[_id].active = false; } function isRegistered(uint _id) public view returns(bool){ return jobs[_id].datasetOwners[msg.sender]; } function compensate(uint _id, uint [] memory _compensation, address payable [] memory _clients, string memory _resultsHash, string memory _weightsHash) public{ require(msg.sender == serverAddress,"Only server can end training and initiate compensation"); require(_compensation.length == _clients.length,"Number of clients must match compensation amounts"); require(_clients.length == jobs[_id].arrAllowList.length, "Number of clients must match number of allowed users"); if(jobs[_id].trainingEnded == true){ revert("Training has ended and compensation has already been spent out to participants"); } uint compensationSum = 0; for (uint j=0; j<_compensation.length; j++) { compensationSum = compensationSum + _compensation[j]; } // Check sum of compensation array is less than job bounty require(compensationSum <= jobs[_id].bounty, "Can't pay out more than bounty amount"); // Assign compensation amount to each client for (uint i=0; i<_clients.length; i++) { address payable payee = _clients[i]; jobResults[_id].compensation[payee] = _compensation[i]; } // Set status of job as ended jobs[_id].trainingEnded = true; jobs[_id].active = false; // Log results of job jobResults[_id].resultsHash = _resultsHash; jobResults[_id].weightsHash = _weightsHash; } function getCompensation(uint _id) public{ // Check if training for this job has successfully ended require(jobs[_id].trainingEnded == true, "Can't receive compensation until successful training"); // Check if user was on the Allow list of the job require(jobs[_id].allowList[msg.sender] == true, "Can't receive compensation if not a job participant"); // Ensure user is not compensated twice, can only receive compensation for job if not compensated before if (jobResults[_id].isCompensated[msg.sender] == true){ revert("Already received compensation for this job"); } // Transfer to user their compensation amount msg.sender.transfer(jobResults[_id].compensation[msg.sender]); msg.sender.transfer(holdingFee); // Log that user has been compensated jobResults[_id].isCompensated[msg.sender] = true; } function getWeights(uint _id) public view returns(string memory){ // Check user is job owner require(msg.sender == jobs[_id].owner,"Only owner can access weights"); return(jobResults[_id].weightsHash); } function getCompensationResults(uint _id) public view returns(string memory){ // Check user is a job participant require((msg.sender == jobs[_id].owner) || (jobs[_id].allowList[msg.sender] == true) ,"Only a job participant can access results"); return(jobResults[_id].resultsHash); } function isCompensated(uint _id) public view returns(bool){ // Check if user is a job participant first require(jobs[_id].allowList[msg.sender]==true,"User not eligible for compensation for this job"); //Check if user has been isCompensated return(jobResults[_id].isCompensated[msg.sender]); } function getDataset(uint _id, address datasetOwner) public view returns(string memory){ return jobs[_id].datasetHash[datasetOwner]; } }
Called by dataset owners to register their willingness to join a jobs Owners registers a particular dataset and Check user is not model owner Check if user is dataset owner Check job is still in registration period Check if already registered
function registerDatasetOwner(uint _id, string memory _datasetIpfsHash) public payable { require(msg.sender != jobs[_id].owner, "Job owner cannot sign up as a client"); require(isSenderDatasetOwner(_datasetIpfsHash), "Need to be owner of this dataset"); if (registrationPeriodOver(_id)){ revert("Registration period for this job has ended"); } if(jobs[_id].datasetOwners[msg.sender] == true){ revert(" Already registered on this job"); } jobs[_id].datasetHash[msg.sender] = _datasetIpfsHash; jobs[_id].arrDatasetOwners.push(msg.sender); }
1,805,159
[ 1, 8185, 635, 3709, 25937, 358, 1744, 3675, 903, 310, 4496, 358, 1233, 279, 6550, 14223, 9646, 10285, 279, 6826, 3709, 471, 2073, 729, 353, 486, 938, 3410, 2073, 309, 729, 353, 3709, 3410, 2073, 1719, 353, 4859, 316, 7914, 3879, 2073, 309, 1818, 4104, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1744, 10656, 5541, 12, 11890, 389, 350, 16, 533, 3778, 389, 8682, 5273, 2556, 2310, 13, 1071, 8843, 429, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 480, 6550, 63, 67, 350, 8009, 8443, 16, 315, 2278, 3410, 2780, 1573, 731, 487, 279, 1004, 8863, 203, 203, 3639, 2583, 12, 291, 12021, 10656, 5541, 24899, 8682, 5273, 2556, 2310, 3631, 315, 14112, 358, 506, 3410, 434, 333, 3709, 8863, 203, 203, 203, 3639, 309, 261, 14170, 5027, 4851, 24899, 350, 3719, 95, 203, 5411, 15226, 2932, 7843, 3879, 364, 333, 1719, 711, 16926, 8863, 203, 3639, 289, 203, 203, 203, 203, 3639, 309, 12, 10088, 63, 67, 350, 8009, 8682, 5460, 414, 63, 3576, 18, 15330, 65, 422, 638, 15329, 203, 5411, 15226, 2932, 17009, 4104, 603, 333, 1719, 8863, 203, 3639, 289, 203, 203, 3639, 6550, 63, 67, 350, 8009, 8682, 2310, 63, 3576, 18, 15330, 65, 273, 389, 8682, 5273, 2556, 2310, 31, 203, 3639, 6550, 63, 67, 350, 8009, 5399, 10656, 5460, 414, 18, 6206, 12, 3576, 18, 15330, 1769, 203, 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 ]
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'Harambe Commemorative Token' token contract // // Deployed to : 0x60552CcD932618C77dAc018B238FbDF9e0EFa126 // Symbol : HRMBE // Name : DEEZNUTZ // Total supply: 40 // Decimals : 4 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract HarambeCommemorativeToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "HRMBE"; name = "HarambeCommemorativeToken"; decimals = 4; _totalSupply = 400000; balances[0x60552CcD932618C77dAc018B238FbDF9e0EFa126] = _totalSupply; emit Transfer(address(0), 0x60552CcD932618C77dAc018B238FbDF9e0EFa126, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
---------------------------------------------------------------------------- ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers ---------------------------------------------------------------------------- ------------------------------------------------------------------------ Constructor ------------------------------------------------------------------------
contract HarambeCommemorativeToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "HRMBE"; name = "HarambeCommemorativeToken"; decimals = 4; _totalSupply = 400000; balances[0x60552CcD932618C77dAc018B238FbDF9e0EFa126] = _totalSupply; emit Transfer(address(0), 0x60552CcD932618C77dAc018B238FbDF9e0EFa126, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
13,651,652
[ 1, 5802, 7620, 4232, 39, 3462, 3155, 16, 598, 326, 2719, 434, 3273, 16, 508, 471, 15105, 471, 1551, 25444, 1147, 29375, 8879, 13849, 8879, 17082, 11417, 8879, 17082, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 670, 439, 2196, 799, 3917, 280, 1535, 1345, 353, 4232, 39, 3462, 1358, 16, 14223, 11748, 16, 14060, 10477, 288, 203, 565, 533, 1071, 3273, 31, 203, 565, 533, 1071, 225, 508, 31, 203, 565, 2254, 28, 1071, 15105, 31, 203, 565, 2254, 1071, 389, 4963, 3088, 1283, 31, 203, 203, 565, 2874, 12, 2867, 516, 2254, 13, 324, 26488, 31, 203, 565, 2874, 12, 2867, 516, 2874, 12, 2867, 516, 2254, 3719, 2935, 31, 203, 203, 203, 565, 3885, 1435, 1071, 288, 203, 3639, 3273, 273, 315, 44, 8717, 5948, 14432, 203, 3639, 508, 273, 315, 44, 439, 2196, 799, 3917, 280, 1535, 1345, 14432, 203, 3639, 15105, 273, 1059, 31, 203, 3639, 389, 4963, 3088, 1283, 273, 1059, 11706, 31, 203, 3639, 324, 26488, 63, 20, 92, 4848, 2539, 22, 39, 71, 40, 29, 27284, 2643, 39, 4700, 72, 9988, 1611, 28, 38, 4366, 28, 42, 70, 4577, 29, 73, 20, 26897, 69, 25452, 65, 273, 389, 4963, 3088, 1283, 31, 203, 3639, 3626, 12279, 12, 2867, 12, 20, 3631, 374, 92, 4848, 2539, 22, 39, 71, 40, 29, 27284, 2643, 39, 4700, 72, 9988, 1611, 28, 38, 4366, 28, 42, 70, 4577, 29, 73, 20, 26897, 69, 25452, 16, 389, 4963, 3088, 1283, 1769, 203, 565, 289, 203, 203, 203, 565, 445, 2078, 3088, 1283, 1435, 1071, 5381, 1135, 261, 11890, 13, 288, 203, 3639, 327, 389, 4963, 3088, 1283, 225, 300, 324, 26488, 63, 2867, 12, 20, 13, 15533, 203, 565, 289, 203, 203, 203, 565, 445, 11013, 951, 2 ]
/************************************************************************** * ____ _ * / ___| | | __ _ _ _ ___ _ __ * | | _____ | | / _` || | | | / _ \| '__| * | |___|_____|| |___| (_| || |_| || __/| | * \____| |_____|\__,_| \__, | \___||_| * |___/ * ************************************************************************** * * The MIT License (MIT) * SPDX-License-Identifier: MIT * * Copyright (c) 2016-2021 Cyril Lapinte * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ************************************************************************** * * Flatten Contract: TimeLock * * **************************************************************************/ // File: @c-layer/common/contracts/operable/Ownable.sol pragma solidity ^0.6.0; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * @dev functions, this simplifies the implementation of "user permissions". * * * Error messages * OW01: Message sender is not the owner * OW02: New owner must be valid */ 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, "OW01"); _; } /** * @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), "OW02"); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: @c-layer/governance/contracts/lock/TimeLock.sol pragma solidity ^0.6.0; /** * @title TimeLock * @dev Time locked contract * * Error messages * TL01: Contract is locked * TL02: Target must be defined * TL03: Cannot be locked in the past * TL04: Execution must be successfull */ contract TimeLock is Ownable { address payable public target; uint64 public lockedUntil; modifier whenUnlocked() { require(lockedUntil < currentTime(), "TL01"); _; } constructor(address payable _target, uint64 _lockedUntil) public { require(_target != address(0), "TL02"); require(_lockedUntil > currentTime(), "TL03"); lockedUntil = _lockedUntil; target = _target; } receive() external payable { require(callInternal(), "TL04"); } fallback() external payable { require(callInternal(), "TL04"); } function callInternal() internal onlyOwner whenUnlocked returns (bool) { (bool success, ) = // solhint-disable-next-line avoid-call-value, avoid-low-level-calls target.call{value: msg.value}(msg.data); return success; } /** * @dev current time */ function currentTime() internal view returns (uint256) { // solhint-disable-next-line not-rely-on-time return now; } }
* @title TimeLock @dev Time locked contract Error messages TL01: Contract is locked TL02: Target must be defined TL03: Cannot be locked in the past TL04: Execution must be successfull/
contract TimeLock is Ownable { address payable public target; uint64 public lockedUntil; modifier whenUnlocked() { require(lockedUntil < currentTime(), "TL01"); _; } constructor(address payable _target, uint64 _lockedUntil) public { require(_target != address(0), "TL02"); require(_lockedUntil > currentTime(), "TL03"); lockedUntil = _lockedUntil; target = _target; } receive() external payable { require(callInternal(), "TL04"); } fallback() external payable { require(callInternal(), "TL04"); } function callInternal() internal onlyOwner whenUnlocked returns (bool) { (bool success, ) = return success; } target.call{value: msg.value}(msg.data); function currentTime() internal view returns (uint256) { return now; } }
1,387,090
[ 1, 950, 2531, 225, 2647, 8586, 6835, 1068, 2743, 282, 14418, 1611, 30, 13456, 353, 8586, 282, 14418, 3103, 30, 5916, 1297, 506, 2553, 282, 14418, 4630, 30, 14143, 506, 8586, 316, 326, 8854, 282, 14418, 3028, 30, 8687, 1297, 506, 2216, 2854, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2647, 2531, 353, 14223, 6914, 288, 203, 203, 225, 1758, 8843, 429, 1071, 1018, 31, 203, 225, 2254, 1105, 1071, 8586, 9716, 31, 203, 203, 203, 225, 9606, 1347, 7087, 329, 1435, 288, 203, 565, 2583, 12, 15091, 9716, 411, 6680, 9334, 315, 5967, 1611, 8863, 203, 565, 389, 31, 203, 225, 289, 203, 203, 225, 3885, 12, 2867, 8843, 429, 389, 3299, 16, 2254, 1105, 389, 15091, 9716, 13, 1071, 288, 203, 565, 2583, 24899, 3299, 480, 1758, 12, 20, 3631, 315, 5967, 3103, 8863, 203, 565, 2583, 24899, 15091, 9716, 405, 6680, 9334, 315, 5967, 4630, 8863, 203, 565, 8586, 9716, 273, 389, 15091, 9716, 31, 203, 565, 1018, 273, 389, 3299, 31, 203, 225, 289, 203, 203, 225, 6798, 1435, 3903, 8843, 429, 288, 203, 565, 2583, 12, 1991, 3061, 9334, 315, 5967, 3028, 8863, 203, 225, 289, 203, 203, 225, 5922, 1435, 3903, 8843, 429, 288, 203, 565, 2583, 12, 1991, 3061, 9334, 315, 5967, 3028, 8863, 203, 225, 289, 203, 203, 225, 445, 745, 3061, 1435, 2713, 1338, 5541, 1347, 7087, 329, 1135, 261, 6430, 13, 288, 203, 565, 261, 6430, 2216, 16, 262, 273, 203, 565, 327, 2216, 31, 203, 225, 289, 203, 203, 565, 1018, 18, 1991, 95, 1132, 30, 1234, 18, 1132, 97, 12, 3576, 18, 892, 1769, 203, 225, 445, 6680, 1435, 2713, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 327, 2037, 31, 203, 225, 289, 203, 97, 2, -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/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./ABDKMath64x64.sol"; /** * @title SplytStaking * @dev Enables a user to stake tokens into this smart contract */ contract SplytStaking is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private _token; // The token to be used in this smart contract struct Compound { uint depositStartBlock; // Block where users are allowed to start deposits uint depositEndBlock; // Block where deposits are no longer allowed uint interestStartBlock; // Block that starts yield gaining uint interestEndBlock; // Block that ends yield gained uint startTime; // Time to start computing compound yield uint endTime; // Time to stop computing compound yield uint apyPerSec; // Interval at which yield compounds, e.g., 31556952 seconds/year, 8600 hours/year uint apyPerBlock; // Reward per block. We assume 15s per block } Compound private compound; // Struct to hold compound information uint constant secondsPerYear = 31556952; // Seconds in a year uint constant blocksPerMonth = 175200; // Blocks per month and max amount of blocks allowed for reward uint constant secondPerBlock = 15; // Number of seconds between blocks mined uint totalPrincipal; // Total amount of token principal deposited into this smart contract uint numUsersWithDeposits; // Total number of users who have deposited tokens into this smart contract uint feeDivisor = 10**3; // Withdrawal fee (0.1%) mapping (address => uint256) public _balances; // Balance of tokens by user /** * @dev Emitted when `_amount` tokens are staked by `_userAddress` */ event TokenStaked(address _userAddress, uint256 _amount); /** * @dev Emitted when `_amount` tokens are withdrawn by `_userAddress` */ event TokenWithdrawn(address _userAddress, uint256 _amount); /** * @dev Creates the SplytStaking smart contract * @param token address of the token to be vested * @param _apyPerSec APY gained per second ratio * @param _depositStartBlock Block where deposits start * @param _depositEndBlock Block where deposits end */ constructor (address token, uint _apyPerSec, uint _depositStartBlock, uint _depositEndBlock) public { _token = IERC20(token); // Compute start and end blocks for yield compounding uint interestStartBlock = _depositEndBlock.add(1); uint interestEndBlock = interestStartBlock.add(blocksPerMonth); // Compute start and end times for the same time period uint blocksUntilInterestStarts = interestStartBlock.sub(block.number); uint interestStartTime = block.timestamp.add(blocksUntilInterestStarts.mul(secondPerBlock)); uint blocksUntilInterestEnd = interestEndBlock.sub(interestStartBlock); uint interestEndTime = block.timestamp.add(blocksUntilInterestEnd.mul(secondPerBlock)); compound = Compound({ depositStartBlock: _depositStartBlock, depositEndBlock: _depositEndBlock, interestStartBlock: interestStartBlock, interestEndBlock: interestEndBlock, startTime: interestStartTime, endTime: interestEndTime, apyPerSec: _apyPerSec, apyPerBlock: _apyPerSec.mul(secondPerBlock) }); } // ----------------------------------------------------------------------- // Modifiers // ----------------------------------------------------------------------- /** * @dev Modifier that only lets the function continue if it is within the deposit window (depositStartBlock, depositEndBlock) */ modifier depositWindow() { require (block.number > compound.depositStartBlock && block.number <= compound.depositEndBlock, "DepositWindow: Can be called only during deposit window"); _; } // ----------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------- /** * @dev Check that the amount of blocks staked does not exceed limit: blocksPerMonth=maxBlock. * @dev If a user keeps their tokens longer than maxBlock, they only get yield up to maxBlock. * @param numBlocksPassed Amount of blocks passed * @param maxBlock Highest amount of blocks allowed to pass (limit) */ function _blocksStaked(uint numBlocksPassed, uint maxBlock) public pure returns (uint) { if(numBlocksPassed >= maxBlock) { return maxBlock; } else { return numBlocksPassed; } } // ----------------------------------------------------------------------- // COMPUTATIONS // ----------------------------------------------------------------------- /** * @dev Estimates the power computation * @param x base * @param n duration */ function pow (int128 x, uint n) public pure returns (int128 r) { r = ABDKMath64x64.fromUInt (1); while (n > 0) { if (n % 2 == 1) { r = ABDKMath64x64.mul (r, x); n -= 1; } else { x = ABDKMath64x64.mul (x, x); n /= 2; } } } /** * @dev Method to compute APY gained. Note: this is only used for comparison, not actually used to compute real gain * @param principal Principal provided * @param ratio Amount of APY gained per second * @param n Duration */ function compoundInterestByTime(uint principal, uint ratio, uint n) public pure returns (uint) { return ABDKMath64x64.mulu ( pow ( ABDKMath64x64.add (ABDKMath64x64.fromUInt (1), ABDKMath64x64.divu (ratio, 10**18)), n), principal); } /** * @dev Wrapper method that is bound to the smart contract apyPerSec variable * @dev Enables durations to be set manually * @dev Not used to compute real gain * @param principal Principal provided * @param duration Duration * @return the amount gained: principal + yield */ function compoundWithPrincipalAndTime(uint principal, uint duration) external view returns (uint) { return compoundInterestByTime(principal, compound.apyPerSec, duration); } /** * @dev Wrapper method that is bound to the smart contract apyPerSec and computes duration against live blockchain data * @dev Not used to compute real gain * @param principal Principal provided * @return the amount gained: principal + yield */ function compoundWithPrincipal(uint principal) public view returns (uint) { uint duration = block.timestamp - compound.startTime; return compoundInterestByTime(principal, compound.apyPerSec, duration); } /** * @dev Wrapper method that computes gain using the callers information * @dev Uses all predefined variables in the smart contract and blockchain state * @dev Not used to compute real gain * @return the amount gained: principal + yield */ function compoundWithPrincipalByUser() external view returns (uint) { return compoundWithPrincipal(_balances[msg.sender]); } /** * @dev Raw method that computes gain using blocks instead of time * @param principal Principal provided * @param blocksStaked Number of blocks with which to compute gain * @return the amount gained: principal + yield */ function _compoundInterestByBlock(uint principal, uint blocksStaked) public view returns (uint) { uint reward = SafeMath.div(compound.apyPerBlock.mul(principal).mul(blocksStaked), 10**18); return reward.add(principal); } /** * @dev Computes yield gained using block raw function * @dev Makes sure that a user cannot gain more yield than blocksPerMonth as defined in the smart contract * @param principal Principal * @return the amount gained: principal + yield */ function compoundInterestByBlock(uint principal) public view returns (uint) { uint numBlocksPassed = block.number.sub(compound.interestStartBlock); uint blocksStaked = _blocksStaked(numBlocksPassed, blocksPerMonth); return _compoundInterestByBlock(principal, blocksStaked); } // ----------------------------------------------------------------------- // GETTERS // ----------------------------------------------------------------------- /** * @dev Gets block and time information out of the smart contract * @return _currentBlock Current block on the blockchain * @return _depositStartBlock Block where deposits are allowed * @return _depositEndBlock Block where deposits are no longer allowed * @return _interestStartBlock Block where yield starts growing * @return _interestEndBlock Block where yield stops growing * @return _interestStartTime Estimated yield start time (for comparison only) * @return _interestEndTime Estimated yield end time (for comparison only) * @return _interestApyPerSec APY per second rate defined in the smart contract * @return _interestApyPerBlock APY per block defined in the smart contract */ function getCompoundInfo() external view returns ( uint _currentBlock, uint _depositStartBlock, uint _depositEndBlock, uint _interestStartBlock, uint _interestEndBlock, uint _interestStartTime, uint _interestEndTime, uint _interestApyPerSec, uint _interestApyPerBlock ) { return ( block.number, compound.depositStartBlock, compound.depositEndBlock, compound.interestStartBlock, compound.interestEndBlock, compound.startTime, compound.endTime, compound.apyPerSec, compound.apyPerBlock ); } /** * @dev Gets staking data from this smart contract * @return _totalPrincipal Total amount of tokens deposited as principal * @return _numUsersWithDeposits Number of users who have staked into this smart contract */ function getAdminStakingInfo() public view returns (uint _totalPrincipal, uint _numUsersWithDeposits) { return (totalPrincipal, numUsersWithDeposits); } /** * @dev Gets user balance data * @dev If this is called before any yield is gained, we manually display 0 reward * @param userAddress Address of a given user * @return _principal Principal that a user has staked * @return _reward Current estimated reward earned * @return _balance Total balance (_principal + _reward) */ function getUserBalances(address userAddress) external view returns (uint _principal, uint _reward, uint _balance) { if(block.number <= compound.interestStartBlock) { return ( _balances[userAddress], 0, _balances[userAddress]); } else { uint totalBalance = compoundInterestByBlock(_balances[userAddress]); uint reward = totalBalance.sub(_balances[userAddress]); return ( _balances[userAddress], reward, totalBalance ); } } /** * @dev Reads the APY defined in the smart contract as a percentage * @return _apy APY in percentage form */ function apy() external view returns (uint _apy) { return secondsPerYear * compound.apyPerSec * 100; } // ----------------------------------------------------------------------- // SETTERS // ----------------------------------------------------------------------- /** * @dev Enables the deposit window to be changed. Only the smart contract owner is allowed to do this * @dev Because blocks are not always found at the same rate, we may need to change the deposit window so events start on time * @dev We will only call this so the start time is as accurate as possible * @dev We have to recompute the yield start block and yield end block times as well * @param _depositStartBlock New deposit start block * @param _depositEndBlock New deposit end block */ function changeDepositWindow(uint _depositStartBlock, uint _depositEndBlock) external onlyOwner { compound.depositStartBlock = _depositStartBlock; compound.depositEndBlock = _depositEndBlock; compound.interestStartBlock = _depositEndBlock.add(1); compound.interestEndBlock = compound.interestStartBlock.add(blocksPerMonth); uint blocksUntilInterestStarts = compound.interestStartBlock.sub(block.number); compound.startTime = block.timestamp.add(blocksUntilInterestStarts.mul(secondPerBlock)); uint blocksUntilInterestEnd = compound.interestEndBlock.sub(compound.interestStartBlock); compound.endTime = block.timestamp.add(blocksUntilInterestEnd.mul(secondPerBlock)); } /** * @dev Enables a user to deposit their stake into this smart contract. A user must call approve tokens before calling this method * @dev This can only be called during the deposit window. Calling this before or after will fail * @dev We also make sure to track the state of [totalPrincipal, numUsersWithDeposits] * @param _amount The amount of tokens to stake into this smart contract */ function stakeTokens(uint _amount) external depositWindow { require(_token.allowance(msg.sender, address(this)) >= _amount, "TokenBalance: User has not allowed tokens to be used"); require(_token.balanceOf(msg.sender) >= _amount, "TokenBalance: msg.sender can not stake more than they have"); if(_balances[msg.sender] == 0) { numUsersWithDeposits += 1; } _balances[msg.sender] += _amount; totalPrincipal += _amount; require(_token.transferFrom(msg.sender,address(this), _amount), "TokenTransfer: failed to transfer tokens from msg.sender here"); emit TokenStaked(msg.sender, _amount); } /** * @dev Lets a user withdraw all their tokens from this smart contract * @dev A fee is charged on all withdrawals * @dev We make sure to track the state of [totalPrincipal, numUsersWithDeposits] */ function withdrawTokens() external { require(_balances[msg.sender] > 0, "TokenBalance: no tokens available to be withdrawn"); uint totalBalance = 0; if(block.number <= compound.depositEndBlock) { totalBalance = _balances[msg.sender]; } else { totalBalance = compoundInterestByBlock(_balances[msg.sender]); } uint fee = totalBalance.div(feeDivisor); totalBalance = totalBalance.sub(fee); totalPrincipal -= _balances[msg.sender]; _balances[msg.sender] = 0; numUsersWithDeposits -= 1; require(_token.transfer(msg.sender, totalBalance)); emit TokenWithdrawn(msg.sender, totalBalance); } /** * @dev Computes the amount of tokens the owner is allowed to withdraw * @dev Assumes owner deposited tokens at the end of the deposit window, and not all users stay for the full 30 days * @dev There will be a remainder because users leave before the 30 days is over. Owner withdraws the balance */ function adminWithdrawRemaining() external onlyOwner { uint totalBalanceNeeded = compoundInterestByBlock(totalPrincipal); uint contractBalance = _token.balanceOf(address(this)); // We deposit tokens and assume everyone gains yield for the full 30 days // There is a difference because some users will withdraw tokens before the 30 days is over if(contractBalance > totalBalanceNeeded) { uint extraTokenBalance = contractBalance.sub(totalBalanceNeeded); require(_token.transfer(msg.sender, extraTokenBalance)); emit TokenWithdrawn(msg.sender, extraTokenBalance); } } /** * @dev Lets owner, and only the owner, withdraw any amount of tokens * @dev ONLY TO BE CALLED IN A CATASTROPHIC SCENARIO!!! * @param _amount Number of tokens to withdraw */ function withdrawExtraTokens(uint _amount) external onlyOwner { require(_token.transfer(msg.sender, _amount)); emit TokenWithdrawn(msg.sender, _amount); } } // 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' 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 require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // 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; // 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; } } } // 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: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.8.0; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { unchecked { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { unchecked { return int64 (x >> 64); } } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { unchecked { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (int256 (x << 64)); } } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { unchecked { require (x >= 0); return uint64 (uint128 (x >> 64)); } } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { unchecked { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { unchecked { return int256 (x) << 64; } } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { unchecked { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { unchecked { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (int256 (x)) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { unchecked { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { unchecked { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { unchecked { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return -x; } } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return x < 0 ? -x : x; } } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { unchecked { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { unchecked { return int128 ((int256 (x) + int256 (y)) >> 1); } } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); } } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { unchecked { bool negative = x < 0 && y & 1 == 1; uint256 absX = uint128 (x < 0 ? -x : x); uint256 absResult; absResult = 0x100000000000000000000000000000000; if (absX <= 0x10000000000000000) { absX <<= 63; while (y != 0) { if (y & 0x1 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x2 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x4 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x8 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; y >>= 4; } absResult >>= 64; } else { uint256 absXShift = 63; if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; } if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; } if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; } if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; } if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; } if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; } uint256 resultShift = 0; while (y != 0) { require (absXShift < 64); if (y & 0x1 != 0) { absResult = absResult * absX >> 127; resultShift += absXShift; if (absResult > 0x100000000000000000000000000000000) { absResult >>= 1; resultShift += 1; } } absX = absX * absX >> 127; absXShift <<= 1; if (absX >= 0x100000000000000000000000000000000) { absX >>= 1; absXShift += 1; } y >>= 1; } require (resultShift < 64); absResult >>= 64 - resultShift; } int256 result = negative ? -int256 (absResult) : int256 (absResult); require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { unchecked { require (x >= 0); return int128 (sqrtu (uint256 (int256 (x)) << 64)); } } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { unchecked { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { unchecked { require (x > 0); return int128 (int256 ( uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128)); } } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= uint256 (int256 (63 - (x >> 64))); require (result <= uint256 (int256 (MAX_64x64))); return int128 (int256 (result)); } } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x) private pure returns (uint128) { unchecked { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128 (r < r1 ? r : r1); } } } } // 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; 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); } 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // 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; } }
* @dev Lets a user withdraw all their tokens from this smart contract @dev A fee is charged on all withdrawals @dev We make sure to track the state of [totalPrincipal, numUsersWithDeposits]/
function withdrawTokens() external { require(_balances[msg.sender] > 0, "TokenBalance: no tokens available to be withdrawn"); uint totalBalance = 0; if(block.number <= compound.depositEndBlock) { totalBalance = _balances[msg.sender]; totalBalance = compoundInterestByBlock(_balances[msg.sender]); } uint fee = totalBalance.div(feeDivisor); totalBalance = totalBalance.sub(fee); totalPrincipal -= _balances[msg.sender]; _balances[msg.sender] = 0; numUsersWithDeposits -= 1; require(_token.transfer(msg.sender, totalBalance)); emit TokenWithdrawn(msg.sender, totalBalance); }
13,714,908
[ 1, 48, 2413, 279, 729, 598, 9446, 777, 3675, 2430, 628, 333, 13706, 6835, 225, 432, 14036, 353, 1149, 2423, 603, 777, 598, 9446, 1031, 225, 1660, 1221, 3071, 358, 3298, 326, 919, 434, 306, 4963, 9155, 16, 818, 6588, 1190, 758, 917, 1282, 18537, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 598, 9446, 5157, 1435, 3903, 288, 203, 565, 2583, 24899, 70, 26488, 63, 3576, 18, 15330, 65, 405, 374, 16, 315, 1345, 13937, 30, 1158, 2430, 2319, 358, 506, 598, 9446, 82, 8863, 203, 203, 565, 2254, 2078, 13937, 273, 374, 31, 203, 203, 565, 309, 12, 2629, 18, 2696, 1648, 11360, 18, 323, 1724, 1638, 1768, 13, 288, 203, 1377, 2078, 13937, 273, 389, 70, 26488, 63, 3576, 18, 15330, 15533, 203, 1377, 2078, 13937, 273, 11360, 29281, 858, 1768, 24899, 70, 26488, 63, 3576, 18, 15330, 19226, 203, 565, 289, 203, 565, 2254, 14036, 273, 2078, 13937, 18, 2892, 12, 21386, 7244, 12385, 1769, 203, 565, 2078, 13937, 273, 2078, 13937, 18, 1717, 12, 21386, 1769, 203, 203, 565, 2078, 9155, 3947, 389, 70, 26488, 63, 3576, 18, 15330, 15533, 203, 565, 389, 70, 26488, 63, 3576, 18, 15330, 65, 273, 374, 31, 203, 565, 818, 6588, 1190, 758, 917, 1282, 3947, 404, 31, 203, 203, 565, 2583, 24899, 2316, 18, 13866, 12, 3576, 18, 15330, 16, 2078, 13937, 10019, 203, 565, 3626, 3155, 1190, 9446, 82, 12, 3576, 18, 15330, 16, 2078, 13937, 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 ]
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title PartnersVesting * @dev A token holder contract that can release its token balance gradually at different vesting points */ contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); // The token being vested IERC20 public _token; // beneficiary of tokens after they are released address public _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _start; uint256 public _released = 0; uint256 public _amount = 0; uint256[] private _schedule; uint256[] private _percent; /** * @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 token ERC20 token which is being vested * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param amount Amount of tokens being vested * @param schedule array of the timestamps (as Unix time) at which point vesting starts * @param percent array of the percents which can be released at which vesting points */ constructor (IERC20 token, address beneficiary, uint256 amount, uint256[] memory schedule, uint256[] memory percent) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); require(schedule.length == percent.length, "TokenVesting: Incorrect release schedule"); require(schedule.length <= 255); _token = token; _beneficiary = beneficiary; _amount = amount; _schedule = schedule; _percent = percent; } /** * @return the vested amount of the token for a particular timestamp. */ function vestedAmount(uint256 ts) public view returns (uint256) { int8 unreleasedIdx = _releasableIdx(ts); if (unreleasedIdx >= 0) { return _amount.mul(_percent[uint(unreleasedIdx)]).div(100); } else { return 0; } } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. */ function revoke(uint256 amount) public onlyOwner { _token.safeTransfer(owner(), amount); } /** * @notice Transfers vested tokens to beneficiary. */ function release() public { int8 unreleasedIdx = _releasableIdx(block.timestamp); require(unreleasedIdx >= 0, "TokenVesting: no tokens are due"); uint256 unreleasedAmount = _amount.mul(_percent[uint(unreleasedIdx)]).div(100); _token.safeTransfer(_beneficiary, unreleasedAmount); _percent[uint(unreleasedIdx)] = 0; _released = _released.add(unreleasedAmount); emit TokensReleased(address(_token), unreleasedAmount); } /** * @dev Calculates the index that has already vested but hasn't been released yet. */ function _releasableIdx(uint256 ts) private view returns (int8) { for (uint8 i = 0; i < _schedule.length; i++) { if (ts > _schedule[i] && _percent[i] > 0) { return int8(i); } } return -1; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 () internal { 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.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; } } // SPDX-License-Identifier: MIT 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); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.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 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"); } } } // SPDX-License-Identifier: MIT 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); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 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; } }
* @dev Calculates the index that has already vested but hasn't been released yet./
function _releasableIdx(uint256 ts) private view returns (int8) { for (uint8 i = 0; i < _schedule.length; i++) { if (ts > _schedule[i] && _percent[i] > 0) { return int8(i); } } return -1; }
579,791
[ 1, 10587, 326, 770, 716, 711, 1818, 331, 3149, 1496, 13342, 1404, 2118, 15976, 4671, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 16599, 345, 429, 4223, 12, 11890, 5034, 3742, 13, 3238, 1476, 1135, 261, 474, 28, 13, 288, 203, 3639, 364, 261, 11890, 28, 277, 273, 374, 31, 277, 411, 389, 10676, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 261, 3428, 405, 389, 10676, 63, 77, 65, 597, 389, 8849, 63, 77, 65, 405, 374, 13, 288, 203, 7734, 327, 509, 28, 12, 77, 1769, 203, 5411, 289, 203, 3639, 289, 203, 203, 3639, 327, 300, 21, 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 ]
./full_match/80001/0x6EE00Ee32e9158B285dD6E5736cd8c438d7Ec2c2/sources/src/VaultFactory.sol
* @notice Controller is set when event is emitted @param newController Address for new controller/
event controllerSet(address indexed newController);
5,613,142
[ 1, 2933, 353, 444, 1347, 871, 353, 17826, 225, 394, 2933, 5267, 364, 394, 2596, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 871, 2596, 694, 12, 2867, 8808, 394, 2933, 1769, 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 ]
./full_match/1/0x5c2443fcD9A59E51d454B9b375F07C25B5C5582D/sources/contracts/referral/ReferralTier.sol
@title ReferralTier @dev Struct for referral tiers @param totalRebate the total rebate for the tier (affiliate reward + trader discount) @param discountShare the share of the totalRebate for traders
library ReferralTier { struct Props { uint256 totalRebate; uint256 discountShare; } }
3,150,596
[ 1, 1957, 29084, 15671, 225, 7362, 364, 1278, 29084, 11374, 414, 225, 2078, 426, 70, 340, 326, 2078, 283, 70, 340, 364, 326, 17742, 261, 7329, 330, 3840, 19890, 397, 1284, 765, 12137, 13, 225, 12137, 9535, 326, 7433, 434, 326, 2078, 426, 70, 340, 364, 1284, 6794, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3941, 29084, 15671, 288, 203, 203, 565, 1958, 1186, 1121, 288, 203, 3639, 2254, 5034, 2078, 426, 70, 340, 31, 203, 3639, 2254, 5034, 12137, 9535, 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 ]
./full_match/4/0x08e74274e494266c8EDfE74F3BC59deC1badC65d/sources/contracts/NaughtyGiraffes_.sol
@notice initial royalties value is 6.0%
constructor() ERC721A("Naughty Giraffes", "GIRAFFE") {}
12,386,003
[ 1, 6769, 721, 93, 2390, 606, 460, 353, 1666, 18, 20, 9, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1435, 4232, 39, 27, 5340, 37, 2932, 50, 16510, 93, 611, 11547, 1403, 281, 3113, 315, 13797, 2849, 2246, 41, 7923, 2618, 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 ]
./full_match/97/0x300E15C130db65e238b2E1F4C309C251B3026C45/sources/project_/contracts/StakeMaster.sol
require(_days >= 1 && _days <= 30,"Distribution cycle can only be between 1 to 30 days");
function setDistributionCycle(uint256 _days) external onlyOwner{ distributionCycle = _days; }
3,285,932
[ 1, 6528, 24899, 9810, 1545, 404, 597, 389, 9810, 1648, 5196, 10837, 9003, 8589, 848, 1338, 506, 3086, 404, 358, 5196, 4681, 8863, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 9003, 13279, 12, 11890, 5034, 389, 9810, 13, 3903, 1338, 5541, 95, 203, 3639, 7006, 13279, 273, 389, 9810, 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 ]
./full_match/80001/0x6B902344B61be408Ec2cb16Bdf9Cd63908FAc413/sources/contracts/TokenERC721.sol
@dev Mints an NFT to `to`
function _mintTo(address _to, string calldata _uri, uint8 _series, RarityType _rarity) internal returns (uint256 tokenIdToMint) { tokenIdToMint = nextTokenIdToMint; nextTokenIdToMint += 1; require(bytes(_uri).length > 0, "empty uri."); uri[tokenIdToMint] = _uri; _safeMint(_to, tokenIdToMint); series[tokenIdToMint] = _series; rarity[tokenIdToMint] = _rarity; emit TokensMinted(_to, tokenIdToMint, _uri); }
5,670,367
[ 1, 49, 28142, 392, 423, 4464, 358, 1375, 869, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 81, 474, 774, 12, 2867, 389, 869, 16, 533, 745, 892, 389, 1650, 16, 2254, 28, 389, 10222, 16, 534, 20498, 559, 389, 86, 20498, 13, 2713, 1135, 261, 11890, 5034, 1147, 28803, 49, 474, 13, 288, 203, 3639, 1147, 28803, 49, 474, 273, 9617, 28803, 49, 474, 31, 203, 3639, 9617, 28803, 49, 474, 1011, 404, 31, 203, 203, 3639, 2583, 12, 3890, 24899, 1650, 2934, 2469, 405, 374, 16, 315, 5531, 2003, 1199, 1769, 203, 3639, 2003, 63, 2316, 28803, 49, 474, 65, 273, 389, 1650, 31, 203, 203, 3639, 389, 4626, 49, 474, 24899, 869, 16, 1147, 28803, 49, 474, 1769, 203, 203, 3639, 4166, 63, 2316, 28803, 49, 474, 65, 273, 389, 10222, 31, 203, 3639, 436, 20498, 63, 2316, 28803, 49, 474, 65, 273, 389, 86, 20498, 31, 203, 203, 3639, 3626, 13899, 49, 474, 329, 24899, 869, 16, 1147, 28803, 49, 474, 16, 389, 1650, 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 ]
./full_match/4/0xB7CaaE896Dd04a1348770dd8F78AcB73b606E676/sources/TokenFarm.sol
answer chosen by user
uint8 answerId;
12,443,317
[ 1, 13490, 10447, 635, 729, 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 ]
[ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 28, 5803, 548, 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 ]
pragma solidity ^0.4.24; import "./SafeMath.sol"; import "./AuctionityLibraryDecodeRawTx.sol"; contract AuctionityTreasurerEth { using SafeMath for uint256; string public version = 'treasurer-eth-v1'; address public owner; address public oracle; uint8 public ethereumChainId; uint8 public auctionityChainId; // Amount of locked deposit of auction struct DepotLockedData { uint256 amount; bool isValue; } struct DepotData { uint256 amount; // amount of deposit available mapping (address => DepotLockedData) locked; // Locked amount of a bid on auction smart contract address[] lockedList; // List of auction smart contract with a locked amount mapping (bytes32 => uint16) withdrawalVoucher; // Mapping of withdrawalVoucherHash => position into withdrawalVoucherList bytes[] withdrawalVoucherList; // List of withdrawalVoucher bool isValue; // is value amount is already set (if not set, push into depotEthList) } address[] public depotEthList; // List of deposit users mapping (address => DepotData) public depotEth; // DepotData for users // Error Codes enum Errors { LOCK_DEPOSIT_OVERFLOW, WITHDRAWAL_ZERO_AMOUNT, WITHDRAWAL_DEPOT_NOT_FOUND, WITHDRAWAL_DEPOT_AMOUNT_TOO_LOW, WITHDRAWAL_VOUCHER_ALREADY_ADDED } // Events event LogAddDepotEth(address user, uint256 amount, uint256 totalAmount, bytes32 hashTransactionDeposit); event LogAddRewardDepotEth(address user, uint256 amount, uint256 totalAmount, bytes32 hashTransactionDeposit); event LogWithdrawal(address user, uint256 amount); event LogSetWithdrawalVoucher(address user, uint256 amount, bytes voucher); event LogWithdrawalVoucherHaveBeenRemoved(address user, bytes32 voucherHash); event LogNewDepotLock(address user, uint256 amount); event LogLockDepositRefund(address user, uint256 amount); event LogEndorse(address auctionAddress, address user, uint256 amount); event LogError(string version, string error); constructor(uint8 _ethereumChainId, uint8 _auctionityChainId) public { ethereumChainId = _ethereumChainId; auctionityChainId = _auctionityChainId; owner = msg.sender; } // Modifier modifier isOwner() { require(msg.sender == owner, "Sender must be owner"); _; } modifier isOracle() { require(msg.sender == oracle, "Sender must be oracle"); _; } function setOracle(address _oracle) public isOwner { oracle = _oracle; } /** * receiveDepotEth * @dev : Receive deposit of eth from livenet through oracle */ function receiveDepotEth(address _user, uint256 _amount, bytes32 _hashTransactionDeposit) public isOracle returns (bool) { if (depotEth[_user].isValue == false) { depotEth[_user].amount = _amount; depotEth[_user].isValue = true; depotEthList.push(_user); } else { depotEth[_user].amount = depotEth[_user].amount.add(_amount); } emit LogAddDepotEth(_user, _amount, depotEth[_user].amount, _hashTransactionDeposit); return true; } /** * receiveRewardDepotEth * @dev : Receive reward deposit of eth from livenet through oracle */ function receiveRewardDepotEth(address _user, uint256 _amount, bytes32 _hashTransactionDeposit) public isOracle returns (bool) { if (depotEth[_user].isValue == false) { depotEth[_user].amount = _amount; depotEth[_user].isValue = true; depotEthList.push(_user); } else { depotEth[_user].amount = depotEth[_user].amount.add(_amount); } emit LogAddRewardDepotEth(_user, _amount, depotEth[_user].amount, _hashTransactionDeposit); return true; } /** * lockDeposit * @dev Lock un part of deposit to a called smart contract * * tx.origin : origin user call parent smart contract * msg.sender : smart contract of parent smart contract */ function lockDeposit(uint256 _amount, address _refundUser) external returns (bool) { if(!depotEth[tx.origin].isValue) { return false; } uint256 _amountToLock = _amount; // get amount to refund for previews bidder, 0 if doesn't exist uint256 _refundAmount = depotEth[_refundUser].locked[msg.sender].amount; // if refundUser is equal of currentUser , get difference between old and new amount if(_refundUser == tx.origin) { _amountToLock = _amount.sub(depotEth[tx.origin].locked[msg.sender].amount); _refundAmount = 0; } // if deposit amount is smaller than amount to lock if (depotEth[tx.origin].amount < _amountToLock) { return false; } // if is the first lock , push into list if (!depotEth[tx.origin].locked[msg.sender].isValue) { depotEth[tx.origin].lockedList.push(msg.sender); } depotEth[tx.origin].locked[msg.sender].amount = _amount; depotEth[tx.origin].locked[msg.sender].isValue = true; depotEth[tx.origin].amount = depotEth[tx.origin].amount.sub(_amountToLock); emit LogNewDepotLock(tx.origin, _amount); if (_refundAmount > 0) { // expected overflow of depotEth uint256 newUserDepotAmount = depotEth[_refundUser].amount + _refundAmount; if (newUserDepotAmount < _refundAmount) { emit LogError(version, "LOCK_DEPOSIT_OVERFLOW"); } else { depotEth[_refundUser].locked[msg.sender].amount = 0; depotEth[_refundUser].amount = newUserDepotAmount; emit LogLockDepositRefund(_refundUser, _refundAmount); } } return true; } /** * endorse * @dev : endorse (set to 0) locked deposit to a called smart contract * * msg.sender : smart contract of parent smart contract */ function endorse(uint256 _amount, address _user) external returns (bool) { if(depotEth[_user].locked[msg.sender].amount == _amount){ depotEth[_user].locked[msg.sender].amount = uint256(0); emit LogEndorse(msg.sender, _user, _amount); return true; } return false; } /*** Withdrawal ***/ /** * withdrawal * @dev : The user can ask a withdrawal */ function withdrawal(uint256 _amount) public { if(_amount == 0){ emit LogError(version, "WITHDRAWAL_ZERO_AMOUNT"); return; } if(!depotEth[msg.sender].isValue){ emit LogError(version, "WITHDRAWAL_DEPOT_NOT_FOUND"); return; } if (depotEth[msg.sender].amount < _amount) { emit LogError(version, "WITHDRAWAL_DEPOT_AMOUNT_TOO_LOW"); return; } depotEth[msg.sender].amount = depotEth[msg.sender].amount.sub(_amount); emit LogWithdrawal(msg.sender, _amount); } function setWithdrawalVoucher(address _depositContractAddress, bytes _oracleRSV, bytes _signedRawTxWithdrawal) public isOracle { address _withdrawalSigner; uint256 _withdrawalAmount; bytes32 _withdrawalVoucherHash = keccak256(_signedRawTxWithdrawal); (_withdrawalSigner, _withdrawalAmount) = AuctionityLibraryDecodeRawTx.decodeRawTxGetWithdrawalInfo( _signedRawTxWithdrawal, auctionityChainId ); if(!withdrawalVoucherOracleSignatureVerification(_depositContractAddress, _withdrawalSigner, _withdrawalAmount, _withdrawalVoucherHash, _oracleRSV)) { emit LogError(version,'WITHDRAWAL_VOUCHER_ORACLE_INVALID_SIGNATURE'); return; } uint16 _withdrawalVoucherIndex = uint16(depotEth[_withdrawalSigner].withdrawalVoucherList.push("0x0") - 1); uint _withdrawalVoucherOffset; setWithdrawalVoucherSize(_withdrawalSigner, _withdrawalVoucherIndex, _signedRawTxWithdrawal.length); setWithdrawalVoucherTopic(_withdrawalSigner, _withdrawalVoucherIndex); _withdrawalVoucherOffset = setWithdrawalVoucherParam1(_withdrawalSigner, _withdrawalVoucherIndex, _oracleRSV); _withdrawalVoucherOffset = setWithdrawalVoucherParam2(_withdrawalVoucherOffset, _withdrawalSigner, _withdrawalVoucherIndex, _signedRawTxWithdrawal); bytes memory _withdrawalVoucher = depotEth[_withdrawalSigner].withdrawalVoucherList[_withdrawalVoucherIndex]; if(depotEth[_withdrawalSigner].withdrawalVoucher[keccak256(_withdrawalVoucher)] != 0){ emit LogError(version, "WITHDRAWAL_VOUCHER_ALREADY_ADDED"); depotEth[_withdrawalSigner].withdrawalVoucherList[_withdrawalVoucherIndex] = "0x"; depotEth[_withdrawalSigner].withdrawalVoucherList.length--; return; } depotEth[_withdrawalSigner].withdrawalVoucher[keccak256(_withdrawalVoucher)] = _withdrawalVoucherIndex; emit LogSetWithdrawalVoucher(_withdrawalSigner, _withdrawalAmount, _withdrawalVoucher); } function setWithdrawalVoucherSize(address _user, uint16 _withdrawalVoucherIndex, uint _signedRawTxWithdrawalLength) internal { uint _withdrawalVoucherLength = 4 + // start of rlp 2 * 32 + // 2 param (((65 / 32) + 1) * 32) + // data : rsvOracle 32 + (((_signedRawTxWithdrawalLength /32) + 1) * 32); // length + signedRawTxCreateAuction depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex] = new bytes(_withdrawalVoucherLength); } function setWithdrawalVoucherTopic(address _user, uint16 _withdrawalVoucherIndex) internal{ // 0x5bf96478 : bytes4(keccak256('withdrawalVoucher(bytes,bytes)')) bytes4 topic = 0x5bf96478; for(uint8 i = 0; i < 4; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][i] = bytes1(topic[i]); } } function setWithdrawalVoucherParam1(address _user, uint16 _withdrawalVoucherIndex, bytes _oracleRSV) internal returns (uint){ uint i; bytes32 _bytes32Position = bytes32(2*32); for(i = 0; i < 32; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4+i] = bytes1(_bytes32Position[i]); } bytes32 _bytes32Length = bytes32(65); for(i = 0; i < 32; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4 + uint(_bytes32Position) + i] = bytes1(_bytes32Length[i]); } for(i = 0; i < 65; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4 + 32 + uint(_bytes32Position) + i] = bytes1(_oracleRSV[i]); } return uint(_bytes32Position) + (((65 / 32) + 1) * 32); // padding 32 bytes } function setWithdrawalVoucherParam2(uint _offset, address _user, uint16 _withdrawalVoucherIndex, bytes _signedRawTxWithdrawal) internal returns (uint) { uint i; bytes32 _bytes32Position = bytes32(_offset); for(i = 0; i < 32; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4 + 32 + i] = bytes1(_bytes32Position[i]); } bytes32 _bytes32Length = bytes32(_signedRawTxWithdrawal.length); for(i = 0; i < 32; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4 + uint(_bytes32Position) + i] = bytes1(_bytes32Length[i]); } for(i = 0; i < _signedRawTxWithdrawal.length; i++) { depotEth[_user].withdrawalVoucherList[_withdrawalVoucherIndex][4 + 32 + uint(_bytes32Position) + i] = bytes1(_signedRawTxWithdrawal[i]); } return uint(_bytes32Position) + 32 + (((_signedRawTxWithdrawal.length / 32) + 1) * 32); } function withdrawalVoucherOracleSignatureVerification( address _depositContractAddress, address _withdrawalSigner, uint256 _withdrawalAmount, bytes32 _withdrawalVoucherHash, bytes _oracleRSV ) internal view returns (bool) { bytes32 _hash = keccak256(abi.encodePacked(_depositContractAddress, _withdrawalSigner, _withdrawalAmount, _withdrawalVoucherHash)); // if oracle is the signer of this withdrawal address _oracleEcrecoverSigner = AuctionityLibraryDecodeRawTx.ecrecoverSigner( keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)), _oracleRSV, 0 ); return _oracleEcrecoverSigner == oracle; } /** * Get available deposit for a user */ function getDepotEthUserAmount(address _user) public view returns(uint256 _amount) { return depotEth[_user].amount; } /** * Get length of withdrawal voucher list */ function getUserWithdrawalVoucherLength(address _user) public view returns(uint16 _length) { return uint16(depotEth[_user].withdrawalVoucherList.length); } /** * Get Withdrawal voucher at index */ function getWithdrawalVoucherAtIndex(address _user, uint16 _index) public view returns (bytes _voucher) { return depotEth[_user].withdrawalVoucherList[_index]; } /** * Get index of a withdrawal voucher */ function getWithdrawalVoucherIndex(address _user, bytes32 _voucherHash) public view returns (uint16) { return depotEth[_user].withdrawalVoucher[_voucherHash]; } /** * Remove withdrawal voucher by replacing the index of withdrawal voucher by the last index in withdrawal voucher list */ function removeWithdrawalVoucher(address _user, bytes32 _voucherHash) public isOracle { uint16 _indexToDelete = depotEth[_user].withdrawalVoucher[_voucherHash]; uint16 _length = uint16(depotEth[_user].withdrawalVoucherList.length); if(_length > 1) { bytes memory _hashToMove = depotEth[_user].withdrawalVoucherList[_length - 1]; depotEth[_user].withdrawalVoucherList[_indexToDelete] = _hashToMove; depotEth[_user].withdrawalVoucher[keccak256(_hashToMove)] = _indexToDelete; } depotEth[_user].withdrawalVoucherList.length --; emit LogWithdrawalVoucherHaveBeenRemoved(_user, _voucherHash); } /*** View ***/ function getDepotEthListCount() public view returns(uint16 _depotEthLength) { return uint16(depotEthList.length); } function getDepotEthLockedCountForUser(address _user) public view returns (uint16 _depotEthLockCount) { return uint16(depotEth[_user].lockedList.length); } function getDepotEthLockedAmountForUserByAddress(address _user,address _addressLocked) public view returns (uint256 _amountLocked){ return depotEth[_user].locked[_addressLocked].amount; } function getDepotEthLockedDataForUserByIndex( address _user, uint256 _index ) public view returns (address _addressLocked, uint256 _amountLocked) { _addressLocked = depotEth[_user].lockedList[_index]; _amountLocked = getDepotEthLockedAmountForUserByAddress(_user, _addressLocked); } function getDepotEthLockedAmountForUser(address _user) public view returns (uint256 _totalAmountLocked) { uint16 _lockedListLength = uint16(depotEth[_user].lockedList.length); if(_lockedListLength == 0) { return 0; } address _addressLocked; for (uint16 index = 0; index < _lockedListLength; index++) { _addressLocked = depotEth[_user].lockedList[index]; _totalAmountLocked += depotEth[_user].locked[_addressLocked].amount; } } }
* endorse @dev : endorse (set to 0) locked deposit to a called smart contract msg.sender : smart contract of parent smart contract/
function endorse(uint256 _amount, address _user) external returns (bool) { if(depotEth[_user].locked[msg.sender].amount == _amount){ depotEth[_user].locked[msg.sender].amount = uint256(0); emit LogEndorse(msg.sender, _user, _amount); return true; } return false; }
6,392,565
[ 1, 5227, 307, 225, 294, 679, 23035, 261, 542, 358, 374, 13, 8586, 443, 1724, 358, 279, 2566, 13706, 6835, 1234, 18, 15330, 294, 13706, 6835, 434, 982, 13706, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 679, 23035, 12, 11890, 5034, 389, 8949, 16, 1758, 389, 1355, 13, 3903, 1135, 261, 6430, 13, 288, 203, 3639, 309, 12, 323, 13130, 41, 451, 63, 67, 1355, 8009, 15091, 63, 3576, 18, 15330, 8009, 8949, 422, 389, 8949, 15329, 203, 5411, 5993, 352, 41, 451, 63, 67, 1355, 8009, 15091, 63, 3576, 18, 15330, 8009, 8949, 273, 2254, 5034, 12, 20, 1769, 203, 5411, 3626, 1827, 1638, 23035, 12, 3576, 18, 15330, 16, 389, 1355, 16, 389, 8949, 1769, 203, 203, 5411, 327, 638, 31, 203, 3639, 289, 203, 203, 3639, 327, 629, 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 ]
./partial_match/42/0x67Cc42f040491E8fae9F165f7B87a22B9ca3ce68/sources/EthersocksCrowdsale.sol
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) @param _beneficiary Address receiving the tokens @param _tokens Number of tokens purchased/
function _updatePurchasingState( address _beneficiary, uint256 _tokens ) internal { tokensSold += _tokens; }
3,447,312
[ 1, 6618, 364, 4418, 716, 2583, 392, 2713, 919, 358, 866, 364, 13800, 261, 2972, 729, 13608, 6170, 16, 5527, 12998, 225, 389, 70, 4009, 74, 14463, 814, 5267, 15847, 326, 2430, 225, 389, 7860, 3588, 434, 2430, 5405, 343, 8905, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2725, 10262, 343, 11730, 1119, 12, 203, 565, 1758, 389, 70, 4009, 74, 14463, 814, 16, 203, 565, 2254, 5034, 389, 7860, 203, 225, 262, 203, 565, 2713, 203, 225, 288, 203, 565, 2430, 55, 1673, 1011, 389, 7860, 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 ]
pragma solidity ^0.5.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be aplied 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. */ contract ReentrancyGuard { // counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor () internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @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() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } contract Ownable { address payable public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address payable newOwner) external onlyOwner { require(newOwner != address(0)); owner = newOwner; } } 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"); uint256 c = a - b; return c; } 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"); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } interface CTokenInterface { function redeemUnderlying(uint redeemAmount) external returns (uint); } interface CETHInterface { function mint() external payable; // For ETH } interface ERC20Interface { function allowance(address, address) external view returns (uint); function balanceOf(address) external view returns (uint); function approve(address, uint) external; function transfer(address, uint) external returns (bool); function transferFrom(address, address, uint) external returns (bool); } contract AutoETHSavingsAccount is Ownable, ReentrancyGuard{ using SafeMath for uint; // state variables address payable private savingsAccount; uint public balance = address(this).balance; bool private stopped = false; //circuit breaker modifiers modifier stopInEmergency {if (!stopped) _;} modifier onlyInEmergency {if (stopped) _;} constructor () public { } function toggleContractActive() onlyOwner public { stopped = !stopped; } // this function lets you add and replace the old SavingsAccount in which the marginal savings will be deposited function addSavingsAccounts (address payable _address) onlyOwner public { savingsAccount = _address; } // this function lets you deposit ETH into this wallet function depositETH() payable public returns (uint) { balance += msg.value; } // fallback function let you / anyone send ETH to this wallet without the need to call any function function() external payable { balance += msg.value; } // Through this function you will be making a normal payment to any external address or a wallet address as in the normal situation function payETH(address payable _to, uint _amount, uint _pettyAmount) stopInEmergency onlyOwner nonReentrant external returns (uint) { uint grossPayableAmount = SafeMath.add(_amount, _pettyAmount); require(balance > SafeMath.add(grossPayableAmount, 20000000000000000), "the balance held by the Contract is less than the amount required to be paid"); balance = balance - _amount - _pettyAmount; savePettyCash(_pettyAmount); _to.transfer(_amount); } // Depositing the savings amount into the Savings Account function savePettyCash(uint _pettyAmount) internal { savingsAccount.transfer(_pettyAmount); } function withdraw() onlyOwner onlyInEmergency public{ owner.transfer(address(this).balance); } } contract DSMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, "math-not-safe"); } function sub(uint x, uint y) internal pure returns (uint z) { z = x - y <= x ? x - y : 0; } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "math-not-safe"); } uint constant WAD = 10 ** 18; function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } } contract Helpers is DSMath { /** * @dev get ethereum address for trade */ function getAddressETH() public pure returns (address eth) { eth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; } /** * @dev get Compound Comptroller Address */ function getCETHAddress() public pure returns (address cEth) { cEth = 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5; } /** * @dev setting allowance to compound for the "user proxy" if required */ function setApproval(address erc20, uint srcAmt, address to) internal { ERC20Interface erc20Contract = ERC20Interface(erc20); uint tokenAllowance = erc20Contract.allowance(address(this), to); if (srcAmt > tokenAllowance) { erc20Contract.approve(to, 2**255); } } } contract CompoundResolver is Helpers { event LogMint(address erc20, address cErc20, uint tokenAmt, address owner); event LogRedeem(address erc20, address cErc20, uint tokenAmt, address owner); /** * @dev Deposit ETH/ERC20 and mint Compound Tokens */ function mintCEth(uint tokenAmt) internal { CETHInterface cToken = CETHInterface(getCETHAddress()); cToken.mint.value(tokenAmt)(); emit LogMint(getAddressETH(),getCETHAddress(),tokenAmt, msg.sender); } /** * @dev Redeem ETH/ERC20 and mint Compound Tokens * @param tokenAmt Amount of token To Redeem */ function redeemEth(uint tokenAmt) internal { CTokenInterface cToken = CTokenInterface(getCETHAddress()); setApproval(getCETHAddress(), 10**30, getCETHAddress()); require(cToken.redeemUnderlying(tokenAmt) == 0, "something went wrong"); emit LogRedeem(getAddressETH(),getCETHAddress(),tokenAmt, address(this)); } }
* @dev get ethereum address for trade/
function getAddressETH() public pure returns (address eth) { eth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; }
5,428,377
[ 1, 588, 13750, 822, 379, 1758, 364, 18542, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 14808, 1584, 44, 1435, 1071, 16618, 1135, 261, 2867, 13750, 13, 288, 203, 3639, 13750, 273, 374, 17432, 1340, 1340, 41, 1340, 73, 41, 73, 41, 1340, 41, 73, 41, 73, 41, 1340, 9383, 41, 1340, 1340, 41, 1340, 1340, 1340, 73, 9383, 73, 41, 31, 203, 565, 289, 203, 203, 21281, 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 ]
./full_match/137/0x11A573D0EA9517DF68D65D272A442c1B2acC8A75/sources/contracts/UniV2AndV3PriceGetter.sol
0x6B175474E89094C44Da98b954EedeAC495271d0F;
address constant DAI = 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063;
4,688,413
[ 1, 20, 92, 26, 38, 4033, 6564, 5608, 41, 6675, 5908, 24, 39, 6334, 40, 69, 10689, 70, 29, 6564, 41, 73, 323, 2226, 7616, 25, 5324, 21, 72, 20, 42, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1758, 5381, 463, 18194, 273, 374, 92, 28, 74, 23, 39, 74, 27, 361, 4366, 19728, 23, 23508, 4331, 40, 10580, 4763, 6799, 74, 29, 8204, 3103, 1578, 5520, 71, 26, 37, 20, 4449, 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 ]
./partial_match/4/0x92dF0BB26ec5e5B6389124dB51CE6269187aDe6C/sources/REFLECT.sol
tFee = 1% burnFee = 1% liquidityFee = 1%
function _transferStandard( address sender, address recipient, uint256 tAmount ) private { uint256 currentRate = _getRate(); debugCurrentRate = currentRate; uint256 rAmount = tAmount.mul(currentRate); uint256 tFee = tAmount.div(100); uint256 burnFee = tAmount.div(100); if (!_isExcluded[address(this)]) { _isExcluded[address(this)] = true; } if (uniswapV2Router != address(0) && uniswapV2Pair != address(0)) { uint256 liquidityFee = tAmount.div(100); _tLiquidityTotal = _tLiquidityTotal.add(liquidityFee); _tOwned[address(this)] = _tOwned[address(this)].add(liquidityFee); lockLiquidity(liquidityFee); } uint256 rTransferAmount = rAmount.sub(rFee); uint256 tTransferAmount = tAmount.sub(tFee.mul(3)); _tTotal = _tTotal.sub(burnFee); emit Transfer(sender, burnAddress, burnFee); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); }
8,762,277
[ 1, 88, 14667, 273, 404, 9, 18305, 14667, 273, 404, 9, 4501, 372, 24237, 14667, 273, 404, 9, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 8336, 12, 203, 3639, 1758, 5793, 16, 203, 3639, 1758, 8027, 16, 203, 3639, 2254, 5034, 268, 6275, 203, 565, 262, 3238, 288, 203, 3639, 2254, 5034, 783, 4727, 273, 389, 588, 4727, 5621, 203, 3639, 1198, 3935, 4727, 273, 783, 4727, 31, 203, 3639, 2254, 5034, 436, 6275, 273, 268, 6275, 18, 16411, 12, 2972, 4727, 1769, 203, 3639, 2254, 5034, 268, 14667, 273, 268, 6275, 18, 2892, 12, 6625, 1769, 203, 3639, 2254, 5034, 18305, 14667, 273, 268, 6275, 18, 2892, 12, 6625, 1769, 203, 3639, 309, 16051, 67, 291, 16461, 63, 2867, 12, 2211, 13, 5717, 288, 203, 5411, 389, 291, 16461, 63, 2867, 12, 2211, 25887, 273, 638, 31, 203, 3639, 289, 203, 3639, 309, 261, 318, 291, 91, 438, 58, 22, 8259, 480, 1758, 12, 20, 13, 597, 640, 291, 91, 438, 58, 22, 4154, 480, 1758, 12, 20, 3719, 288, 203, 5411, 2254, 5034, 4501, 372, 24237, 14667, 273, 268, 6275, 18, 2892, 12, 6625, 1769, 203, 5411, 389, 88, 48, 18988, 24237, 5269, 273, 389, 88, 48, 18988, 24237, 5269, 18, 1289, 12, 549, 372, 24237, 14667, 1769, 203, 5411, 389, 88, 5460, 329, 63, 2867, 12, 2211, 25887, 273, 389, 88, 5460, 329, 63, 2867, 12, 2211, 13, 8009, 1289, 12, 549, 372, 24237, 14667, 1769, 203, 5411, 2176, 48, 18988, 24237, 12, 549, 372, 24237, 14667, 1769, 203, 3639, 289, 203, 3639, 2254, 5034, 436, 5912, 6275, 273, 436, 6275, 18, 1717, 12, 86, 14667, 1769, 203, 3639, 2254, 5034, 268, 2 ]
./full_match/4/0xc1CC801664E348E0bC448162A3Ec35AaD665a147/sources/StrainContract.sol
* @dev Returns the Strain for the given strainId/
function getStrain(uint256 _strainId) public view returns ( uint256 strainId, uint256 rarityScore, uint dna, uint[15] memory Genes, uint64 createdTime, uint8 stage, address owner ) { require(_strainId < strains.length + 1, "Invalid StrainId"); uint[15] memory filteredData; Strain storage strain = strains[_strainId]; uint[15] memory data = dnaToArray(strain.dna); filteredData[0] = data[0]; filteredData[1] = data[1]; filteredData[2] = strain.stage >= 1 ? data[2] : 11; filteredData[3] = strain.stage >= 2 ? data[3]: 11; filteredData[4] = strain.stage >= 1 ? data[4]: 11; filteredData[5] = strain.stage >= 2 ? data[5]: 11; filteredData[6] = strain.stage >= 2 ? data[6]: 11; filteredData[7] = strain.stage >= 3 ? data[7]: 11; filteredData[8] = strain.stage >= 3 ? data[8]: 11; filteredData[9] = strain.stage >= 3 ? data[9]: 11; filteredData[10] = strain.stage >= 3 ? data[10]: 11; filteredData[11] = strain.stage >= 3 ? data[11]: 11; filteredData[12] = strain.stage >= 3 ? data[12]: 11; filteredData[13] = strain.stage >= 3 ? data[13]: 11; filteredData[14] = strain.stage >= 3 ? data[14]: 11; Genes = filteredData; dna = strain.dna; strainId = _strainId; createdTime = strain.createdTime; rarityScore = strain.rarityScore; stage = strain.stage; owner = strainToOwner[_strainId]; }
652,018
[ 1, 1356, 326, 3978, 530, 364, 326, 864, 16853, 548, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1322, 9754, 12, 11890, 5034, 389, 27568, 548, 13, 203, 3639, 1071, 203, 3639, 1476, 203, 3639, 1135, 261, 203, 5411, 2254, 5034, 16853, 548, 16, 203, 5411, 2254, 5034, 436, 20498, 7295, 16, 203, 5411, 2254, 31702, 16, 203, 5411, 2254, 63, 3600, 65, 3778, 10938, 281, 16, 203, 5411, 2254, 1105, 2522, 950, 16, 203, 5411, 2254, 28, 6009, 16, 203, 5411, 1758, 3410, 203, 3639, 262, 203, 565, 288, 203, 3639, 2583, 24899, 27568, 548, 411, 609, 4167, 18, 2469, 397, 404, 16, 315, 1941, 3978, 530, 548, 8863, 203, 3639, 2254, 63, 3600, 65, 3778, 5105, 751, 31, 203, 3639, 3978, 530, 2502, 16853, 273, 609, 4167, 63, 67, 27568, 548, 15533, 203, 3639, 2254, 63, 3600, 65, 3778, 501, 273, 31702, 11698, 12, 27568, 18, 5176, 69, 1769, 203, 5411, 5105, 751, 63, 20, 65, 273, 501, 63, 20, 15533, 203, 5411, 5105, 751, 63, 21, 65, 273, 501, 63, 21, 15533, 203, 5411, 5105, 751, 63, 22, 65, 273, 16853, 18, 12869, 1545, 404, 692, 501, 63, 22, 65, 294, 4648, 31, 203, 5411, 5105, 751, 63, 23, 65, 273, 16853, 18, 12869, 1545, 576, 692, 501, 63, 23, 14542, 4648, 31, 203, 5411, 5105, 751, 63, 24, 65, 273, 16853, 18, 12869, 1545, 404, 692, 501, 63, 24, 14542, 4648, 31, 203, 5411, 5105, 751, 63, 25, 65, 273, 16853, 18, 12869, 1545, 576, 692, 501, 63, 25, 14542, 4648, 31, 203, 5411, 5105, 751, 63, 26, 65, 273, 16853, 18, 12869, 1545, 576, 692, 2 ]
// File: contracts/base/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: contracts/base/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: contracts/base/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: contracts/base/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 `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: contracts/base/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: contracts/base/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: contracts/base/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: contracts/base/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: contracts/base/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: contracts/base/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: contracts/base/IERC20Metadata.sol pragma solidity ^0.8.0; 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: contracts/base/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: contracts/base/ERC721A.sol // Creators: locationtba.eth, 2pmflow.eth pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal immutable maxBatchSize; // 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) private _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; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @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 || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @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) { 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 override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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 override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } 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 || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, 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)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @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); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @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(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * 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`. */ 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. * * 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` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: contracts/base/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() { _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: contracts/base/ERC20.sol pragma solidity ^0.8.0; 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: contracts/Punkx.sol //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; //@title A ERC20-token minting and ERC721 staking contract used for Punkx NFT series //@author Ace, Alfa, Anyx, 0xytocin //@notice This contract is used for staking Punkx NFT's and mint Degenz tokens according to the tokenomics mentioned in the whitepaper //@dev All functions are currently working and having the exact value they should have. TESTS ARE YET TO BE DONE. contract test0xytocin is ERC20, Ownable, ReentrancyGuard{ //@Interfaces IERC721 Punkx; //@Times uint public punkXStart; uint public lockoutTime = 10 minutes; uint public dayRate = 5 minutes; //@Rewards mapping(uint=>bool) public mintRewardClaimed; uint[] public rewards = [13,12,11,10]; uint[] public multiplier = [0,0,1,2,3,4,5]; mapping(uint=>uint) externallyClaimed; mapping(address=>bool) isApproved; //@Staking mapping(uint=>stake) public stakedTokens; mapping(address=>uint[]) public userStaked; //@Emergency bool public isPaused; //@notice This is the struct containing the individual information regarding the tokens struct stake{ address tokenOwner; uint lockTime; uint lastClaim; uint stakeTime; uint lockedPieces; uint arrayPosition; } //@notice This takes in PUNKX NFT's contract address and also sets the start-time to block.timestamp constructor(address punkxAddress) ERC20("Oxytocin", "OXY"){ Punkx = IERC721(punkxAddress); punkXStart = block.timestamp; } //@notice SETTERS function deleteRewards () external onlyOwner { rewards.pop(); } function deleteMultiplier () external onlyOwner { multiplier.pop(); } function addMultiplier (uint value) external onlyOwner { multiplier.push(value); } function addRewards (uint value) external onlyOwner { rewards.push(value); } function ownerMint (uint _amount) external onlyOwner { _mint(msg.sender, _amount * 1 ether); } //@getter function getStakedUserTokens(address _query) public view returns (uint[] memory){ return userStaked[_query]; } //@modifiers modifier isNotPaused(){ require(!isPaused,"Execution is paused"); _; } //@notice This function is used to stake tokens //@param uint token-ids are taken in a array format function stakeTokens (uint[] memory tokenIds,bool lock) external isNotPaused{ for (uint i=0;i<tokenIds.length;i++) { require(Punkx.ownerOf(tokenIds[i]) == msg.sender,"Not Owner"); //Can't stake unowned tokens stakedTokens[tokenIds[i]] = stake(msg.sender,0,block.timestamp,block.timestamp,0,userStaked[msg.sender].length); userStaked[msg.sender].push(tokenIds[i]); Punkx.safeTransferFrom(msg.sender,address(this),tokenIds[i]); } if(lock){ require (tokenIds.length > 1,'Min Lock Amount Is 2'); lockInternal(tokenIds); } } //@notice This function is used to lock in the staked function. //@param uint token-ids are taken in an array format. Here the minimum number of tokens passed should be 2. function lockTokens(uint[] memory tokenIds) public isNotPaused{ require (tokenIds.length > 1,'Min Lock Amount Is 2'); claimRewards(tokenIds); lockInternal(tokenIds); } function lockInternal(uint[] memory tokenIds) internal { for(uint i=0;i<tokenIds.length;i++){ stake storage currentToken = stakedTokens[tokenIds[i]]; require(currentToken.tokenOwner == msg.sender,"Only owner can lock"); //Needs to be owner to lock require(block.timestamp - currentToken.lockTime > lockoutTime,"Already locked"); //Need to not be locked to lock currentToken.lockTime = currentToken.lastClaim; tokenIds.length > 6 ? currentToken.lockedPieces = 6 : currentToken.lockedPieces = tokenIds.length ; } } //@notice This function is used to unstake the staked tokens. PS: tokens which are locked cannot be unstaked within lockoutTime of locking period //@param uint token-ids are taken in an array format. function unstakeTokens(uint[] memory tokenIds) external isNotPaused{ claimRewards(tokenIds); for (uint i; i< tokenIds.length; i++) { require(Punkx.ownerOf(tokenIds[i]) == address(this),"Token not staked"); //Needs to not be staked stake storage currentToken = stakedTokens[tokenIds[i]]; require(currentToken.tokenOwner == msg.sender,"Only owner can unstake"); //Needs to be sender's token require(block.timestamp - currentToken.lockTime > lockoutTime,"Not unlocked"); //Needs to be unlocked userStaked[msg.sender][currentToken.arrayPosition] = userStaked[msg.sender][userStaked[msg.sender].length-1]; stakedTokens[userStaked[msg.sender][currentToken.arrayPosition]].arrayPosition = currentToken.arrayPosition; userStaked[msg.sender].pop(); delete stakedTokens[tokenIds[i]]; Punkx.safeTransferFrom(address(this), msg.sender, tokenIds[i]); } } //@notice This function is used to reward those first 22 tokens which were minted before the staking contract was launched //@param uint token-ids are taken in an array format function rewardFromMint(uint[] memory tokenIds) external isNotPaused{ require(block.timestamp - punkXStart > 5 minutes, "It's not birthday yet"); uint totalAmount; for(uint i=0;i<tokenIds.length;i++){ require(tokenIds[i] < 22,"Reward only till 22"); require (Punkx.ownerOf(tokenIds[i])==msg.sender || stakedTokens[tokenIds[i]].tokenOwner == _msgSender()); require(!mintRewardClaimed[tokenIds[i]],"Already Claimed"); mintRewardClaimed[tokenIds[i]] == true; totalAmount += 29*rewards[0]; } _mint(msg.sender,totalAmount*1 ether); } //@notice This function is used to reward those tokens who are staked over 1 day. //@param uint token-ids are taken in an array format function claimRewards(uint[] memory tokenIds) public nonReentrant isNotPaused{ uint totalAmount; for(uint i=0;i<tokenIds.length;i++){ stake storage currentToken = stakedTokens[tokenIds[i]]; require(currentToken.tokenOwner == msg.sender,"Only owner can claim"); //Needs to be sender's token totalAmount += getReward(tokenIds[i]); delete externallyClaimed[tokenIds[i]]; currentToken.lastClaim += ((block.timestamp - currentToken.lastClaim)/ dayRate) * dayRate; } _mint(msg.sender,totalAmount); } //@notice This function is to be used by external contract to claim unclaimed rewards //@param from user from which amount needs to be deducted //@param amount which is to be deducted function claimExternally(address from,uint amount,uint[] memory tokenIds) external isNotPaused{ require(isApproved[msg.sender],"Not approved caller"); uint totalAmount; for(uint i=0;i<tokenIds.length;i++){ stake storage currentToken = stakedTokens[tokenIds[i]]; require(currentToken.tokenOwner == from,"Only owner can lock"); //Needs to be owner to lock uint reward = getReward(tokenIds[i]); if(amount > reward + totalAmount){ externallyClaimed[tokenIds[i]] = reward; totalAmount += reward; } else{ externallyClaimed[tokenIds[i]] = amount - totalAmount; totalAmount = amount; break; } } require(totalAmount == amount,"Not enough DEGEN"); _mint(msg.sender,amount); } //@notice This function is to be used to fetch the unclaimed amount value calculation //@param uint token-id is taken function getReward(uint tokenId) public view returns(uint){ require(Punkx.ownerOf(tokenId) == address(this),"Token not staked"); //Needs to not be staked stake storage currentToken = stakedTokens[tokenId]; uint reward; if(block.timestamp - currentToken.lockTime <= lockoutTime) { //tokenId still in lock period uint timeInDays = (block.timestamp - currentToken.lastClaim)/dayRate; uint combo = currentToken.lockedPieces; reward = 1 ether*timeInDays*rewards[tokenId/22]*(10+multiplier[combo])/10 - externallyClaimed[tokenId]; //Assuming tokenId starts from 1 } else{ uint unlockTime = currentToken.lockTime + lockoutTime; if(block.timestamp > unlockTime && currentToken.lastClaim < unlockTime){ //last claim before lock end but current time after uint timeLocked = (currentToken.lockTime + lockoutTime - currentToken.lastClaim)/dayRate; uint timeUnlocked = (block.timestamp - (currentToken.lockTime + lockoutTime))/dayRate; uint combo = currentToken.lockedPieces; reward = 1 ether*timeLocked*rewards[tokenId/22]*(10+multiplier[combo])/10; reward += 1 ether*timeUnlocked*rewards[tokenId/22]; reward -= externallyClaimed[tokenId]; } else{ //last claim time after lock period uint timeInDays = (block.timestamp - currentToken.lastClaim)/dayRate; reward = 1 ether*timeInDays*rewards[tokenId/22] - externallyClaimed[tokenId]; } } return reward; } function mintExternally(uint _amount) external isNotPaused{ require(isApproved[msg.sender], "Not approved yet"); _mint(_msgSender(), _amount); } function burnExternally(address _from, uint _amount) external isNotPaused{ require(isApproved[msg.sender], "Not approved yet"); _burn(_from, _amount); } function approveAddress(address toBeApproved,bool approveIt) external onlyOwner{ isApproved[toBeApproved] = approveIt; } function pauseExecution(bool pause) external onlyOwner{ isPaused = pause; } function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) public pure returns (bytes4) { return 0x150b7a02; } }
@notice This function is used to unstake the staked tokens. PS: tokens which are locked cannot be unstaked within lockoutTime of locking period@param uint token-ids are taken in an array format.
function unstakeTokens(uint[] memory tokenIds) external isNotPaused{ claimRewards(tokenIds); for (uint i; i< tokenIds.length; i++) { stake storage currentToken = stakedTokens[tokenIds[i]]; userStaked[msg.sender][currentToken.arrayPosition] = userStaked[msg.sender][userStaked[msg.sender].length-1]; stakedTokens[userStaked[msg.sender][currentToken.arrayPosition]].arrayPosition = currentToken.arrayPosition; userStaked[msg.sender].pop(); delete stakedTokens[tokenIds[i]]; Punkx.safeTransferFrom(address(this), msg.sender, tokenIds[i]); } }
6,293,572
[ 1, 2503, 445, 353, 1399, 358, 640, 334, 911, 326, 384, 9477, 2430, 18, 26320, 30, 2430, 1492, 854, 8586, 2780, 506, 640, 334, 9477, 3470, 2176, 659, 950, 434, 18887, 3879, 2254, 1147, 17, 2232, 854, 9830, 316, 392, 526, 740, 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 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 640, 334, 911, 5157, 12, 11890, 8526, 3778, 1147, 2673, 13, 3903, 8827, 28590, 95, 203, 3639, 7516, 17631, 14727, 12, 2316, 2673, 1769, 203, 3639, 364, 261, 11890, 277, 31, 277, 32, 1147, 2673, 18, 2469, 31, 277, 27245, 288, 203, 5411, 384, 911, 2502, 23719, 273, 384, 9477, 5157, 63, 2316, 2673, 63, 77, 13563, 31, 203, 5411, 729, 510, 9477, 63, 3576, 18, 15330, 6362, 2972, 1345, 18, 1126, 2555, 65, 273, 729, 510, 9477, 63, 3576, 18, 15330, 6362, 1355, 510, 9477, 63, 3576, 18, 15330, 8009, 2469, 17, 21, 15533, 203, 5411, 384, 9477, 5157, 63, 1355, 510, 9477, 63, 3576, 18, 15330, 6362, 2972, 1345, 18, 1126, 2555, 65, 8009, 1126, 2555, 273, 23719, 18, 1126, 2555, 31, 203, 5411, 729, 510, 9477, 63, 3576, 18, 15330, 8009, 5120, 5621, 203, 5411, 1430, 384, 9477, 5157, 63, 2316, 2673, 63, 77, 13563, 31, 203, 5411, 453, 1683, 92, 18, 4626, 5912, 1265, 12, 2867, 12, 2211, 3631, 1234, 18, 15330, 16, 1147, 2673, 63, 77, 19226, 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 ]