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
./partial_match/1/0x420D08Dad4fcd7896500d5E183D8BA934c919220/sources/EaselyFixedCollection.sol
@notice Generates a pseudo random number based on arguments with decent entropy @param max The maximum value we want to receive @return A random number less than the max
function _random(uint256 max) internal view returns (uint256) { if (max == 0) { return 0; } uint256 rand = uint256( keccak256( abi.encode( msg.sender, block.difficulty, block.timestamp, blockhash(block.number - 1) ) ) ); return rand % max; }
2,825,437
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 31902, 279, 12454, 2744, 1300, 2511, 603, 1775, 598, 2109, 319, 15943, 632, 891, 943, 1021, 4207, 460, 732, 2545, 358, 6798, 632, 2463, 432, 2744, 1300, 5242, 2353, 326, 943, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 9188, 12, 11890, 5034, 943, 13, 2713, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 309, 261, 1896, 422, 374, 13, 288, 203, 5411, 327, 374, 31, 203, 3639, 289, 203, 203, 3639, 2254, 5034, 5605, 273, 2254, 5034, 12, 203, 5411, 417, 24410, 581, 5034, 12, 203, 7734, 24126, 18, 3015, 12, 203, 10792, 1234, 18, 15330, 16, 203, 10792, 1203, 18, 5413, 21934, 16, 203, 10792, 1203, 18, 5508, 16, 203, 10792, 1203, 2816, 12, 2629, 18, 2696, 300, 404, 13, 203, 7734, 262, 203, 5411, 262, 203, 3639, 11272, 203, 3639, 327, 5605, 738, 943, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/3/0x4fbE4eeC75FB837176c5E0E86683671704AAbd35/sources/contracts/Obscurite.sol
* @param newmaxPurchase The new maximum number of NFT that can be minted per transaction. @dev Sets the new maximum number of NFT purchases per transaction. @dev Can only be called by owner./
function setmaxPurchase(uint256 newmaxPurchase) public onlyOwner { maxPurchase = newmaxPurchase; }
8,164,343
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 891, 394, 1896, 23164, 1021, 394, 4207, 1300, 434, 423, 4464, 716, 848, 506, 312, 474, 329, 1534, 2492, 18, 632, 5206, 11511, 326, 394, 4207, 1300, 434, 423, 4464, 5405, 343, 3304, 1534, 2492, 18, 632, 5206, 4480, 1338, 506, 2566, 635, 3410, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 444, 1896, 23164, 12, 11890, 5034, 394, 1896, 23164, 13, 1071, 1338, 5541, 288, 203, 3639, 943, 23164, 273, 394, 1896, 23164, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: UNLICENSED // Copyright (c) WildCredit - All rights reserved // https://twitter.com/WildCredit pragma solidity 0.8.6; import "TransferHelper.sol"; import "SafeOwnable.sol"; import "IFeeRecipient.sol"; contract FeeRecipient is IFeeRecipient, TransferHelper, SafeOwnable { address public feeConverter; event FeeDistribution(uint amount); modifier onlyConverter() { require(msg.sender == feeConverter, "FeeRecipient: caller is not the converter"); _; } // Push any ERC20 token to FeeConverter function pushToken(address _token, uint _amount) external override onlyConverter { _safeTransfer(_token, feeConverter, _amount); } function setFeeConverter(address _value) external onlyOwner { feeConverter = _value; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "IWETH.sol"; import "IERC20.sol"; import "SafeERC20.sol"; contract TransferHelper { using SafeERC20 for IERC20; // Mainnet IWETH internal constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // Goerli // IWETH internal constant WETH = IWETH(0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6); function _safeTransferFrom(address _token, address _sender, uint _amount) internal { require(_amount > 0, "TransferHelper: amount must be > 0"); IERC20(_token).safeTransferFrom(_sender, address(this), _amount); } function _safeTransfer(address _token, address _recipient, uint _amount) internal { require(_amount > 0, "TransferHelper: amount must be > 0"); IERC20(_token).safeTransfer(_recipient, _amount); } function _wethWithdrawTo(address _to, uint _amount) internal { require(_amount > 0, "TransferHelper: amount must be > 0"); require(_to != address(0), "TransferHelper: invalid recipient"); WETH.withdraw(_amount); (bool success, ) = _to.call { value: _amount }(new bytes(0)); require(success, 'TransferHelper: ETH transfer failed'); } function _depositWeth() internal { require(msg.value > 0, "TransferHelper: amount must be > 0"); WETH.deposit { value: msg.value }(); } } // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.6; import "IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint wad) external; } // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.7.0; interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint256 amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function decimals() external view returns(uint8); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import "IERC20.sol"; import "SafeMath.sol"; import "AddressLibrary.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 AddressLibrary 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.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.2; /** * @dev Collection of functions related to the address type */ library AddressLibrary { /** * @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: UNLICENSED pragma solidity 0.8.6; import "IOwnable.sol"; contract SafeOwnable is IOwnable { uint public constant RENOUNCE_TIMEOUT = 1 hours; address public override owner; address public pendingOwner; uint public renouncedAt; event OwnershipTransferInitiated(address indexed previousOwner, address indexed newOwner); event OwnershipTransferConfirmed(address indexed previousOwner, address indexed newOwner); constructor() { owner = msg.sender; emit OwnershipTransferConfirmed(address(0), msg.sender); } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return msg.sender == owner; } function transferOwnership(address _newOwner) external override onlyOwner { require(_newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferInitiated(owner, _newOwner); pendingOwner = _newOwner; } function acceptOwnership() external override { require(msg.sender == pendingOwner, "Ownable: caller is not pending owner"); emit OwnershipTransferConfirmed(msg.sender, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } function initiateRenounceOwnership() external onlyOwner { require(renouncedAt == 0, "Ownable: already initiated"); renouncedAt = block.timestamp; } function acceptRenounceOwnership() external onlyOwner { require(renouncedAt > 0, "Ownable: not initiated"); require(block.timestamp - renouncedAt > RENOUNCE_TIMEOUT, "Ownable: too early"); owner = address(0); pendingOwner = address(0); renouncedAt = 0; } function cancelRenounceOwnership() external onlyOwner { require(renouncedAt > 0, "Ownable: not initiated"); renouncedAt = 0; } } // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.6; interface IOwnable { function owner() external view returns(address); function transferOwnership(address _newOwner) external; function acceptOwnership() external; } // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.6; interface IFeeRecipient { function pushToken(address _token, uint _amount) external; }
Push any ERC20 token to FeeConverter
function pushToken(address _token, uint _amount) external override onlyConverter { _safeTransfer(_token, feeConverter, _amount); }
1,367,281
[ 1, 4625, 348, 7953, 560, 30, 225, 8547, 1281, 4232, 39, 3462, 1147, 358, 30174, 5072, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 1817, 1345, 12, 2867, 389, 2316, 16, 2254, 389, 8949, 13, 3903, 3849, 1338, 5072, 288, 203, 565, 389, 4626, 5912, 24899, 2316, 16, 14036, 5072, 16, 389, 8949, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/7001/0x40aF9F5720d7C573d06F9D2003Aa1d7dD60eD97B/sources/contracts/Bitsave.sol
********------ Constants ------********
string public constant JON = "JON";
13,228,882
[ 1, 4625, 348, 7953, 560, 30, 225, 380, 27243, 13093, 5245, 31913, 1644, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 533, 1071, 5381, 804, 673, 273, 315, 46, 673, 14432, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.24; contract RSEvents { // fired whenever a player registers a name event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); // fired at end of buy or reload event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); // fired whenever theres a withdraw event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); // fired whenever a withdraw forces end round to be ran event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 genAmount ); // fired whenever a player tries a buy after round timer // hit zero, and causes end round to be ran. event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 genAmount ); // fired whenever a player tries a reload after round timer // hit zero, and causes end round to be ran. event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 genAmount ); // fired whenever an affiliate is paid event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); } contract modularLastUnicorn is RSEvents {} contract LastUnicorn is modularLastUnicorn { using SafeMath for *; using NameFilter for string; using RSKeysCalc for uint256; // TODO: check address UnicornInterfaceForForwarder constant private TeamUnicorn = UnicornInterfaceForForwarder(0xBB14004A6f3D15945B3786012E00D9358c63c92a); UnicornBookInterface constant private UnicornBook = UnicornBookInterface(0x98547788f328e1011065E4068A8D72bacA1DDB49); string constant public name = "LastUnicorn Round #1"; string constant public symbol = "RS1"; uint256 private rndGap_ = 0; // TODO: check time uint256 constant private rndInit_ = 1 hours; // round timer starts at this uint256 constant private rndInc_ = 30 seconds; // every full key purchased adds this much to the timer uint256 constant private rndMax_ = 24 hours; // max length a round timer can be //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public airDropPot_; // person who gets the airdrop wins part of this pot uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => RSdatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => RSdatasets.PlayerRounds) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** RSdatasets.Round public round_; // round data //**************** // TEAM FEE DATA //**************** uint256 public fees_ = 60; // fee distribution uint256 public potSplit_ = 45; // pot split distribution //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true, "its not ready yet"); _; } /** * @dev prevents contracts from interacting with LastUnicorn */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "non smart contract address only"); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "too little money"); require(_eth <= 100000000000000000000000, "too much money"); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID and team snek */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, _eventData_); } /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee */ function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // buy core buyCore(_pID, _affCode, _eventData_); } function buyXaddr(address _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } function buyXname(bytes32 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data RSdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // reload core reLoadCore(_pID, _affCode, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data RSdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data RSdatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_.end && round_.ended == false && round_.plyr != 0) { // set up our tx event data RSdatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_.ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit RSEvents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit RSEvents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = UnicornBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = UnicornBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = UnicornBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; // fire event emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) return ( (round_.keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else // rounds over. need price for new round return ( 75000000000000 ); // init } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // grab time uint256 _now = now; if (_now < round_.end) if (_now > round_.strt + rndGap_) return( (round_.end).sub(_now) ); else return( (round_.strt + rndGap_).sub(_now)); else return(0); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_.end && round_.ended == false && round_.plyr != 0) { // if player is winner if (round_.plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_.pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID).sub(plyrRnds_[_pID].mask) ), plyr_[_pID].aff ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID).sub(plyrRnds_[_pID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ function getPlayerVaultsHelper(uint256 _pID) private view returns(uint256) { return( ((((round_.mask).add(((((round_.pot).mul(potSplit_)) / 100).mul(1000000000000000000)) / (round_.keys))).mul(plyrRnds_[_pID].keys)) / 1000000000000000000) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return total keys * @return time ends * @return time started * @return current pot * @return current player ID in lead * @return current player in leads address * @return current player in leads name * @return airdrop tracker # & airdrop pot */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256) { return ( round_.keys, //0 round_.end, //1 round_.strt, //2 round_.pot, //3 round_.plyr, //4 plyr_[round_.plyr].addr, //5 plyr_[round_.plyr].name, //6 airDropTracker_ + (airDropPot_ * 1000) //7 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, RSdatasets.EventReturns memory _eventData_) private { // grab time uint256 _now = now; // if round is active if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) { // call core core(_pID, msg.value, _affID, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_.end && round_.ended == false) { // end the round (distributes pot) & start new round round_.ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit RSEvents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, RSdatasets.EventReturns memory _eventData_) private { // grab time uint256 _now = now; // if round is active if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_pID, _eth, _affID, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_.end && round_.ended == false) { // end the round (distributes pot) & start new round round_.ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit RSEvents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_) private { // if player is new to round if (plyrRnds_[_pID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // early round eth limiter if (round_.eth < 100000000000000000000 && plyrRnds_[_pID].eth.add(_eth) > 10000000000000000000) { uint256 _availableLimit = (10000000000000000000).sub(plyrRnds_[_pID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } // if eth left is greater than min eth allowed (sorry no pocket lint) if (_eth > 1000000000) { // mint the new keys uint256 _keys = (round_.eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys); // set new leaders if (round_.plyr != _pID) round_.plyr = _pID; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // manage airdrops if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { // gib muni uint256 _prize; if (_eth >= 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 3 prize was won _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 2 prize was won _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { // calculate prize and give it to winner _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); // adjust airDropPot airDropPot_ = (airDropPot_).sub(_prize); // let event know a tier 1 prize was won _eventData_.compressedData += 100000000000000000000000000000000; } // set airdrop happened bool to true _eventData_.compressedData += 10000000000000000000000000000000; // let event know how much was won _eventData_.compressedData += _prize * 1000000000000000000000000000000000; // reset air drop tracker airDropTracker_ = 0; } } // store the air drop tracker number (number of buys since last airdrop) _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); // update player plyrRnds_[_pID].keys = _keys.add(plyrRnds_[_pID].keys); plyrRnds_[_pID].eth = _eth.add(plyrRnds_[_pID].eth); // update round round_.keys = _keys.add(round_.keys); round_.eth = _eth.add(round_.eth); // distribute eth _eventData_ = distributeExternal(_pID, _eth, _affID, _eventData_); _eventData_ = distributeInternal(_pID, _eth, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, _eth, _keys, _eventData_); } } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ function calcUnMaskedEarnings(uint256 _pID) private view returns(uint256) { return((((round_.mask).mul(plyrRnds_[_pID].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID].mask)); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) return ( (round_.eth).keysRec(_eth) ); else // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) return ( (round_.keys.add(_keys)).ethRec(_keys) ); else // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(UnicornBook), "only UnicornBook can call this function"); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(UnicornBook), "only UnicornBook can call this function"); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(RSdatasets.EventReturns memory _eventData_) private returns (RSdatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of LastUnicorn if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = UnicornBook.getPlayerID(msg.sender); bytes32 _name = UnicornBook.getPlayerName(_pID); uint256 _laff = UnicornBook.getPlayerLAff(_pID); // set up player account pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, RSdatasets.EventReturns memory _eventData_) private returns (RSdatasets.EventReturns) { // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(RSdatasets.EventReturns memory _eventData_) private returns (RSdatasets.EventReturns) { // grab our winning player and team id's uint256 _winPID = round_.plyr; // grab our pot amount // add airdrop pot into the final pot uint256 _pot = round_.pot + airDropPot_; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(45)) / 100; uint256 _com = (_pot / 10); uint256 _gen = (_pot.mul(potSplit_)) / 100; // calculate ppt for round mask uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_.keys); uint256 _dust = _gen.sub((_ppt.mul(round_.keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _com = _com.add(_dust); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards if (!address(TeamUnicorn).call.value(_com)(bytes4(keccak256("deposit()")))) { _gen = _gen.add(_com); _com = 0; } // distribute gen portion to key holders round_.mask = _ppt.add(round_.mask); // prepare event data _eventData_.compressedData = _eventData_.compressedData + (round_.end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.newPot = 0; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID) private { uint256 _earnings = calcUnMaskedEarnings(_pID); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID].mask = _earnings.add(plyrRnds_[_pID].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys) private { // grab time uint256 _now = now; // calculate time based on number of keys bought uint256 _newTime; if (_now > round_.end && round_.plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_.end); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_.end = _newTime; else round_.end = rndMax_.add(_now); } /** * @dev generates a random number between 0-99 and checks to see if thats * resulted in an airdrop win * @return do we have a winner? */ function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } /** * @dev distributes eth based on fees to com, aff, and p3d */ function distributeExternal(uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_) private returns(RSdatasets.EventReturns) { // pay 5% out to community rewards uint256 _com = _eth * 5 / 100; // distribute share to affiliate uint256 _aff = _eth / 10; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit RSEvents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _pID, _aff, now); } else { // no affiliates, add to community _com += _aff; } if (!address(TeamUnicorn).call.value(_com)(bytes4(keccak256("deposit()")))) { // This ensures TeamUnicorn cannot influence the outcome // bank migrations by breaking outgoing transactions. } return(_eventData_); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _pID, uint256 _eth, uint256 _keys, RSdatasets.EventReturns memory _eventData_) private returns(RSdatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_)) / 100; // toss 5% into airdrop pot uint256 _air = (_eth / 20); airDropPot_ = airDropPot_.add(_air); // calculate pot (20%) uint256 _pot = (_eth.mul(20) / 100); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_.pot = _pot.add(_dust).add(round_.pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_.keys); round_.mask = _ppt.add(round_.mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID].mask = (((round_.mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_.keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID); // from vaults uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _eth, uint256 _keys, RSdatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit RSEvents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only owner can activate // TODO: set owner require( (msg.sender == 0xcD0fce8d255349092496F131f2900DF25f0569F8), "only owner can activate" ); // can only be ran once require(activated_ == false, "LastUnicorn already activated"); // activate the contract activated_ = true; round_.strt = now - rndGap_; round_.end = now + rndInit_; } } //============================================================================== // __|_ _ __|_ _ . // _\ | | |_|(_ | _\ . //============================================================================== library RSdatasets { //compressedData key // [76-33][32][31][30][29][28-18][17][16-6][5-3][2][1][0] // 0 - new player (bool) // 1 - joined round (bool) // 2 - new leader (bool) // 3-5 - air drop tracker (uint 0-999) // 6-16 - round end time // 17 - winnerTeam // 18 - 28 timestamp // 29 - team // 30 - 0 = reinvest (round), 1 = buy (round), 2 = buy (ico), 3 = reinvest (ico) // 31 - airdrop happened bool // 32 - airdrop tier // 33 - airdrop amount won //compressedIDs key // [77-52][51-26][25-0] // 0-25 - pID // 26-51 - winPID // 52-77 - rID struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new pot uint256 genAmount; // amount distributed to gen uint256 potAmount; // amount added to pot } struct Player { address addr; // player address bytes32 name; // player name uint256 win; // winnings vault uint256 gen; // general vault uint256 aff; // affiliate vault uint256 laff; // last affiliate id used } struct PlayerRounds { uint256 eth; // eth player has added to round (used for eth limiter) uint256 keys; // keys uint256 mask; // player mask } struct Round { uint256 plyr; // pID of player in lead uint256 end; // time ends/ended bool ended; // has round end function been ran uint256 strt; // time round started uint256 keys; // keys uint256 eth; // total eth in uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends) uint256 mask; // global mask } } //============================================================================== // | _ _ _ | _ . // |<(/_\/ (_(_||(_ . //=======/====================================================================== library RSKeysCalc { using SafeMath for *; /** * @dev calculates number of keys received given X eth * @param _curEth current amount of eth in contract * @param _newEth eth being spent * @return amount of ticket purchased */ function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } /** * @dev calculates amount of eth received if you sold X keys * @param _curKeys current amount of keys that exist * @param _sellKeys amount of keys you wish to sell * @return amount of eth received */ function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } /** * @dev calculates how many keys would exist with given an amount of eth * @param _eth eth "in contract" * @return number of keys that would exist */ function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } /** * @dev calculates how much eth would be in contract given a number of keys * @param _keys number of keys "in contract" * @return eth that would exists */ function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } interface UnicornInterfaceForForwarder { function deposit() external payable returns(bool); } interface UnicornBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { /** * @dev filters name strings * -converts uppercase to lower case. * -makes sure it does not start/end with a space * -makes sure it does not contain multiple spaces in a row * -cannot be only numbers * -cannot start with 0x * -restricts characters to A-Z, a-z, 0-9, and space. * @return reprocessed string in bytes32 format */ function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; //sorry limited to 32 characters require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); // make sure it doesnt start with or end with space require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); // make sure first two characters are not 0x if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } // create a bool to track if we have a non number character bool _hasNonNumber; // convert & check for (uint256 i = 0; i < _length; i++) { // if its uppercase A-Z if (_temp[i] > 0x40 && _temp[i] < 0x5b) { // convert to lower case a-z _temp[i] = byte(uint(_temp[i]) + 32); // we have a non number if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( // require character is a space _temp[i] == 0x20 || // OR lowercase a-z (_temp[i] > 0x60 && _temp[i] < 0x7b) || // or 0-9 (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); // make sure theres not 2x spaces in a row if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); // see if we have a character other than a number if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } /** * @title SafeMath v0.1.9 * @dev Math operations with safety checks that throw on error * change notes: original SafeMath library from OpenZeppelin modified by Inventor * - added sqrt * - added sq * - changed asserts to requires with error log outputs * - removed div, its useless */ 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; } /** * @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)); } }
distribute gen portion to key holders
round_.mask = _ppt.add(round_.mask);
533,584
[ 1, 4625, 348, 7953, 560, 30, 225, 25722, 3157, 14769, 358, 498, 366, 4665, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 3643, 27799, 4455, 273, 389, 84, 337, 18, 1289, 12, 2260, 27799, 4455, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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: No License // File: 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 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. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * 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: 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: utils/structs/EnumerableMap.sol pragma solidity ^0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping (bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (_contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), errorMessage); return value; } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // File: utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = "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] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: 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) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: 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 () { 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; } } // File: 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; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: 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: 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: 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: 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: token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: 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: 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: token/ERC721/MerkleListNFT.sol pragma solidity ^0.8.0; /** * @dev Once a coby, always a coby */ contract MerkleAllowableRegisterV2 is Context, ERC165, IERC721, IERC721Metadata, Ownable, IERC721Enumerable { using Address for address; using SafeMath for uint256; using Strings for uint256; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; string private _name; string private _desc; bytes public _imageprefix; bytes public _imagemid; bytes public _imagesuffix; string private _symbol; address private _owner; uint256 public price; bool public sale; // 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; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _balances; // Mapping from holder address to their (enumerable) set of owned tokens EnumerableMap.UintToAddressMap private _tokenHolders; // Merkle Token Data mapping (uint256 => address) private contractAddresses; mapping (uint256 => bytes32) private merkleRoots; mapping (uint256 => bytes) private claimedBitMaps; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor () { _name = "Merkle Lists"; _symbol = "MRK"; _owner = _msgSender(); price = 0; sale = false; // Mint Genesis List to Owner _mint(msg.sender, 0); // Set token _imageprefix = ''; _imagemid = ''; _imagesuffix = ''; _desc = ''; } /** * @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) public pure returns (bool) { 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 = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } function claimBalanceOf(uint256 tokenId_, uint256 index) public view returns (uint256 ) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); return uint256(uint8(claimedBitMaps[tokenId_][index])); } function setList(uint256 tokenId_, address contractAddress_, bytes32 merkleRoot_, bytes calldata claimedBitMap_) public returns (address, bytes32, bytes memory) { require(msg.sender == MerkleAllowableRegisterV2.ownerOf(tokenId_), "Not allowed to operate on this token."); require(claimedBitMap_.length <= 8192, "Exceeds max list size."); contractAddresses[tokenId_]=contractAddress_; merkleRoots[tokenId_]=merkleRoot_; claimedBitMaps[tokenId_]=claimedBitMap_; return (contractAddresses[tokenId_], merkleRoots[tokenId_], claimedBitMaps[tokenId_]); } function totalBalances(uint256 tokenId_) public view returns (uint256) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); return claimedBitMaps[tokenId_].length; } function _setClaimed(uint256 tokenId_, uint256 index, uint256 amount) internal { uint8 number = uint8(claimBalanceOf(tokenId_,index).sub(amount)); claimedBitMaps[tokenId_][index]=bytes1(number); } function claim(uint256 tokenId_, address claimee_, uint256 index, uint256 amount, bytes32[] calldata merkleProof) external { require(claimBalanceOf(tokenId_, index).sub(amount)>=0, 'MerkleDistributor: Greedy fuck.'); require(contractAddresses[tokenId_] == msg.sender, 'Sender is not the address defined.'); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, claimee_)); require(verify(merkleProof, merkleRoots[tokenId_], node), 'MerkleDistributor: Invalid proof.'); // Mark it claimed and send the token. _setClaimed(tokenId_, index, amount); } function withdraw(uint256 amount_) onlyOwner external { payable(_owner).transfer(amount_); } function getEthBalance() public view returns (uint256) { return address(this).balance; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override (ERC165, IERC165) returns (bool) { // ERC165 == 0x01ffc9a7 // ERC721 == 0x80ac58cd // ERC721_METADATA == 0x5b5e139f // ERC721_ENUMERABLE == 0x780e9d63 if( (interfaceId == 0x01ffc9a7 ) || (interfaceId == 0x80ac58cd) || (interfaceId == 0x5b5e139f) || (interfaceId == 0x780e9d63) ) { return true; } else { return false; } } /** * @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].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenHolders.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } function totalSupply() external view override returns (uint256) { return _tokenHolders.length(); } function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < MerkleAllowableRegisterV2.balanceOf(owner), "Owner index out of bounds"); return _balances[owner].at(index); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < _tokenHolders.length(), "Global index out of bounds"); (uint256 tokenId, ) = _tokenHolders.at(index); return tokenId; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } function mint() payable public { require(sale == true, "Sale has not begun"); require(price == msg.value, "Ether value sent is not correct"); uint256 tokenId_ = _tokenHolders.length(); _safeMint(msg.sender, tokenId_); } function getContractAddress(uint256 tokenId_) public view returns (address) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); return contractAddresses[tokenId_]; } function getMerkleRoot(uint256 tokenId_) public view returns (bytes32) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); return merkleRoots[tokenId_]; } function getClaimedBitMap(uint256 tokenId_) public view returns (bytes memory) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); return claimedBitMaps[tokenId_]; } function tokenURI(uint256 tokenId_) override public view returns (string memory) { require(_exists(tokenId_), "ERC721: approved query for nonexistent token"); string[3] memory parts; parts[0] = toString(getContractAddress(tokenId_)); parts[1] = toString(getMerkleRoot(tokenId_)); parts[2] = toString(getClaimedBitMap(tokenId_)); string memory output = string(abi.encodePacked(_imageprefix, parts[0], _imagemid, parts[1], _imagesuffix)); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name":"', _name, ' #', toString(tokenId_), '", "description":"', _desc, '" , "attributes": [{"trait_type": "Contract Address", "value":"', parts[0], '"}, {"trait_type":"Merkle Root", "value":"', parts[1], '"}, {"display_type": "number", "trait_type":"Balances", "value":"', parts[2], '"}], "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}')))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function toString(bytes32 value) public pure returns(string memory) { return toString(abi.encodePacked(value)); } function toString(address account) public pure returns(string memory) { return toString(abi.encodePacked(account)); } function toString(bytes memory data) public pure returns(string memory) { bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(2 + data.length * 2); str[0] = "0"; str[1] = "x"; for (uint i = 0; i < data.length; i++) { str[2+i*2] = alphabet[uint(uint8(data[i] >> 4))]; str[3+i*2] = alphabet[uint(uint8(data[i] & 0x0f))]; } return string(str); } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // 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); } function setTokenMetadata(string memory desc_, bytes calldata imageprefix_, bytes calldata imagemid_, bytes calldata imagesuffix_) public onlyOwner returns (string memory, bytes memory, bytes memory, bytes memory) { _desc = desc_; _imageprefix = imageprefix_; _imagemid = imagemid_; _imagesuffix = imagesuffix_; return (_desc, imageprefix_, imagemid_, imagesuffix_); } function setSale(bool toggle_) public onlyOwner returns (bool) { sale = toggle_; return sale; } function setPrice(uint256 price_) public onlyOwner returns (uint256) { price = price_; return price; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = MerkleAllowableRegisterV2.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 _tokenHolders.contains(tokenId); } /** * @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 = MerkleAllowableRegisterV2.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } 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].add(tokenId); _tokenHolders.set(tokenId, to); emit Transfer(address(0), to, 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(MerkleAllowableRegisterV2.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].remove(tokenId); _balances[to].add(tokenId); _tokenHolders.set(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(MerkleAllowableRegisterV2.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { // solhint-disable-next-line no-inline-assembly 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 { } } /// [MIT License] /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
* @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./ Clear approvals from the previous owner
function _transfer(address from, address to, uint256 tokenId) internal virtual { require(MerkleAllowableRegisterV2.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); _approve(address(0), tokenId); _balances[from].remove(tokenId); _balances[to].add(tokenId); _tokenHolders.set(tokenId, to); emit Transfer(from, to, tokenId); }
5,944,010
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2604, 18881, 1375, 2316, 548, 68, 628, 1375, 2080, 68, 358, 1375, 869, 8338, 225, 2970, 1061, 7423, 358, 288, 13866, 1265, 5779, 333, 709, 10522, 1158, 17499, 603, 1234, 18, 15330, 18, 29076, 30, 300, 1375, 869, 68, 2780, 506, 326, 3634, 1758, 18, 300, 1375, 2316, 548, 68, 1147, 1297, 506, 16199, 635, 1375, 2080, 8338, 7377, 1282, 279, 288, 5912, 97, 871, 18, 19, 10121, 6617, 4524, 628, 326, 2416, 3410, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 13866, 12, 2867, 628, 16, 1758, 358, 16, 2254, 5034, 1147, 548, 13, 2713, 5024, 288, 203, 3639, 2583, 12, 8478, 15609, 31508, 3996, 58, 22, 18, 8443, 951, 12, 2316, 548, 13, 422, 628, 16, 315, 654, 39, 27, 5340, 30, 7412, 434, 1147, 716, 353, 486, 4953, 8863, 203, 3639, 2583, 12, 869, 480, 1758, 12, 20, 3631, 315, 654, 39, 27, 5340, 30, 7412, 358, 326, 3634, 1758, 8863, 203, 203, 3639, 389, 5771, 1345, 5912, 12, 2080, 16, 358, 16, 1147, 548, 1769, 203, 203, 3639, 389, 12908, 537, 12, 2867, 12, 20, 3631, 1147, 548, 1769, 203, 203, 3639, 389, 70, 26488, 63, 2080, 8009, 4479, 12, 2316, 548, 1769, 203, 3639, 389, 70, 26488, 63, 869, 8009, 1289, 12, 2316, 548, 1769, 203, 3639, 389, 2316, 27003, 18, 542, 12, 2316, 548, 16, 358, 1769, 203, 203, 3639, 3626, 12279, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/43114/0xD7c45c551A8dB06c2a30dAa75Ef09c5d655975F6/sources/contracts/AvaX.sol
Token InfoDivider for the buyLimit based on circulating Supply (1%)Divider for the MaxBalance based on circulating Supply (1.5%)Divider for the Whitelist MaxBalance based on initial Supply(1.5%)Divider for sellLimit based on circulating Supply (0.75%)Sellers get locked for MaxSellLockTime so they can't dump repeatedly Team walletsTODO: Change to MainnetTestNetaddress private constant JOERouter=0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3;MainNet 0x10ED43C718714eb63d5aA57B78B54704E256024Evariables that track balanceLimit and sellLimit,can be updated based on circulating supply and Sell- and BalanceLimitDividersLimits max tax, only gets applied for tax changes, doesn't affect inital TaxTracks the current Taxes, different Taxes can be applied for buy/sell/transfermodifier for functions only the team can call
{ using Address for address; using EnumerableSet for EnumerableSet.AddressSet; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => uint256) private _sellLock; mapping (address => bool) public wListed; EnumerableSet.AddressSet private _excluded; EnumerableSet.AddressSet private _whiteList; EnumerableSet.AddressSet private _excludedFromSellLock; mapping (address => bool) public _blacklist; bool isBlacklist = true; string private constant _name = 'Ravax'; string private constant _symbol = 'Ravax'; uint8 private constant _decimals = 9; uint256 swapLimit = 1 * 10**5 * 10**_decimals; bool isSwapPegged = true; uint16 public constant BuyLimitDivider=50; uint8 public constant BalanceLimitDivider=50; uint16 public constant WhiteListBalanceLimitDivider=50; uint16 public constant SellLimitDivider=50; uint16 public constant MaxSellLockTime= 2 seconds; address public constant TeamWallet=0xD32060Db00a731516B9aAa6555F06c569E1ee256; address public constant SecondTeamWallet=0xD32060Db00a731516B9aAa6555F06c569E1ee256; address payable private baller=payable(owner()); address private constant JOERouter=0x60aE616a2155Ee3d9A68541Ba4544862310933d4; uint256 private _circulatingSupply =InitialSupply; uint256 public balanceLimit = _circulatingSupply; uint256 public sellLimit = _circulatingSupply; uint256 public buyLimit = _circulatingSupply; address[] public triedToDump; uint8 public constant MaxTax=95; uint8 private _buyTax; uint8 private _sellTax; uint8 private _transferTax; bool botRekt = true; uint8 private _burnTax; uint8 private _liquidityTax; uint8 private _marketingTax; bool isTokenSwapManual = true; address private _JOEPairAddress; IJOERouter02 private _JOERouter; modifier onlyTeam() { require(_isTeam(msg.sender), "Caller not in Team"); _; } function _isTeam(address addr) private view returns (bool){ return addr==owner()||addr==TeamWallet||addr==SecondTeamWallet; } constructor () { uint256 deployerBalance=_circulatingSupply*9/10; _balances[msg.sender] = deployerBalance; emit Transfer(address(0), msg.sender, deployerBalance); uint256 injectBalance=_circulatingSupply-deployerBalance; _balances[address(this)]=injectBalance; emit Transfer(address(0), address(this),injectBalance); _JOERouter = IJOERouter02(JOERouter); _JOEPairAddress = IJOEFactory(_JOERouter.factory()).createPair(address(this), _JOERouter.WAVAX()); balanceLimit=InitialSupply/BalanceLimitDivider; sellLimit=InitialSupply/SellLimitDivider; buyLimit=InitialSupply/BuyLimitDivider; sellLockTime=2 seconds; _buyTax=10; _sellTax=10; _transferTax=10; _liquidityTax=1; _marketingTax=99; _excluded.add(TeamWallet); _excluded.add(SecondTeamWallet); _excluded.add(msg.sender); _excludedFromSellLock.add(address(_JOERouter)); _excludedFromSellLock.add(_JOEPairAddress); _excludedFromSellLock.add(address(this)); } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _transfer(address sender, address recipient, uint256 amount) private{ require(sender != address(0), "Transfer from zero"); require(recipient != address(0), "Transfer to zero"); bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient)); bool isContractTransfer=(sender==address(this) || recipient==address(this)); address JOERouter=address(_JOERouter); bool isLiquidityTransfer = ((sender == _JOEPairAddress && recipient == JOERouter) || (recipient == _JOEPairAddress && sender == JOERouter)); bool isBuy=sender==_JOEPairAddress|| sender == JOERouter; bool isSell=recipient==_JOEPairAddress|| recipient == JOERouter; if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); } else{ if (!tradingEnabled) { if (sender != owner() && recipient != owner()) { if (!wListed[sender] && !wListed[recipient]) { require(tradingEnabled,"trading not yet enabled"); } } } else{ _taxedTransfer(sender,recipient,amount,isBuy,isSell); } } } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(isBlacklist) { require(!_blacklist[sender]); } if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } if(amount>sellLimit) { triedToDump.push(sender); } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; require(amount<=buyLimit, "whale protection"); tax=_buyTax; require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } _swapContractToken(amount); emit Transfer(sender,recipient,taxedAmount); } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(isBlacklist) { require(!_blacklist[sender]); } if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } if(amount>sellLimit) { triedToDump.push(sender); } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; require(amount<=buyLimit, "whale protection"); tax=_buyTax; require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } _swapContractToken(amount); emit Transfer(sender,recipient,taxedAmount); } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(isBlacklist) { require(!_blacklist[sender]); } if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } if(amount>sellLimit) { triedToDump.push(sender); } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; require(amount<=buyLimit, "whale protection"); tax=_buyTax; require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } _swapContractToken(amount); emit Transfer(sender,recipient,taxedAmount); } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(isBlacklist) { require(!_blacklist[sender]); } if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } if(amount>sellLimit) { triedToDump.push(sender); } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; require(amount<=buyLimit, "whale protection"); tax=_buyTax; require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } _swapContractToken(amount); emit Transfer(sender,recipient,taxedAmount); } function _taxedTransfer(address sender, address recipient, uint256 amount,bool isBuy,bool isSell) private{ uint256 recipientBalance = _balances[recipient]; uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); swapLimit = sellLimit/2; uint8 tax; if(isSell){ if(isBlacklist) { require(!_blacklist[sender]); } if(!_excludedFromSellLock.contains(sender)){ require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Seller in sellLock"); _sellLock[sender]=block.timestamp+sellLockTime; } if(amount>sellLimit) { triedToDump.push(sender); } require(amount<=sellLimit,"Dump protection"); tax=_sellTax; require(amount<=buyLimit, "whale protection"); tax=_buyTax; require(_sellLock[sender]<=block.timestamp||sellLockDisabled,"Sender in Lock"); tax=_transferTax; } _swapContractToken(amount); emit Transfer(sender,recipient,taxedAmount); } } else if(isBuy){ require(recipientBalance+amount<=balanceLimit,"whale protection"); require(recipientBalance+amount<=balanceLimit,"whale protection"); if(!_excludedFromSellLock.contains(sender)) if((sender!=_JOEPairAddress)&&(!manualConversion)&&(!_isSwappingContractModifier)) uint256 contractToken=_calculateFee(amount, tax, _marketingTax+_liquidityTax); uint256 taxedAmount=amount-(contractToken); _removeToken(sender,amount); _balances[address(this)] += contractToken; _addToken(recipient, taxedAmount); function _feelessTransfer(address sender, address recipient, uint256 amount) private{ uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer exceeds balance"); _removeToken(sender,amount); _addToken(recipient, amount); emit Transfer(sender,recipient,amount); } function _calculateFee(uint256 amount, uint8 tax, uint8 taxPercent) private pure returns (uint256) { return (amount*tax*taxPercent) / 10000; } function _addToken(address addr, uint256 amount) private { uint256 newAmount=_balances[addr]+amount; _balances[addr]=newAmount; } function _removeToken(address addr, uint256 amount) private { uint256 newAmount=_balances[addr]-amount; _balances[addr]=newAmount; } uint256 dshare=10; bool private _isTokenSwaping; uint256 public totalTokenSwapGenerated; uint256 public totalPayouts; uint8 public marketingShare=100; uint256 public marketingBalance; mapping(address => uint256) private toBePaid; function _distributeFeesAVAX(uint256 AVAXamount) private { uint256 marketingSplit = (AVAXamount * marketingShare) / 100; marketingBalance+=marketingSplit; } uint256 public totalLPAVAX; bool private _isSwappingContractModifier; modifier lockTheSwap { _isSwappingContractModifier = true; _; _isSwappingContractModifier = false; } function _swapContractToken(uint256 totalMax) private lockTheSwap{ uint256 contractBalance=_balances[address(this)]; uint16 totalTax=_liquidityTax+_marketingTax; uint256 tokenToSwap=swapLimit; if(tokenToSwap > totalMax) { if(isSwapPegged) { tokenToSwap = totalMax; } } if(contractBalance<tokenToSwap||totalTax==0){ return; } uint256 tokenForMarketing= tokenToSwap-tokenForLiquidity; uint256 liqAVAXToken=tokenForLiquidity-liqToken; _swapTokenForAVAX(swapToken); uint256 newAVAX=(address(this).balance - initialAVAXBalance); _addLiquidity(liqToken, liqAVAX); } function _swapContractToken(uint256 totalMax) private lockTheSwap{ uint256 contractBalance=_balances[address(this)]; uint16 totalTax=_liquidityTax+_marketingTax; uint256 tokenToSwap=swapLimit; if(tokenToSwap > totalMax) { if(isSwapPegged) { tokenToSwap = totalMax; } } if(contractBalance<tokenToSwap||totalTax==0){ return; } uint256 tokenForMarketing= tokenToSwap-tokenForLiquidity; uint256 liqAVAXToken=tokenForLiquidity-liqToken; _swapTokenForAVAX(swapToken); uint256 newAVAX=(address(this).balance - initialAVAXBalance); _addLiquidity(liqToken, liqAVAX); } function _swapContractToken(uint256 totalMax) private lockTheSwap{ uint256 contractBalance=_balances[address(this)]; uint16 totalTax=_liquidityTax+_marketingTax; uint256 tokenToSwap=swapLimit; if(tokenToSwap > totalMax) { if(isSwapPegged) { tokenToSwap = totalMax; } } if(contractBalance<tokenToSwap||totalTax==0){ return; } uint256 tokenForMarketing= tokenToSwap-tokenForLiquidity; uint256 liqAVAXToken=tokenForLiquidity-liqToken; _swapTokenForAVAX(swapToken); uint256 newAVAX=(address(this).balance - initialAVAXBalance); _addLiquidity(liqToken, liqAVAX); } function _swapContractToken(uint256 totalMax) private lockTheSwap{ uint256 contractBalance=_balances[address(this)]; uint16 totalTax=_liquidityTax+_marketingTax; uint256 tokenToSwap=swapLimit; if(tokenToSwap > totalMax) { if(isSwapPegged) { tokenToSwap = totalMax; } } if(contractBalance<tokenToSwap||totalTax==0){ return; } uint256 tokenForMarketing= tokenToSwap-tokenForLiquidity; uint256 liqAVAXToken=tokenForLiquidity-liqToken; _swapTokenForAVAX(swapToken); uint256 newAVAX=(address(this).balance - initialAVAXBalance); _addLiquidity(liqToken, liqAVAX); } uint256 tokenForLiquidity=(tokenToSwap*_liquidityTax)/totalTax; uint256 liqToken=tokenForLiquidity/2; uint256 swapToken=liqAVAXToken+tokenForMarketing; uint256 initialAVAXBalance = address(this).balance; uint256 liqAVAX = (newAVAX*liqAVAXToken)/swapToken; uint256 generatedAVAX=(address(this).balance - initialAVAXBalance); _distributeFeesAVAX(generatedAVAX); function _swapTokenForAVAX(uint256 amount) private { _approve(address(this), address(_JOERouter), amount); address[] memory path = new address[](2); path[0] = address(this); path[1] = _JOERouter.WAVAX(); _JOERouter.swapExactTokensForAVAXSupportingFeeOnTransferTokens( amount, 0, path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenamount, uint256 AVAXamount) private { totalLPAVAX+=AVAXamount; _approve(address(this), address(_JOERouter), tokenamount); address(this), tokenamount, 0, 0, address(this), block.timestamp ); } _JOERouter.addLiquidityAVAX{value: AVAXamount}( function getBurnedTokens() public view returns(uint256){ return (InitialSupply-_circulatingSupply)/10**_decimals; } function getLimits() public view returns(uint256 balance, uint256 sell){ return(balanceLimit/10**_decimals, sellLimit/10**_decimals); } function getTaxes() public view returns(uint256 burnTax,uint256 liquidityTax,uint256 marketingTax, uint256 buyTax, uint256 sellTax, uint256 transferTax){ return (_burnTax,_liquidityTax,_marketingTax,_buyTax,_sellTax,_transferTax); } function getAddressSellLockTimeInSeconds(address AddressToCheck) public view returns (uint256){ uint256 lockTime=_sellLock[AddressToCheck]; if(lockTime<=block.timestamp) { return 0; } return lockTime-block.timestamp; } function getAddressSellLockTimeInSeconds(address AddressToCheck) public view returns (uint256){ uint256 lockTime=_sellLock[AddressToCheck]; if(lockTime<=block.timestamp) { return 0; } return lockTime-block.timestamp; } function getSellLockTimeInSeconds() public view returns(uint256){ return sellLockTime; } function AddressResetSellLock() public{ _sellLock[msg.sender]=block.timestamp+sellLockTime; } bool public sellLockDisabled; uint256 public sellLockTime; bool public manualConversion; function TeamSetWhitelistedAddressAlt(address addy, bool booly) public onlyTeam { wListed[addy] = booly; } function TeamSetWhitelistedAddress(address addy, bool booly) public onlyTeam { wListed[addy] = booly; _excluded.add(addy); } function TeamSetWhitelistedAddressesAlt( address[] memory addy, bool booly) public onlyTeam { uint256 i; for(i=0; i<addy.length; i++) { wListed[addy[i]] = booly; } } function TeamSetWhitelistedAddressesAlt( address[] memory addy, bool booly) public onlyTeam { uint256 i; for(i=0; i<addy.length; i++) { wListed[addy[i]] = booly; } } function TeamSetWhitelistedAddresses( address[] memory addy, bool booly) public onlyTeam { uint256 i; for(i=0; i<addy.length; i++) { wListed[addy[i]] = booly; _excluded.add(addy[i]); } } function TeamSetWhitelistedAddresses( address[] memory addy, bool booly) public onlyTeam { uint256 i; for(i=0; i<addy.length; i++) { wListed[addy[i]] = booly; _excluded.add(addy[i]); } } function TeamSetPeggedSwap(bool isPegged) public onlyTeam { isSwapPegged = isPegged; } function TeamWithdrawMarketingAVAX() public onlyTeam{ uint256 amount=marketingBalance; marketingBalance=0; require(sent,"withdraw failed"); } (bool sent,) =SecondTeamWallet.call{value: (amount)}(""); function TeamSwitchManualAVAXConversion(bool manual) public onlyTeam{ manualConversion=manual; } function TeamDisableSellLock(bool disabled) public onlyTeam{ sellLockDisabled=disabled; } function TeamSetSellLockTime(uint256 sellLockSeconds)public onlyTeam{ require(sellLockSeconds<=MaxSellLockTime,"Sell Lock time too high"); sellLockTime=sellLockSeconds; } function TeamSetTaxes(uint8 burnTaxes, uint8 liquidityTaxes, uint8 marketingTaxes,uint8 buyTax, uint8 sellTax, uint8 transferTax) public onlyTeam{ uint8 totalTax=burnTaxes+liquidityTaxes+marketingTaxes; require(totalTax==100, "burn+liq+marketing needs to equal 100%"); require(buyTax<=MaxTax&&sellTax<=MaxTax&&transferTax<=MaxTax,"taxes higher than max tax"); _burnTax=burnTaxes; _liquidityTax=liquidityTaxes; _marketingTax=marketingTaxes; _buyTax=buyTax; _sellTax=sellTax; _transferTax=transferTax; } function TeamChangeMarketingShare(uint8 newShare) public onlyTeam{ marketingShare=newShare; } function TeamManualGenerateTokenSwapBalance(uint256 _qty) public onlyTeam{ _swapContractToken(_qty * 10**9); } function TeamExcludeAccountFromFees(address account) public onlyTeam { _excluded.add(account); } function TeamIncludeAccountToFees(address account) public onlyTeam { _excluded.remove(account); } function TeamExcludeAccountFromSellLock(address account) public onlyTeam { _excludedFromSellLock.add(account); } function TeamIncludeAccountToSellLock(address account) public onlyTeam { _excludedFromSellLock.remove(account); } function TeamUpdateLimits(uint256 newBalanceLimit, uint256 newSellLimit) public onlyTeam{ newBalanceLimit=newBalanceLimit*10**_decimals; newSellLimit=newSellLimit*10**_decimals; balanceLimit = newBalanceLimit; sellLimit = newSellLimit; } function TeamDistributePresale(uint256 amount, address[] memory addresses) public onlyTeam { uint256 i; for(i=0; i<addresses.length; i++) { _balances[addresses[i]] += amount * 10**_decimals; _balances[address(this)] -= amount * 10**_decimals; emit Transfer(address(this), addresses[i], amount * 10**_decimals); } } bool public tradingEnabled; bool public whiteListTrading; address private _liquidityTokenAddress; function TeamDistributePresale(uint256 amount, address[] memory addresses) public onlyTeam { uint256 i; for(i=0; i<addresses.length; i++) { _balances[addresses[i]] += amount * 10**_decimals; _balances[address(this)] -= amount * 10**_decimals; emit Transfer(address(this), addresses[i], amount * 10**_decimals); } } bool public tradingEnabled; bool public whiteListTrading; address private _liquidityTokenAddress; function SetupEnableTrading() public onlyTeam{ tradingEnabled=true; } function SetupLiquidityTokenAddress(address liquidityTokenAddress) public onlyTeam{ _liquidityTokenAddress=liquidityTokenAddress; } function SetupAddToWhitelist(address addressToAdd) public onlyTeam{ _whiteList.add(addressToAdd); } function SetupAddArrayToWhitelist(address[] memory addressesToAdd) public onlyTeam{ for(uint i=0; i<addressesToAdd.length; i++){ _whiteList.add(addressesToAdd[i]); } } function SetupAddArrayToWhitelist(address[] memory addressesToAdd) public onlyTeam{ for(uint i=0; i<addressesToAdd.length; i++){ _whiteList.add(addressesToAdd[i]); } } function SetupRemoveFromWhitelist(address addressToRemove) public onlyTeam{ _whiteList.remove(addressToRemove); } receive() external payable {} fallback() external payable {} function getOwner() external view override returns (address) { return owner(); } function name() external pure override returns (string memory) { return _name; } function symbol() external pure override returns (string memory) { return _symbol; } function decimals() external pure override returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _circulatingSupply; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address _owner, address spender) external view override returns (uint256) { return _allowances[_owner][spender]; } function approve(address spender, uint256 amount) external override returns (bool) { _approve(msg.sender, spender, amount); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "Approve from zero"); require(spender != address(0), "Approve to zero"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "Transfer > allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) external returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "<0 allowance"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } }
4,505,292
[ 1, 4625, 348, 7953, 560, 30, 3155, 3807, 25558, 364, 326, 30143, 3039, 2511, 603, 5886, 1934, 1776, 3425, 1283, 261, 21, 9, 13, 25558, 364, 326, 4238, 13937, 2511, 603, 5886, 1934, 1776, 3425, 1283, 261, 21, 18, 25, 9, 13, 25558, 364, 326, 3497, 7523, 4238, 13937, 2511, 603, 2172, 3425, 1283, 12, 21, 18, 25, 9, 13, 25558, 364, 357, 80, 3039, 2511, 603, 5886, 1934, 1776, 3425, 1283, 261, 20, 18, 5877, 9, 13, 55, 1165, 414, 336, 8586, 364, 4238, 55, 1165, 2531, 950, 1427, 2898, 848, 1404, 4657, 30412, 10434, 17662, 2413, 6241, 30, 7576, 358, 12740, 2758, 4709, 50, 1167, 72, 663, 3238, 5381, 804, 51, 654, 14068, 33, 20, 92, 29, 9988, 1105, 39, 71, 26, 73, 6334, 3600, 25339, 39, 24, 2539, 18096, 28, 41, 8875, 6418, 2954, 69, 2539, 26, 4630, 73, 25, 71, 23, 31, 6376, 7308, 374, 92, 2163, 2056, 8942, 39, 27, 2643, 27, 3461, 24008, 4449, 72, 25, 69, 37, 10321, 38, 8285, 38, 6564, 27, 3028, 41, 5034, 3103, 24, 41, 7528, 716, 3298, 11013, 3039, 471, 357, 80, 3039, 16, 4169, 506, 3526, 2511, 603, 5886, 1934, 1776, 14467, 471, 348, 1165, 17, 471, 30918, 3039, 7244, 24290, 12768, 943, 5320, 16, 1338, 5571, 6754, 364, 5320, 3478, 16, 3302, 1404, 13418, 1208, 287, 18240, 22138, 326, 783, 399, 10855, 16, 3775, 399, 10855, 848, 506, 6754, 364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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 95, 203, 565, 1450, 5267, 364, 1758, 31, 203, 565, 1450, 6057, 25121, 694, 364, 6057, 25121, 694, 18, 1887, 694, 31, 203, 377, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 70, 26488, 31, 203, 565, 2874, 261, 2867, 516, 2874, 261, 2867, 516, 2254, 5034, 3719, 3238, 389, 5965, 6872, 31, 203, 565, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 87, 1165, 2531, 31, 203, 202, 6770, 261, 2867, 516, 1426, 13, 1071, 341, 682, 329, 31, 203, 202, 203, 203, 565, 6057, 25121, 694, 18, 1887, 694, 3238, 389, 24602, 31, 203, 565, 6057, 25121, 694, 18, 1887, 694, 3238, 389, 14739, 682, 31, 203, 565, 6057, 25121, 694, 18, 1887, 694, 3238, 389, 24602, 31145, 1165, 2531, 31, 203, 377, 203, 565, 2874, 261, 2867, 516, 1426, 13, 1071, 389, 22491, 31, 203, 565, 1426, 353, 25811, 273, 638, 31, 203, 377, 203, 565, 533, 3238, 5381, 389, 529, 273, 296, 54, 842, 651, 13506, 203, 565, 533, 3238, 5381, 389, 7175, 273, 296, 54, 842, 651, 13506, 203, 565, 2254, 28, 3238, 5381, 389, 31734, 273, 2468, 31, 203, 203, 565, 2254, 5034, 7720, 3039, 273, 404, 380, 1728, 636, 25, 380, 1728, 636, 67, 31734, 31, 203, 565, 1426, 353, 12521, 52, 1332, 2423, 273, 638, 31, 203, 377, 203, 565, 2254, 2313, 1071, 5381, 605, 9835, 3039, 25558, 33, 3361, 31, 203, 565, 2254, 28, 1071, 5381, 30918, 3039, 25558, 33, 3361, 31, 203, 565, 2254, 2313, 1071, 5381, 30233, 682, 13937, 3039, 25558, 33, 3361, 31, 203, 565, 2254, 2313, 1071, 5381, 348, 1165, 3039, 25558, 33, 3361, 31, 203, 565, 2254, 2313, 1071, 5381, 4238, 55, 1165, 2531, 950, 33, 576, 3974, 31, 203, 565, 1758, 1071, 5381, 10434, 16936, 33, 20, 17593, 31273, 4848, 4331, 713, 69, 9036, 3600, 2313, 38, 29, 69, 37, 69, 26, 2539, 25, 42, 7677, 71, 4313, 29, 41, 21, 1340, 5034, 31, 203, 565, 1758, 1071, 5381, 7631, 8689, 16936, 33, 20, 17593, 31273, 4848, 4331, 713, 69, 9036, 3600, 2313, 38, 29, 69, 37, 69, 26, 2539, 25, 42, 7677, 71, 4313, 29, 41, 21, 1340, 5034, 31, 203, 377, 203, 565, 1758, 8843, 429, 3238, 26503, 264, 33, 10239, 429, 12, 8443, 10663, 203, 565, 1758, 3238, 5381, 804, 51, 654, 14068, 33, 20, 92, 4848, 69, 41, 26, 2313, 69, 5340, 2539, 41, 73, 23, 72, 29, 37, 9470, 6564, 21, 38, 69, 7950, 6334, 5292, 4366, 22267, 3707, 72, 24, 31, 203, 203, 565, 2254, 5034, 3238, 389, 11614, 1934, 1776, 3088, 1283, 273, 4435, 3088, 1283, 31, 203, 565, 2254, 5034, 1071, 225, 11013, 3039, 273, 389, 11614, 1934, 1776, 3088, 1283, 31, 203, 565, 2254, 5034, 1071, 225, 357, 80, 3039, 273, 389, 11614, 1934, 1776, 3088, 1283, 31, 203, 565, 2254, 5034, 1071, 225, 30143, 3039, 273, 389, 11614, 1934, 1776, 3088, 1283, 31, 203, 565, 1758, 8526, 1071, 12928, 774, 10628, 31, 203, 203, 565, 2254, 28, 1071, 5381, 4238, 7731, 33, 8778, 31, 203, 377, 203, 565, 2254, 28, 3238, 389, 70, 9835, 7731, 31, 203, 565, 2254, 28, 3238, 389, 87, 1165, 7731, 31, 203, 565, 2254, 28, 3238, 389, 13866, 7731, 31, 203, 565, 1426, 2512, 426, 8629, 273, 638, 31, 203, 565, 2254, 28, 3238, 389, 70, 321, 7731, 31, 203, 565, 2254, 28, 3238, 389, 549, 372, 24237, 7731, 31, 203, 565, 2254, 28, 3238, 389, 3355, 21747, 7731, 31, 203, 377, 203, 565, 1426, 353, 1345, 12521, 25139, 273, 638, 31, 203, 203, 3639, 203, 565, 1758, 3238, 389, 22720, 41, 4154, 1887, 31, 7010, 565, 467, 22720, 654, 14068, 3103, 3238, 225, 389, 22720, 654, 14068, 31, 203, 377, 203, 565, 9606, 1338, 8689, 1435, 288, 203, 3639, 2583, 24899, 291, 8689, 12, 3576, 18, 15330, 3631, 315, 11095, 486, 316, 10434, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 377, 203, 565, 445, 389, 291, 8689, 12, 2867, 3091, 13, 3238, 1476, 1135, 261, 6430, 15329, 203, 3639, 327, 3091, 631, 8443, 1435, 20081, 4793, 631, 8689, 16936, 20081, 4793, 631, 8211, 8689, 16936, 31, 203, 565, 289, 203, 203, 203, 565, 3885, 1832, 288, 203, 3639, 2254, 5034, 7286, 264, 13937, 33, 67, 11614, 1934, 1776, 3088, 1283, 14, 29, 19, 2163, 31, 203, 3639, 389, 70, 26488, 63, 3576, 18, 15330, 65, 273, 7286, 264, 13937, 31, 203, 3639, 3626, 12279, 12, 2867, 12, 20, 3631, 1234, 18, 15330, 16, 7286, 264, 13937, 1769, 203, 3639, 2254, 5034, 4590, 13937, 33, 67, 11614, 1934, 1776, 3088, 1283, 17, 12411, 264, 13937, 31, 203, 3639, 389, 70, 26488, 63, 2867, 12, 2211, 25887, 33, 22170, 13937, 31, 203, 4202, 3626, 12279, 12, 2867, 12, 20, 3631, 1758, 12, 2211, 3631, 22170, 13937, 1769, 203, 203, 3639, 389, 22720, 654, 14068, 273, 467, 22720, 654, 14068, 3103, 12, 22720, 654, 14068, 1769, 203, 3639, 389, 22720, 41, 4154, 1887, 273, 467, 22720, 41, 1733, 24899, 22720, 654, 14068, 18, 6848, 1435, 2934, 2640, 4154, 12, 2867, 12, 2211, 3631, 389, 22720, 654, 14068, 18, 59, 5856, 2501, 10663, 203, 540, 203, 3639, 11013, 3039, 33, 4435, 3088, 1283, 19, 13937, 3039, 25558, 31, 203, 3639, 357, 80, 3039, 33, 4435, 3088, 1283, 19, 55, 1165, 3039, 25558, 31, 203, 3639, 30143, 3039, 33, 4435, 3088, 1283, 19, 38, 9835, 3039, 25558, 31, 203, 203, 3639, 357, 80, 2531, 950, 33, 22, 3974, 31, 203, 203, 3639, 389, 70, 9835, 7731, 33, 2163, 31, 203, 3639, 389, 87, 1165, 7731, 33, 2163, 31, 203, 3639, 389, 13866, 7731, 33, 2163, 31, 203, 540, 203, 3639, 389, 549, 372, 24237, 7731, 33, 21, 31, 203, 3639, 389, 3355, 21747, 7731, 33, 2733, 31, 203, 3639, 389, 24602, 18, 1289, 12, 8689, 16936, 1769, 203, 3639, 389, 24602, 18, 1289, 12, 8211, 8689, 16936, 1769, 203, 3639, 389, 24602, 18, 1289, 12, 3576, 18, 15330, 1769, 203, 3639, 389, 24602, 31145, 1165, 2531, 18, 1289, 12, 2867, 24899, 22720, 654, 14068, 10019, 203, 3639, 389, 24602, 31145, 1165, 2531, 18, 1289, 24899, 22720, 41, 4154, 1887, 1769, 203, 3639, 389, 24602, 31145, 1165, 2531, 18, 1289, 12, 2 ]
pragma solidity >=0.6.0 <0.9.0; /** * SAFEMATH LIBRARY */ library SafeMath { 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); } } function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function getOwner() external view returns (address); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } abstract contract Auth { address internal owner; mapping (address => bool) internal authorizations; constructor(address _owner) { owner = _owner; authorizations[_owner] = true; } /** * Function modifier to require caller to be contract owner */ modifier onlyOwner() { require(isOwner(msg.sender), "!OWNER"); _; } /** * Function modifier to require caller to be authorized */ modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; } /** * Authorize address. Owner only */ function authorize(address adr) public onlyOwner { authorizations[adr] = true; } /** * Remove address' authorization. Owner only */ function unauthorize(address adr) public onlyOwner { authorizations[adr] = false; } /** * Check if address is owner */ function isOwner(address account) public view returns (bool) { return account == owner; } /** * Return address' authorization status */ function isAuthorized(address adr) public view returns (bool) { return authorizations[adr]; } /** * Transfer ownership to new address. Caller must be owner. Leaves old owner authorized */ function transferOwnership(address payable adr) public onlyOwner { owner = adr; authorizations[adr] = true; emit OwnershipTransferred(adr); } event OwnershipTransferred(address owner); } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function 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; } contract ESG_OLD is IERC20, Auth { using SafeMath for uint256; //address public MATIC = 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd; //BSC TEST address public MATIC = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // ROPSTEN address DEAD = 0x000000000000000000000000000000000000dEaD; address ZERO = 0x0000000000000000000000000000000000000000; address DEAD_NON_CHECKSUM = 0x000000000000000000000000000000000000dEaD; string constant _name = "eSkillz Games"; string constant _symbol = "ESG"; uint8 constant _decimals = 9; uint256 _totalSupply = 100000000 * (10 ** _decimals); mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _allowances; address [] holderList; mapping (address => bool) isTokenHolder; mapping (address => uint256) holderIndexes; mapping (address => bool) isFeeExempt; uint256 taxFee = 800; uint256 totalFee = 800; uint256 feeDenominator = 10000; address public autoLiquidityReceiver; address public taxFeeReceiver; IDEXRouter public router; address public pair; bool inSwap; modifier swapping() { inSwap = true; _; inSwap = false; } constructor ( address _dexRouter ) Auth(msg.sender) { router = IDEXRouter(_dexRouter); pair = IDEXFactory(router.factory()).createPair(MATIC, address(this)); _allowances[address(this)][address(router)] = _totalSupply; MATIC = router.WETH(); isFeeExempt[msg.sender] = true; isFeeExempt[pair] = true; isFeeExempt[_dexRouter] = true; taxFeeReceiver = 0x18461667028745Cd20138059E57d8d882b7b3B3B; approve(_dexRouter, _totalSupply); approve(address(pair), _totalSupply); _balances[msg.sender] = _totalSupply; //own code holderList.push(msg.sender); isTokenHolder[msg.sender] = true; emit Transfer(address(0), msg.sender, _totalSupply); } receive() external payable { } function totalSupply() external view override returns (uint256) { return _totalSupply; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function approveMax(address spender) external returns (bool) { return approve(spender, _totalSupply); } function transfer(address recipient, uint256 amount) external override returns (bool) { return _transferFrom(msg.sender, recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if(_allowances[sender][msg.sender] != _totalSupply){ _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance"); } return _transferFrom(sender, recipient, amount); } function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { if(inSwap){ return _basicTransfer(sender, recipient, amount); } // _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); // uint256 amountReceived = shouldTakeFee(sender) ? takeFee(sender, recipient, amount) : amount; // _balances[recipient] = _balances[recipient].add(amountReceived); // emit Transfer(sender, recipient, amountReceived); // checkHolderList(sender); // checkHolderList(recipient); //return _basicTransfer(sender, recipient, amount); //return true; } function addTokenHolder(address _address) internal { if(balanceOf(_address)==0) return; if(isTokenHolder[_address]) return; holderIndexes[_address] = holderList.length; isTokenHolder[_address] = true; holderList.push(_address); } function removeTokenHolder(address _address) internal { if(balanceOf(_address)>0 || isTokenHolder[_address]==false) return; holderList[holderIndexes[_address]] = holderList[holderList.length-1]; holderIndexes[holderList[holderList.length-1]] = holderIndexes[_address]; isTokenHolder[_address] = false; holderList.pop(); } function getHolder(uint256 index) external view returns(address) { return holderList[index]; } function getHoldersLength() external view returns(uint256) { return holderList.length; } function checkHolderList(address _address) internal { if(balanceOf(_address)>0 && isTokenHolder[_address]!=true) { addTokenHolder(_address); } if(balanceOf(_address)==0) { removeTokenHolder(_address); } } function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amount); return true; } function shouldTakeFee(address sender) internal view returns (bool) { return !isFeeExempt[sender]; } function getTotalFee() public view returns (uint256) { return totalFee; } function takeFee(address sender, address receiver, uint256 amount) internal returns (uint256) { uint256 feeAmount = amount.mul(getTotalFee()).div(feeDenominator); _balances[address(this)] = _balances[address(this)].add(feeAmount); emit Transfer(sender, address(this), feeAmount); swapBack(feeAmount); return amount.sub(feeAmount); } function swapBack(uint256 amount) internal swapping { address[] memory path = new address[](2); path[0] = address(this); path[1] = MATIC; uint256 balanceBefore = address(this).balance; router.swapExactTokensForETHSupportingFeeOnTransferTokens( amount, 0, path, address(this), block.timestamp ); uint256 amountBNB = address(this).balance.sub(balanceBefore); payable(taxFeeReceiver).transfer(amountBNB); } function buyTokens(uint256 amount, address to) internal swapping { address[] memory path = new address[](2); path[0] = MATIC; path[1] = address(this); router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, path, to, block.timestamp ); } function setIsFeeExempt(address holder, bool exempt) external authorized { isFeeExempt[holder] = exempt; } function setFees(uint256 _taxFee, uint256 _feeDenominator) external authorized { taxFee = _taxFee; totalFee = _taxFee; feeDenominator = _feeDenominator; require(totalFee < feeDenominator/4); } function setFeeReceivers(address _taxFeeReceiver) external authorized { taxFeeReceiver = _taxFeeReceiver; } function getCirculatingSupply() public view returns (uint256) { return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO)); } function getLiquidityBacking(uint256 accuracy) public view returns (uint256) { return accuracy.mul(balanceOf(pair).mul(2)).div(getCirculatingSupply()); } function isOverLiquified(uint256 target, uint256 accuracy) public view returns (bool) { return getLiquidityBacking(accuracy) > target; } }
_balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); uint256 amountReceived = shouldTakeFee(sender) ? takeFee(sender, recipient, amount) : amount; _balances[recipient] = _balances[recipient].add(amountReceived); emit Transfer(sender, recipient, amountReceived); checkHolderList(sender); checkHolderList(recipient);return _basicTransfer(sender, recipient, amount);return true;
function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { }
910,929
[ 1, 4625, 348, 7953, 560, 30, 225, 389, 70, 26488, 63, 15330, 65, 273, 389, 70, 26488, 63, 15330, 8009, 1717, 12, 8949, 16, 315, 5048, 11339, 30918, 8863, 2254, 5034, 3844, 8872, 273, 1410, 13391, 14667, 12, 15330, 13, 692, 4862, 14667, 12, 15330, 16, 8027, 16, 3844, 13, 294, 3844, 31, 389, 70, 26488, 63, 20367, 65, 273, 389, 70, 26488, 63, 20367, 8009, 1289, 12, 8949, 8872, 1769, 3626, 12279, 12, 15330, 16, 8027, 16, 3844, 8872, 1769, 866, 6064, 682, 12, 15330, 1769, 866, 6064, 682, 12, 20367, 1769, 2463, 389, 13240, 5912, 12, 15330, 16, 8027, 16, 3844, 1769, 2463, 638, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 13866, 1265, 12, 2867, 5793, 16, 1758, 8027, 16, 2254, 5034, 3844, 13, 2713, 1135, 261, 6430, 13, 288, 203, 203, 203, 203, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/* * This code has not been reviewed. * Do not use or deploy this code before reviewing it personally first. */ pragma solidity >=0.6.0 <0.9.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol"; import "./IERC1400.sol"; /** * @title ERC1400 * @dev ERC1400 logic */ contract ERC1400 is IERC20, IERC1400, Ownable, ChainlinkClient { using SafeMath for uint256; // Token string constant internal ERC1400_INTERFACE_NAME = "ERC1400Token"; string constant internal ERC20_INTERFACE_NAME = "ERC20Token"; /************************************* Token description ****************************************/ string internal _name; string internal _symbol; uint256 internal _granularity; uint256 internal _totalSupply; bool internal _migrated; /************************************************************************************************/ /**************************************** Token behaviours **************************************/ // Indicate whether the token can still be controlled by operators or not anymore. bool internal _isControllable; // Indicate whether the token can still be issued by the issuer or not anymore. bool internal _isIssuable; /************************************************************************************************/ /********************************** ERC20 Token mappings ****************************************/ // Mapping from tokenHolder to balance. mapping(address => uint256) internal _balances; // Mapping from (tokenHolder, spender) to allowed value. mapping (address => mapping (address => uint256)) internal _allowed; /************************************************************************************************/ /**************************************** Documents *********************************************/ struct Doc { string docURI; bytes32 docHash; } // Mapping for token URIs. mapping(bytes32 => Doc) internal _documents; /************************************************************************************************/ /*********************************** Partitions mappings ***************************************/ // List of partitions. bytes32[] internal _totalPartitions; // Mapping from partition to their index. mapping (bytes32 => uint256) internal _indexOfTotalPartitions; // Mapping from partition to global balance of corresponding partition. mapping (bytes32 => uint256) internal _totalSupplyByPartition; // Mapping from tokenHolder to their partitions. mapping (address => bytes32[]) internal _partitionsOf; // Mapping from (tokenHolder, partition) to their index. mapping (address => mapping (bytes32 => uint256)) internal _indexOfPartitionsOf; // Mapping from (tokenHolder, partition) to balance of corresponding partition. mapping (address => mapping (bytes32 => uint256)) internal _balanceOfByPartition; // List of token default partitions (for ERC20 compatibility). bytes32[] internal _defaultPartitions; /************************************************************************************************/ /********************************* Global operators mappings ************************************/ // Mapping from (operator, tokenHolder) to authorized status. [TOKEN-HOLDER-SPECIFIC] mapping(address => mapping(address => bool)) internal _authorizedOperator; // Array of controllers. [GLOBAL - NOT TOKEN-HOLDER-SPECIFIC] address[] internal _controllers; // Mapping from operator to controller status. [GLOBAL - NOT TOKEN-HOLDER-SPECIFIC] mapping(address => bool) internal _isController; /************************************************************************************************/ /******************************** Partition operators mappings **********************************/ // Mapping from (partition, tokenHolder, spender) to allowed value. [TOKEN-HOLDER-SPECIFIC] mapping(bytes32 => mapping (address => mapping (address => uint256))) internal _allowedByPartition; // Mapping from (tokenHolder, partition, operator) to 'approved for partition' status. [TOKEN-HOLDER-SPECIFIC] mapping (address => mapping (bytes32 => mapping (address => bool))) internal _authorizedOperatorByPartition; // Mapping from partition to controllers for the partition. [NOT TOKEN-HOLDER-SPECIFIC] mapping (bytes32 => address[]) internal _controllersByPartition; // Mapping from (partition, operator) to PartitionController status. [NOT TOKEN-HOLDER-SPECIFIC] mapping (bytes32 => mapping (address => bool)) internal _isControllerByPartition; /************************************************************************************************/ /******************************************* Oracle *********************************************/ // Kovan address private oracle = 0x8bF43cA0b3CeAE338C9A579E3eA8DC6b0aDcAe09; bytes32 private jobId = "906ac2562c77472cb5a881dce34e000c"; uint256 private fee = 0.1 * 10 ** 18; mapping(bytes32 => address) public receivers; mapping(bytes32 => string) public paymentIntents; event ReleasePaidTokens(address indexed receiver, string intent); /************************************************************************************************/ /***************************************** Modifiers ********************************************/ /** * @dev Modifier to verify if token is issuable. */ modifier isIssuableToken() { require(_isIssuable, "55"); // 0x55 funds locked (lockup period) _; } /** * @dev Modifier to make a function callable only when the contract is not migrated. */ modifier isNotMigratedToken() { require(!_migrated, "54"); // 0x54 transfers halted (contract paused) _; } /************************************************************************************************/ /**************************** Events (additional - not mandatory) *******************************/ event ApprovalByPartition(bytes32 indexed partition, address indexed owner, address indexed spender, uint256 value); /************************************************************************************************/ /** * @dev Initialize ERC1400 + register the contract implementation in ERC1820Registry. * @param name Name of the token. * @param symbol Symbol of the token. * @param granularity Granularity of the token. * @param controllers Array of initial controllers. * @param defaultPartitions Partitions chosen by default, when partition is * not specified, like the case ERC20 tranfers. */ constructor( string memory name, string memory symbol, uint256 granularity, address[] memory controllers, bytes32[] memory defaultPartitions ) public { _name = name; _symbol = symbol; _totalSupply = 0; require(granularity >= 1); // Constructor Blocked - Token granularity can not be lower than 1 _granularity = granularity; _setControllers(controllers); _defaultPartitions = defaultPartitions; _isControllable = true; _isIssuable = true; } /** * @dev Config function to set address of Chainlink token. */ function setChainlinkToken() external onlyOwner { setPublicChainlinkToken(); } /************************************************************************************************/ /************************************ DELIVERY-vs-PAYMENT ***************************************/ /************************************************************************************************/ /** * @dev Issue reserved tokens and make a request to the oracle to verify payment. * @param amount Amount of tokens to be reserved. * @param intent Key obtained by PSP (Stripe). * @param sig Encrypted with user's key message containing amount and intent. * @return requestId from chainlink request. */ function reserveAndVerifyPayment( uint256 amount, string calldata intent, bytes calldata sig ) external returns (bytes32 requestId) { require(_defaultPartitions.length != 0, "55"); // 0x55 funds locked (lockup period) // verify sig validity bytes32 message = prefixed(keccak256(abi.encodePacked(msg.sender, amount, intent))); require(recoverSigner(message, sig) == msg.sender, "Not same user"); // issue "reserved" tokens _issueByPartition(_defaultPartitions[0], msg.sender, msg.sender, amount, ""); // call Chainlink Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.releasePaidTokens.selector); string memory _addr = addressToString(msg.sender); string memory _q = string(abi.encodePacked("payment_intent_id=", intent, "&addr=", _addr)); request.add("get", string(abi.encodePacked("https://dvp-server.barakov.xyz/check?", _q))); request.add("queryParams", _q); request.add("path", "SUCCESS"); requestId = sendChainlinkRequestTo(oracle, request, fee); receivers[requestId] = msg.sender; paymentIntents[requestId] = intent; } /** * @dev Callback ivoked by the oracle with result of payment verification. * @param requestId Chainlink request id, obtained in "reserveAndVerifyPayment". * @param success Result of verification. If successfull, issue tokens and emit ReleasePaidTokens. */ function releasePaidTokens(bytes32 requestId, bool success) public recordChainlinkFulfillment(requestId) { require(_defaultPartitions.length > 1, "55"); // 0x55 funds locked (lockup period) require(success, "Unable to verify"); address receiver = receivers[requestId]; string memory intent = paymentIntents[requestId]; uint256 amount = _balanceOfByPartition[receiver][_defaultPartitions[0]]; _redeemByDefaultPartitions(receiver, receiver, amount, ""); _issueByPartition(_defaultPartitions[1], receiver, receiver, amount, ""); emit ReleasePaidTokens(receiver, intent); } /************************************************************************************************/ /******************************** Utils internal functions ***************************************/ /** * @dev Cast address to string. * @param _address Address to be cast. * @return Address transformed in string. */ function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(_address)); bytes memory HEX = "0123456789abcdef"; bytes memory _string = new bytes(42); _string[0] = '0'; _string[1] = 'x'; for(uint i = 0; i < 20; i++) { _string[2+i*2] = HEX[uint8(_bytes[i + 12] >> 4)]; _string[3+i*2] = HEX[uint8(_bytes[i + 12] & 0x0f)]; } return string(_string); } /** * @dev Low-level function used to obtain parts of the ecrypted message. * @param sig Message to be split. * @return Three parts of the msg. */ function splitSignature(bytes memory sig) internal pure returns (uint8, bytes32, bytes32) { require(sig.length == 65); bytes32 r; bytes32 s; uint8 v; assembly { // first 32 bytes, after the length prefix r := mload(add(sig, 32)) // second 32 bytes s := mload(add(sig, 64)) // final byte (first byte of the next 32 bytes) v := byte(0, mload(add(sig, 96))) } return (v, r, s); } /** * @dev Recover address used to sign an ecrypted msg. * @param message. * @return Address of signer. */ function recoverSigner(bytes32 message, bytes memory sig) internal pure returns (address) { uint8 v; bytes32 r; bytes32 s; (v, r, s) = splitSignature(sig); return ecrecover(message, v, r, s); } // Builds a prefixed hash to mimic the behavior of eth_sign. function prefixed(bytes32 hash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /************************************************************************************************/ /************************************************************************************************/ /****************************** EXTERNAL FUNCTIONS (ERC20 INTERFACE) ****************************/ /************************************************************************************************/ /** * @dev Get the total number of issued tokens. * @return Total supply of tokens currently in circulation. */ function totalSupply() external view override returns (uint256) { return _totalSupply; } /** * @dev Get the balance of the account with address 'tokenHolder'. * @param tokenHolder Address for which the balance is returned. * @return Amount of token held by 'tokenHolder' in the token contract. */ function balanceOf(address tokenHolder) external view override returns (uint256) { return _balances[tokenHolder]; } /** * @dev Transfer token for a specified address. * @param to The address to transfer to. * @param value The value to be transferred. * @return A boolean that indicates if the operation was successful. */ function transfer(address to, uint256 value) external override returns (bool) { _transferByDefaultPartitions(msg.sender, msg.sender, to, value, ""); return true; } /** * @dev Check the value 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 value of tokens still available for the spender. */ function allowance(address owner, address spender) external view override returns (uint256) { return _allowed[owner][spender]; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of 'msg.sender'. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean that indicates if the operation was successful. */ function approve(address spender, uint256 value) external override returns (bool) { require(spender != address(0), "56"); // 0x56 invalid sender _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * @param from The address which you want to transfer tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean that indicates if the operation was successful. */ function transferFrom(address from, address to, uint256 value) external override returns (bool) { require( _isOperator(msg.sender, from) || (value <= _allowed[from][msg.sender]), "53"); // 0x53 insufficient allowance if(_allowed[from][msg.sender] >= value) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); } else { _allowed[from][msg.sender] = 0; } _transferByDefaultPartitions(msg.sender, from, to, value, ""); return true; } /************************************************************************************************/ /****************************** EXTERNAL FUNCTIONS (ERC1400 INTERFACE) **************************/ /************************************************************************************************/ /************************************* Document Management **************************************/ /** * @dev Access a document associated with the token. * @param name Short name (represented as a bytes32) associated to the document. * @return Requested document + document hash. */ function getDocument(bytes32 name) external view override returns (string memory, bytes32) { require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document return ( _documents[name].docURI, _documents[name].docHash ); } /** * @dev Associate a document with the token. * @param name Short name (represented as a bytes32) associated to the document. * @param uri Document content. * @param documentHash Hash of the document [optional parameter]. */ function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external override { require(_isController[msg.sender]); _documents[name] = Doc({ docURI: uri, docHash: documentHash }); emit Document(name, uri, documentHash); } /************************************************************************************************/ /************************************** Token Information ***************************************/ /** * @dev Get balance of a tokenholder for a specific partition. * @param partition Name of the partition. * @param tokenHolder Address for which the balance is returned. * @return Amount of token of partition 'partition' held by 'tokenHolder' in the token contract. */ function balanceOfByPartition(bytes32 partition, address tokenHolder) external view override returns (uint256) { return _balanceOfByPartition[tokenHolder][partition]; } /** * @dev Get partitions index of a tokenholder. * @param tokenHolder Address for which the partitions index are returned. * @return Array of partitions index of 'tokenHolder'. */ function partitionsOf(address tokenHolder) external view override returns (bytes32[] memory) { return _partitionsOf[tokenHolder]; } /************************************************************************************************/ /****************************************** Transfers *******************************************/ /** * @dev Transfer the amount of tokens from the address 'msg.sender' to the address 'to'. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, by the token holder. */ function transferWithData(address to, uint256 value, bytes calldata data) external override { _transferByDefaultPartitions(msg.sender, msg.sender, to, value, data); } /** * @dev Transfer the amount of tokens on behalf of the address 'from' to the address 'to'. * @param from Token holder (or 'address(0)' to set from to 'msg.sender'). * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, and intended for the token holder ('from'). */ function transferFromWithData(address from, address to, uint256 value, bytes calldata data) external override { require(_isOperator(msg.sender, from), "58"); // 0x58 invalid operator (transfer agent) _transferByDefaultPartitions(msg.sender, from, to, value, data); } /************************************************************************************************/ /********************************** Partition Token Transfers ***********************************/ /** * @dev Transfer tokens from a specific partition. * @param partition Name of the partition. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, by the token holder. * @return Destination partition. */ function transferByPartition( bytes32 partition, address to, uint256 value, bytes calldata data ) external override returns (bytes32) { return _transferByPartition(partition, msg.sender, msg.sender, to, value, data, ""); } /** * @dev Transfer tokens from a specific partition through an operator. * @param partition Name of the partition. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] * @param operatorData Information attached to the transfer, by the operator. * @return Destination partition. */ function operatorTransferByPartition( bytes32 partition, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData ) external override returns (bytes32) { require(_isOperatorForPartition(partition, msg.sender, from) || (value <= _allowedByPartition[partition][from][msg.sender]), "53"); // 0x53 insufficient allowance if(_allowedByPartition[partition][from][msg.sender] >= value) { _allowedByPartition[partition][from][msg.sender] = _allowedByPartition[partition][from][msg.sender].sub(value); } else { _allowedByPartition[partition][from][msg.sender] = 0; } return _transferByPartition(partition, msg.sender, from, to, value, data, operatorData); } /************************************************************************************************/ /************************************* Controller Operation *************************************/ /** * @dev Know if the token can be controlled by operators. * If a token returns 'false' for 'isControllable()'' then it MUST always return 'false' in the future. * @return bool 'true' if the token can still be controlled by operators, 'false' if it can't anymore. */ function isControllable() external view override returns (bool) { return _isControllable; } /************************************************************************************************/ /************************************* Operator Management **************************************/ /** * @dev Set a third party operator address as an operator of 'msg.sender' to transfer * and redeem tokens on its behalf. * @param operator Address to set as an operator for 'msg.sender'. */ function authorizeOperator(address operator) external override { require(operator != msg.sender); _authorizedOperator[operator][msg.sender] = true; emit AuthorizedOperator(operator, msg.sender); } /** * @dev Remove the right of the operator address to be an operator for 'msg.sender' * and to transfer and redeem tokens on its behalf. * @param operator Address to rescind as an operator for 'msg.sender'. */ function revokeOperator(address operator) external override { require(operator != msg.sender); _authorizedOperator[operator][msg.sender] = false; emit RevokedOperator(operator, msg.sender); } /** * @dev Set 'operator' as an operator for 'msg.sender' for a given partition. * @param partition Name of the partition. * @param operator Address to set as an operator for 'msg.sender'. */ function authorizeOperatorByPartition(bytes32 partition, address operator) external override { _authorizedOperatorByPartition[msg.sender][partition][operator] = true; emit AuthorizedOperatorByPartition(partition, operator, msg.sender); } /** * @dev Remove the right of the operator address to be an operator on a given * partition for 'msg.sender' and to transfer and redeem tokens on its behalf. * @param partition Name of the partition. * @param operator Address to rescind as an operator on given partition for 'msg.sender'. */ function revokeOperatorByPartition(bytes32 partition, address operator) external override { _authorizedOperatorByPartition[msg.sender][partition][operator] = false; emit RevokedOperatorByPartition(partition, operator, msg.sender); } /************************************************************************************************/ /************************************* Operator Information *************************************/ /** * @dev Indicate whether the operator address is an operator of the tokenHolder address. * @param operator Address which may be an operator of tokenHolder. * @param tokenHolder Address of a token holder which may have the operator address as an operator. * @return 'true' if operator is an operator of 'tokenHolder' and 'false' otherwise. */ function isOperator(address operator, address tokenHolder) external view override returns (bool) { return _isOperator(operator, tokenHolder); } /** * @dev Indicate whether the operator address is an operator of the tokenHolder * address for the given partition. * @param partition Name of the partition. * @param operator Address which may be an operator of tokenHolder for the given partition. * @param tokenHolder Address of a token holder which may have the operator address as an operator for the given partition. * @return 'true' if 'operator' is an operator of 'tokenHolder' for partition 'partition' and 'false' otherwise. */ function isOperatorForPartition(bytes32 partition, address operator, address tokenHolder) external view override returns (bool) { return _isOperatorForPartition(partition, operator, tokenHolder); } /************************************************************************************************/ /**************************************** Token Issuance ****************************************/ /** * @dev Know if new tokens can be issued in the future. * @return bool 'true' if tokens can still be issued by the issuer, 'false' if they can't anymore. */ function isIssuable() external view override returns (bool) { return _isIssuable; } /** * @dev Issue tokens from default partition. * @param tokenHolder Address for which we want to issue tokens. * @param value Number of tokens issued. * @param data Information attached to the issuance, by the issuer. */ function issue(address tokenHolder, uint256 value, bytes calldata data) external override onlyOwner isIssuableToken { require(_defaultPartitions.length != 0, "55"); // 0x55 funds locked (lockup period) _issueByPartition(_defaultPartitions[0], msg.sender, tokenHolder, value, data); } /** * @dev Issue tokens from a specific partition. * @param partition Name of the partition. * @param tokenHolder Address for which we want to issue tokens. * @param value Number of tokens issued. * @param data Information attached to the issuance, by the issuer. */ function issueByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata data) external override onlyOwner isIssuableToken { _issueByPartition(partition, msg.sender, tokenHolder, value, data); } /************************************************************************************************/ /*************************************** Token Redemption ***************************************/ /** * @dev Redeem the amount of tokens from the address 'msg.sender'. * @param value Number of tokens to redeem. * @param data Information attached to the redemption, by the token holder. */ function redeem(uint256 value, bytes calldata data) external override { _redeemByDefaultPartitions(msg.sender, msg.sender, value, data); } /** * @dev Redeem the amount of tokens on behalf of the address from. * @param from Token holder whose tokens will be redeemed (or address(0) to set from to msg.sender). * @param value Number of tokens to redeem. * @param data Information attached to the redemption. */ function redeemFrom(address from, uint256 value, bytes calldata data) external override { require(_isOperator(msg.sender, from), "58"); // 0x58 invalid operator (transfer agent) _redeemByDefaultPartitions(msg.sender, from, value, data); } /** * @dev Redeem tokens of a specific partition. * @param partition Name of the partition. * @param value Number of tokens redeemed. * @param data Information attached to the redemption, by the redeemer. */ function redeemByPartition(bytes32 partition, uint256 value, bytes calldata data) external override { _redeemByPartition(partition, msg.sender, msg.sender, value, data, ""); } /** * @dev Redeem tokens of a specific partition. * @param partition Name of the partition. * @param tokenHolder Address for which we want to redeem tokens. * @param value Number of tokens redeemed * @param operatorData Information attached to the redemption, by the operator. */ function operatorRedeemByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata operatorData) external override { require(_isOperatorForPartition(partition, msg.sender, tokenHolder), "58"); // 0x58 invalid operator (transfer agent) _redeemByPartition(partition, msg.sender, tokenHolder, value, "", operatorData); } /************************************************************************************************/ /************************************************************************************************/ /************************ EXTERNAL FUNCTIONS (ADDITIONAL - NOT MANDATORY) ***********************/ /************************************************************************************************/ /************************************ Token description *****************************************/ /** * @dev Get the name of the token, e.g., "MyToken". * @return Name of the token. */ function name() external view returns(string memory) { return _name; } /** * @dev Get the symbol of the token, e.g., "MYT". * @return Symbol of the token. */ function symbol() external view returns(string memory) { return _symbol; } /** * @dev Get the number of decimals of the token. * @return The number of decimals of the token. For retrocompatibility, decimals are forced to 18 in ERC1400. */ function decimals() external pure returns(uint8) { return uint8(18); } /** * @dev Get the smallest part of the token that’s not divisible. * @return The smallest non-divisible part of the token. */ function granularity() external view returns(uint256) { return _granularity; } /** * @dev Get list of existing partitions. * @return Array of all exisiting partitions. */ function totalPartitions() external view returns (bytes32[] memory) { return _totalPartitions; } /** * @dev Get the total number of issued tokens for a given partition. * @param partition Name of the partition. * @return Total supply of tokens currently in circulation, for a given partition. */ function totalSupplyByPartition(bytes32 partition) external view returns (uint256) { return _totalSupplyByPartition[partition]; } /************************************************************************************************/ /************************************************************************************************/ /************************************* INTERNAL FUNCTIONS ***************************************/ /************************************************************************************************/ /**************************************** Token Transfers ***************************************/ /** * @dev Perform the transfer of tokens. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. */ function _transferWithData( address from, address to, uint256 value ) internal isNotMigratedToken { require(_isMultiple(value), "50"); // 0x50 transfer failure require(to != address(0), "57"); // 0x57 invalid receiver require(_balances[from] >= value, "52"); // 0x52 insufficient balance _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); // ERC20 retrocompatibility } /** * @dev Transfer tokens from a specific partition. * @param fromPartition Partition of the tokens to transfer. * @param operator The address performing the transfer. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] * @param operatorData Information attached to the transfer, by the operator (if any). * @return Destination partition. */ function _transferByPartition( bytes32 fromPartition, address operator, address from, address to, uint256 value, bytes memory data, bytes memory operatorData ) internal returns (bytes32) { require(_balanceOfByPartition[from][fromPartition] >= value, "52"); // 0x52 insufficient balance bytes32 toPartition = fromPartition; if(operatorData.length != 0 && data.length >= 64) { toPartition = _getDestinationPartition(fromPartition, data); } //_callSenderExtension(fromPartition, operator, from, to, value, data, operatorData); //_callTokenExtension(fromPartition, operator, from, to, value, data, operatorData); _removeTokenFromPartition(from, fromPartition, value); _transferWithData(from, to, value); _addTokenToPartition(to, toPartition, value); //_callRecipientExtension(toPartition, operator, from, to, value, data, operatorData); emit TransferByPartition(fromPartition, operator, from, to, value, data, operatorData); if(toPartition != fromPartition) { emit ChangedPartition(fromPartition, toPartition, value); } return toPartition; } /** * @dev Transfer tokens from default partitions. * Function used for ERC20 retrocompatibility. * @param operator The address performing the transfer. * @param from Token holder. * @param to Token recipient. * @param value Number of tokens to transfer. * @param data Information attached to the transfer, and intended for the token holder ('from') [CAN CONTAIN THE DESTINATION PARTITION]. */ function _transferByDefaultPartitions( address operator, address from, address to, uint256 value, bytes memory data ) internal { require(_defaultPartitions.length != 0, "55"); // // 0x55 funds locked (lockup period) uint256 _remainingValue = value; uint256 _localBalance; for (uint i = 0; i < _defaultPartitions.length; i++) { _localBalance = _balanceOfByPartition[from][_defaultPartitions[i]]; if(_remainingValue <= _localBalance) { _transferByPartition(_defaultPartitions[i], operator, from, to, _remainingValue, data, ""); _remainingValue = 0; break; } else if (_localBalance != 0) { _transferByPartition(_defaultPartitions[i], operator, from, to, _localBalance, data, ""); _remainingValue = _remainingValue - _localBalance; } } require(_remainingValue == 0, "52"); // 0x52 insufficient balance } /** * @dev Retrieve the destination partition from the 'data' field. * By convention, a partition change is requested ONLY when 'data' starts * with the flag: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff * When the flag is detected, the destination tranche is extracted from the * 32 bytes following the flag. * @param fromPartition Partition of the tokens to transfer. * @param data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] * @return toPartition Destination partition. */ function _getDestinationPartition(bytes32 fromPartition, bytes memory data) internal pure returns(bytes32 toPartition) { bytes32 changePartitionFlag = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; bytes32 flag; assembly { flag := mload(add(data, 32)) } if(flag == changePartitionFlag) { assembly { toPartition := mload(add(data, 64)) } } else { toPartition = fromPartition; } } /** * @dev Remove a token from a specific partition. * @param from Token holder. * @param partition Name of the partition. * @param value Number of tokens to transfer. */ function _removeTokenFromPartition(address from, bytes32 partition, uint256 value) internal { _balanceOfByPartition[from][partition] = _balanceOfByPartition[from][partition].sub(value); _totalSupplyByPartition[partition] = _totalSupplyByPartition[partition].sub(value); // If the total supply is zero, finds and deletes the partition. if(_totalSupplyByPartition[partition] == 0) { uint256 index1 = _indexOfTotalPartitions[partition]; require(index1 > 0, "50"); // 0x50 transfer failure // move the last item into the index being vacated bytes32 lastValue = _totalPartitions[_totalPartitions.length - 1]; _totalPartitions[index1 - 1] = lastValue; // adjust for 1-based indexing _indexOfTotalPartitions[lastValue] = index1; _totalPartitions.pop(); _indexOfTotalPartitions[partition] = 0; } // If the balance of the TokenHolder's partition is zero, finds and deletes the partition. if(_balanceOfByPartition[from][partition] == 0) { uint256 index2 = _indexOfPartitionsOf[from][partition]; require(index2 > 0, "50"); // 0x50 transfer failure // move the last item into the index being vacated bytes32 lastValue = _partitionsOf[from][_partitionsOf[from].length - 1]; _partitionsOf[from][index2 - 1] = lastValue; // adjust for 1-based indexing _indexOfPartitionsOf[from][lastValue] = index2; _partitionsOf[from].pop(); _indexOfPartitionsOf[from][partition] = 0; } } /** * @dev Add a token to a specific partition. * @param to Token recipient. * @param partition Name of the partition. * @param value Number of tokens to transfer. */ function _addTokenToPartition(address to, bytes32 partition, uint256 value) internal { if(value != 0) { if (_indexOfPartitionsOf[to][partition] == 0) { _partitionsOf[to].push(partition); _indexOfPartitionsOf[to][partition] = _partitionsOf[to].length; } _balanceOfByPartition[to][partition] = _balanceOfByPartition[to][partition].add(value); if (_indexOfTotalPartitions[partition] == 0) { _totalPartitions.push(partition); _indexOfTotalPartitions[partition] = _totalPartitions.length; } _totalSupplyByPartition[partition] = _totalSupplyByPartition[partition].add(value); } } /** * @dev Check if 'value' is multiple of the granularity. * @param value The quantity that want's to be checked. * @return 'true' if 'value' is a multiple of the granularity. */ function _isMultiple(uint256 value) internal view returns(bool) { return(value.div(_granularity).mul(_granularity) == value); } /************************************************************************************************/ /************************************* Operator Information *************************************/ /** * @dev Indicate whether the operator address is an operator of the tokenHolder address. * @param operator Address which may be an operator of 'tokenHolder'. * @param tokenHolder Address of a token holder which may have the 'operator' address as an operator. * @return 'true' if 'operator' is an operator of 'tokenHolder' and 'false' otherwise. */ function _isOperator(address operator, address tokenHolder) internal view returns (bool) { return (operator == tokenHolder || _authorizedOperator[operator][tokenHolder] || (_isControllable && _isController[operator]) ); } /** * @dev Indicate whether the operator address is an operator of the tokenHolder * address for the given partition. * @param partition Name of the partition. * @param operator Address which may be an operator of tokenHolder for the given partition. * @param tokenHolder Address of a token holder which may have the operator address as an operator for the given partition. * @return 'true' if 'operator' is an operator of 'tokenHolder' for partition 'partition' and 'false' otherwise. */ function _isOperatorForPartition(bytes32 partition, address operator, address tokenHolder) internal view returns (bool) { return (_isOperator(operator, tokenHolder) || _authorizedOperatorByPartition[tokenHolder][partition][operator] || (_isControllable && _isControllerByPartition[partition][operator]) ); } /************************************************************************************************/ /**************************************** Token Issuance ****************************************/ /** * @dev Perform the issuance of tokens. * @param operator Address which triggered the issuance. * @param to Token recipient. * @param value Number of tokens issued. * @param data Information attached to the issuance, and intended for the recipient (to). */ function _issue(address operator, address to, uint256 value, bytes memory data) internal isNotMigratedToken { require(_isMultiple(value), "50"); // 0x50 transfer failure require(to != address(0), "57"); // 0x57 invalid receiver _totalSupply = _totalSupply.add(value); _balances[to] = _balances[to].add(value); emit Issued(operator, to, value, data); emit Transfer(address(0), to, value); // ERC20 retrocompatibility } /** * @dev Issue tokens from a specific partition. * @param toPartition Name of the partition. * @param operator The address performing the issuance. * @param to Token recipient. * @param value Number of tokens to issue. * @param data Information attached to the issuance. */ function _issueByPartition( bytes32 toPartition, address operator, address to, uint256 value, bytes memory data ) internal { //_callTokenExtension(toPartition, operator, address(0), to, value, data, ""); _issue(operator, to, value, data); _addTokenToPartition(to, toPartition, value); //_callRecipientExtension(toPartition, operator, address(0), to, value, data, ""); emit IssuedByPartition(toPartition, operator, to, value, data, ""); } /************************************************************************************************/ /*************************************** Token Redemption ***************************************/ /** * @dev Perform the token redemption. * @param operator The address performing the redemption. * @param from Token holder whose tokens will be redeemed. * @param value Number of tokens to redeem. * @param data Information attached to the redemption. */ function _redeem(address operator, address from, uint256 value, bytes memory data) internal isNotMigratedToken { require(_isMultiple(value), "50"); // 0x50 transfer failure require(from != address(0), "56"); // 0x56 invalid sender require(_balances[from] >= value, "52"); // 0x52 insufficient balance _balances[from] = _balances[from].sub(value); _totalSupply = _totalSupply.sub(value); emit Redeemed(operator, from, value, data); emit Transfer(from, address(0), value); // ERC20 retrocompatibility } /** * @dev Redeem tokens of a specific partition. * @param fromPartition Name of the partition. * @param operator The address performing the redemption. * @param from Token holder whose tokens will be redeemed. * @param value Number of tokens to redeem. * @param data Information attached to the redemption. * @param operatorData Information attached to the redemption, by the operator (if any). */ function _redeemByPartition( bytes32 fromPartition, address operator, address from, uint256 value, bytes memory data, bytes memory operatorData ) internal { require(_balanceOfByPartition[from][fromPartition] >= value, "52"); // 0x52 insufficient balance //_callSenderExtension(fromPartition, operator, from, address(0), value, data, operatorData); //_callTokenExtension(fromPartition, operator, from, address(0), value, data, operatorData); _removeTokenFromPartition(from, fromPartition, value); _redeem(operator, from, value, data); emit RedeemedByPartition(fromPartition, operator, from, value, operatorData); } /** * @dev Redeem tokens from a default partitions. * @param operator The address performing the redeem. * @param from Token holder. * @param value Number of tokens to redeem. * @param data Information attached to the redemption. */ function _redeemByDefaultPartitions( address operator, address from, uint256 value, bytes memory data ) internal { require(_defaultPartitions.length != 0, "55"); // 0x55 funds locked (lockup period) uint256 _remainingValue = value; uint256 _localBalance; for (uint i = 0; i < _defaultPartitions.length; i++) { _localBalance = _balanceOfByPartition[from][_defaultPartitions[i]]; if(_remainingValue <= _localBalance) { _redeemByPartition(_defaultPartitions[i], operator, from, _remainingValue, data, ""); _remainingValue = 0; break; } else { _redeemByPartition(_defaultPartitions[i], operator, from, _localBalance, data, ""); _remainingValue = _remainingValue - _localBalance; } } require(_remainingValue == 0, "52"); // 0x52 insufficient balance } /************************************************************************************************/ /************************************************************************************************/ /************************ INTERNAL FUNCTIONS (ADDITIONAL - NOT MANDATORY) ***********************/ /************************************************************************************************/ /************************************ Token controllers *****************************************/ /** * @dev Set list of token controllers. * @param operators Controller addresses. */ function _setControllers(address[] memory operators) internal { for (uint i = 0; i<_controllers.length; i++){ _isController[_controllers[i]] = false; } for (uint j = 0; j<operators.length; j++){ _isController[operators[j]] = true; } _controllers = operators; } /** * @dev Set list of token partition controllers. * @param partition Name of the partition. * @param operators Controller addresses. */ function _setPartitionControllers(bytes32 partition, address[] memory operators) internal { for (uint i = 0; i<_controllersByPartition[partition].length; i++){ _isControllerByPartition[partition][_controllersByPartition[partition][i]] = false; } for (uint j = 0; j<operators.length; j++){ _isControllerByPartition[partition][operators[j]] = true; } _controllersByPartition[partition] = operators; } /************************************************************************************************/ }
0x55 funds locked (lockup period)
require(_defaultPartitions.length > 1, "55");
13,112,447
[ 1, 4625, 348, 7953, 560, 30, 225, 374, 92, 2539, 202, 74, 19156, 8586, 261, 739, 416, 3879, 13, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2583, 24899, 1886, 13738, 18, 2469, 405, 404, 16, 315, 2539, 8863, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0xfDA0Da7E45dDCFBaDA35BF01Dd2C85bA881FAef3/sources/contracts/MaximPresale.sol
Function for purchasing tokens params - _tokenId for checking if address owns NFT/
function nftHolderPurchase() external payable nonReentrant whenNotPaused { require(getNFTBalanceOfAddress(msg.sender) > 0, "ERROR 421: Address does not own NFT."); _purchase(); }
16,557,798
[ 1, 4625, 348, 7953, 560, 30, 225, 4284, 364, 5405, 343, 11730, 2430, 859, 300, 389, 2316, 548, 364, 6728, 309, 1758, 29065, 423, 4464, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 290, 1222, 6064, 23164, 1435, 3903, 8843, 429, 1661, 426, 8230, 970, 1347, 1248, 28590, 288, 203, 3639, 2583, 12, 588, 50, 4464, 13937, 951, 1887, 12, 3576, 18, 15330, 13, 405, 374, 16, 315, 3589, 1059, 5340, 30, 5267, 1552, 486, 4953, 423, 4464, 1199, 1769, 203, 3639, 389, 12688, 12104, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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 /* ████ ████ ██████ ██████ ████████ ████████ ██████████████████████ ██████████████████████ ██████ ██████ ██████ ██████ ██ ██ ██████ ██████████████████████████ ██████████ ██████████ ████████ ████████ ██████████████████ ██████████ Wulfz / 2021 */ pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "./Profile.sol"; import "./Awoo.sol"; import "./StakingPool.sol"; contract WulfzNFT is Profile, Ownable { enum WulfzType { Genesis, Pupz, Alpha } struct WulfzInfo { WulfzType wType; bool bStaked; uint256 lastBreedTime; } event WulfzMinted( address indexed user, uint256 indexed tokenId, uint256 indexed wType ); event PreSaleTimeChanged(uint256 newTime, uint256 currentTime); event PublicSaleTimeChanged(uint256 newTime, uint256 currentTime); event StakingTimeChanged(uint256 newTime, uint256 currentTime); event EvolveTimeChanged(uint256 newTime, uint256 currentTime); event AdoptionTimeChanged(uint256 newTime, uint256 currentTime); event PoolAddrSet(address from, address addr); event UtilityAddrSet(address from, address addr); uint256 public constant MINT_PRICE = 80000000000000000; // 0.08 ETH uint256 public constant BREED_PRICE = 600; uint256 public constant EVOLVE_PRICE = 1500; uint256[] private COOLDOWN_TIME_FOR_BREED = [14 days, 0, 7 days]; uint256[] private MAX_SUPPLY_BY_TYPE = [5555, 10000, 100]; uint256[] private START_ID_BY_TYPE = [0, 6000, 5600]; uint256[] public totalSupplyByType = [0, 0, 0]; uint256 public startTimeOfPrivateSale; uint256 public startTimeOfPublicSale; uint256 public startTimeOfStaking; uint256 public startTimeOfAdopt; uint256 public startTimeOfEvolve; mapping(uint256 => WulfzInfo) public wulfz; mapping(address => bool) private claimInPresale; mapping(address => uint256) private claimInPublicSale; string public _baseTokenURI = "https://ipfs.io/ipfs/QmQtN81i9eNrD3wxcr67scDpLvZDDXxbmAvNXMaZh3D6tB/"; UtilityToken private _utilityToken; StakingPool private _pool; constructor(string memory _name, string memory _symbol) Profile(_name, _symbol) { startTimeOfPrivateSale = 1640624400; // Mon Dec 27 2021 12:00:00 GMT-0500 (Eastern Standard Time) startTimeOfPublicSale = 1640710800; // Tue Dec 28 2021 12:00:00 GMT-0500 (Eastern Standard Time) startTimeOfStaking = 1641574800; // Fri Jan 07 2022 12:00:00 GMT-0500 (Eastern Standard Time) startTimeOfAdopt = 1646110800; // Tue Mar 01 2022 00:00:00 GMT-0500 (Eastern Standard Time) startTimeOfEvolve = 1654056000; // Wed Jun 01 2022 00:00:00 GMT-0400 (Eastern Daylight Time) // 55 Wulfz will be held in the Vault for Promotional purposes for (uint256 i = 0; i < 55; i++) { mintOne(WulfzType.Genesis); } } /** * @dev return the Base URI of the token */ function _baseURI() internal view override returns (string memory) { return _baseTokenURI; } /** * @dev set the _baseTokenURI * @param _newURI of the _baseTokenURI */ function setBaseURI(string calldata _newURI) external onlyOwner { _baseTokenURI = _newURI; } function withdraw() public onlyOwner { uint256 balance = address(this).balance; require(balance > 0, "Balance is zero"); payable(msg.sender).transfer(balance); } function getWulfzType(uint256 _tokenId) public view returns (uint256) { return uint256(wulfz[_tokenId].wType); } /** * @dev Only whitelisted can mint */ function Presale(bytes32[] calldata _proof) external payable { require(msg.value >= MINT_PRICE, "Minting Price is not enough"); require( block.timestamp > startTimeOfPrivateSale, "Private Sale is not started yet" ); require( block.timestamp < startTimeOfPrivateSale + 86400, "Private Sale is already ended" ); require( !claimInPresale[msg.sender], "You've already minted token. If you want more, you will be able to mint during Public Sale" ); bytes32 merkleTreeRoot = 0x12b1013fe853dea282b3440a70e5d739b7ef75e135122659fe5408bde23a4cc1; bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require( MerkleProof.verify(_proof, merkleTreeRoot, leaf), "Sorry, you're not whitelisted. Please try Public Sale" ); claimInPresale[msg.sender] = true; mintOne(WulfzType.Genesis); } /** * @dev Mint the _amount of tokens * @param _amount is the token count */ function PublicSale(uint256 _amount) external payable { require( msg.value >= MINT_PRICE * _amount, "Minting Price is not enough" ); require( block.timestamp > startTimeOfPublicSale, "Public Sale is not started yet" ); require( block.timestamp < startTimeOfPublicSale + 86400, "Public Sale is already ended" ); require(_amount < 3, "You can only require at most 2"); require( claimInPublicSale[msg.sender] < 3, "You can only mint at most 2 during Public Sale" ); claimInPublicSale[msg.sender] += _amount; for (uint256 i = 0; i < _amount; i++) { mintOne(WulfzType.Genesis); } } function mintOne(WulfzType _type) private { require(msg.sender == tx.origin); require( totalSupplyByType[uint256(_type)] < MAX_SUPPLY_BY_TYPE[uint256(_type)], "All tokens are minted" ); uint256 tokenId = ++totalSupplyByType[uint256(_type)]; tokenId += START_ID_BY_TYPE[uint256(_type)]; _safeMint(msg.sender, tokenId); wulfz[tokenId].wType = _type; emit WulfzMinted(msg.sender, tokenId, uint256(_type)); } function setUtilitytoken(address _addr) external onlyOwner { _utilityToken = UtilityToken(_addr); emit UtilityAddrSet(address(this), _addr); } function setStakingPool(address _addr) external onlyOwner { _pool = StakingPool(_addr); emit PoolAddrSet(address(this), _addr); } function setStartTimeOfPrivateSale(uint256 _timeStamp) external onlyOwner { startTimeOfPrivateSale = _timeStamp; emit PreSaleTimeChanged(startTimeOfPrivateSale, block.timestamp); } function setStartTimeOfPublicSale(uint256 _timeStamp) external onlyOwner { startTimeOfPublicSale = _timeStamp; emit PublicSaleTimeChanged(startTimeOfPublicSale, block.timestamp); } /******************************************************************************* *** Staking Logic *** ******************************************************************************** */ function setStakingTime(uint256 _timeStamp) external onlyOwner { startTimeOfStaking = _timeStamp; emit StakingTimeChanged(startTimeOfStaking, block.timestamp); } function startStaking(uint256 _tokenId) external { require( block.timestamp > startTimeOfStaking, "Staking Mechanism is not started yet" ); require(ownerOf(_tokenId) == msg.sender, "Staking: owner not matched"); require( !wulfz[_tokenId].bStaked, "This Token is already staked. Please try another token." ); _pool.startStaking(msg.sender, _tokenId); _safeTransfer(msg.sender, address(_pool), _tokenId, ""); wulfz[_tokenId].bStaked = true; } function stopStaking(uint256 _tokenId) external { require( wulfz[_tokenId].bStaked, "This token hasn't ever been staked yet." ); _pool.stopStaking(msg.sender, _tokenId); _safeTransfer(address(_pool), msg.sender, _tokenId, ""); wulfz[_tokenId].bStaked = false; } /******************************************************************************* *** Adopting Logic *** ********************************************************************************/ function setAdoptTime(uint256 _timeStamp) external onlyOwner { startTimeOfAdopt = _timeStamp; emit AdoptionTimeChanged(startTimeOfAdopt, block.timestamp); } function canAdopt(uint256 _tokenId) public view returns (bool) { uint256 wType = uint256(wulfz[_tokenId].wType); require( wulfz[_tokenId].wType != WulfzType.Pupz, "Try adopting with Genesis or Alpha Wulfz" ); uint256 lastBreedTime = wulfz[_tokenId].lastBreedTime; uint256 cooldown = COOLDOWN_TIME_FOR_BREED[wType]; return (block.timestamp - lastBreedTime) > cooldown; } function isAdoptionStart() public view returns (bool) { return block.timestamp > startTimeOfAdopt; } function adopt(uint256 _parent) external { require( canAdopt(_parent), "Already adopt in the past days. Genesis Wulfz can adopt every 14 days and Alpha can do every 7 days." ); require(isAdoptionStart(), "Adopting Pupz is not ready yet"); require( ownerOf(_parent) == msg.sender, "Adopting: You're not owner of this token" ); require( !wulfz[_parent].bStaked, "This Token is already staked. Please try another token." ); _utilityToken.burn( msg.sender, BREED_PRICE * (10**_utilityToken.decimals()) ); mintOne(WulfzType.Pupz); wulfz[_parent].lastBreedTime = block.timestamp; } /******************************************************************************* *** Evolution Logic *** ********************************************************************************/ function setEvolveTime(uint256 _timeStamp) external onlyOwner { startTimeOfEvolve = _timeStamp; emit EvolveTimeChanged(startTimeOfEvolve, block.timestamp); } function isEvolveStart() public view returns (bool) { return block.timestamp > startTimeOfEvolve; } function evolve(uint256 _tokenId) external { require(isEvolveStart(), "Evolving Wulfz is not ready yet"); require( ownerOf(_tokenId) == msg.sender, "Evolve: You're not owner of this token" ); require( wulfz[_tokenId].wType == WulfzType.Genesis, "Genesis can only evolve Alpha" ); require( !wulfz[_tokenId].bStaked, "This Token is already staked. Please try another token." ); _utilityToken.burn( msg.sender, EVOLVE_PRICE * (10**_utilityToken.decimals()) ); _burn(_tokenId); mintOne(WulfzType.Alpha); } /******************************************************************************* *** Profile Change *** ********************************************************************************/ function changeName(uint256 _tokenId, string memory newName) public override { require( ownerOf(_tokenId) == msg.sender, "ChangeName: you're not the owner" ); require( !wulfz[_tokenId].bStaked, "This Token is already staked. Please try another token." ); _utilityToken.burn( msg.sender, NAME_CHANGE_PRICE * (10**_utilityToken.decimals()) ); super.changeName(_tokenId, newName); } function changeBio(uint256 _tokenId, string memory _bio) public override { require( ownerOf(_tokenId) == msg.sender, "ChangeBio: you're not the owner" ); _utilityToken.burn( msg.sender, BIO_CHANGE_PRICE * (10**_utilityToken.decimals()) ); super.changeBio(_tokenId, _bio); } } // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./Awoo.sol"; interface IWulfz { function getWulfzType(uint256 _tokenId) external view returns (uint256); } contract StakingPool is IERC721Receiver, Ownable { using EnumerableSet for EnumerableSet.UintSet; event StakeStarted(address indexed user, uint256 indexed tokenId); event StakeStopped(address indexed user, uint256 indexed tokenId); event UtilityAddrSet(address from, address addr); uint256[] private STAKE_REWARD_BY_TYPE = [10, 5, 50]; IWulfz private _wulfzContract; UtilityToken private _utilityToken; struct StakedInfo { uint256 wType; uint256 lastUpdate; } mapping(uint256 => StakedInfo) private tokenInfo; mapping(address => EnumerableSet.UintSet) private stakedWulfz; modifier masterContract() { require( msg.sender == address(_wulfzContract), "Master Contract can only call Staking Contract" ); _; } constructor(address _wulfzAddr) { _wulfzContract = IWulfz(_wulfzAddr); } function setUtilitytoken(address _addr) external onlyOwner { _utilityToken = UtilityToken(_addr); emit UtilityAddrSet(address(this), _addr); } function startStaking(address _user, uint256 _tokenId) external masterContract { require(!stakedWulfz[_user].contains(_tokenId), "Already staked"); tokenInfo[_tokenId].wType = _wulfzContract.getWulfzType(_tokenId); tokenInfo[_tokenId].lastUpdate = block.timestamp; stakedWulfz[_user].add(_tokenId); emit StakeStarted(_user, _tokenId); } function stopStaking(address _user, uint256 _tokenId) external masterContract { require(stakedWulfz[_user].contains(_tokenId), "You're not the owner"); uint256 wType = tokenInfo[_tokenId].wType; uint256 rewardBase = STAKE_REWARD_BY_TYPE[wType]; uint256 interval = block.timestamp - tokenInfo[_tokenId].lastUpdate; uint256 reward = ((rewardBase * interval) * 10**_utilityToken.decimals()) / 86400; _utilityToken.reward(_user, reward); delete tokenInfo[_tokenId]; stakedWulfz[_user].remove(_tokenId); emit StakeStopped(_user, _tokenId); } function stakedTokensOf(address _user) public view returns (uint256[] memory) { uint256[] memory tokens = new uint256[](stakedWulfz[_user].length()); for (uint256 i = 0; i < stakedWulfz[_user].length(); i++) { tokens[i] = stakedWulfz[_user].at(i); } return tokens; } function getClaimableToken(address _user) public view returns (uint256) { uint256[] memory tokens = stakedTokensOf(_user); uint256 totalAmount = 0; for (uint256 i = 0; i < tokens.length; i++) { uint256 wType = tokenInfo[tokens[i]].wType; uint256 rewardBase = STAKE_REWARD_BY_TYPE[wType]; uint256 interval = block.timestamp - tokenInfo[tokens[i]].lastUpdate; uint256 reward = ((rewardBase * interval) * 10**_utilityToken.decimals()) / 86400; totalAmount += reward; } return totalAmount; } function getReward() external { _utilityToken.reward(msg.sender, getClaimableToken(msg.sender)); for (uint256 i = 0; i < stakedWulfz[msg.sender].length(); i++) { uint256 tokenId = stakedWulfz[msg.sender].at(i); tokenInfo[tokenId].lastUpdate = block.timestamp; } } /** * ERC721Receiver hook for single transfer. * @dev Reverts if the caller is not the whitelisted NFT contract. */ function onERC721Received( address, /*operator*/ address, /*from*/ uint256, /* tokenId */ bytes calldata /*data*/ ) external view override returns (bytes4) { require( address(_wulfzContract) == msg.sender, "You can stake only Wulfz" ); return this.onERC721Received.selector; } } // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; // import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract Profile is ERC721Enumerable { event NameChange(uint256 indexed tokenId, string newName); event BioChange(uint256 indexed tokenId, string bio); uint256 public constant NAME_CHANGE_PRICE = 50; uint256 public constant BIO_CHANGE_PRICE = 100; mapping(uint256 => string) public bio; // Mapping from token ID to name mapping(uint256 => string) private _tokenName; // Mapping if certain name string has already been reserved mapping(string => bool) private _nameReserved; constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {} function changeBio(uint256 _tokenId, string memory _bio) public virtual { address owner = ownerOf(_tokenId); require(msg.sender == owner, "ERC721: caller is not the owner"); bio[_tokenId] = _bio; emit BioChange(_tokenId, _bio); } function changeName(uint256 tokenId, string memory newName) public virtual { address owner = ownerOf(tokenId); require(msg.sender == owner, "ERC721: caller is not the owner"); require(validateName(newName) == true, "Not a valid new name"); require( sha256(bytes(newName)) != sha256(bytes(_tokenName[tokenId])), "New name is same as the current one" ); require(isNameReserved(newName) == false, "Name already reserved"); // If already named, dereserve old name if (bytes(_tokenName[tokenId]).length > 0) { toggleReserveName(_tokenName[tokenId], false); } toggleReserveName(newName, true); _tokenName[tokenId] = newName; emit NameChange(tokenId, newName); } /** * @dev Reserves the name if isReserve is set to true, de-reserves if set to false */ function toggleReserveName(string memory str, bool isReserve) internal { _nameReserved[toLower(str)] = isReserve; } /** * @dev Returns name of the NFT at index. */ function tokenNameByIndex(uint256 index) public view returns (string memory) { return _tokenName[index]; } /** * @dev Returns if the name has been reserved. */ function isNameReserved(string memory nameString) public view returns (bool) { return _nameReserved[toLower(nameString)]; } function validateName(string memory str) public pure returns (bool) { bytes memory b = bytes(str); if (b.length < 1) return false; if (b.length > 25) return false; // Cannot be longer than 25 characters if (b[0] == 0x20) return false; // Leading space if (b[b.length - 1] == 0x20) return false; // Trailing space bytes1 lastChar = b[0]; for (uint256 i; i < b.length; i++) { bytes1 char = b[i]; if (char == 0x20 && lastChar == 0x20) return false; // Cannot contain continous spaces if ( !(char >= 0x30 && char <= 0x39) && //9-0 !(char >= 0x41 && char <= 0x5A) && //A-Z !(char >= 0x61 && char <= 0x7A) && //a-z !(char == 0x20) //space ) return false; lastChar = char; } return true; } /** * @dev Converts the string to lowercase */ function toLower(string memory str) public pure returns (string memory) { bytes memory bStr = bytes(str); bytes memory bLower = new bytes(bStr.length); for (uint256 i = 0; i < bStr.length; i++) { // Uppercase character if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90)) { bLower[i] = bytes1(uint8(bStr[i]) + 32); } else { bLower[i] = bStr[i]; } } return string(bLower); } } // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract UtilityToken is ERC20("Awoo", "AWOO"), Ownable { event AwooBurn(address indexed user, uint256 amount); event AwooRewarded(address indexed user, uint256 amount); uint256 public constant TOTAL_SUPPLY_AWOO = 200000000 * 10**2; address private _wulfzAddr; address private _stakingAddr; constructor(address wulfzAddr_, address stakingAddr_) { _wulfzAddr = wulfzAddr_; _stakingAddr = stakingAddr_; } function decimals() public pure override returns (uint8) { return 2; } function burn(address _from, uint256 _amount) external { require(msg.sender == _wulfzAddr, "Only Wulfz Contract can call"); _burn(_from, _amount); emit AwooBurn(_from, _amount); } function reward(address _to, uint256 _amount) external { require(msg.sender == _stakingAddr, "Only Staking Contract can call"); if (_amount > 0) { require( (totalSupply() + _amount) < TOTAL_SUPPLY_AWOO, "MAX LIMIT SUPPLY EXCEEDED" ); _mint(_to, _amount); emit AwooRewarded(_to, _amount); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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]; } /** * @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 // 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; } } } // SPDX-License-Identifier: MIT // 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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) 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 // OpenZeppelin Contracts v4.4.1 (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 = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // 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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.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 ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // 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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @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; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.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 ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 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 // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) 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 Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) 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() { _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); } }
Fri Jan 07 2022 12:00:00 GMT-0500 (Eastern Standard Time)
startTimeOfStaking = 1641574800;
13,991,706
[ 1, 4625, 348, 7953, 560, 30, 225, 478, 566, 23214, 10934, 26599, 22, 2593, 30, 713, 30, 713, 21706, 17, 6260, 713, 261, 41, 2440, 82, 8263, 2647, 13, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 8657, 951, 510, 6159, 273, 404, 1105, 3600, 5608, 17374, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/11155111/0x6165aA9A34DBc9b171b6B0b2aF0ad08E2d930F30/sources/project:/contracts/vaultAnalyzer/VaultAnalizer.sol
* Function to get the amount of tokens generated by depositing the underlying assets @param _assets List of assets to be deposited/
function previewDeposit( uint256[] memory _assets, address vault ) public view returns (uint256) { Token[] memory tokens = getTokens(vault); uint256 maxMintable = 0; if (_assets.length != tokens.length) return maxMintable; maxMintable = _assets[0] / tokens[0].allocation; for (uint256 i = 1; i < tokens.length; i++) { if (_assets[i] / tokens[i].allocation < maxMintable) maxMintable = _assets[i] / tokens[i].allocation; } return maxMintable; }
3,808,623
[ 1, 4625, 348, 7953, 560, 30, 380, 4284, 358, 336, 326, 3844, 434, 2430, 4374, 635, 443, 1724, 310, 326, 6808, 7176, 632, 891, 389, 9971, 987, 434, 7176, 358, 506, 443, 1724, 329, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 10143, 758, 1724, 12, 203, 565, 2254, 5034, 8526, 3778, 389, 9971, 16, 203, 565, 1758, 9229, 203, 225, 262, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 3155, 8526, 3778, 2430, 273, 18349, 12, 26983, 1769, 203, 565, 2254, 5034, 943, 49, 474, 429, 273, 374, 31, 203, 565, 309, 261, 67, 9971, 18, 2469, 480, 2430, 18, 2469, 13, 327, 943, 49, 474, 429, 31, 203, 565, 943, 49, 474, 429, 273, 389, 9971, 63, 20, 65, 342, 2430, 63, 20, 8009, 29299, 31, 203, 565, 364, 261, 11890, 5034, 277, 273, 404, 31, 277, 411, 2430, 18, 2469, 31, 277, 27245, 288, 203, 1377, 309, 261, 67, 9971, 63, 77, 65, 342, 2430, 63, 77, 8009, 29299, 411, 943, 49, 474, 429, 13, 203, 3639, 943, 49, 474, 429, 273, 389, 9971, 63, 77, 65, 342, 2430, 63, 77, 8009, 29299, 31, 203, 565, 289, 203, 565, 327, 943, 49, 474, 429, 31, 203, 225, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/11155111/0x298F37fFd4B31d216B8954968cEe7EC5273CB891/sources/src/Drips.sol
@notice Maximum number of streams receivers of a single account. Limits cost of changes in streams configuration. @notice The additional decimals for all amtPerSec values. @notice The multiplier for all amtPerSec values. @notice Maximum number of splits receivers of a single account. Limits the cost of splitting. @notice The total splits weight of an account @notice The offset of the controlling driver ID in the account ID. In other words the controlling driver ID is the highest 32 bits of the account ID. Every account ID is a 256-bit integer constructed by concatenating: `driverId (32 bits) | driverCustomData (224 bits)`. @notice The total amount the protocol can store of each token. It's the minimum of _MAX_STREAMS_BALANCE and _MAX_SPLITS_BALANCE. @notice On every timestamp `T`, which is a multiple of `cycleSecs`, the receivers gain access to steams received during `T - cycleSecs` to `T - 1`. Always higher than 1. @notice The minimum amtPerSec of a stream. It's 1 token per cycle. @notice The ERC-1967 storage slot holding a single `DripsStorage` structure. @notice Emitted when a driver is registered @param driverId The driver ID @param driverAddr The driver address @notice Emitted when a driver address is updated @param driverId The driver ID @param oldDriverAddr The old driver address @param newDriverAddr The new driver address @notice Emitted when funds are withdrawn. @param erc20 The used ERC-20 token. @param receiver The address that the funds are sent to. @param amt The withdrawn amount. @notice Emitted by the account to broadcast metadata. The key and the value are not standardized by the protocol, it's up to the users to establish and follow conventions to ensure compatibility with the consumers. @param accountId The ID of the account emitting metadata @param key The metadata key @param value The metadata value
struct DripsStorage { uint32 nextDriverId; mapping(uint32 driverId => address) driverAddresses; mapping(IERC20 erc20 => Balance) balances;
3,819,314
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 18848, 1300, 434, 8205, 22686, 434, 279, 2202, 2236, 18, 27240, 6991, 434, 3478, 316, 8205, 1664, 18, 632, 20392, 1021, 3312, 15105, 364, 777, 25123, 2173, 2194, 924, 18, 632, 20392, 1021, 15027, 364, 777, 25123, 2173, 2194, 924, 18, 632, 20392, 18848, 1300, 434, 11019, 22686, 434, 279, 2202, 2236, 18, 27240, 326, 6991, 434, 20347, 18, 632, 20392, 1021, 2078, 11019, 3119, 434, 392, 2236, 632, 20392, 1021, 1384, 434, 326, 3325, 2456, 3419, 1599, 316, 326, 2236, 1599, 18, 657, 1308, 4511, 326, 3325, 2456, 3419, 1599, 353, 326, 9742, 3847, 4125, 434, 326, 2236, 1599, 18, 16420, 2236, 1599, 353, 279, 8303, 17, 3682, 3571, 15688, 635, 8311, 1776, 30, 1375, 7407, 548, 261, 1578, 4125, 13, 571, 3419, 3802, 751, 261, 23622, 4125, 13, 8338, 632, 20392, 1021, 2078, 3844, 326, 1771, 848, 1707, 434, 1517, 1147, 18, 2597, 1807, 326, 5224, 434, 389, 6694, 67, 13693, 55, 67, 38, 1013, 4722, 471, 389, 6694, 67, 3118, 48, 10158, 67, 38, 1013, 4722, 18, 632, 20392, 2755, 3614, 2858, 1375, 56, 9191, 1492, 353, 279, 3229, 434, 1375, 13946, 25059, 9191, 326, 22686, 17527, 2006, 358, 384, 3820, 87, 5079, 4982, 1375, 56, 300, 8589, 25059, 68, 358, 1375, 56, 300, 404, 8338, 14178, 10478, 2353, 404, 18, 632, 20392, 1021, 5224, 25123, 2173, 2194, 434, 279, 1407, 18, 2597, 1807, 404, 1147, 1534, 8589, 18, 632, 20392, 1021, 4232, 39, 17, 3657, 9599, 2502, 4694, 19918, 279, 2202, 1375, 40, 566, 1121, 3245, 68, 3695, 18, 632, 20392, 512, 7948, 1347, 279, 3419, 353, 4104, 632, 891, 3419, 548, 1021, 3419, 1599, 632, 891, 3419, 3178, 1021, 3419, 1758, 632, 20392, 512, 7948, 1347, 279, 3419, 1758, 353, 3526, 632, 891, 3419, 548, 1021, 3419, 1599, 632, 891, 1592, 4668, 3178, 1021, 1592, 3419, 1758, 632, 891, 394, 4668, 3178, 1021, 394, 3419, 1758, 632, 20392, 512, 7948, 1347, 284, 19156, 854, 598, 9446, 82, 18, 632, 891, 6445, 71, 3462, 1021, 1399, 4232, 39, 17, 3462, 1147, 18, 632, 891, 5971, 1021, 1758, 716, 326, 284, 19156, 854, 3271, 358, 18, 632, 891, 25123, 1021, 598, 9446, 82, 3844, 18, 632, 20392, 512, 7948, 635, 326, 2236, 358, 8959, 1982, 18, 1021, 498, 471, 326, 460, 854, 486, 4529, 1235, 635, 326, 1771, 16, 518, 1807, 731, 358, 326, 3677, 358, 18312, 471, 2805, 356, 24862, 358, 3387, 8926, 598, 326, 18350, 18, 632, 891, 17398, 1021, 1599, 434, 326, 2236, 3626, 1787, 1982, 632, 891, 498, 1021, 1982, 498, 632, 891, 460, 1021, 1982, 460, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1958, 463, 566, 1121, 3245, 288, 203, 3639, 2254, 1578, 1024, 4668, 548, 31, 203, 3639, 2874, 12, 11890, 1578, 3419, 548, 516, 1758, 13, 3419, 7148, 31, 203, 3639, 2874, 12, 45, 654, 39, 3462, 6445, 71, 3462, 516, 30918, 13, 324, 26488, 31, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0xd507cebBd76bFA8ef39562282a2c8EdD4Fc68D77/sources/project_/contracts/BaseContracts/Base721A.sol
@notice The rate of mints per user
mapping(Phase => mapping(address => uint256)) public _mintsPerUser;
1,901,204
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 1021, 4993, 434, 312, 28142, 1534, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2874, 12, 11406, 516, 2874, 12, 2867, 516, 2254, 5034, 3719, 1071, 389, 81, 28142, 2173, 1299, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x1BC85741e7612083E7A2B6d76B75aE4ec7D44cA8/sources/ERC20.sol
* @dev Sets the values for {name} and {symbol}. All two of these values are immutable: they can only be set once during construction./
constructor() { _name = "SHIB"; _symbol = "SHIB"; _totalSupply = 1000000000 * 10 ** 18; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); }
15,476,150
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 11511, 326, 924, 364, 288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 3639, 389, 529, 273, 315, 2664, 13450, 14432, 203, 3639, 389, 7175, 273, 315, 2664, 13450, 14432, 203, 3639, 389, 4963, 3088, 1283, 273, 15088, 3784, 380, 1728, 2826, 6549, 31, 203, 3639, 389, 70, 26488, 63, 3576, 18, 15330, 65, 273, 389, 4963, 3088, 1283, 31, 203, 3639, 3626, 12279, 12, 2867, 12, 20, 3631, 1234, 18, 15330, 16, 389, 4963, 3088, 1283, 1769, 203, 203, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.11; contract HouseICO { function name() constant returns (string) { return "House"; } function symbol() constant returns (string) { return "HSE"; } function decimals() constant returns (uint8) { return 0; } uint256 public INITIAL_SUPPLY; uint256 public totalSupply; uint256 public totalContrib; uint256 public rate; address public owner; //init owner address uint256 public amount; function HouseICO() { INITIAL_SUPPLY = 30000000; //Starting coin supply totalSupply = 0; totalContrib = 0; rate = 5000; //How many tokens per ETH given owner = msg.sender; //Make owner of contract the creator balances[msg.sender] = INITIAL_SUPPLY; //Send owner of contract all starting tokens } //This function is called when Ether is sent to the contract address //Even if 0 ether is sent. function () payable { uint256 tryAmount = div((mul(msg.value, rate)), 1 ether); //Don&#39;t let people buy more tokens than there are. if (msg.value == 0 || msg.value < 0 || balanceOf(owner) < tryAmount) { //If zero ether is sent, kill. Do nothing. revert(); } amount = 0; //set the &#39;amount&#39; var back to zero amount = div((mul(msg.value, rate)), 1 ether); //take sent ether, multiply it by the rate then divide by 1 ether. transferFrom(owner, msg.sender, amount); //Send tokens to buyer totalSupply += amount; //Keep track of how many have been sold. totalContrib = (totalContrib + msg.value); amount = 0; //set the &#39;amount&#39; var back to zero owner.transfer(msg.value); //Send the ETH to contract owner. } event Transfer(address indexed _from, address indexed _to, uint256 _value); mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool success) { if (_value == 0) { return false; } uint256 fromBalance = balances[msg.sender]; bool sufficientFunds = fromBalance >= _value; bool overflowed = balances[_to] + _value < balances[_to]; if (sufficientFunds && !overflowed) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_value == 0) { return false; } uint256 fromBalance = balances[owner]; bool sufficientFunds = fromBalance >= _value; if (sufficientFunds) { balances[_to] += _value; balances[_from] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function getStats() constant returns (uint256, uint256) { return (totalSupply, totalContrib); } 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; } }
Send owner of contract all starting tokens
balances[msg.sender] = INITIAL_SUPPLY;
7,790,883
[ 1, 4625, 348, 7953, 560, 30, 2479, 3410, 434, 6835, 777, 5023, 2430, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 202, 70, 26488, 63, 3576, 18, 15330, 65, 273, 28226, 67, 13272, 23893, 31, 1082, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.23; /** * @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; } } /** * @title ERC20 interface (only needed methods) * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); } /** * @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 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; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } /** * @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 QWoodDAOTokenSale * @dev The QWoodDAOTokenSale contract receive ether and other foreign tokens and exchange them to set tokens. */ contract QWoodDAOTokenSale is Pausable { using SafeMath for uint256; // Represents data of foreign token which can be exchange to token struct ReceivedToken { // name of foreign token string name; // number of token units a buyer gets per foreign token unit uint256 rate; // amount of raised foreign tokens uint256 raised; } // The token being sold ERC20 public token; // Address where funds are collected address public wallet; // How many token units a buyer gets per wei. // The rate is the conversion between wei and the smallest and indivisible token unit. // So, if you are using a rate of 1 with a ERC20 token with 3 decimals called TOK // 1 wei will give you 1 unit, or 0.001 TOK. uint256 public rate; // Amount of wei raised uint256 public weiRaised; // Map from token address to token data mapping (address => ReceivedToken) public receivedTokens; /** * 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 for token purchase for token logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value foreign tokens units paid for purchase * @param amount amount of tokens purchased */ event TokenForTokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); /** * Event for change rate logging * @param newRate new number of token units a buyer gets per wei */ event ChangeRate(uint256 newRate); /** * Event for add received token logging * @param tokenAddress address of added foreign token * @param name name of added token * @param rate number of token units a buyer gets per added foreign token unit */ event AddReceivedToken( address indexed tokenAddress, string name, uint256 rate ); /** * Event for remove received token logging * @param tokenAddress address of removed foreign token */ event RemoveReceivedToken(address indexed tokenAddress); /** * Event for set new received token rate logging * @param tokenAddress address of foreign token * @param newRate new number of token units a buyer gets per added foreign token unit */ event SetReceivedTokenRate( address indexed tokenAddress, uint256 newRate ); /** * Event for send excess ether logging * @param beneficiary who gets excess ether * @param value excess weis */ event SendEtherExcess( address indexed beneficiary, uint256 value ); /** * Event for send tokens excess logging * @param beneficiary who gets tokens excess * @param value excess token units */ event SendTokensExcess( address indexed beneficiary, uint256 value ); /** * Event for logging received tokens from approveAndCall function * @param from who send tokens * @param amount amount of received purchased * @param tokenAddress address of token contract * @param extraData data attached to payment */ event ReceivedTokens( address indexed from, uint256 amount, address indexed tokenAddress, bytes extraData ); /** * @param _rate Number of token units a buyer gets per wei * @param _wallet Address where collected funds will be forwarded to * @param _token Address of the token being sold */ constructor ( uint256 _rate, address _wallet, ERC20 _token ) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () whenNotPaused external payable { buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) whenNotPaused public payable { require(_beneficiary != address(0)); uint256 weiAmount = msg.value; require(weiAmount != 0); uint256 tokenBalance = token.balanceOf(address(this)); require(tokenBalance > 0); uint256 tokens = _getTokenAmount(address(0), weiAmount); if (tokens > tokenBalance) { tokens = tokenBalance; weiAmount = _inverseGetTokenAmount(address(0), tokens); uint256 senderExcess = msg.value.sub(weiAmount); msg.sender.transfer(senderExcess); emit SendEtherExcess( msg.sender, senderExcess ); } weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); } /** * @dev Sets new rate. * @param _newRate New number of token units a buyer gets per wei */ function setRate(uint256 _newRate) onlyOwner external { require(_newRate > 0); rate = _newRate; emit ChangeRate(_newRate); } /** * @dev Set new wallet address. * @param _newWallet New address where collected funds will be forwarded to */ function setWallet(address _newWallet) onlyOwner external { require(_newWallet != address(0)); wallet = _newWallet; } /** * @dev Set new token address. * @param _newToken New address of the token being sold */ function setToken(ERC20 _newToken) onlyOwner external { require(_newToken != address(0)); token = _newToken; } /** * @dev Withdraws any tokens from this contract to wallet. * @param _tokenContract The address of the foreign token */ function withdrawTokens(ERC20 _tokenContract) onlyOwner external { require(_tokenContract != address(0)); uint256 amount = _tokenContract.balanceOf(address(this)); _tokenContract.transfer(wallet, amount); } /** * @dev Withdraws all ether from this contract to wallet. */ function withdraw() onlyOwner external { wallet.transfer(address(this).balance); } /** * @dev Adds received foreign token. * @param _tokenAddress Address of the foreign token being added * @param _tokenName Name of the foreign token * @param _tokenRate Number of token units a buyer gets per foreign token unit */ function addReceivedToken( ERC20 _tokenAddress, string _tokenName, uint256 _tokenRate ) onlyOwner external { require(_tokenAddress != address(0)); require(_tokenRate > 0); ReceivedToken memory _token = ReceivedToken({ name: _tokenName, rate: _tokenRate, raised: 0 }); receivedTokens[_tokenAddress] = _token; emit AddReceivedToken( _tokenAddress, _token.name, _token.rate ); } /** * @dev Removes received foreign token. * @param _tokenAddress Address of the foreign token being removed */ function removeReceivedToken(ERC20 _tokenAddress) onlyOwner external { require(_tokenAddress != address(0)); delete receivedTokens[_tokenAddress]; emit RemoveReceivedToken(_tokenAddress); } /** * @dev Sets new rate for received foreign token. * @param _tokenAddress Address of the foreign token * @param _newTokenRate New number of token units a buyer gets per foreign token unit */ function setReceivedTokenRate( ERC20 _tokenAddress, uint256 _newTokenRate ) onlyOwner external { require(_tokenAddress != address(0)); require(receivedTokens[_tokenAddress].rate > 0); require(_newTokenRate > 0); receivedTokens[_tokenAddress].rate = _newTokenRate; emit SetReceivedTokenRate( _tokenAddress, _newTokenRate ); } /** * @dev Receives approved foreign tokens and exchange them to tokens. * @param _from Address of foreign tokens sender * @param _amount Amount of the foreign tokens * @param _tokenAddress Address of the foreign token contract * @param _extraData Data attached to payment */ function receiveApproval( address _from, uint256 _amount, address _tokenAddress, bytes _extraData ) whenNotPaused external { require(_from != address(0)); require(_tokenAddress != address(0)); require(receivedTokens[_tokenAddress].rate > 0); // check: token in receivedTokens require(_amount > 0); require(msg.sender == _tokenAddress); emit ReceivedTokens( _from, _amount, _tokenAddress, _extraData ); _exchangeTokens(ERC20(_tokenAddress), _from, _amount); } /** * @dev Deposits foreign token and exchange them to tokens. * @param _tokenAddress Address of the foreign token * @param _amount Amount of the foreign tokens */ function depositToken( ERC20 _tokenAddress, uint256 _amount ) whenNotPaused external { // Remember to call ERC20(address).approve(this, amount) // or this contract will not be able to do the transfer on your behalf require(_tokenAddress != address(0)); require(receivedTokens[_tokenAddress].rate > 0); require(_amount > 0); _exchangeTokens(_tokenAddress, msg.sender, _amount); } // ----------------------------------------- // Internal interface // ----------------------------------------- /** * @dev Exchanges foreign tokens to self token. Low-level exchange method. * @param _tokenAddress Address of the foreign token contract * @param _sender Sender address * @param _amount Number of tokens for exchange */ function _exchangeTokens( ERC20 _tokenAddress, address _sender, uint256 _amount ) internal { uint256 foreignTokenAmount = _amount; require(_tokenAddress.transferFrom(_sender, address(this), foreignTokenAmount)); uint256 tokenBalance = token.balanceOf(address(this)); require(tokenBalance > 0); uint256 tokens = _getTokenAmount(_tokenAddress, foreignTokenAmount); if (tokens > tokenBalance) { tokens = tokenBalance; foreignTokenAmount = _inverseGetTokenAmount(_tokenAddress, tokens); uint256 senderForeignTokenExcess = _amount.sub(foreignTokenAmount); _tokenAddress.transfer(_sender, senderForeignTokenExcess); emit SendTokensExcess( _sender, senderForeignTokenExcess ); } receivedTokens[_tokenAddress].raised = receivedTokens[_tokenAddress].raised.add(foreignTokenAmount); _processPurchase(_sender, tokens); emit TokenForTokenPurchase( _sender, _sender, foreignTokenAmount, tokens ); } /** * @dev Source of tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.transfer(_beneficiary, _tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _deliverTokens(_beneficiary, _tokenAmount); } /** * @dev Override to extend the way in which ether or foreign token unit is converted to tokens. * @param _tokenAddress Address of foreign token or 0 if ether to tokens * @param _amount Value in wei or foreign token units to be converted into tokens * @return Number of tokens that can be purchased with the specified _amount (wei or foreign token units) */ function _getTokenAmount(address _tokenAddress, uint256 _amount) internal view returns (uint256) { uint256 _rate; if (_tokenAddress == address(0)) { _rate = rate; } else { _rate = receivedTokens[_tokenAddress].rate; } return _amount.mul(_rate); } /** * @dev Get wei or foreign tokens amount. Inverse _getTokenAmount method. */ function _inverseGetTokenAmount(address _tokenAddress, uint256 _tokenAmount) internal view returns (uint256) { uint256 _rate; if (_tokenAddress == address(0)) { _rate = rate; } else { _rate = receivedTokens[_tokenAddress].rate; } return _tokenAmount.div(_rate); } }
* @dev fallback function DO NOT OVERRIDE/
function () whenNotPaused external payable { buyTokens(msg.sender); }
566,219
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 5922, 445, 5467, 4269, 22577, 25382, 19, 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 203, 565, 30143, 5157, 12, 3576, 18, 15330, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/5/0x84Ff2c20810186E663955A8841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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2874, 261, 11890, 5034, 516, 5059, 13, 1071, 389, 7094, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.25; /* * ---How to use: * 1. Send from ETH wallet to the smart contract address any amount ETH. * 2a. Claim your profit by sending 0 ether transaction (1 time per 12 hour) * OR * 2b. Send more ether to reinvest AND get your profit * 2c. If you hold, the percentage grows * 3. If you earn more than 150%, you can withdraw only one finish time * 4. If you want withdraw invested, send 0.00000911 ether * 5. Max invest 25 ETH per 12 hours * 6. Withdraw and deposit no more 1 time per 12 hour * * RECOMMENDED GAS LIMIT: 150000 * RECOMMENDED GAS PRICE: https://ethgasstation.info/ * * THE PROJECT HAS HIGH RISKS! * PROJECT PAYS IF BALANCE HAS ETHER! */ contract HodlETH { //use library for safe math operations using SafeMath for uint; // records amount of invest mapping (address => uint) public userInvested; // records time of payment mapping (address => uint) public entryTime; // records withdrawal amount mapping (address => uint) public withdrawAmount; // records you use the referral program or not mapping (address => uint) public referrerOn; // advertising fund 6% address advertisingFund = 0x9348739Fb4BA75fB316D3C01B9a89AbeB683162b; uint public advertisingPercent = 6; // tech support fund 2 % address techSupportFund = 0xC52d419a8cCD8b57586b67B668635faA1931e443; uint public techSupportPercent = 2; // "hodl" mode uint public startPercent = 100; // 2.4% per day or 0.1% per hours uint public fiveDayHodlPercent = 125; // 3% per day or 0.125% per hours uint public tenDayHodlPercent = 150; // 3.6% per day or 0.155 per hours uint public twentyDayHodlPercent = 200; // 4.8% per day or 0.2% per hours // bonus percent of balance uint public lowBalance = 500 ether; uint public middleBalance = 2000 ether; uint public highBalance = 3500 ether; uint public soLowBalanceBonus = 25; // 0.6% per day or 0.025% per hours uint public lowBalanceBonus = 50; // 1.2% per day or 0.05% per hours uint public middleBalanceBonus = 75; // 1.8% per day or 0.075% per hours uint public highBalanceBonus = 100; // 2.4% per day or 0.1% per hours uint public countOfInvestors = 0; // get bonus percent function _bonusPercent() public view returns(uint){ uint balance = address(this).balance; if (balance < lowBalance){ return (soLowBalanceBonus); // if balance less 500 ether, rate 0.6% per days } if (balance > lowBalance && balance < middleBalance){ return (lowBalanceBonus); // if balance more 500 ether, rate 1.2% per days } if (balance > middleBalance && balance < highBalance){ return (middleBalanceBonus); // if balance more 2000 ether, rate 1.8% per days } if (balance > highBalance){ return (highBalanceBonus); // if balance more 3500 ether, rate 2.4% per days } } // get personal percent function _personalPercent() public view returns(uint){ // how many days you hold uint hodl = (now).sub(entryTime[msg.sender]); if (hodl < 5 days){ return (startPercent); // if you don't withdraw less 5 day, your rate 2.4% per days } if (hodl > 5 days && hodl < 10 days){ return (fiveDayHodlPercent); // if you don't withdraw more 5 day , your rate 3% per days } if (hodl > 10 days && hodl < 20 days){ return (tenDayHodlPercent); // if you don't withdraw more 10 day , your rate 3.6% per days } if (hodl > 20 days){ return (twentyDayHodlPercent); // if you don't withdraw more 20 day, your rate 4.8% per days } } // if send 0.00000911 ETH contract will return your invest, else make invest function() external payable { if (msg.value == 0.00000911 ether) { returnInvestment(); } else { invest(); } } // return of deposit(userInvested - withdrawAmount - (userInvested / 10(fund fee)) , after delete user function returnInvestment() timeWithdraw private{ if(userInvested[msg.sender] > 0){ uint refundAmount = userInvested[msg.sender].sub(withdrawAmount[msg.sender]).sub(userInvested[msg.sender].div(10)); require(userInvested[msg.sender] > refundAmount, 'You have already returned the investment'); userInvested[msg.sender] = 0; entryTime[msg.sender] = 0; withdrawAmount[msg.sender] = 0; msg.sender.transfer(refundAmount); } } // make invest function invest() timeWithdraw maxInvest private { if (userInvested[msg.sender] == 0) { countOfInvestors += 1; } if (msg.value > 0 ){ // call terminal terminal(); // record invested amount (msg.value) of this transaction userInvested[msg.sender] += msg.value; // record entry time entryTime[msg.sender] = now; // sending fee for advertising and tech support advertisingFund.transfer((msg.value).mul(advertisingPercent).div(100)); techSupportFund.transfer((msg.value).mul(techSupportPercent).div(100)); // if you entered the address that invited you and didn’t do this before if (msg.data.length != 0 && referrerOn[msg.sender] != 1){ //pays his bonus transferRefBonus(); } } else{ // call terminal terminal(); } } function terminal() internal { // if the user received 150% or more of his contribution, delete user if (userInvested[msg.sender].mul(15).div(10) < withdrawAmount[msg.sender]){ userInvested[msg.sender] = 0; entryTime[msg.sender] = 0; withdrawAmount[msg.sender] = 0; } else { // you percent = bonusPercent + personalPercent, min 3% and max 7.2% per day or min 0.125% and max 0.3% per hours uint bonusPercent = _bonusPercent(); uint personalPercent = _personalPercent(); uint percent = (bonusPercent).add(personalPercent); // calculate profit amount as such: // amount = (amount invested) * you percent / 100000 * ((now - your entry time) / 1 hour) uint amount = userInvested[msg.sender].mul(percent).div(100000).mul(((now).sub(entryTime[msg.sender])).div(1 hours)); // record entry time entryTime[msg.sender] = now; // record withdraw amount withdrawAmount[msg.sender] += amount; // send calculated amount of ether directly to sender (aka YOU) msg.sender.transfer(amount); } } // convert bytes to eth address function bytesToAddress(bytes bys) private pure returns (address addr) { assembly { addr := mload(add(bys, 20)) } } // transfer referrer bonus of invested function transferRefBonus() private { address referrer = bytesToAddress(msg.data); if (referrer != msg.sender && userInvested[referrer] != 0){ //referrer ON referrerOn[msg.sender] = 1; //transfer to referrer 2 % of invested uint refBonus = (msg.value).mul(2).div(100); referrer.transfer(refBonus); } } modifier timeWithdraw(){ require(entryTime[msg.sender].add(12 hours) <= now, 'Withdraw and deposit no more 1 time per 12 hour'); _; } modifier maxInvest(){ require(msg.value <= 25 ether, 'Max invest 25 ETH per 12 hours'); _; } } /** * @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; } }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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 11890, 1071, 3551, 13937, 38, 22889, 273, 2130, 31, 1082, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/* _________-----_____ _____------ __ ----_ ___---- ___------ \ ----________ ---- \ -----__ | _____) __- / \ _______----- ___-- \ /)\ ------_______ ---____ \__/ / -----__ \ -- _ /\ --__--__ \_____/ \_/\ ----| / | | |___________| | | ((_(_)| )_) | \_((_(_)|/(_) \ ( \_____________) 💰Welcome To Gang DAO💰 Gang DAO is the first Decentralized Hedge Fund that will find and invest in multiple DeFi protocols and opportunities ranging from low cap gems, mid cap coins and more (such as arbitrage, front running and more !✅ The Gang DAO family will be rewarded with profits generated from Gang DAO investment strategies.💵 https://t.me/GangDaoPortal */ // SPDX-License-Identifier: MIT pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0; pragma experimental ABIEncoderV2; ////// lib/openzeppelin-contracts/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.0 (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; } } ////// lib/openzeppelin-contracts/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) /* 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() { _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); } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (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); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) /* 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); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) /* 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 Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } ////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol // OpenZeppelin Contracts v4.4.0 (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; } } } ////// src/IUniswapV2Factory.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } ////// src/IUniswapV2Pair.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } ////// src/IUniswapV2Router02.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } ////// src/GangDAO.sol /* pragma solidity >=0.8.10; */ /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */ /* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */ contract GangDAO is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyTreasuryFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellTreasuryFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Gang DAO", "GANG") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 3; uint256 _buyLiquidityFee = 1; uint256 _buyTreasuryFee = 4; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 2; uint256 _sellTreasuryFee = 5; uint256 totalSupply = 1_000_000_000 * 1e18; maxTransactionAmount = 10_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn maxWallet = 20_000_000 * 1e18; // 2% from total supply maxWallet swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyTreasuryFee = _buyTreasuryFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyTreasuryFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellTreasuryFee = _sellTreasuryFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellTreasuryFee; marketingWallet = address(0x162906B1c49228245A840E0f470cE4948b4636d0); // set as marketing wallet devWallet = address(0x162906B1c49228245A840E0f470cE4948b4636d0); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require( newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply." ); require( newAmount <= (totalSupply() * 5) / 1000, "Swap amount cannot be higher than 0.5% total supply." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 5) / 1000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _treasuryFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyTreasuryFee = _treasuryFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyTreasuryFee; } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _treasuryFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellTreasuryFee = _treasuryFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellTreasuryFee; } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled) { if ( to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair) ) { require( _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed." ); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if ( automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to] ) { require( amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount." ); require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } //when sell else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require( amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount." ); } else if (!_isExcludedMaxTransactionAmount[to]) { require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellTreasuryFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyTreasuryFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div( totalTokensToSwap ); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
exclude from paying fees or having max transaction amount
constructor() ERC20("Gang DAO", "GANG") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 3; uint256 _buyLiquidityFee = 1; uint256 _buyTreasuryFee = 4; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 2; uint256 _sellTreasuryFee = 5; uint256 totalSupply = 1_000_000_000 * 1e18; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyTreasuryFee = _buyTreasuryFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyTreasuryFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellTreasuryFee = _sellTreasuryFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellTreasuryFee; excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again _mint(msg.sender, totalSupply);
544,338
[ 1, 4625, 348, 7953, 560, 30, 225, 4433, 628, 8843, 310, 1656, 281, 578, 7999, 943, 2492, 3844, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 3885, 1435, 4232, 39, 3462, 2932, 43, 539, 463, 20463, 3113, 315, 43, 3388, 7923, 288, 203, 3639, 467, 984, 291, 91, 438, 58, 22, 8259, 3103, 389, 318, 291, 91, 438, 58, 22, 8259, 273, 467, 984, 291, 91, 438, 58, 22, 8259, 3103, 12, 203, 5411, 374, 92, 27, 69, 26520, 72, 4313, 5082, 38, 24, 71, 42, 25, 5520, 27, 5520, 72, 42, 22, 39, 25, 72, 37, 7358, 24, 71, 26, 6162, 42, 3247, 5482, 40, 203, 3639, 11272, 203, 203, 3639, 4433, 1265, 2747, 3342, 12, 2867, 24899, 318, 291, 91, 438, 58, 22, 8259, 3631, 638, 1769, 203, 3639, 640, 291, 91, 438, 58, 22, 8259, 273, 389, 318, 291, 91, 438, 58, 22, 8259, 31, 203, 203, 3639, 640, 291, 91, 438, 58, 22, 4154, 273, 467, 984, 291, 91, 438, 58, 22, 1733, 24899, 318, 291, 91, 438, 58, 22, 8259, 18, 6848, 10756, 203, 5411, 263, 2640, 4154, 12, 2867, 12, 2211, 3631, 389, 318, 291, 91, 438, 58, 22, 8259, 18, 59, 1584, 44, 10663, 203, 3639, 4433, 1265, 2747, 3342, 12, 2867, 12, 318, 291, 91, 438, 58, 22, 4154, 3631, 638, 1769, 203, 3639, 389, 542, 22932, 690, 3882, 278, 12373, 4154, 12, 2867, 12, 318, 291, 91, 438, 58, 22, 4154, 3631, 638, 1769, 203, 203, 3639, 2254, 5034, 389, 70, 9835, 3882, 21747, 14667, 273, 890, 31, 203, 3639, 2254, 5034, 389, 70, 9835, 48, 18988, 24237, 14667, 273, 404, 31, 203, 3639, 2254, 5034, 389, 70, 9835, 56, 266, 345, 22498, 14667, 273, 1059, 31, 203, 203, 3639, 2254, 5034, 389, 87, 1165, 3882, 21747, 14667, 273, 1381, 31, 203, 3639, 2254, 5034, 389, 87, 1165, 48, 18988, 24237, 14667, 273, 576, 31, 203, 3639, 2254, 5034, 389, 87, 1165, 56, 266, 345, 22498, 14667, 273, 1381, 31, 203, 203, 3639, 2254, 5034, 2078, 3088, 1283, 273, 404, 67, 3784, 67, 3784, 67, 3784, 380, 404, 73, 2643, 31, 203, 203, 203, 3639, 30143, 3882, 21747, 14667, 273, 389, 70, 9835, 3882, 21747, 14667, 31, 203, 3639, 30143, 48, 18988, 24237, 14667, 273, 389, 70, 9835, 48, 18988, 24237, 14667, 31, 203, 3639, 30143, 56, 266, 345, 22498, 14667, 273, 389, 70, 9835, 56, 266, 345, 22498, 14667, 31, 203, 3639, 30143, 5269, 2954, 281, 273, 30143, 3882, 21747, 14667, 397, 30143, 48, 18988, 24237, 14667, 397, 30143, 56, 266, 345, 22498, 14667, 31, 203, 203, 3639, 357, 80, 3882, 21747, 14667, 273, 389, 87, 1165, 3882, 21747, 14667, 31, 203, 3639, 357, 80, 48, 18988, 24237, 14667, 273, 389, 87, 1165, 48, 18988, 24237, 14667, 31, 203, 3639, 357, 80, 56, 266, 345, 22498, 14667, 273, 389, 87, 1165, 56, 266, 345, 22498, 14667, 31, 203, 3639, 357, 80, 5269, 2954, 281, 273, 357, 80, 3882, 21747, 14667, 397, 357, 80, 48, 18988, 24237, 14667, 397, 357, 80, 56, 266, 345, 22498, 14667, 31, 203, 203, 203, 3639, 4433, 1265, 2954, 281, 12, 8443, 9334, 638, 1769, 203, 3639, 4433, 1265, 2954, 281, 12, 2867, 12, 2211, 3631, 638, 1769, 203, 3639, 4433, 1265, 2954, 281, 12, 2867, 12, 20, 92, 22097, 3631, 638, 1769, 203, 203, 3639, 4433, 1265, 2747, 3342, 12, 8443, 9334, 638, 1769, 203, 3639, 4433, 1265, 2747, 3342, 12, 2867, 12, 2211, 3631, 638, 1769, 203, 3639, 4433, 1265, 2747, 3342, 12, 2867, 12, 20, 92, 22097, 3631, 638, 1769, 203, 203, 5411, 389, 81, 474, 353, 392, 2713, 445, 316, 4232, 39, 3462, 18, 18281, 716, 353, 1338, 2566, 2674, 16, 203, 5411, 471, 385, 16791, 506, 2566, 14103, 3382, 203, 3639, 389, 81, 474, 12, 3576, 18, 15330, 16, 2078, 3088, 1283, 1769, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/80001/0x197D234F93722FaB2D090370900FC5A648Db3b55/sources/contracts/LoePools.sol
* @notice reads total withdrawn amount by the receiver from the pool/
function getTotalWithdrawn(address receiver, uint256 poolId) external view returns (uint256 _totalWithdrawn) { uint256 maxPoolId = poolBalance.length; require(poolId < maxPoolId, "LoePools: Invalid poolId"); WithdrawalsPointer storage _totalWithdrawnPointer = totalWithdrawn[receiver]; assembly { _totalWithdrawn := sload(add(_totalWithdrawnPointer.slot, poolId)) } }
5,682,786
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 6838, 2078, 598, 9446, 82, 3844, 635, 326, 5971, 628, 326, 2845, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 12831, 1190, 9446, 82, 12, 2867, 5971, 16, 2254, 5034, 2845, 548, 13, 3903, 1476, 1135, 261, 11890, 5034, 389, 4963, 1190, 9446, 82, 13, 288, 203, 3639, 2254, 5034, 943, 25136, 273, 2845, 13937, 18, 2469, 31, 203, 3639, 2583, 12, 6011, 548, 411, 943, 25136, 16, 315, 1504, 73, 16639, 30, 1962, 2845, 548, 8863, 203, 3639, 3423, 9446, 1031, 4926, 2502, 389, 4963, 1190, 9446, 82, 4926, 273, 2078, 1190, 9446, 82, 63, 24454, 15533, 203, 3639, 19931, 288, 203, 5411, 389, 4963, 1190, 9446, 82, 519, 272, 945, 12, 1289, 24899, 4963, 1190, 9446, 82, 4926, 18, 14194, 16, 2845, 548, 3719, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x2cfe1C35bb695d4eff2736054EAc3B6CE4DeA90B/sources/project:/contracts/lending/ZhartaLending.sol
@title Zharta Lending @notice Manages creating and repaying a loan on Zharta
contract ZhartaLending is INFTLending { using SafeERC20 for IERC20; ILoansPeripheral public constant loansPeripheral = ILoansPeripheral(0xaF2F471d3B46171f876f465165dcDF2F0E788636); ILoansCore public constant loansCore = ILoansCore(0x5Be916Cff5f07870e9Aef205960e07d9e287eF27); address public constant collateralVaultCore = 0x7CA34cF45a119bEBEf4D106318402964a331DfeD; error InvalidCollateralLength(); function getLoanDetails( uint256 _loanId pragma solidity 0.8.19; import {IWETH} from "../IWETH.sol"; ) external view returns (LoanDetails memory loanDetails) { ILoansCore.Loan memory loanDetail = loansCore.getLoan( msg.sender, _loanId ); uint256 repayAmount = loansPeripheral.getLoanPayableAmount( msg.sender, _loanId, block.timestamp ); return LoanDetails( ); } function borrow( bytes calldata _inputData ) external payable returns (uint256) { ILoansPeripheral.Calldata memory callData = abi.decode( _inputData, (ILoansPeripheral.Calldata) ); IERC721 nft = IERC721(callData.collateral.contractAddress); if (!nft.isApprovedForAll(address(this), collateralVaultCore)) { nft.setApprovalForAll(collateralVaultCore, true); } ILoansPeripheral.Collateral[] memory collaterals = new ILoansPeripheral.Collateral[](1); collaterals[0] = callData.collateral; callData.amount, callData.interest, callData.maturity, collaterals, callData.delegations, callData.deadline, callData.nonce, callData.genesisToken, callData.v, callData.r, callData.s ); } function borrow( bytes calldata _inputData ) external payable returns (uint256) { ILoansPeripheral.Calldata memory callData = abi.decode( _inputData, (ILoansPeripheral.Calldata) ); IERC721 nft = IERC721(callData.collateral.contractAddress); if (!nft.isApprovedForAll(address(this), collateralVaultCore)) { nft.setApprovalForAll(collateralVaultCore, true); } ILoansPeripheral.Collateral[] memory collaterals = new ILoansPeripheral.Collateral[](1); collaterals[0] = callData.collateral; callData.amount, callData.interest, callData.maturity, collaterals, callData.delegations, callData.deadline, callData.nonce, callData.genesisToken, callData.v, callData.r, callData.s ); } uint256 loanId = loansPeripheral.reserveEth( return loanId; function repay(uint256 _loanId, address _receiver) external payable { uint256 repayAmount = loansPeripheral.getLoanPayableAmount( address(this), _loanId, block.timestamp ); if (_receiver != address(this)) { ILoansCore.Loan memory loanDetail = loansCore.getLoan( address(this), _loanId ); IERC721(loanDetail.collaterals[0].contractAddress).safeTransferFrom( address(this), _receiver, loanDetail.collaterals[0].tokenId ); } } loansPeripheral.pay{value: repayAmount}(_loanId); function repay(uint256 _loanId, address _receiver) external payable { uint256 repayAmount = loansPeripheral.getLoanPayableAmount( address(this), _loanId, block.timestamp ); if (_receiver != address(this)) { ILoansCore.Loan memory loanDetail = loansCore.getLoan( address(this), _loanId ); IERC721(loanDetail.collaterals[0].contractAddress).safeTransferFrom( address(this), _receiver, loanDetail.collaterals[0].tokenId ); } } receive() external payable {} }
4,992,147
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 2649, 2285, 76, 485, 69, 511, 2846, 632, 20392, 490, 940, 281, 4979, 471, 2071, 528, 310, 279, 28183, 603, 2285, 76, 485, 69, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 2285, 76, 485, 69, 48, 2846, 353, 2120, 4464, 48, 2846, 288, 203, 565, 1450, 14060, 654, 39, 3462, 364, 467, 654, 39, 3462, 31, 203, 203, 565, 467, 1504, 634, 2173, 4337, 287, 1071, 5381, 437, 634, 2173, 4337, 287, 273, 203, 3639, 467, 1504, 634, 2173, 4337, 287, 12, 20, 6995, 42, 22, 42, 9462, 21, 72, 23, 38, 8749, 4033, 21, 74, 28, 6669, 74, 8749, 25, 28275, 7201, 4577, 22, 42, 20, 41, 27, 5482, 4449, 26, 1769, 203, 203, 565, 467, 1504, 634, 4670, 1071, 5381, 437, 634, 4670, 273, 203, 3639, 467, 1504, 634, 4670, 12, 20, 92, 25, 1919, 29, 2313, 39, 1403, 25, 74, 20, 8285, 7301, 73, 29, 37, 10241, 3462, 6162, 4848, 73, 8642, 72, 29, 73, 6030, 27, 73, 42, 5324, 1769, 203, 203, 565, 1758, 1071, 5381, 4508, 2045, 287, 12003, 4670, 273, 374, 92, 27, 3587, 5026, 71, 42, 7950, 69, 23635, 70, 41, 5948, 74, 24, 40, 2163, 4449, 29242, 3103, 29, 1105, 69, 3707, 21, 40, 3030, 40, 31, 203, 203, 565, 555, 1962, 13535, 2045, 287, 1782, 5621, 203, 203, 565, 445, 336, 1504, 304, 3790, 12, 203, 3639, 2254, 5034, 389, 383, 304, 548, 203, 683, 9454, 18035, 560, 374, 18, 28, 18, 3657, 31, 203, 5666, 288, 45, 59, 1584, 44, 97, 628, 315, 6216, 45, 59, 1584, 44, 18, 18281, 14432, 203, 565, 262, 3903, 1476, 1135, 261, 1504, 304, 3790, 3778, 28183, 3790, 13, 288, 203, 3639, 467, 1504, 634, 4670, 18, 1504, 304, 3778, 28183, 6109, 273, 437, 634, 4670, 18, 588, 1504, 304, 12, 203, 5411, 1234, 18, 15330, 16, 203, 5411, 389, 383, 304, 548, 203, 3639, 11272, 203, 203, 3639, 2254, 5034, 2071, 528, 6275, 273, 437, 634, 2173, 4337, 287, 18, 588, 1504, 304, 9148, 429, 6275, 12, 203, 5411, 1234, 18, 15330, 16, 203, 5411, 389, 383, 304, 548, 16, 203, 5411, 1203, 18, 5508, 203, 3639, 11272, 203, 203, 3639, 327, 3176, 304, 3790, 12, 203, 3639, 11272, 203, 565, 289, 203, 203, 565, 445, 29759, 12, 203, 3639, 1731, 745, 892, 389, 2630, 751, 203, 565, 262, 3903, 8843, 429, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 467, 1504, 634, 2173, 4337, 287, 18, 1477, 892, 3778, 745, 751, 273, 24126, 18, 3922, 12, 203, 5411, 389, 2630, 751, 16, 203, 5411, 261, 45, 1504, 634, 2173, 4337, 287, 18, 1477, 892, 13, 203, 3639, 11272, 203, 203, 3639, 467, 654, 39, 27, 5340, 290, 1222, 273, 467, 654, 39, 27, 5340, 12, 1991, 751, 18, 12910, 2045, 287, 18, 16351, 1887, 1769, 203, 203, 3639, 309, 16051, 82, 1222, 18, 291, 31639, 1290, 1595, 12, 2867, 12, 2211, 3631, 4508, 2045, 287, 12003, 4670, 3719, 288, 203, 5411, 290, 1222, 18, 542, 23461, 1290, 1595, 12, 12910, 2045, 287, 12003, 4670, 16, 638, 1769, 203, 3639, 289, 203, 203, 3639, 467, 1504, 634, 2173, 4337, 287, 18, 13535, 2045, 287, 8526, 3778, 4508, 2045, 1031, 273, 394, 467, 1504, 634, 2173, 4337, 287, 18, 13535, 2045, 287, 8526, 12, 21, 1769, 203, 3639, 4508, 2045, 1031, 63, 20, 65, 273, 745, 751, 18, 12910, 2045, 287, 31, 203, 203, 5411, 745, 751, 18, 8949, 16, 203, 5411, 745, 751, 18, 2761, 395, 16, 203, 5411, 745, 751, 18, 7373, 2336, 16, 203, 5411, 4508, 2045, 1031, 16, 203, 5411, 745, 751, 18, 3771, 1332, 1012, 16, 203, 5411, 745, 751, 18, 22097, 1369, 16, 203, 5411, 745, 751, 18, 12824, 16, 203, 5411, 745, 751, 18, 4507, 16786, 1345, 16, 203, 5411, 745, 751, 18, 90, 16, 203, 5411, 745, 751, 18, 86, 16, 203, 5411, 745, 751, 18, 87, 203, 3639, 11272, 203, 203, 565, 289, 203, 203, 565, 445, 29759, 12, 203, 3639, 1731, 745, 892, 389, 2630, 751, 203, 565, 262, 3903, 8843, 429, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 467, 1504, 634, 2173, 4337, 287, 18, 1477, 892, 3778, 745, 751, 273, 24126, 18, 3922, 12, 203, 5411, 389, 2630, 751, 16, 203, 5411, 261, 45, 1504, 634, 2173, 4337, 287, 18, 1477, 892, 13, 203, 3639, 11272, 203, 203, 3639, 467, 654, 39, 27, 5340, 290, 1222, 273, 467, 654, 39, 27, 5340, 12, 1991, 751, 18, 12910, 2045, 287, 18, 16351, 1887, 1769, 203, 203, 3639, 309, 16051, 82, 1222, 18, 291, 31639, 1290, 1595, 12, 2867, 12, 2211, 3631, 4508, 2045, 287, 12003, 4670, 3719, 288, 203, 5411, 290, 1222, 18, 542, 23461, 1290, 1595, 12, 12910, 2045, 287, 12003, 4670, 16, 638, 1769, 203, 3639, 289, 203, 203, 3639, 467, 1504, 634, 2173, 4337, 287, 18, 13535, 2045, 287, 8526, 3778, 4508, 2045, 1031, 273, 394, 467, 1504, 634, 2173, 4337, 287, 18, 13535, 2045, 287, 8526, 12, 21, 1769, 203, 3639, 4508, 2045, 1031, 63, 20, 65, 273, 745, 751, 18, 12910, 2045, 287, 31, 203, 203, 5411, 745, 751, 18, 8949, 16, 203, 5411, 745, 751, 18, 2761, 395, 16, 203, 5411, 745, 751, 18, 7373, 2336, 16, 203, 5411, 4508, 2045, 1031, 16, 203, 5411, 745, 751, 18, 3771, 1332, 1012, 16, 203, 5411, 745, 751, 18, 22097, 1369, 16, 203, 5411, 745, 751, 18, 12824, 16, 203, 5411, 745, 751, 18, 4507, 16786, 1345, 16, 203, 5411, 745, 751, 18, 90, 16, 203, 5411, 745, 751, 18, 86, 16, 203, 5411, 745, 751, 18, 87, 203, 3639, 11272, 203, 203, 565, 289, 203, 203, 3639, 2254, 5034, 28183, 548, 273, 437, 634, 2173, 4337, 287, 18, 455, 6527, 41, 451, 12, 203, 3639, 327, 28183, 548, 31, 203, 565, 445, 2071, 528, 12, 11890, 5034, 389, 383, 304, 548, 16, 1758, 389, 24454, 13, 3903, 8843, 429, 288, 203, 3639, 2254, 5034, 2071, 528, 6275, 273, 437, 634, 2173, 4337, 287, 18, 588, 1504, 304, 9148, 429, 6275, 12, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 389, 383, 304, 548, 16, 203, 5411, 1203, 18, 5508, 203, 3639, 11272, 203, 203, 3639, 309, 261, 67, 24454, 480, 1758, 12, 2211, 3719, 288, 203, 5411, 467, 1504, 634, 4670, 18, 1504, 304, 3778, 28183, 6109, 273, 437, 634, 4670, 18, 588, 1504, 304, 12, 203, 7734, 1758, 2 ]
pragma solidity ^0.5.0; // Copyright 2017 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. // // ---------------------------------------------------------------------------- // ValueChain: SimpleStake // // http://www.simpletoken.org/ // // ---------------------------------------------------------------------------- import "./EIP20Interface.sol"; import "../lib/SafeMath.sol"; import "./ProtocolVersioned.sol"; /** * @title SimpleStake contract which implements ProtocolVersioned. * * @notice Stakes the value of an EIP20 token on Ethereum * for a utility token on the OpenST platform. */ contract SimpleStake is ProtocolVersioned { using SafeMath for uint256; /* Events */ event ReleasedStake(address indexed _protocol, address indexed _to, uint256 _amount); /* Storage */ /** EIP20 token contract that can be staked. */ EIP20Interface public eip20Token; address public gateway; /* Public functions */ /** * @notice Contract constructor. * * @dev Sets the protocol and the EIP20 token to stake. * * @param _eip20Token EIP20 token that will be staked. * @param _gateway Gateway contract that governs staking. */ constructor( EIP20Interface _eip20Token, address _gateway ) ProtocolVersioned(_gateway) public { eip20Token = _eip20Token; gateway = _gateway; } /** * @notice Public function releaseTo. * * @dev Callable only by protocol. Allows the protocol to release the staked amount * into provided address. The protocol MUST be a contract that sets the rules * on how the stake can be released and to who. * The protocol takes the role of an "owner" of the stake. * * @param _to Beneficiary of the amount of the stake. * @param _amount Amount of stake to release to beneficiary. * * @return bool True if stake is released to beneficiary, false otherwise. */ function releaseTo(address _to, uint256 _amount) public onlyProtocol returns (bool) { require(_to != address(0)); require(eip20Token.transfer(_to, _amount)); emit ReleasedStake(msg.sender, _to, _amount); return true; } /* Web3 call functions */ /** * @notice Public view function getTotalStake. * * @dev Total stake is the balance of the staking contract * accidental transfers directly to SimpleStake bypassing * the OpenST protocol will not mint new utility tokens, * but will add to the total stake, * (accidental) donations can not be prevented. * * @return uint256 Total staked amount. */ function getTotalStake() public view returns (uint256) { return eip20Token.balanceOf(address(this)); } }
Events */ Storage */* EIP20 token contract that can be staked. */ Public functions */* @notice Contract constructor. @dev Sets the protocol and the EIP20 token to stake. @param _eip20Token EIP20 token that will be staked. @param _gateway Gateway contract that governs staking./
{ eip20Token = _eip20Token; gateway = _gateway; }
2,510,622
[ 1, 4625, 348, 7953, 560, 30, 225, 9043, 1195, 5235, 1195, 14, 512, 2579, 3462, 1147, 6835, 716, 848, 506, 384, 9477, 18, 1195, 7224, 4186, 1195, 14, 225, 632, 20392, 13456, 3885, 18, 225, 632, 5206, 11511, 326, 1771, 471, 326, 512, 2579, 3462, 1147, 358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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x3061579E7dF4e618D9b657ccdE6c52Fb4ca0d439/sources/contracts/UncleBondCvxConvex.sol
The amount of CVX that needs to remain unlocked for redemptions
uint256 public outstandingRedemptions;
9,187,541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, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 20974, 426, 19117, 573, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2022-01-18 */ /** *Submitted for verification at Etherscan.io on 2020-09-18 */ pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view 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); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- 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; } } contract CoinResearchTokenfinal is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "Itsroom Coin Token"; symbol = "PRT"; decimals = 18; _totalSupply = 9900000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } 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 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; } }
* Constructor function Initializes contract with initial supply tokens to the creator of the contract/
constructor() public { name = "Itsroom Coin Token"; symbol = "PRT"; decimals = 18; _totalSupply = 9900000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); }
10,632,940
[ 1, 4625, 348, 7953, 560, 30, 380, 11417, 445, 10188, 3128, 6835, 598, 2172, 14467, 2430, 358, 326, 11784, 434, 326, 6835, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 3885, 1435, 1071, 288, 203, 3639, 508, 273, 315, 45, 3428, 13924, 28932, 3155, 14432, 203, 3639, 3273, 273, 315, 8025, 56, 14432, 203, 3639, 15105, 273, 6549, 31, 203, 3639, 389, 4963, 3088, 1283, 273, 14605, 12648, 12648, 2787, 9449, 31, 203, 540, 203, 3639, 324, 26488, 63, 3576, 18, 15330, 65, 273, 389, 4963, 3088, 1283, 31, 203, 3639, 3626, 12279, 12, 2867, 12, 20, 3631, 1234, 18, 15330, 16, 389, 4963, 3088, 1283, 1769, 203, 565, 289, 203, 377, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: NOLICENSE // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&.(@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,@@@@@@@@@@@@%.&@@@..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@&**&@@@@@@@@@.*#@@#*,,*@,..,&@@@&,.&,...,./@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@((((((/**@@@.,*,***&,.,*(@&@%,,,***%@@@@@@@@@@@@,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@#*((((((((((((@.****@,,**@,,.******,,@(((((/*@....,*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@*#(((((((((((#%@*,*,,*@***@,,,**,,*****&#((((((((**@***@%***@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@&#%(((((%%.,,**(,,,#***/,**,,*******@(((((((((((((*&@,,,....,**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@/@@@@@@@,..******,,,****,,*,,*@**/@*@#(((((((((((((((****@****@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@,........,****%,,,*,,,,,,@*,,,,*/#((((((((((*******((/@**@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@#@(******@**@,/,*,,,&***(,,,**#(((((***%@@%######(@(,../@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@,,*@@#(*/(**%***/,/,@,/#&,,#,.,*#@%***%**/&****/&&%&***@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@,/&#******@*#,..............,,#,.,*#......../@(*******.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@,@@#&,****@*//,................,,,,*,,*#... ./((/,&*****(@@@@@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@%***(*/@,..................,%.***,,*,%..#******,,@(**.**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@%*,,(*/@@@.............@@@@@@%&**##****,...@********#,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@*.,#**#@/*@&,,,,,,...%@,,,/&@@/**.@,%@**#&@&&@@/****/#(,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@&*@&(###%@@@&#*,,@#@,...,#(/(**../.(/.,,,,*%@@@@**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@#####*. .@%,......,@ ... (.(,.,,,(#@ ...... #&@@@**@@@,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@###,,*,,@,........,& /. @......./&...,,@(@,.,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@%@@@&%(@*...............,.....................&*****&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@/****,,.................................#(****(*@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@&//,@@@@@#..........*&@@...........*@@/***&***/&@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&%%&@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@(*(*/**,,,........@&((,&@.......,.&*(#/********@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@(/&,....../@((( ./.......,,@***(.....**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@*#....,.@&@,,,,,.,,,&(**(*......*@&///@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**,,@&(,,,,,*,,@#****(.....,*%#(((((%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&**,,**%@%&******.....,*&(((((((#,.@@/@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%&&&@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@%/****/@(,,,.,*&((((((((#@.. (@* @@@@@@@@@@@@@@@@@@@@@@@@@@@%#####################################&@@ // @@@@@@@@@@@@@@@@@@@@@@&..%@@@#@@@@@@@@@%%&*******,,,,*@/((((((((##*..&..@@ * %@@@@@@@@@@@@@@@@@@@@@@@%#####################################@@@ // @@@@@@@@@@@@@@@@@@@*,&,,&#%@@*,@@@@@@@%@%%&***/&*,,##(//((#(((###&..,.. (@& * @@@@@@@@@@@@@@@@@@@@######################################@@@ // @@@@@@@@@@@@@@@@,.....&*&&&**@@@@&..@@%%&%%&**,,,**@%%%@/####(#((&..&. @@ @@@@@@@@@@@@@@@#####################################%@@@ // @@@@@@@@@@@@,.,%...&,,,&/**@@@,....@@%%%&&%*******/%%%%%&/(##((((,../, &@ / %@@@@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@@,,,...%..,(/,(**@@.....(@@&%%%&&&********@%&&&&&./((((@.. %. @@ .. .%%#&@@@@@@@@@@@@@@@@@@@@@############@@@@@@@@@@@@@@@@ // @@@@@@@@@(.,@*(.,,%,.&.#*,*.....@@@@&&.#&&&#*******&&&&&&.....@(....&. @@ ..., .@ ,@@@@@@@@@@@@@@@@@&############@@@@@@@@@@@@@@@@ // @@@@@@@@@@..,***(#.&.%***/..,@@@ (@@@.@&&&******%&&&&&& ..........@ .@&..../ ..& @@@@@@@@@@@@@@@@@&############@@@@@@@@@@@@@@@@ // @@@@@@@@@@(.************,%..(/@ @@.@&&&/***(&&&&&#/. ......*&,. @@ ...@ ...# @@@@@@@@@@@@@@@@@%############@@@@@@@@@@@@@@@@ // @@@@@@@@@@@,***********(/ /@# ,@&*%&&&&*&&&@%%#/(& ....&*,. ##@ ..& ..&.. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@********&*#. % @(*%%%&&&&&&@(((((% .........*% &@ ..,..&.. /@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@*****@***.. .( * @%(%&&&&&&&((((#@ .........@. @@* .&..,.. . @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@********,&.*@@@@@@@@@@# %%((&&&&@@@@@@@@@@@@@@@@@@@@@@&, @@/ .&@@@@@@@@@@@@@@@@@@/ .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@ @@*******.,@@( @@ &(/(%&&@@ @@*@@* *@@ /@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@ // @@. @@(*****/@@ @@@((((&&&@@. ,@@./ ,@@ .@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@ // @@/ @@@***(@@ @@#(((#&&&@@/ @@@@&%#*. @@&@& .@@ @@@@@# ,@@@@@@@@@@@@@* @@@@@@@@@@@@@@@@@ // @@# *@@*@@@ @@%#((&&&&@@& @@@@@@@@@@@@@ &@ /@@ @@ @@@ @@@@@@@@@@@@# @@@@@@@@@@@@@@@@@ // @@& @@@. .@@%%#%&&&&@@@ @@ @( ..@@ @@ @@, &@@@@@@@@@@@& ,@@@@@@@@@@@@@@@@@ // @@@..............@...... ........@@#((%&&&&&@@.................. @@ ##/ ..,@@....... @@ #@@.......*@@@@@@@@@@@&.......*@@@@@@@@@@@@@@@@@ // @@&.......@............%@........@@(((&&&&&@@@........&&&&&&&%/./@@@@ ./.@@........@@.. @@........@@@@@@@@@@@@(.......,@@@@@@@@@@@@@@@@@ // @@(.......@@/.........@@@........@@%@(&&&&&@@(........@@@@@@@@@@@@@@ #.(.@@........@@&&@@@@&........%@@@@@@@@@@@@,........@@@@@@@@@@@@@@@@@ // @@,.......@@@@.......@@@&........@@((%&&&&&@@,....................@@# ..(,*@@........................@@@@@@@@@@@@@@.........@@@@@@@@@@@@@@@@@ // @@........@@@@@....,@@@@#........@@((&&&&&&@@.....................@@ ..#@%.@@.....................,@@@@@@@@@@@@@@@@.........@@@@@@@@@@@@@@@@@ // @@.,,,,,,,@@/*@@,,,@@*@@#,,,,,,,,@@((@&&&&&@@.,,,,,,,,,,,,,,,,,,,(@@ .,,@%.*@@,,,,,,,,,,,,,,..(@@@@@@@@@@@@@@@@@@@@@.,,,,,,,.@@@@@@@@@@@@@@@@@ // @@@@@@@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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ pragma solidity ^0.8.9; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } 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; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _setOwner(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } 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); } } interface IFactory{ function createPair(address tokenA, address tokenB) external returns (address pair); } interface IRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external; } contract MediTokenV2 is Context, IERC20, Ownable { 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) private _isBot; address[] private _excluded; bool public swapEnabled; bool private swapping; IRouter public router; address public pair; uint8 private constant _decimals = 9; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000000000 * 10**_decimals; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 public swapTokensAtAmount = 1000000 * 10**_decimals; uint256 public maxTxAmount = 2000000000000000 * 10**_decimals; bool private _isTradingState = true; // Anti Dump // mapping (address => uint256) public _lastTrade; bool public coolDownEnabled = true; uint256 public coolDownTime = 69 seconds; address public constant deadAddress = 0x000000000000000000000000000000000000dEaD; address public devAddress = 0xC56d6d2ae78102C9D7a72bCab720ca1CAe97b2cC; address public charityAddress = 0xb3AaE54BE35E8044c8044F5488aAF3861279328B; address public marketingAddress = 0x45b495b912c33db96D57B18FbB5f4A439573D770; address private routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; //uniswap v2 string private constant _name = "Medi Token V2"; string private constant _symbol = "MEDI"; struct Taxes { uint256 rfi; uint256 burn; uint256 liquidity; uint256 charity; uint256 dev; uint256 marketing; } Taxes public taxes = Taxes(1,1,1,3,3,2); struct TotFeesPaidStruct{ uint256 rfi; uint256 burn; uint256 liquidity; uint256 charity; uint256 dev; uint256 marketing; } TotFeesPaidStruct public totFeesPaid; struct valuesFromGetValues{ uint256 rAmount; uint256 rTransferAmount; uint256 rRfi; uint256 rBurn; uint256 rLiquidity; uint256 rCharity; uint256 rDev; uint256 rMarketing; uint256 tTransferAmount; uint256 tRfi; uint256 tBurn; uint256 tLiquidity; uint256 tCharity; uint256 tDev; uint256 tMarketing; } event FeesChanged(); event UpdatedRouter(address oldRouter, address newRouter); modifier lockTheSwap { swapping = true; _; swapping = false; } constructor () { IRouter _router = IRouter(routerAddress); address _pair = IFactory(_router.factory()) .createPair(address(this), _router.WETH()); router = _router; pair = _pair; excludeFromReward(pair); excludeFromReward(deadAddress); _rOwned[owner()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[charityAddress]=true; _isExcludedFromFee[devAddress]=true; _isExcludedFromFee[marketingAddress]=true; _isExcludedFromFee[deadAddress] = true; _isTradingState = true; swapEnabled = true; emit Transfer(address(0), owner(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } 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) { require(_isTradingState == true, "Trading is currently disabled."); _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function tradingEnabled() public view returns (bool) { return _isTradingState; } 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 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; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } 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; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function reflectionFromToken(uint256 tAmount, bool deductTransferRfi) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferRfi) { valuesFromGetValues memory s = _getValues(tAmount, true); return s.rAmount; } else { valuesFromGetValues memory s = _getValues(tAmount, true); return s.rTransferAmount; } } 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 excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is not excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function setTaxes(uint256 _rfi, uint256 _charity, uint256 _dev, uint256 _marketing, uint256 _liquidity, uint256 _burn) public onlyOwner { taxes.rfi = _rfi; taxes.charity = _charity; taxes.dev = _dev; taxes.marketing = _marketing; taxes.liquidity = _liquidity; taxes.burn = _burn; emit FeesChanged(); } function _reflectRfi(uint256 rRfi, uint256 tRfi) private { _rTotal -=rRfi; totFeesPaid.rfi +=tRfi; } function _takeLiquidity(uint256 rLiquidity, uint256 tLiquidity) private { totFeesPaid.liquidity +=tLiquidity; if(_isExcluded[address(this)]) { _tOwned[address(this)]+=tLiquidity; } _rOwned[address(this)] +=rLiquidity; } function _takeDev(uint256 rDev, uint256 tDev) private { totFeesPaid.dev +=tDev; if(_isExcluded[address(this)]) { _tOwned[address(this)]+=tDev; } _rOwned[address(this)] +=rDev; } function _takeMarketing(uint256 rMarketing, uint256 tMarketing) private { totFeesPaid.marketing +=tMarketing; if(_isExcluded[address(this)]) { _tOwned[address(this)]+=tMarketing; } _rOwned[address(this)] +=rMarketing; } function _takeCharity(uint256 rCharity, uint256 tCharity) private { totFeesPaid.charity +=tCharity; if(_isExcluded[address(this)]) { _tOwned[address(this)]+=tCharity; } _rOwned[address(this)] +=rCharity; } function _takeBurn(uint256 rBurn, uint256 tBurn) private{ totFeesPaid.burn +=tBurn; if(_isExcluded[deadAddress]) { _tOwned[deadAddress]+=tBurn; } _rOwned[deadAddress] +=rBurn; } function _getValues(uint256 tAmount, bool takeFee) private view returns (valuesFromGetValues memory to_return) { to_return = _getTValues(tAmount, takeFee); (to_return.rAmount, to_return.rTransferAmount, to_return.rRfi, to_return.rCharity, to_return.rDev, to_return.rMarketing, to_return.rLiquidity, to_return.rBurn) = _getRValues(to_return, tAmount, takeFee, _getRate()); return to_return; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (valuesFromGetValues memory s) { if(!takeFee) { s.tTransferAmount = tAmount; return s; } s.tRfi = tAmount*taxes.rfi/100; s.tCharity = tAmount*taxes.charity/100; s.tDev = tAmount*taxes.dev/100; s.tMarketing = tAmount*taxes.marketing/100; s.tLiquidity = tAmount*taxes.liquidity/100; s.tBurn = tAmount*taxes.burn/100; s.tTransferAmount = tAmount-s.tRfi-s.tCharity-s.tDev-s.tMarketing-s.tLiquidity-s.tBurn; return s; } function _getRValues(valuesFromGetValues memory s, uint256 tAmount, bool takeFee, uint256 currentRate) private pure returns (uint256 rAmount, uint256 rTransferAmount, uint256 rRfi, uint256 rCharity, uint256 rDev, uint256 rMarketing, uint256 rLiquidity, uint256 rBurn) { rAmount = tAmount*currentRate; if(!takeFee) { return(rAmount, rAmount, 0,0,0,0,0,0); } rRfi = s.tRfi*currentRate; rCharity = s.tCharity*currentRate; rDev = s.tDev*currentRate; rMarketing = s.tMarketing*currentRate; rLiquidity = s.tLiquidity*currentRate; rBurn = s.rBurn*currentRate; rTransferAmount = rAmount-rRfi-rCharity-rDev-rMarketing-rLiquidity-rBurn; return (rAmount, rTransferAmount, rRfi, rCharity, rDev, rMarketing, rLiquidity, rBurn); } 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 = rSupply-_rOwned[_excluded[i]]; tSupply = tSupply-_tOwned[_excluded[i]]; } if (rSupply < _rTotal/_tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(amount <= balanceOf(from),"You are trying to transfer more than your balance"); require(!_isBot[from] && !_isBot[to], "You are a bot"); if(!_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !swapping){ require(amount <= maxTxAmount ,"Amount is exceeding maxTxAmount"); if(from != pair && coolDownEnabled){ uint256 timePassed = block.timestamp - _lastTrade[from]; require(timePassed > coolDownTime, "You must wait coolDownTime"); _lastTrade[from] = block.timestamp; } if(to != pair && coolDownEnabled){ uint256 timePassed2 = block.timestamp - _lastTrade[to]; require(timePassed2 > coolDownTime, "You must wait coolDownTime"); _lastTrade[to] = block.timestamp; } } bool canSwap = balanceOf(address(this)) >= swapTokensAtAmount; if(!swapping && swapEnabled && canSwap && from != pair && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]){ swapAndLiquify(swapTokensAtAmount); } _tokenTransfer(from, to, amount, !(_isExcludedFromFee[from] || _isExcludedFromFee[to])); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 tAmount, bool takeFee) private { valuesFromGetValues memory s = _getValues(tAmount, takeFee); if (_isExcluded[sender] ) { //from excluded _tOwned[sender] = _tOwned[sender]-tAmount; } if (_isExcluded[recipient]) { //to excluded _tOwned[recipient] = _tOwned[recipient]+s.tTransferAmount; } _rOwned[sender] = _rOwned[sender]-s.rAmount; _rOwned[recipient] = _rOwned[recipient]+s.rTransferAmount; _reflectRfi(s.rRfi, s.tRfi); _takeLiquidity(s.rLiquidity,s.tLiquidity); _takeDev(s.rDev, s.tDev); _takeMarketing(s.rMarketing, s.tMarketing); _takeCharity(s.rCharity, s.tCharity); _takeBurn(s.rBurn, s.tBurn); emit Transfer(sender, deadAddress, s.tBurn); emit Transfer(sender, recipient, s.tTransferAmount); emit Transfer(sender, address(this), s.tLiquidity + s.tCharity + s.tDev + s.tMarketing); } function swapAndLiquify(uint256 tokens) private lockTheSwap{ // Split the contract balance into halves uint256 denominator = (taxes.liquidity + taxes.dev + taxes.charity + taxes.marketing ) * 2; uint256 tokensToAddLiquidityWith = tokens * taxes.liquidity / denominator; uint256 toSwap = tokens - tokensToAddLiquidityWith; uint256 initialBalance = address(this).balance; swapTokensForETH(toSwap); uint256 deltaBalance = address(this).balance - initialBalance; uint256 unitBalance= deltaBalance / (denominator - taxes.liquidity); uint256 ethToAddLiquidityWith = unitBalance * taxes.liquidity; if(ethToAddLiquidityWith > 0){ // Add liquidity to uniswap addLiquidity(tokensToAddLiquidityWith, ethToAddLiquidityWith); } uint256 devAmt = unitBalance * 2 * taxes.charity; if(devAmt > 0){ payable(devAddress).transfer(devAmt); } uint256 charityAmt = unitBalance * 2 * taxes.dev; if(charityAmt > 0){ payable(charityAddress).transfer(charityAmt); } uint256 marketingAmt = unitBalance * 2 * taxes.marketing; if(marketingAmt > 0){ payable(marketingAddress).transfer(marketingAmt); } } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(router), tokenAmount); // add the liquidity router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function swapTokensForETH(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); _approve(address(this), address(router), tokenAmount); // make the swap router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function updatedevWallet(address newWallet) external onlyOwner{ require(devAddress != newWallet ,'Wallet already set'); devAddress = newWallet; _isExcludedFromFee[devAddress]; } function updatecharityWallet(address newWallet) external onlyOwner{ require(charityAddress != newWallet ,'Wallet already set'); charityAddress = newWallet; _isExcludedFromFee[charityAddress]; } function updatemarketingWallet(address newWallet) external onlyOwner{ require(marketingAddress != newWallet ,'Wallet already set'); marketingAddress = newWallet; _isExcludedFromFee[marketingAddress]; } function updatMaxTxAmt(uint256 amount) external onlyOwner{ maxTxAmount = amount * 10 **_decimals; } function updateSwapTokensAtAmount(uint256 amount) external onlyOwner{ swapTokensAtAmount = amount * 10 **_decimals; } function updateSwapEnabled(bool _enabled) external onlyOwner{ swapEnabled = _enabled; } function updateCoolDownSettings(bool _enabled, uint256 _timeInSeconds) external onlyOwner{ coolDownEnabled = _enabled; coolDownTime = _timeInSeconds * 1 seconds; } function setAntibot(address account, bool state) external onlyOwner{ require(_isBot[account] != state, 'Value already set'); _isBot[account] = state; } function bulkAntiBot(address[] memory accounts, bool state) external onlyOwner{ for(uint256 i = 0; i < accounts.length; i++){ _isBot[accounts[i]] = state; } } function updateRouterAndPair(address newRouter, address newPair) external onlyOwner{ router = IRouter(newRouter); pair = newPair; } function isBot(address account) public view returns(bool){ return _isBot[account]; } //Use this in case ETH are sent to the contract by mistake function rescueETH(uint256 weiAmount) external onlyOwner{ require(address(this).balance >= weiAmount, "insufficient ETH balance"); payable(msg.sender).transfer(weiAmount); } // Function to allow admin to claim *other* BEP20 tokens sent to this contract (by mistake) // Owner cannot transfer out cakecoin from this smart contract function rescueAnyERC20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner { IERC20(_tokenAddr).transfer(_to, _amount); } function setTradingState(bool _state) external onlyOwner{ _isTradingState = _state; } receive() external payable{ } }
Split the contract balance into halves
function swapAndLiquify(uint256 tokens) private lockTheSwap{ uint256 denominator = (taxes.liquidity + taxes.dev + taxes.charity + taxes.marketing ) * 2; uint256 tokensToAddLiquidityWith = tokens * taxes.liquidity / denominator; uint256 toSwap = tokens - tokensToAddLiquidityWith; uint256 initialBalance = address(this).balance; swapTokensForETH(toSwap); uint256 deltaBalance = address(this).balance - initialBalance; uint256 unitBalance= deltaBalance / (denominator - taxes.liquidity); uint256 ethToAddLiquidityWith = unitBalance * taxes.liquidity; if(ethToAddLiquidityWith > 0){ addLiquidity(tokensToAddLiquidityWith, ethToAddLiquidityWith); } uint256 devAmt = unitBalance * 2 * taxes.charity; if(devAmt > 0){ payable(devAddress).transfer(devAmt); } uint256 charityAmt = unitBalance * 2 * taxes.dev; if(charityAmt > 0){ payable(charityAddress).transfer(charityAmt); } uint256 marketingAmt = unitBalance * 2 * taxes.marketing; if(marketingAmt > 0){ payable(marketingAddress).transfer(marketingAmt); } }
12,810,345
[ 1, 4625, 348, 7953, 560, 30, 225, 5385, 326, 6835, 11013, 1368, 19514, 3324, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 7720, 1876, 48, 18988, 1164, 12, 11890, 5034, 2430, 13, 3238, 2176, 1986, 12521, 95, 203, 3639, 2254, 5034, 15030, 273, 261, 8066, 281, 18, 549, 372, 24237, 397, 5320, 281, 18, 5206, 397, 5320, 281, 18, 3001, 560, 397, 5320, 281, 18, 3355, 21747, 262, 380, 576, 31, 203, 3639, 2254, 5034, 2430, 13786, 48, 18988, 24237, 1190, 273, 2430, 380, 5320, 281, 18, 549, 372, 24237, 342, 15030, 31, 203, 3639, 2254, 5034, 358, 12521, 273, 2430, 300, 2430, 13786, 48, 18988, 24237, 1190, 31, 203, 203, 3639, 2254, 5034, 2172, 13937, 273, 1758, 12, 2211, 2934, 12296, 31, 203, 203, 3639, 7720, 5157, 1290, 1584, 44, 12, 869, 12521, 1769, 203, 203, 3639, 2254, 5034, 3622, 13937, 273, 1758, 12, 2211, 2934, 12296, 300, 2172, 13937, 31, 203, 3639, 2254, 5034, 2836, 13937, 33, 3622, 13937, 342, 261, 13002, 26721, 300, 5320, 281, 18, 549, 372, 24237, 1769, 203, 3639, 2254, 5034, 13750, 13786, 48, 18988, 24237, 1190, 273, 2836, 13937, 380, 5320, 281, 18, 549, 372, 24237, 31, 203, 203, 3639, 309, 12, 546, 13786, 48, 18988, 24237, 1190, 405, 374, 15329, 203, 5411, 527, 48, 18988, 24237, 12, 7860, 13786, 48, 18988, 24237, 1190, 16, 13750, 13786, 48, 18988, 24237, 1190, 1769, 203, 3639, 289, 203, 203, 3639, 2254, 5034, 4461, 31787, 273, 2836, 13937, 380, 576, 380, 5320, 281, 18, 3001, 560, 31, 203, 3639, 309, 12, 5206, 31787, 405, 374, 15329, 203, 5411, 8843, 429, 12, 5206, 1887, 2934, 13866, 12, 5206, 31787, 1769, 203, 3639, 289, 203, 203, 3639, 2254, 5034, 1149, 560, 31787, 273, 2836, 13937, 380, 576, 380, 5320, 281, 18, 5206, 31, 203, 3639, 309, 12, 3001, 560, 31787, 405, 374, 15329, 203, 5411, 8843, 429, 12, 3001, 560, 1887, 2934, 13866, 12, 3001, 560, 31787, 1769, 203, 3639, 289, 203, 203, 3639, 2254, 5034, 13667, 310, 31787, 273, 2836, 13937, 380, 576, 380, 5320, 281, 18, 3355, 21747, 31, 203, 3639, 309, 12, 3355, 21747, 31787, 405, 374, 15329, 203, 5411, 8843, 429, 12, 3355, 21747, 1887, 2934, 13866, 12, 3355, 21747, 31787, 1769, 203, 3639, 289, 203, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.7.6; pragma abicoder v2; import "@chainlink/contracts/src/v0.7/interfaces/KeeperRegistryInterface.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; import "./LimitOrderMonitor.sol"; /// @title LimitOrderMonitorChainlink contract LimitOrderMonitorChainlinkV2 is LimitOrderMonitor { /// @dev fast gas AggregatorV3Interface public FAST_GAS_FEED; function initialize(IOrderManager _orderManager, IUniswapV3Factory _factory, IERC20 _KROM, address _keeper, uint256 _batchSize, uint256 _monitorSize, uint256 _upkeepInterval, AggregatorV3Interface fastGasFeed) public initializer { super.initialize( _orderManager, _factory, _KROM, _keeper, _batchSize, _monitorSize, _upkeepInterval ); FAST_GAS_FEED = fastGasFeed; } function _getGasPrice(uint256 _txnGasPrice) internal view virtual override returns (uint256 gasPrice) { if (_txnGasPrice > 0) { return _txnGasPrice; } uint256 timestamp; int256 feedValue; (,feedValue,,timestamp,) = FAST_GAS_FEED.latestRoundData(); gasPrice = uint256(feedValue); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.7.6; interface IOrderMonitor { function startMonitor(uint256 _tokenId) external; function stopMonitor(uint256 _tokenId) external; function getTokenIdsLength() external view returns (uint256); function monitorSize() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.7.6; pragma abicoder v2; interface IOrderManager { struct LimitOrderParams { address _token0; address _token1; uint24 _fee; uint160 _sqrtPriceX96; uint128 _amount0; uint128 _amount1; uint256 _amount0Min; uint256 _amount1Min; } function placeLimitOrder(LimitOrderParams calldata params) external payable returns (uint256 tokenId); function processLimitOrder( uint256 _tokenId, uint256 _serviceFee, uint256 _monitorFee ) external returns (uint128, uint128); function canProcess(uint256 _tokenId, uint256 gasPrice) external returns (bool, uint256, uint256); function quoteKROM(uint256 weiAmount) external returns (uint256 quote); function funding(address owner) external view returns (uint256 balance); function feeAddress() external view returns (address); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.7.6; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@chainlink/contracts/src/v0.7/interfaces/KeeperCompatibleInterface.sol"; import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; import "@chainlink/contracts/src/v0.7/KeeperBase.sol"; import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; import "./interfaces/IOrderMonitor.sol"; import "./interfaces/IOrderManager.sol"; /// @title LimitOrderMonitor contract LimitOrderMonitor is Initializable, IOrderMonitor, KeeperCompatibleInterface, KeeperBase { using SafeMath for uint256; uint256 private constant MAX_INT = 2**256 - 1; uint256 private constant MAX_BATCH_SIZE = 100; uint256 private constant MAX_MONITOR_SIZE = 10000; event BatchProcessed(uint256 batchSize, uint256 gasUsed, uint256 paymentPaid, bytes data); /// @dev when batch size have changed event BatchSizeChanged(address from, uint256 newValue); /// @dev when monitor size have changed event MonitorSizeChanged(address from, uint256 newValue); /// @dev when upkeep interval changed event UpkeepIntervalChanged(address from, uint256 newValue); /// @dev when controller has changed event ControllerChanged(address from, address newValue); /// @dev when keeper has changed event KeeperChanged(address from, address newValue); /// @dev when monitor is started event MonitorStarted(uint256 tokenId); /// @dev when monitor is stopped event MonitorStopped(uint256 tokenId); /// @dev tokenIds index per token id mapping (uint256 => uint256) public tokenIndexPerTokenId; /// @dev tokens to monitor uint256[] public tokenIds; /// @dev controller address; could be DAO address public controller; /// @dev keeper address; can do upkeep address public keeper; /// @dev order manager IOrderManager public orderManager; /// @dev univ3 factory IUniswapV3Factory public factory; /// @dev krom token IERC20 public KROM; /// @dev last upkeep block uint256 public lastUpkeep; /// @dev max batch size uint256 public batchSize; /// @dev max monitor size uint256 public override monitorSize; /// @dev interval between 2 upkeeps, in blocks uint256 public upkeepInterval; constructor () initializer {} function initialize (IOrderManager _orderManager, IUniswapV3Factory _factory, IERC20 _KROM, address _keeper, uint256 _batchSize, uint256 _monitorSize, uint256 _upkeepInterval) public initializer { require(_batchSize <= MAX_BATCH_SIZE, "INVALID_BATCH_SIZE"); require(_monitorSize <= MAX_MONITOR_SIZE, "INVALID_MONITOR_SIZE"); require(_batchSize <= _monitorSize, "SIZE_MISMATCH"); orderManager = _orderManager; factory = _factory; KROM = _KROM; batchSize = _batchSize; monitorSize = _monitorSize; upkeepInterval = _upkeepInterval; controller = msg.sender; keeper = _keeper; require(KROM.approve(address(orderManager), MAX_INT)); } function startMonitor(uint256 _tokenId) external override { isAuthorizedTradeManager(); require(tokenIds.length < monitorSize, "MONITOR_FULL"); tokenIds.push(_tokenId); tokenIndexPerTokenId[_tokenId] = tokenIds.length; emit MonitorStarted(_tokenId); } function stopMonitor(uint256 _tokenId) external override { isAuthorizedTradeManager(); _stopMonitor(_tokenId); emit MonitorStopped(_tokenId); } function checkUpkeep( bytes calldata ) external override cannotExecute returns ( bool upkeepNeeded, bytes memory performData ) { if (upkeepNeeded = (_getBlockNumber() - lastUpkeep) > upkeepInterval) { uint256 _tokenId; uint256[] memory batchTokenIds = new uint256[](batchSize); uint256 count; // iterate through all active tokens; for (uint256 i = 0; i < tokenIds.length; i++) { _tokenId = tokenIds[i]; (upkeepNeeded,,) = orderManager.canProcess( _tokenId, _getGasPrice(tx.gasprice) ); if (upkeepNeeded) { batchTokenIds[count] = _tokenId; count++; } if (count >= batchSize) { break; } } upkeepNeeded = count > 0; if (upkeepNeeded) { performData = abi.encode(batchTokenIds, count); } } } function performUpkeep( bytes calldata performData ) external override { uint256 _gasUsed = gasleft(); (uint256[] memory _tokenIds, uint256 _count) = abi.decode( performData, (uint256[], uint256) ); uint256 serviceFeePaid; uint256 monitorFeePaid; uint256 validCount; { bool validTrade; uint256 _serviceFee; uint256 _monitorFee; uint256 _tokenId; require(_count <= _tokenIds.length, "LOC_CL"); require(_count <= batchSize, "LOC_BS"); for (uint256 i = 0; i < _count; i++) { _tokenId = _tokenIds[i]; (validTrade, _serviceFee, _monitorFee) = orderManager.canProcess(_tokenId, _getGasPrice(tx.gasprice)); if (validTrade) { validCount++; _stopMonitor(_tokenId); orderManager.processLimitOrder( _tokenId, _serviceFee, _monitorFee ); serviceFeePaid = serviceFeePaid.add(_serviceFee); monitorFeePaid = monitorFeePaid.add(_monitorFee); } } } require(validCount > 0, "LOC_VC"); _gasUsed = _gasUsed - gasleft(); lastUpkeep = _getBlockNumber(); // send the paymentPaid to the keeper _transferFees(monitorFeePaid, keeper); // send the diff to the fee address _transferFees(serviceFeePaid.sub(monitorFeePaid), orderManager.feeAddress()); emit BatchProcessed( validCount, _gasUsed, serviceFeePaid, performData ); } function setBatchSize(uint256 _batchSize) external { isAuthorizedController(); require(_batchSize <= MAX_BATCH_SIZE, "INVALID_BATCH_SIZE"); require(_batchSize <= monitorSize, "SIZE_MISMATCH"); batchSize = _batchSize; emit BatchSizeChanged(msg.sender, _batchSize); } function setMonitorSize(uint256 _monitorSize) external { isAuthorizedController(); require(_monitorSize <= MAX_MONITOR_SIZE, "INVALID_MONITOR_SIZE"); require(_monitorSize >= batchSize, "SIZE_MISMATCH"); monitorSize = _monitorSize; emit MonitorSizeChanged(msg.sender, _monitorSize); } function setUpkeepInterval(uint256 _upkeepInterval) external { isAuthorizedController(); upkeepInterval = _upkeepInterval; emit UpkeepIntervalChanged(msg.sender, _upkeepInterval); } function changeController(address _controller) external { isAuthorizedController(); controller = _controller; emit ControllerChanged(msg.sender, _controller); } function changeKeeper(address _keeper) external { isAuthorizedController(); keeper = _keeper; emit KeeperChanged(msg.sender, _keeper); } function _stopMonitor(uint256 _tokenId) internal { uint256 tokenIndexToRemove = tokenIndexPerTokenId[_tokenId] - 1; uint256 lastTokenId = tokenIds[tokenIds.length - 1]; removeElementFromArray(tokenIndexToRemove, tokenIds); if (tokenIds.length == 0) { delete tokenIndexPerTokenId[lastTokenId]; } else if (tokenIndexToRemove != tokenIds.length) { tokenIndexPerTokenId[lastTokenId] = tokenIndexToRemove + 1; delete tokenIndexPerTokenId[_tokenId]; } } // TODO override for chainlink (use fast gas) function _getGasPrice(uint256 _txnGasPrice) internal virtual view returns (uint256 gasPrice) { gasPrice = _txnGasPrice > 0 ? _txnGasPrice : 0; } // TODO (override block numbers for L2) function _getBlockNumber() internal virtual view returns (uint256 blockNumber) { blockNumber = block.number; } function _transferFees(uint256 _amount, address _owner) internal virtual { if (_amount > 0) { TransferHelper.safeTransfer(address(KROM), _owner, _amount); } } function getTokenIdsLength() external view override returns (uint256) { return tokenIds.length; } function isAuthorizedController() internal view { require(msg.sender == controller, "LOC_AC"); } function isAuthorizedTradeManager() internal view { require(msg.sender == address(orderManager), "LOC_ATM"); } /// @notice Removes index element from the given array. /// @param index index to remove from the array /// @param array the array itself function removeElementFromArray(uint256 index, uint256[] storage array) private { if (index == array.length - 1) { array.pop(); } else { array[index] = array[array.length - 1]; array.pop(); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; } // 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; /** * @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 // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity >=0.7.5; /** * @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 * ==== * * [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. 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"); (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 // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity >=0.7.5; import "../utils/AddressUpgradeable.sol"; /** * @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 proxied contracts do not make use of 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. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * constructor() initializer {} * ``` * ==== */ 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() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface KeeperRegistryBaseInterface { function registerUpkeep( address target, uint32 gasLimit, address admin, bytes calldata checkData ) external returns ( uint256 id ); function performUpkeep( uint256 id, bytes calldata performData ) external returns ( bool success ); function cancelUpkeep( uint256 id ) external; function addFunds( uint256 id, uint96 amount ) external; function getUpkeep(uint256 id) external view returns ( address target, uint32 executeGas, bytes memory checkData, uint96 balance, address lastKeeper, address admin, uint64 maxValidBlocknumber ); function getUpkeepCount() external view returns (uint256); function getCanceledUpkeepList() external view returns (uint256[] memory); function getKeeperList() external view returns (address[] memory); function getKeeperInfo(address query) external view returns ( address payee, bool active, uint96 balance ); function getConfig() external view returns ( uint32 paymentPremiumPPB, uint24 checkFrequencyBlocks, uint32 checkGasLimit, uint24 stalenessSeconds, uint16 gasCeilingMultiplier, uint256 fallbackGasPrice, uint256 fallbackLinkPrice ); } /** * @dev The view methods are not actually marked as view in the implementation * but we want them to be easily queried off-chain. Solidity will not compile * if we actually inherrit from this interface, so we document it here. */ interface KeeperRegistryInterface is KeeperRegistryBaseInterface { function checkUpkeep( uint256 upkeepId, address from ) external view returns ( bytes memory performData, uint256 maxLinkPayment, uint256 gasLimit, int256 gasWei, int256 linkEth ); } interface KeeperRegistryExecutableInterface is KeeperRegistryBaseInterface { function checkUpkeep( uint256 upkeepId, address from ) external returns ( bytes memory performData, uint256 maxLinkPayment, uint256 gasLimit, uint256 adjustedGasWei, uint256 linkEth ); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface KeeperCompatibleInterface { /** * @notice method that is simulated by the keepers to see if any work actually * needs to be performed. This method does does not actually need to be * executable, and since it is only ever simulated it can consume lots of gas. * @dev To ensure that it is never called, you may want to add the * cannotExecute modifier from KeeperBase to your implementation of this * method. * @param checkData specified in the upkeep registration so it is always the * same for a registered upkeep. This can easilly be broken down into specific * arguments using `abi.decode`, so multiple upkeeps can be registered on the * same contract and easily differentiated by the contract. * @return upkeepNeeded boolean to indicate whether the keeper should call * performUpkeep or not. * @return performData bytes that the keeper should call performUpkeep with, if * upkeep is needed. If you would like to encode data to decode later, try * `abi.encode`. */ function checkUpkeep( bytes calldata checkData ) external returns ( bool upkeepNeeded, bytes memory performData ); /** * @notice method that is actually executed by the keepers, via the registry. * The data returned by the checkUpkeep simulation will be passed into * this method to actually be executed. * @dev The input to this method should not be trusted, and the caller of the * method should not even be restricted to any single registry. Anyone should * be able call it, and the input should be validated, there is no guarantee * that the data passed in is the performData returned from checkUpkeep. This * could happen due to malicious keepers, racing keepers, or simply a state * change while the performUpkeep transaction is waiting for confirmation. * Always validate the data passed in. * @param performData is the data which was passed back from the checkData * simulation. If it is encoded, it can easily be decoded into other types by * calling `abi.decode`. This data should not be trusted, and should be * validated against the contract's current state. */ function performUpkeep( bytes calldata performData ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface AggregatorV3Interface { function decimals() external view returns ( uint8 ); function description() external view returns ( string memory ); function version() external view returns ( uint256 ); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData( uint80 _roundId ) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; contract KeeperBase { /** * @notice method that allows it to be simulated via eth_call by checking that * the sender is the zero address. */ function preventExecution() internal view { require(tx.origin == address(0), "only for simulated backend"); } /** * @notice modifier that allows it to be simulated via eth_call by checking * that the sender is the zero address. */ modifier cannotExecute() { preventExecution(); _; } }
TODO override for chainlink (use fast gas)
function _getGasPrice(uint256 _txnGasPrice) internal virtual view returns (uint256 gasPrice) { gasPrice = _txnGasPrice > 0 ? _txnGasPrice : 0; }
6,078,683
[ 1, 4625, 348, 7953, 560, 30, 225, 2660, 3849, 364, 2687, 1232, 261, 1202, 4797, 16189, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 588, 27998, 5147, 12, 11890, 5034, 389, 24790, 27998, 5147, 13, 2713, 5024, 1476, 203, 565, 1135, 261, 11890, 5034, 16189, 5147, 13, 288, 203, 3639, 16189, 5147, 273, 389, 24790, 27998, 5147, 405, 374, 692, 389, 24790, 27998, 5147, 294, 374, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x4fE0BBc2614391AB455fc4Df27e63669d30B94Ff/sources/src/x-key/AirdropTicket.sol
/ the base URI for the metadata
contract AirdropTicket is ERC721AQueryable, Ownable { string private baseURI; pragma solidity 0.8.20; An NFT ticket to be used for claiming airdrops. constructor() payable ERC721A("Airdrop Ticket", "AIRDROP") {} function _baseURI() internal view override returns (string memory) { return baseURI; } function _startTokenId() internal pure override returns (uint256) { return 1; } function mintTicket(address to, uint8 nTokens) external onlyOwner { _mint(to, nTokens); } function burn(uint256 tokenId) external { _burn(tokenId, true); } function setBaseURI(string calldata newBaseURI) external onlyOwner { baseURI = newBaseURI; } }
9,800,225
[ 1, 4625, 348, 7953, 560, 30, 342, 326, 1026, 3699, 364, 326, 1982, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 432, 6909, 1764, 13614, 353, 4232, 39, 27, 5340, 37, 1138, 429, 16, 14223, 6914, 288, 203, 565, 533, 3238, 1026, 3098, 31, 203, 203, 203, 683, 9454, 18035, 560, 374, 18, 28, 18, 3462, 31, 203, 979, 423, 4464, 9322, 358, 506, 1399, 364, 7516, 310, 279, 6909, 16703, 18, 203, 565, 3885, 1435, 8843, 429, 4232, 39, 27, 5340, 37, 2932, 37, 6909, 1764, 22023, 3113, 315, 37, 7937, 18768, 7923, 2618, 203, 565, 445, 389, 1969, 3098, 1435, 2713, 1476, 3849, 1135, 261, 1080, 3778, 13, 288, 203, 3639, 327, 1026, 3098, 31, 203, 565, 289, 203, 203, 565, 445, 389, 1937, 1345, 548, 1435, 2713, 16618, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 404, 31, 203, 565, 289, 203, 203, 565, 445, 312, 474, 13614, 12, 2867, 358, 16, 2254, 28, 290, 5157, 13, 3903, 1338, 5541, 288, 203, 3639, 389, 81, 474, 12, 869, 16, 290, 5157, 1769, 203, 565, 289, 203, 203, 565, 445, 18305, 12, 11890, 5034, 1147, 548, 13, 3903, 288, 203, 3639, 389, 70, 321, 12, 2316, 548, 16, 638, 1769, 203, 565, 289, 203, 203, 565, 445, 26435, 3098, 12, 1080, 745, 892, 394, 2171, 3098, 13, 3903, 1338, 5541, 288, 203, 3639, 1026, 3098, 273, 394, 2171, 3098, 31, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** * ForecasterReward.sol v1.1.0 * * Bilal Arif - https://twitter.com/furusiyya_ * Draglet GbmH */ pragma solidity 0.4.19; library SafeMath { function mul(uint256 a, uint256 b) pure internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) pure internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) pure internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) pure internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) pure internal returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) pure internal returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) pure internal returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) pure internal returns (uint256) { return a < b ? a : b; } } /** * @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() 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)); owner = newOwner; } } /* * Haltable * * Abstract contract that allows children to implement an * emergency stop mechanism. Differs from Pausable by causing a throw when in halt mode. * * * Originally envisioned in FirstBlood ICO contract. */ contract Haltable is Ownable { bool public halted; modifier stopInEmergency { assert(!halted); _; } modifier onlyInEmergency { require(halted); _; } // called by the owner on emergency, triggers stopped state function halt() external onlyOwner { halted = true; } // called by the owner on end of emergency, returns to normal state function unhalt() external onlyOwner onlyInEmergency { halted = false; } } contract ForecasterReward is Haltable { using SafeMath for uint; /* the starting time of the crowdsale */ uint private startsAt; /* the ending time of the crowdsale */ uint private endsAt; /* How many wei of funding we have received so far */ uint private weiRaised = 0; /* How many distinct addresses have invested */ uint private investorCount = 0; /* How many total investments have been made */ uint private totalInvestments = 0; /* Address of pre-ico contract*/ address private multisig; /** How much ETH each address has invested to this crowdsale */ mapping (address => uint256) public investedAmountOf; /** State machine * * - Prefunding: We have not passed start time yet * - Funding: Active crowdsale * - Closed: Funding is closed. */ enum State{PreFunding, Funding, Closed} // A new investment was made event Invested(uint index, address indexed investor, uint weiAmount); // Funds transfer to other address event Transfer(address indexed receiver, uint weiAmount); // Crowdsale end time has been changed event EndsAtChanged(uint endTimestamp); function ForecasterReward() public { owner = 0xed4C73Ad76D90715d648797Acd29A8529ED511A0; multisig = 0x177B63c7CaF85A360074bcB095952Aa8E929aE03; startsAt = 1515600000; endsAt = 1516118400; } /** * Allow investor to just send in money */ function() nonZero payable public{ buy(msg.sender); } /** * Make an investment. * * Crowdsale must be running for one to invest. * We must have not pressed the emergency brake. * * @param receiver The Ethereum address who have invested * */ function buy(address receiver) stopInEmergency inState(State.Funding) nonZero public payable{ require(receiver != 0x00); uint weiAmount = msg.value; if(investedAmountOf[receiver] == 0) { // A new investor investorCount++; } // count all investments totalInvestments++; // Update investor investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount); // Up total accumulated fudns weiRaised = weiRaised.add(weiAmount); // Pocket the money if(!distributeFunds()) revert(); // Tell us invest was success Invested(totalInvestments, receiver, weiAmount); } /** * @return multisig Address of Multisig Wallet contract */ function multisigAddress() public constant returns(address){ return multisig; } /** * @return startDate Crowdsale opening date */ function fundingStartAt() public constant returns(uint ){ return startsAt; } /** * @return endDate Crowdsale closing date */ function fundingEndsAt() public constant returns(uint){ return endsAt; } /** * @return investors Total of distinct investors */ function distinctInvestors() public constant returns(uint){ return investorCount; } /** * @return investments Crowdsale closing date */ function investments() public constant returns(uint){ return totalInvestments; } /** * Send out contributions imediately */ function distributeFunds() private returns(bool){ Transfer(multisig,this.balance); if(!multisig.send(this.balance)){ return false; } return true; } /** * Allow crowdsale owner to close early or extend the crowdsale. * * This is useful e.g. for a manual soft cap implementation: * - after X amount is reached determine manual closing * * This may put the crowdsale to an invalid state, * but we trust owners know what they are doing. * */ function setEndsAt(uint _endsAt) public onlyOwner { // Don't change past require(_endsAt > now); endsAt = _endsAt; EndsAtChanged(_endsAt); } /** * @return total of amount of wie collected by the contract */ function fundingRaised() public constant returns (uint){ return weiRaised; } /** * Crowdfund state machine management. * * We make it a function and do not assign the result to a variable, so there is no chance of the variable being stale. */ function getState() public constant returns (State) { if (now < startsAt) return State.PreFunding; else if (now <= endsAt) return State.Funding; else if (now > endsAt) return State.Closed; } /** Interface marker. */ function isCrowdsale() public pure returns (bool) { return true; } // // Modifiers // /** Modifier allowing execution only if the crowdsale is currently running. */ modifier inState(State state) { require(getState() == state); _; } /** Modifier allowing execution only if received value is greater than zero */ modifier nonZero(){ require(msg.value > 0); _; } }
count all investments
totalInvestments++;
12,627,056
[ 1, 4625, 348, 7953, 560, 30, 225, 1056, 777, 2198, 395, 1346, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2078, 3605, 395, 1346, 9904, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/8453/0xEF153cb7bfc04c657Cb7f582C7411556320098B9/sources/contracts/farm/SynthChef.sol
Function to harvest many pools in a single transaction
function harvestMany(uint256[] calldata _pids) public nonReentrant { uint256 length = _pids.length; require(length <= 25, "harvest many: too many pool ids"); for (uint256 index = 0; index < length; ) { _deposit(_pids[index], 0); unchecked { ++index; } } }
11,558,364
[ 1, 4625, 348, 7953, 560, 30, 225, 4284, 358, 17895, 26923, 4906, 16000, 316, 279, 2202, 2492, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 17895, 26923, 5594, 12, 11890, 5034, 8526, 745, 892, 389, 84, 2232, 13, 1071, 1661, 426, 8230, 970, 288, 203, 3639, 2254, 5034, 769, 273, 389, 84, 2232, 18, 2469, 31, 203, 3639, 2583, 12, 2469, 1648, 6969, 16, 315, 30250, 26923, 4906, 30, 4885, 4906, 2845, 3258, 8863, 203, 3639, 364, 261, 11890, 5034, 770, 273, 374, 31, 770, 411, 769, 31, 262, 288, 203, 5411, 389, 323, 1724, 24899, 84, 2232, 63, 1615, 6487, 374, 1769, 203, 5411, 22893, 288, 203, 7734, 965, 1615, 31, 203, 5411, 289, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x191df0E31e38Ca0a3d9Aa8E1D5595D715B7FaCaC/sources/contracts/BorrowerOperations.sol
bools: coll increase, debt increase
uint newTCR = _getNewTCRFromTroveChange(msg.value, true, vars.compositeDebt, true, vars.price, targetPeg);
2,685,090
[ 1, 4625, 348, 7953, 560, 30, 225, 1426, 87, 30, 4508, 10929, 16, 18202, 88, 10929, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5411, 2254, 394, 56, 5093, 273, 389, 588, 1908, 56, 5093, 1265, 56, 303, 537, 3043, 12, 3576, 18, 1132, 16, 638, 16, 4153, 18, 27676, 758, 23602, 16, 638, 16, 4153, 18, 8694, 16, 1018, 52, 1332, 1769, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x27101367DAb5a3493d34195C1751BE0f559f4eFB/sources/SAD.sol
1,000,000,000,000,000
uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9;
4,431,791
[ 1, 4625, 348, 7953, 560, 30, 225, 404, 16, 3784, 16, 3784, 16, 3784, 16, 3784, 16, 3784, 7010, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 389, 1896, 4188, 6275, 273, 15088, 3784, 380, 1728, 636, 26, 380, 1728, 636, 29, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x7af62458e41E2F490D2Df54A8FeDc56fFedB8c17/sources/lib/solady/src/utils/RedBlackTreeLib.sol
@dev Removes the value at pointer `ptr` from the tree. Reverts if `ptr` is empty (i.e. value does not exist), or if `ptr` is out of bounds. After removal, `ptr` may point to another existing value. For safety, do not reuse `ptr` after calling remove on it.
function remove(bytes32 ptr) internal { uint256 err = tryRemove(ptr); if (err != 0) _revert(err); }
3,202,726
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 20284, 326, 460, 622, 4407, 1375, 6723, 68, 628, 326, 2151, 18, 868, 31537, 309, 1375, 6723, 68, 353, 1008, 261, 77, 18, 73, 18, 460, 1552, 486, 1005, 3631, 578, 309, 1375, 6723, 68, 353, 596, 434, 4972, 18, 7360, 14817, 16, 1375, 6723, 68, 2026, 1634, 358, 4042, 2062, 460, 18, 2457, 24179, 16, 741, 486, 11827, 1375, 6723, 68, 1839, 4440, 1206, 603, 518, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1206, 12, 3890, 1578, 6571, 13, 2713, 288, 203, 3639, 2254, 5034, 393, 273, 775, 3288, 12, 6723, 1769, 203, 3639, 309, 261, 370, 480, 374, 13, 389, 266, 1097, 12, 370, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity 0.4.24; import "solidity-bytes-utils/contracts/BytesLib.sol"; /// @title Extension to the BytesLib library. library BytesLibEx { using BytesLib for bytes; // Data sizes (in bytes). uint public constant UINT16_SIZE = 2; uint public constant UINT32_SIZE = 4; uint public constant UINT64_SIZE = 8; uint public constant UINT256_SIZE = 32; uint public constant BYTES20_SIZE = 20; /// @dev Converts a bytes array to byte20. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toBytes20(bytes memory _bytes, uint _start) internal pure returns (bytes20) { require(_bytes.length >= _start + BYTES20_SIZE, "Invalid length!"); bytes20 tempBytes20; // solhint-disable-next-line no-inline-assembly assembly { tempBytes20 := mload(add(add(_bytes, 32), _start)) } return tempBytes20; } /// @dev Converts a bytes array to a uint16. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint16(bytes memory _bytes, uint _start) internal pure returns (uint16) { return uint16(toUint(_bytes, _start, UINT16_SIZE)); } /// @dev Converts a bytes array to a uint32. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint32(bytes memory _bytes, uint _start) internal pure returns (uint32) { return uint32(toUint(_bytes, _start, UINT32_SIZE)); } /// @dev Converts a bytes array to a uint64. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint64(bytes memory _bytes, uint _start) internal pure returns (uint64) { return uint64(toUint(_bytes, _start, UINT64_SIZE)); } /// @dev Converts a big-endian bytes array to a uint16. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint16BE(bytes memory _bytes, uint _start) internal pure returns (uint16) { return uint16(toUintBE(_bytes, _start, UINT16_SIZE)); } /// @dev Converts a big-endian bytes array to a uint32. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint32BE(bytes memory _bytes, uint _start) internal pure returns (uint32) { return uint32(toUintBE(_bytes, _start, UINT32_SIZE)); } /// @dev Converts a big-endian bytes array to a uint64. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint64BE(bytes memory _bytes, uint _start) internal pure returns (uint64) { return uint64(toUintBE(_bytes, _start, UINT64_SIZE)); } /// @dev Converts a bytes array to a uint of specific size. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUintBE(bytes memory _bytes, uint _start) internal pure returns (uint) { return uint(toUintBE(_bytes, _start, UINT256_SIZE)); } /// @dev Converts a bytes array to a uint of specific size. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUint(bytes memory _bytes, uint _start, uint _size) private pure returns (uint) { require(_bytes.length >= _start + _size, "Invalid length!"); uint tempUint; // solhint-disable-next-line no-inline-assembly assembly { tempUint := mload(add(add(_bytes, _size), _start)) } return tempUint; } /// @dev Reverses the endianness of a given byte array. /// @param _bytes bytes The bytes to reverse. function switchEndianness(bytes memory _bytes) private pure returns (bytes) { bytes memory newBytes = new bytes(_bytes.length); for (uint i = 0; i < _bytes.length; ++i) { newBytes[_bytes.length - i - 1] = _bytes[i]; } return newBytes; } /// @dev Converts a big-endian bytes array to a uint of specific size. /// @param _bytes bytes The raw buffer. /// @param _start uint The offset to start from. function toUintBE(bytes memory _bytes, uint _start, uint _size) private pure returns (uint) { bytes memory newBytes = switchEndianness(_bytes.slice(_start, _size)); return toUint(newBytes, 0, _size); } }
@dev Converts a bytes array to a uint16. @param _bytes bytes The raw buffer. @param _start uint The offset to start from.
function toUint16(bytes memory _bytes, uint _start) internal pure returns (uint16) { return uint16(toUint(_bytes, _start, UINT16_SIZE)); }
12,601,149
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 20377, 279, 1731, 526, 358, 279, 2254, 2313, 18, 632, 891, 389, 3890, 1731, 1021, 1831, 1613, 18, 632, 891, 389, 1937, 2254, 1021, 1384, 358, 787, 628, 18, 2, 0, 0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 24899, 3890, 16, 389, 1937, 16, 27011, 2313, 67, 4574, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.15; import './vendored/openzeppelin/token/StandardToken.sol'; import './vendored/openzeppelin/ownership/Ownable.sol'; import './vendored/openzeppelin/ownership/HasNoTokens.sol'; import './MigrationAgent.sol'; /// @title Moeda Loyalty Points token contract contract MoedaToken is StandardToken, Ownable, HasNoTokens { string public constant name = "Moeda Loyalty Points"; string public constant symbol = "MDA"; uint8 public constant decimals = 18; // The migration agent is used to be to allow opt-in transfer of tokens to a // new token contract. This could be set sometime in the future if additional // functionality needs be added. MigrationAgent public migrationAgent; // used to ensure that a given address is an instance of a particular contract uint256 constant AGENT_MAGIC_ID = 0x6e538c0d750418aae4131a91e5a20363; uint256 public totalMigrated; uint constant TOKEN_MULTIPLIER = 10**uint256(decimals); // don't allow creation of more than this number of tokens uint public constant MAX_TOKENS = 20000000 * TOKEN_MULTIPLIER; // transfers are locked during minting bool public mintingFinished; // Log when tokens are migrated to a new contract event LogMigration(address indexed spender, address grantee, uint256 amount); event LogCreation(address indexed donor, uint256 tokensReceived); event LogDestruction(address indexed sender, uint256 amount); event LogMintingFinished(); modifier afterMinting() { require(mintingFinished); _; } modifier canTransfer(address recipient) { require(mintingFinished && recipient != address(0)); _; } modifier canMint() { require(!mintingFinished); _; } /// @dev Create moeda token and assign partner allocations function MoedaToken() { // manual distribution issueTokens(); } function issueTokens() internal { mint(0x2f37be861699b6127881693010596B4bDD146f5e, MAX_TOKENS); } /// @dev start a migration to a new contract /// @param agent address of contract handling migration function setMigrationAgent(address agent) external onlyOwner afterMinting { require(agent != address(0) && isContract(agent)); require(MigrationAgent(agent).MIGRATE_MAGIC_ID() == AGENT_MAGIC_ID); require(migrationAgent == address(0)); migrationAgent = MigrationAgent(agent); } function isContract(address addr) internal constant returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } /// @dev move a given amount of tokens a new contract (destroying them here) /// @param beneficiary address that will get tokens in new contract /// @param amount the number of tokens to migrate function migrate(address beneficiary, uint256 amount) external afterMinting { require(beneficiary != address(0)); require(migrationAgent != address(0)); require(amount > 0); // safemath subtraction will throw if balance < amount balances[msg.sender] = balances[msg.sender].sub(amount); totalSupply = totalSupply.sub(amount); totalMigrated = totalMigrated.add(amount); migrationAgent.migrateTo(beneficiary, amount); LogMigration(msg.sender, beneficiary, amount); } /// @dev destroy a given amount of tokens owned by sender // anyone that owns tokens can destroy them, reducing the total supply function burn(uint256 amount) external { require(amount > 0); balances[msg.sender] = balances[msg.sender].sub(amount); totalSupply = totalSupply.sub(amount); LogDestruction(msg.sender, amount); } /// @dev unlock transfers function unlock() external onlyOwner canMint { mintingFinished = true; LogMintingFinished(); } /// @dev create tokens, only usable before minting has ended /// @param recipient address that will receive the created tokens /// @param amount the number of tokens to create function mint(address recipient, uint256 amount) internal canMint { require(amount > 0); require(totalSupply.add(amount) <= MAX_TOKENS); balances[recipient] = balances[recipient].add(amount); totalSupply = totalSupply.add(amount); LogCreation(recipient, amount); } // only allowed after minting has ended // note: transfers to null address not allowed, use burn(value) function transfer(address to, uint _value) public canTransfer(to) returns (bool) { return super.transfer(to, _value); } // only allowed after minting has ended // note: transfers to null address not allowed, use burn(value) function transferFrom(address from, address to, uint value) public canTransfer(to) returns (bool) { return super.transferFrom(from, to, value); } }
@dev create tokens, only usable before minting has ended @param recipient address that will receive the created tokens @param amount the number of tokens to create
function mint(address recipient, uint256 amount) internal canMint { require(amount > 0); require(totalSupply.add(amount) <= MAX_TOKENS); balances[recipient] = balances[recipient].add(amount); totalSupply = totalSupply.add(amount); LogCreation(recipient, amount); }
5,538,001
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 752, 2430, 16, 1338, 15603, 1865, 312, 474, 310, 711, 16926, 632, 891, 8027, 1758, 716, 903, 6798, 326, 2522, 2430, 632, 891, 3844, 326, 1300, 434, 2430, 358, 752, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 312, 474, 12, 2867, 8027, 16, 2254, 5034, 3844, 13, 2713, 848, 49, 474, 288, 203, 565, 2583, 12, 8949, 405, 374, 1769, 203, 565, 2583, 12, 4963, 3088, 1283, 18, 1289, 12, 8949, 13, 1648, 4552, 67, 8412, 55, 1769, 203, 203, 565, 324, 26488, 63, 20367, 65, 273, 324, 26488, 63, 20367, 8009, 1289, 12, 8949, 1769, 203, 565, 2078, 3088, 1283, 273, 2078, 3088, 1283, 18, 1289, 12, 8949, 1769, 203, 203, 565, 1827, 9906, 12, 20367, 16, 3844, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x5DE8ab7E27f6E7A1fFf3E5B337584Aa43961BEeF/sources/contracts/SmardexToken/SmardexToken.sol
* @title SmardexToken (SDEX), ERC-20 token @notice Inherit from the ERC20Permit, allowing to sign approve off chain/
contract SmardexToken is ERC20Permit { pragma solidity 0.8.17; constructor(string memory _name, string memory _symbol, uint256 _supply) ERC20(_name, _symbol) ERC20Permit(_name) { _mint(msg.sender, _supply); } }
15,960,212
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 348,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 16351, 348, 3684, 561, 1345, 353, 4232, 39, 3462, 9123, 305, 288, 203, 683, 9454, 18035, 560, 374, 18, 28, 18, 4033, 31, 203, 565, 3885, 12, 1080, 3778, 389, 529, 16, 533, 3778, 389, 7175, 16, 2254, 5034, 389, 2859, 1283, 13, 4232, 39, 3462, 24899, 529, 16, 389, 7175, 13, 4232, 39, 3462, 9123, 305, 24899, 529, 13, 288, 203, 3639, 389, 81, 474, 12, 3576, 18, 15330, 16, 389, 2859, 1283, 1769, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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; /** * * * ooooooooooooo oooo oooo oooooooo .oooooo. 8&#39; 888 `8 `888 `888 dP""""""" d8P&#39; `Y8b 888 .ooooo. .ooooo. 888 .oo. ooo. .oo. .ooooo. 888 .ooooo. .oooooooo oooo ooo d88888b. 888 888 d88&#39; `88b d88&#39; `"Y8 888P"Y88b `888P"Y88b d88&#39; `88b 888 d88&#39; `88b 888&#39; `88b `88. .8&#39; `Y88b 888 888 888ooo888 888 888 888 888 888 888 888 888 888 888 888 888 `88..8&#39; ]88 888 ooooo 888 888 .o 888 .o8 888 888 888 888 888 888 888 888 888 `88bod8P&#39; `888&#39; o. .88P `88. .88&#39; o888o `Y8bod8P&#39; `Y8bod8P&#39; o888o o888o o888o o888o `Y8bod8P&#39; o888o `Y8bod8P&#39; `8oooooo. .8&#39; `8bd88P&#39; `Y8bood8P&#39; d" YD .o..P&#39; "Y88888P&#39; `Y8P&#39; * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn&#39;t hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title 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 { require(_value <= balances[msg.sender]); // 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 address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 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; 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); 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /* * Technology5G is a standard ERC20 token with some additional functionalities: * - Transfers are only enabled after contract owner enables it (after the ICO) * * Note: Token Offering == Initial Coin Offering(ICO) */ contract Technology5G is StandardToken, Ownable { string public constant symbol = "5G"; string public constant name = "Technology5G"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1250000000 * (10 ** uint256(decimals)); uint256 public constant TOKEN_OFFERING_ALLOWANCE = 937500000 * (10 ** uint256(decimals)); uint256 public constant ADMIN_ALLOWANCE = INITIAL_SUPPLY - TOKEN_OFFERING_ALLOWANCE; // Address of token admin address public adminAddr; // Address of token offering address public tokenOfferingAddr; // Enable transfers after conclusion of token offering bool public transferEnabled = false; /** * Check if transfer is allowed * * Permissions: * Owner Admin OffeirngContract Others * transfer (before transferEnabled is true) x x x x * transferFrom (before transferEnabled is true) x v v x * transfer/transferFrom after transferEnabled is true v x x v */ modifier onlyWhenTransferAllowed() { require(transferEnabled || msg.sender == adminAddr || msg.sender == tokenOfferingAddr); _; } /** * Check if token offering address is set or not */ modifier onlyTokenOfferingAddrNotSet() { require(tokenOfferingAddr == address(0x0)); _; } /** * Check if address is a valid destination to transfer tokens to * - must not be zero address * - must not be the token address * - must not be the owner&#39;s address * - must not be the admin&#39;s address * - must not be the token offering contract address */ modifier validDestination(address to) { require(to != address(0x0)); require(to != address(this)); require(to != owner); require(to != address(adminAddr)); require(to != address(tokenOfferingAddr)); _; } /** * Token contract constructor * * @param admin Address of admin account */ function Technology5G(address admin) public { totalSupply = INITIAL_SUPPLY; // Mint tokens balances[msg.sender] = totalSupply; Transfer(address(0x0), msg.sender, totalSupply); // Approve allowance for admin account adminAddr = admin; approve(adminAddr, ADMIN_ALLOWANCE); } /** * Set token offering to approve allowance for offering contract to distribute tokens * * @param offeringAddr Address of token offering contract * @param amountForSale Amount of tokens for sale, set 0 to max out */ function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner onlyTokenOfferingAddrNotSet { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TOKEN_OFFERING_ALLOWANCE : amountForSale; require(amount <= TOKEN_OFFERING_ALLOWANCE); approve(offeringAddr, amount); tokenOfferingAddr = offeringAddr; } /** * Enable transfers */ function enableTransfer() external onlyOwner { transferEnabled = true; // End the offering approve(tokenOfferingAddr, 0); } /** * Transfer from sender to another account * * @param to Destination address * @param value Amount of docks to send */ function transfer(address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transfer(to, value); } /** * Transfer from `from` account to `to` account using allowance in `from` account to the sender * * @param from Origin address * @param to Destination address * @param value Amount of docks to send */ function transferFrom(address from, address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transferFrom(from, to, value); } } contract Technology5GCrowdsale is Pausable { using SafeMath for uint256; // Token to be sold Technology5G public token; // Start and end timestamps where contributions are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // Address where funds are collected address public beneficiary; // Price of the tokens as in tokens per ether uint256 public rate; // Amount of raised in Wei uint256 public weiRaised; // Timelines for contribution limit policy uint256 public capReleaseTimestamp; uint256 public extraTime; // Whitelists of participant address mapping(address => bool) public whitelists; // Contributions in Wei for each participant mapping(address => uint256) public contributions; // Funding cap in ETH. uint256 public constant FUNDING_ETH_HARD_CAP = 15000 * 1 ether; // Min contribution is 0.1 ether uint256 public minContribution = 100**16; // Max contribution is 50 ether uint256 public maxContribution = 500**18; //remainCap uint256 public remainCap; // The current stage of the offering Stages public stage; enum Stages { Setup, OfferingStarted, OfferingEnded } event OfferingOpens(uint256 startTime, uint256 endTime); event OfferingCloses(uint256 endTime, uint256 totalWeiRaised); /** * Event for token purchase logging * * @param purchaser Who paid for the tokens * @param value Weis paid for purchase * @return amount Amount of tokens purchased */ event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount); /** * Modifier that requires certain stage before executing the main function body * * @param expectedStage Value that the current stage is required to match */ modifier atStage(Stages expectedStage) { require(stage == expectedStage); _; } /** * The constructor of the contract. * @param testToEtherRate Number of test per ether * @param beneficiaryAddr Address where funds are collected */ function Technology5GCrowdsale( uint256 testToEtherRate, address beneficiaryAddr, address tokenAddress ) public { require(testToEtherRate > 0); require(beneficiaryAddr != address(0)); require(tokenAddress != address(0)); token = Technology5G(tokenAddress); rate = testToEtherRate; beneficiary = beneficiaryAddr; stage = Stages.Setup; } /** * Fallback function can be used to buy tokens */ function () public payable { buy(); } /** * Withdraw available ethers into beneficiary account, serves as a safety, should never be needed */ function ownerSafeWithdrawal() external onlyOwner { beneficiary.transfer(this.balance); } function updateRate(uint256 bouToEtherRate) public onlyOwner atStage(Stages.Setup) { rate = bouToEtherRate; } /** * Whitelist participant address * * * @param users Array of addresses to be whitelisted */ function whitelist(address[] users) public onlyOwner { for (uint32 i = 0; i < users.length; i++) { whitelists[users[i]] = true; } } function whitelistRemove(address user) public onlyOwner{ require(whitelists[user]); whitelists[user] = false; } /** * Start the offering * * @param durationInSeconds Extra duration of the offering on top of the minimum 4 hours */ function startOffering(uint256 durationInSeconds) public onlyOwner atStage(Stages.Setup) { stage = Stages.OfferingStarted; startTime = now; capReleaseTimestamp = startTime + 5 hours; extraTime = capReleaseTimestamp + 7 days; endTime = extraTime.add(durationInSeconds); OfferingOpens(startTime, endTime); } /** * End the offering */ function endOffering() public onlyOwner atStage(Stages.OfferingStarted) { endOfferingImpl(); } /** * Function to invest ether to buy tokens, can be called directly or called by the fallback function * Only whitelisted users can buy tokens. * * @return bool Return true if purchase succeeds, false otherwise */ function buy() public payable whenNotPaused atStage(Stages.OfferingStarted) returns (bool) { if (whitelists[msg.sender]) { buyTokens(); return true; } revert(); } /** * Function that returns whether offering has ended * * @return bool Return true if token offering has ended */ function hasEnded() public view returns (bool) { return now > endTime || stage == Stages.OfferingEnded; } /** * Modifier that validates a purchase at a tier * All the following has to be met: * - current time within the offering period * - valid sender address and ether value greater than 0.1 * - total Wei raised not greater than FUNDING_ETH_HARD_CAP * - contribution per perticipant within contribution limit * * */ modifier validPurchase() { require(now >= startTime && now <= endTime && stage == Stages.OfferingStarted); if(now > capReleaseTimestamp) { maxContribution = 24000 * 1 ether; } uint256 contributionInWei = msg.value; address participant = msg.sender; require(contributionInWei <= maxContribution.sub(contributions[participant])); require(participant != address(0) && contributionInWei >= minContribution && contributionInWei <= maxContribution); require(weiRaised.add(contributionInWei) <= FUNDING_ETH_HARD_CAP); _; } function buyTokens() internal validPurchase { uint256 contributionInWei = msg.value; address participant = msg.sender; // Calculate token amount to be distributed uint256 tokens = contributionInWei.mul(rate); if (!token.transferFrom(token.owner(), participant, tokens)) { revert(); } weiRaised = weiRaised.add(contributionInWei); contributions[participant] = contributions[participant].add(contributionInWei); remainCap = FUNDING_ETH_HARD_CAP.sub(weiRaised); // Check if the funding cap has been reached, end the offering if so if (weiRaised >= FUNDING_ETH_HARD_CAP) { endOfferingImpl(); } // Transfer funds to beneficiary beneficiary.transfer(contributionInWei); TokenPurchase(msg.sender, contributionInWei, tokens); } /** * End token offering by set the stage and endTime */ function endOfferingImpl() internal { endTime = now; stage = Stages.OfferingEnded; OfferingCloses(endTime, weiRaised); } /** * Allocate tokens for presale participants before public offering, can only be executed at Stages.Setup stage. * * @param to Participant address to send docks to * @param tokens Amount of docks to be sent to parcitipant */ function allocateTokensBeforeOffering(address to, uint256 tokens) public onlyOwner atStage(Stages.Setup) returns (bool) { if (!token.transferFrom(token.owner(), to, tokens)) { revert(); } return true; } /** * Bulk version of allocateTokensBeforeOffering */ function batchAllocateTokensBeforeOffering(address[] toList, uint256[] tokensList) external onlyOwner atStage(Stages.Setup) returns (bool) { require(toList.length == tokensList.length); for (uint32 i = 0; i < toList.length; i++) { allocateTokensBeforeOffering(toList[i], tokensList[i]); } return true; } }
* Bulk version of allocateTokensBeforeOffering/
function batchAllocateTokensBeforeOffering(address[] toList, uint256[] tokensList) external onlyOwner atStage(Stages.Setup) returns (bool) { require(toList.length == tokensList.length); for (uint32 i = 0; i < toList.length; i++) { allocateTokensBeforeOffering(toList[i], tokensList[i]); } return true; }
6,798,479
[ 1, 4625, 348, 7953, 560, 30, 380, 18184, 1177, 434, 10101, 5157, 4649, 17800, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 2581, 27483, 5157, 4649, 17800, 12, 2867, 8526, 12277, 16, 2254, 5034, 8526, 2430, 682, 13, 3903, 1338, 5541, 225, 622, 8755, 12, 31359, 18, 7365, 13, 225, 1135, 261, 6430, 13, 225, 288, 203, 3639, 2583, 12, 869, 682, 18, 2469, 422, 2430, 682, 18, 2469, 1769, 203, 203, 3639, 364, 261, 11890, 1578, 277, 273, 374, 31, 277, 411, 12277, 18, 2469, 31, 277, 27245, 288, 203, 5411, 10101, 5157, 4649, 17800, 12, 869, 682, 63, 77, 6487, 2430, 682, 63, 77, 19226, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.8.0; // File: @openzeppelin/contracts/utils/Context.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 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; } } // File: @openzeppelin/contracts/introspection/IERC165.sol /** * @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/token/ERC721/IERC721.sol /** * @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/IERC721Metadata.sol /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol /** * @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/introspection/ERC165.sol /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File: @openzeppelin/contracts/math/SafeMath.sol /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts/utils/EnumerableMap.sol /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // File: @openzeppelin/contracts/utils/Strings.sol /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` 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); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // 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; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @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_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @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 _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @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 _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @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 || ERC721.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 _tokenOwners.contains(tokenId); } /** * @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 || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `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); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal 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); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @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()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @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 { } } // File: @openzeppelin/contracts/access/Ownable.sol /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/CryptoCopyCats.sol /** * @title CryptoCopyCats contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */ contract CryptoCopyCats is ERC721, Ownable { using SafeMath for uint256; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public maxToMint; uint256 public MAX_CRYPTO_COPY_CATS_SUPPLY; uint256 public REVEAL_TIMESTAMP; string private prerevealURI; string private specialTokenURI; string public PROVENANCE_HASH = ""; bool public saleIsActive; bool public whitelistActive; bytes32[] _rootHash; address wallet1; address wallet2; mapping(uint256 => uint256) private mintNumberToSpecialToken; mapping(uint256 => uint256) private replacedTokenNumber; mapping(address => uint256) public numberOfWhitelistMints; uint256 maxWhitelistMints; uint256 maxSpecialTokens; uint256 numberOfSpecialTokensMinted; uint256 public discountPrice; uint256 public fullPrice; constructor() ERC721("Crypto Copy Cats", "CCCATS") { MAX_CRYPTO_COPY_CATS_SUPPLY = 2510; REVEAL_TIMESTAMP = block.timestamp + 3 days; //block.timestamp + 3 days; specialTokenURI = "https://cryptocopycats.mypinata.cloud/ipfs/QmcP7jLdm6vEs5jFwvUkWUJRBwzcTW6wwtLtVCvvuS6uBT"; prerevealURI = "https://cryptocopycats.mypinata.cloud/ipfs/QmSe33Sr6E5oDoCLvzouaLzJ8y3wiFgevkRmTQnAnrwGcm"; discountPrice = 65000000000000000; // 0.065 Ether fullPrice = 75000000000000000; // 0.075 Ether numberOfSpecialTokensMinted = 0; maxSpecialTokens = 10; maxToMint = 4; maxWhitelistMints = 4; saleIsActive = false; whitelistActive = false; wallet1 = 0x6F10Cdb4901bA272dabbF7a6343A8FE43ec7d460; // ccc payout wallet wallet2 = 0xaf6e1747779744c1CE875A6463e28A5086084ae7; // byt payout wallet _rootHash = new bytes32[](2); _rootHash[0] = 0x435bffa06fdde9f30f2df9afc8937f180217f3a782ef6aa88f0c39326ed0f4b7; _rootHash[1] = 0x1736b74100da5d87fc309b6fb4e084dbd9d21a488951d37cab89c323ebbfb483; } function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function isTokenEthRedeemable(uint256 tokenId) external view returns(bool) { require(startingIndex > 0, "Tokens have not revealed yet"); if(mintNumberToSpecialToken[tokenId] > 0) { return true; } return false; } function uint2str(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; while (_i != 0) { k = k-1; uint8 temp = (48 + uint8(_i - _i / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; _i /= 10; } return string(bstr); } function updateRootHash(bytes32 rootHash) external onlyOwner { _rootHash[1] = rootHash; } /** * Set whitelist price to mint a Crypto Copy Cat. */ function setDiscountPrice(uint256 _price) external onlyOwner { discountPrice = _price; } /** * Set public price to mint a Crypto Copy Cat. */ function setFullPrice(uint256 _price) external onlyOwner { fullPrice = _price; } function getTotalWhitelistPrice(uint256 numberOfTokens) internal view returns(uint256) { uint256 ownedTokens = numberOfWhitelistMints[_msgSender()]; if (ownedTokens == 0) { return discountPrice.mul(numberOfTokens - 1); } else { return discountPrice.mul(numberOfTokens); } } /** * Set maximum count to mint per txn. */ function setMaxToMint(uint256 _maxValue) external onlyOwner { maxToMint = _maxValue; } /** * Mint Crypto Copy Cat by owner. */ function reserveCryptoCopyCat(address _to, uint256 _numberOfTokens) external onlyOwner { require(_to != address(0), "Invalid address to reserve."); uint256 supply = totalSupply(); uint256 i; //Mint address, 0 on first mint //Supply is 1 so mint tokenId = 1 (which is the 2nd token) for (i = 0; i < _numberOfTokens; i++) { _safeMint(_to, supply + i); } } /** * Set reveal timestamp when finished the sale. */ function setRevealTimestamp(uint256 _revealTimeStamp) external onlyOwner { REVEAL_TIMESTAMP = _revealTimeStamp; } function setBaseURI(string memory baseURI) external onlyOwner { _setBaseURI(baseURI); } /** * External function to set the prereveal URI for all token IDs. * This is the URI that is shown on each token until the REVEAL_TIMESTAMP * is surpassed. */ function setPrerevealURI(string memory prerevealURI_) external onlyOwner { prerevealURI = prerevealURI_; } /** * Returns the proper tokenURI only after the startingIndex is finalized. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if(startingIndex != 0 && block.timestamp >= REVEAL_TIMESTAMP) { string memory base = baseURI(); if (mintNumberToSpecialToken[tokenId] != 0) { return specialTokenURI; } else if (replacedTokenNumber[tokenId] != 0){ return string(abi.encodePacked(base, uint2str(replacedTokenNumber[tokenId]))); } else { string memory tokenURIWithOffset = uint2str(((tokenId + startingIndex) % MAX_CRYPTO_COPY_CATS_SUPPLY)); return string(abi.encodePacked(base, tokenURIWithOffset)); } } else { return prerevealURI; } } /* * Pause sale if active, make active if paused */ function setSaleState() external onlyOwner { saleIsActive = !saleIsActive; } /* * Pause whitelist if active, make active if paused */ function setWhitelistState() external onlyOwner { whitelistActive = !whitelistActive; } function isSpecialToken(uint256 tokenId) internal view returns (bool) { if(numberOfSpecialTokensMinted == maxSpecialTokens){ return false; } else if((maxSpecialTokens - numberOfSpecialTokensMinted) == (MAX_CRYPTO_COPY_CATS_SUPPLY - totalSupply())) { return true; } uint256 rando = random(string(abi.encodePacked(block.number, block.timestamp, _msgSender(), tokenId))); if ((rando % 2510) > 2496) { return true; } else { return false; } } /** * Mints tokens */ function mintCryptoCopyCat(uint256 numberOfTokens) external payable { require(saleIsActive, "Sale must be active to mint"); require(numberOfTokens <= maxToMint, "Invalid amount to mint per once"); require(totalSupply().add(numberOfTokens) <= MAX_CRYPTO_COPY_CATS_SUPPLY, "Purchase would exceed max supply"); require(fullPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct"); if (numberOfTokens > 1) { for(uint256 i = 0; i < numberOfTokens; i++) { uint256 tokenId = totalSupply(); if (isSpecialToken(tokenId)){ setSpecialToken(tokenId); } _safeMint(_msgSender(), tokenId); } } else { uint256 tokenId = totalSupply(); if (isSpecialToken(tokenId)){ setSpecialToken(tokenId); } _safeMint(_msgSender(), tokenId); } // If we haven't set the starting index and this is either // 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_CRYPTO_COPY_CATS_SUPPLY || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * Mints whitelisted tokens */ function whitelistMintCryptoCopyCat(uint256 numberOfTokens, uint256 spotInWhitelist, bytes32[] memory proof) external payable { require(whitelistActive, "The whitelist is not active yet"); require(totalSupply().add(numberOfTokens) <= MAX_CRYPTO_COPY_CATS_SUPPLY, "Purchase would exceed max supply"); require(numberOfTokens <= maxToMint, "Invalid amount to mint per once"); require(whitelistValidated(_msgSender(), spotInWhitelist, proof), "You're not on the whitelist"); require((numberOfWhitelistMints[_msgSender()] + numberOfTokens) <= maxWhitelistMints, "This transaction exceeds the max whitelist mints"); require(getTotalWhitelistPrice(numberOfTokens) == msg.value, "Ether value sent is not correct"); //Update numberOfWhitelistMints for the wallet numberOfWhitelistMints[_msgSender()] += numberOfTokens; if (numberOfTokens > 1) { for(uint256 i = 0; i < numberOfTokens; i++) { uint256 tokenId = totalSupply(); if (isSpecialToken(tokenId)){ setSpecialToken(tokenId); } _safeMint(_msgSender(), tokenId); } } else { uint256 tokenId = totalSupply(); if (isSpecialToken(tokenId)){ setSpecialToken(tokenId); } _safeMint(_msgSender(), tokenId); } } function setSpecialToken(uint256 tokenId) internal { uint256 specialTokenNumber = SafeMath.add(2500, numberOfSpecialTokensMinted); mintNumberToSpecialToken[tokenId] = specialTokenNumber; replacedTokenNumber[specialTokenNumber] = tokenId; numberOfSpecialTokensMinted++; } function whitelistValidated(address wallet, uint256 index, bytes32[] memory proof) internal view returns (bool) { uint256 amount = 1; // Compute the merkle root bytes32 node = keccak256(abi.encodePacked(index, wallet, amount)); uint256 path = index; for (uint16 i = 0; i < proof.length; i++) { if ((path & 0x01) == 1) { node = keccak256(abi.encodePacked(proof[i], node)); } else { node = keccak256(abi.encodePacked(node, proof[i])); } path /= 2; } // Check the merkle proof against the root hash array for(uint i = 0; i < _rootHash.length; i++) { if (node == _rootHash[i]) { return true; } } return false; } /** * Set the starting index for the collection */ function setStartingIndex() external { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint256(blockhash(startingIndexBlock)) % MAX_CRYPTO_COPY_CATS_SUPPLY; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint256(blockhash(block.number - 1)) % MAX_CRYPTO_COPY_CATS_SUPPLY; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() external onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } function withdraw() external onlyOwner { uint256 balance = address(this).balance; uint256 walletBalance = balance.mul(93).div(100); payable(wallet1).transfer(walletBalance); payable(wallet2).transfer(balance.sub(walletBalance)); } }
* @dev String operations./
library Strings { function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
1,102,257
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 514, 5295, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 12083, 8139, 288, 203, 203, 565, 445, 1762, 12, 11890, 5034, 460, 13, 2713, 16618, 1135, 261, 1080, 3778, 13, 288, 203, 203, 3639, 309, 261, 1132, 422, 374, 13, 288, 203, 5411, 327, 315, 20, 14432, 203, 3639, 289, 203, 3639, 2254, 5034, 1906, 273, 460, 31, 203, 3639, 2254, 5034, 6815, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 6815, 9904, 31, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 1731, 3778, 1613, 273, 394, 1731, 12, 16649, 1769, 203, 3639, 2254, 5034, 770, 273, 6815, 300, 404, 31, 203, 3639, 1906, 273, 460, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 1613, 63, 1615, 413, 65, 273, 1731, 21, 12, 11890, 28, 12, 8875, 397, 1906, 738, 1728, 10019, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 327, 533, 12, 4106, 1769, 203, 565, 289, 203, 203, 377, 203, 565, 445, 1762, 12, 11890, 5034, 460, 13, 2713, 16618, 1135, 261, 1080, 3778, 13, 288, 203, 203, 3639, 309, 261, 1132, 422, 374, 13, 288, 203, 5411, 327, 315, 20, 14432, 203, 3639, 289, 203, 3639, 2254, 5034, 1906, 273, 460, 31, 203, 3639, 2254, 5034, 6815, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 6815, 9904, 31, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 1731, 3778, 1613, 273, 394, 1731, 12, 16649, 1769, 203, 3639, 2254, 5034, 770, 273, 6815, 300, 404, 31, 203, 3639, 1906, 273, 460, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 1613, 63, 1615, 413, 65, 273, 1731, 21, 12, 11890, 28, 12, 8875, 397, 1906, 738, 1728, 10019, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 327, 533, 12, 4106, 1769, 203, 565, 289, 203, 203, 377, 203, 565, 445, 1762, 12, 11890, 5034, 460, 13, 2713, 16618, 1135, 261, 1080, 3778, 13, 288, 203, 203, 3639, 309, 261, 1132, 422, 374, 13, 288, 203, 5411, 327, 315, 20, 14432, 203, 3639, 289, 203, 3639, 2254, 5034, 1906, 273, 460, 31, 203, 3639, 2254, 5034, 6815, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 6815, 9904, 31, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 1731, 3778, 1613, 273, 394, 1731, 12, 16649, 1769, 203, 3639, 2254, 5034, 770, 273, 6815, 300, 404, 31, 203, 3639, 1906, 273, 460, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 1613, 63, 1615, 413, 65, 273, 1731, 21, 12, 11890, 28, 12, 8875, 397, 1906, 738, 1728, 10019, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 327, 533, 12, 4106, 1769, 203, 565, 289, 203, 203, 377, 203, 565, 445, 1762, 12, 11890, 5034, 460, 13, 2713, 16618, 1135, 261, 1080, 3778, 13, 288, 203, 203, 3639, 309, 261, 1132, 422, 374, 13, 288, 203, 5411, 327, 315, 20, 14432, 203, 3639, 289, 203, 3639, 2254, 5034, 1906, 273, 460, 31, 203, 3639, 2254, 5034, 6815, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 6815, 9904, 31, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 1731, 3778, 1613, 273, 394, 1731, 12, 16649, 1769, 203, 3639, 2254, 5034, 770, 273, 6815, 300, 404, 31, 203, 3639, 1906, 273, 460, 31, 203, 3639, 1323, 261, 5814, 480, 374, 13, 288, 203, 5411, 1613, 63, 1615, 413, 65, 273, 1731, 21, 12, 11890, 28, 12, 8875, 397, 1906, 738, 1728, 10019, 203, 5411, 1906, 9531, 1728, 31, 203, 3639, 289, 203, 3639, 327, 533, 12, 4106, 1769, 203, 565, 289, 203, 203, 377, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2020-10-12 */ // File: contracts/libraries/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } } // File: contracts/libraries/Math.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; // a library for performing various math operations library Math { function min(uint x, uint y) internal pure returns (uint z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x ; //inject UNINIT LOCAL/STATE VAR while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // File: contracts/interfaces/IERC20.sol pragma solidity >=0.5.0; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (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); } // File: contracts/interfaces/IHiposwapV1Callee.sol pragma solidity >=0.5.0; interface IHiposwapV1Callee { function hiposwapV1Call(address sender, uint amount0, uint amount1, bytes calldata data) external; } // File: contracts/interfaces/IHiposwapV2Pair.sol pragma solidity >=0.5.0; interface IHiposwapV2Pair { 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(uint reserve0, uint reserve1); event _Maker(address indexed sender, address token, uint amount, uint time); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function currentPoolId0() external view returns (uint); function currentPoolId1() external view returns (uint); function getMakerPool0(uint poolId) external view returns (uint _balance, uint _swapOut, uint _swapIn); function getMakerPool1(uint poolId) external view returns (uint _balance, uint _swapOut, uint _swapIn); function getReserves() external view returns (uint reserve0, uint reserve1); function getBalance() external view returns (uint _balance0, uint _balance1); function getMaker(address mkAddress) external view returns (uint,address,uint,uint); function getFees() external view returns (uint _fee0, uint _fee1); function getFeeAdmins() external view returns (uint _feeAdmin0, uint _feeAdmin1); function getAvgTimes() external view returns (uint _avgTime0, uint _avgTime1); function transferFeeAdmin(address to) external; function getFeePercents() external view returns (uint _feeAdminPercent, uint _feePercent, uint _totalPercent); function setFeePercents(uint _feeAdminPercent, uint _feePercent, uint _totalPercent) external; function getRemainPercent() external view returns (uint); function getTotalPercent() external view returns (uint); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function order(address to) external returns (address token, uint amount); function retrieve(uint amount0, uint amount1, address sender, address to) external returns (uint, uint); function getAmountA(address to, uint amountB) external view returns(uint amountA, uint _amountB, uint rewardsB, uint remainA); function getAmountB(address to, uint amountA) external view returns(uint _amountA, uint amountB, uint rewardsB, uint remainA); function initialize(address, address) external; } // File: openzeppelin-solidity/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT 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-solidity/contracts/access/Ownable.sol // SPDX-License-Identifier: MIT 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 ; //inject UNINIT LOCAL/STATE VAR _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/HiposwapV2Pair.sol pragma solidity =0.6.6; contract HiposwapV2Pair is IHiposwapV2Pair, Ownable { using SafeMath for uint; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public override factory; address public override token0; address public override token1; uint private fee0; uint private fee1; uint private feeAdmin0; uint private feeAdmin1; uint public totalWeightTime0; uint public totalWeightTime1; uint public totalTokens0; uint public totalTokens1; uint private avgTime0; uint private avgTime1; uint private reserve0; uint private reserve1; uint private feeAdminPercent ; //inject UNINIT LOCAL/STATE VAR uint private feePercent ; //inject UNINIT LOCAL/STATE VAR uint private totalPercent ; //inject UNINIT LOCAL/STATE VAR struct MakerPool { uint balance; // remain tokenA uint swapOut; // swapped tokenA uint swapIn; // received tokenB uint createTime; } MakerPool[] public makerPools0; MakerPool[] public makerPools1; uint public override currentPoolId0; uint public override currentPoolId1; struct Maker { uint poolId; address token; uint amount; uint time; } mapping(address => Maker) private makers; uint public constant MINIMUM_SWITCH_POOL_TIME = 30 minutes; uint private unlocked ; //inject UNINIT LOCAL/STATE VAR modifier lock() { require(unlocked == 1, 'HiposwapV2Pair: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public override view returns (uint _reserve0, uint _reserve1) { _reserve0 = reserve0; _reserve1 = reserve1; } function getFees() public override view returns (uint _fee0, uint _fee1) { _fee0 = fee0; _fee1 = fee1; } function getFeeAdmins() public override view returns (uint _feeAdmin0, uint _feeAdmin1) { _feeAdmin0 = feeAdmin0; _feeAdmin1 = feeAdmin1; } function getAvgTimes() public override view returns (uint _avgTime0, uint _avgTime1) { _avgTime0 = avgTime0; _avgTime1 = avgTime1; } function getFeePercents() public override view returns (uint _feeAdminPercent, uint _feePercent, uint _totalPercent) { _feeAdminPercent = feeAdminPercent; _feePercent = feePercent; _totalPercent = totalPercent; } function getRemainPercent() public override view returns (uint) { return totalPercent.sub(feeAdminPercent).sub(feePercent); } function getTotalPercent() external override view returns (uint) { return totalPercent; } function setFeePercents(uint _feeAdminPercent, uint _feePercent, uint _totalPercent) public override onlyOwner { require(_feeAdminPercent.add(_feePercent) < _totalPercent, "HiposwapV2Pair: INVALID_PARAM"); feeAdminPercent = _feeAdminPercent; feePercent = _feePercent; totalPercent = _totalPercent; } function getBalance() public override view returns (uint _balance0, uint _balance1) { _balance0 = IERC20(token0).balanceOf(address(this)); _balance1 = IERC20(token1).balanceOf(address(this)); } function getMaker(address mkAddress) public override view returns (uint,address,uint,uint) { Maker memory m = makers[mkAddress]; return (m.poolId, m.token, m.amount, m.time); } function getMakerPool0(uint poolId) public override view returns (uint _balance, uint _swapOut, uint _swapIn) { return _getMakerPool(true, poolId); } function getMakerPool1(uint poolId) public override view returns (uint _balance, uint _swapOut, uint _swapIn) { return _getMakerPool(false, poolId); } function _getMakerPool(bool left, uint poolId) private view returns (uint _balance, uint _swapOut, uint _swapIn) { MakerPool[] memory mps = left ? makerPools0 : makerPools1; if (mps.length > poolId) { MakerPool memory mp = mps[poolId]; return (mp.balance, mp.swapOut, mp.swapIn); } } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'HiposwapV2Pair: TRANSFER_FAILED'); } 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(uint reserve0, uint reserve1); event _Maker(address indexed sender, address token, uint amount, uint time); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external override { require(msg.sender == factory, 'HiposwapV2Pair: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } function checkMakerPool(bool left) private { MakerPool[] storage mps = left ? makerPools0 : makerPools1; uint currentPoolId ; //inject UNINIT LOCAL/STATE VAR if (mps.length > 0) { MakerPool storage mp = mps[currentPoolId]; if (mp.swapOut > mp.balance.mul(9) && now > mp.createTime.add(MINIMUM_SWITCH_POOL_TIME)) { mps.push(MakerPool(0, 0, 0, now)); if (left) { currentPoolId0 = currentPoolId0.add(1); mp.swapIn = mp.swapIn.add(fee1); fee1 = 0; totalWeightTime0 = 0; totalTokens0 = 0; avgTime0 = 0; } else { currentPoolId1 = currentPoolId1.add(1); mp.swapIn = mp.swapIn.add(fee0); fee0 = 0; totalWeightTime1 = 0; totalTokens1 = 0; avgTime1 = 0; } } } else { mps.push(MakerPool(0, 0, 0, now)); } } function addFee(bool left, uint fee, uint feeAdmin) private { if (left) { fee1 = fee1.add(fee); feeAdmin1 = feeAdmin1.add(feeAdmin); } else { fee0 = fee0.add(fee); feeAdmin0 = feeAdmin0.add(feeAdmin); } } function checkAvgTime(bool left, uint time) private view returns (bool isChargeFee) { if (left) { if(avgTime0 > 0){ isChargeFee = now < time.add(avgTime0); } } else { if(avgTime1 > 0){ isChargeFee = now < time.add(avgTime1); } } } function updateAvgTime(bool left, uint time, uint amount) private { if(amount > 0 && now > time) { uint weight ; //inject UNINIT LOCAL/STATE VAR if (left) { uint _totalWeightTime0 ; //inject UNINIT LOCAL/STATE VAR if (_totalWeightTime0 >= totalWeightTime0) { totalWeightTime0 = _totalWeightTime0; totalTokens0 = totalTokens0.add(amount); avgTime0 = totalWeightTime0 / totalTokens0; } else { // reset if overflow totalWeightTime0 = 0; totalTokens0 = 0; } } else { uint _totalWeightTime1 ; //inject UNINIT LOCAL/STATE VAR if (_totalWeightTime1 >= totalWeightTime1) { totalWeightTime1 = _totalWeightTime1; totalTokens1 = totalTokens1.add(amount); avgTime1 = totalWeightTime1 / totalTokens1; } else { // reset if overflow totalWeightTime1 = 0; totalTokens1 = 0; } } } } function transferFeeAdmin(address to) external override onlyOwner{ require(feeAdmin0 > 0 || feeAdmin1 > 0, "HiposwapV2Pair: EMPTY_ADMIN_FEES"); if (feeAdmin0 > 0) { _safeTransfer(token0, to, feeAdmin0); feeAdmin0 = 0; } if (feeAdmin1 > 0) { _safeTransfer(token1, to, feeAdmin1); feeAdmin1 = 0; } } function order(address to) external override lock returns (address token, uint amount){ uint amount0 ; //inject UNINIT LOCAL/STATE VAR uint amount1 ; //inject UNINIT LOCAL/STATE VAR require((amount0 > 0 && amount1 == 0) || (amount0 == 0 && amount1 > 0), "HiposwapV2Pair: INVALID_AMOUNT"); bool left ; //inject UNINIT LOCAL/STATE VAR checkMakerPool(left); Maker memory mk = makers[to]; if(mk.amount > 0) { require(mk.token == token0 || mk.token == token1, "HiposwapV2Pair: INVALID_TOKEN"); bool _left ; //inject UNINIT LOCAL/STATE VAR uint _currentPoolId ; //inject UNINIT LOCAL/STATE VAR require(_currentPoolId >= mk.poolId, "HiposwapV2Pair: INVALID_POOL_ID"); if(_currentPoolId > mk.poolId){ deal(to); mk.amount = 0; }else{ require(left == _left, "HiposwapV2Pair: ONLY_ONE_MAKER_ALLOWED"); } } uint currentPoolId ; //inject UNINIT LOCAL/STATE VAR amount = left ? amount0 : amount1; token = left ? token0 : token1; makers[to] = Maker(currentPoolId, token, mk.amount.add(amount), now); emit _Maker(to, token, amount, now); MakerPool storage mp = left ? makerPools0[currentPoolId] : makerPools1[currentPoolId]; mp.balance = mp.balance.add(amount); (reserve0, reserve1) = getBalance(); } function deal(address to) public { Maker storage mk = makers[to]; require(mk.token == token0 || mk.token == token1, "HiposwapV2Pair: INVALID_TOKEN"); bool left ; //inject UNINIT LOCAL/STATE VAR MakerPool storage mp = left ? makerPools0[mk.poolId] : makerPools1[mk.poolId]; (uint amountA, uint amountB) = (mk.amount, 0); if(mp.swapIn > 0 && mp.swapOut > 0){ amountB = Math.min(mk.amount.mul(mp.swapIn) / mp.swapOut, mp.swapIn); uint swapOut ; //inject UNINIT LOCAL/STATE VAR amountA = amountA.sub(swapOut); mp.swapIn = mp.swapIn.sub(amountB); mp.swapOut = mp.swapOut.sub(swapOut); } if (amountA > mp.balance) { // if swapOut, swapIn, balance = 3, 2, 0; mk.amount = 1; then amountB = 0, amountA = 1; uint dust ; //inject UNINIT LOCAL/STATE VAR addFee(!left, dust, 0); mp.swapOut = mp.swapOut.sub(dust); amountA = mp.balance; } mp.balance = mp.balance.sub(amountA); (uint amount0, uint amount1) = left ? (amountA, amountB) : (amountB, amountA); if(amount0 > 0){ _safeTransfer(token0, to, amount0); reserve0 = IERC20(token0).balanceOf(address(this)); } if(amount1 > 0){ _safeTransfer(token1, to, amount1); reserve1 = IERC20(token1).balanceOf(address(this)); } delete makers[to]; } function retrieve(uint amount0, uint amount1, address sender, address to) external override lock onlyOwner returns (uint, uint){ require(amount0 > 0 || amount1 > 0, "HiposwapV2Pair: INVALID_AMOUNT"); Maker storage mk = makers[sender]; require(mk.token == token0 || mk.token == token1, "HiposwapV2Pair: INVALID_TOKEN"); bool left ; //inject UNINIT LOCAL/STATE VAR MakerPool storage mp = left ? makerPools0[mk.poolId] : makerPools1[mk.poolId]; (uint amountA, uint amountB) = left ? (amount0, amount1) : (amount1, amount0); bool isChargeFee ; //inject UNINIT LOCAL/STATE VAR uint amountOrigin ; //inject UNINIT LOCAL/STATE VAR if (amountA > 0) { uint amountAMax ; //inject UNINIT LOCAL/STATE VAR uint remain ; //inject UNINIT LOCAL/STATE VAR amountAMax = isChargeFee ? amountAMax.mul(remain) / totalPercent : amountAMax; // 9985/10000 require(amountA <= amountAMax, "HiposwapV2Pair: INSUFFICIENT_AMOUNT"); if(isChargeFee){ uint fee ; // 10/9985 //inject UNINIT LOCAL/STATE VAR uint feeAdmin ; // = 5/9985 //inject UNINIT LOCAL/STATE VAR amountA = amountA.add(fee).add(feeAdmin); addFee(!left, fee, feeAdmin); } mk.amount = mk.amount.sub(amountA); mp.balance = mp.balance.sub(amountA); } if (amountB > 0) { require(mp.swapIn > 0 && mp.swapOut > 0, "HiposwapV2Pair: INSUFFICIENT_SWAP_BALANCE"); uint amountBMax ; //inject UNINIT LOCAL/STATE VAR amountBMax = isChargeFee ? amountBMax.mul(getRemainPercent()) / totalPercent : amountBMax; // 9985/10000 require(amountB <= amountBMax, "HiposwapV2Pair: INSUFFICIENT_SWAP_AMOUNT"); if(isChargeFee){ uint fee ; // 10/9985 //inject UNINIT LOCAL/STATE VAR uint feeAdmin ; // = 5/9985 //inject UNINIT LOCAL/STATE VAR amountB = amountB.add(fee).add(feeAdmin); addFee(left, fee, feeAdmin); }else if (mk.poolId == (left ? currentPoolId0 : currentPoolId1)) { uint rewards ; // 10/10000 //inject UNINIT LOCAL/STATE VAR if(left){ if (rewards > fee1) { rewards = fee1; } { uint _amount1 ; //inject UNINIT LOCAL/STATE VAR amount1 = _amount1.add(rewards); fee1 = fee1.sub(rewards); } }else{ if (rewards > fee0) { rewards = fee0; } {// avoid stack too deep uint _amount0 ; //inject UNINIT LOCAL/STATE VAR amount0 = _amount0.add(rewards); fee0 = fee0.sub(rewards); } } } uint _amountA ; //inject UNINIT LOCAL/STATE VAR mp.swapIn = mp.swapIn.sub(amountB); mk.amount = mk.amount.sub(_amountA); mp.swapOut = mp.swapOut.sub(_amountA); } updateAvgTime(left, mk.time, amountOrigin.sub(mk.amount)); if (mk.amount == 0) { delete makers[sender]; } if(amount0 > 0){ _safeTransfer(token0, to, amount0); reserve0 = IERC20(token0).balanceOf(address(this)); } if(amount1 > 0){ _safeTransfer(token1, to, amount1); reserve1 = IERC20(token1).balanceOf(address(this)); } return (amount0, amount1); } function getMakerAndPool(address to) private view returns (Maker memory mk, MakerPool memory mp){ mk = makers[to]; require(mk.token == token0 || mk.token == token1, "HiposwapV2Pair: INVALID_TOKEN"); bool left ; //inject UNINIT LOCAL/STATE VAR uint poolId ; //inject UNINIT LOCAL/STATE VAR uint currentPoolId ; //inject UNINIT LOCAL/STATE VAR require(poolId >= 0 && poolId <= currentPoolId, "HiposwapV2Pair: INVALID_POOL_ID"); mp = left ? makerPools0[poolId] : makerPools1[poolId]; } // amountB is exact function getAmountA(address to, uint amountB) external override view returns(uint amountA, uint _amountB, uint rewardsB, uint remainA){ (Maker memory mk, MakerPool memory mp) = getMakerAndPool(to); bool left ; //inject UNINIT LOCAL/STATE VAR uint currentPoolId ; //inject UNINIT LOCAL/STATE VAR bool isChargeFee ; //inject UNINIT LOCAL/STATE VAR uint remain ; //inject UNINIT LOCAL/STATE VAR if(amountB > 0){ if(mp.swapIn > 0 && mp.swapOut > 0){ uint mkAmount ; // 9985/10000 //inject UNINIT LOCAL/STATE VAR uint swapIn ; //inject UNINIT LOCAL/STATE VAR uint amountBMax ; //inject UNINIT LOCAL/STATE VAR uint amountAMax ; //inject UNINIT LOCAL/STATE VAR amountAMax = isChargeFee ? amountAMax.mul(totalPercent) / remain : amountAMax; mk.amount = mk.amount.sub(amountAMax); _amountB = amountBMax; if (!isChargeFee && mk.poolId == currentPoolId) { uint tmp ; // avoid stack too deep //inject UNINIT LOCAL/STATE VAR uint rewards ; //inject UNINIT LOCAL/STATE VAR if(left){ if (rewards > fee1) { rewards = fee1; } }else{ if (rewards > fee0) { rewards = fee0; } } rewardsB = rewards; } } } amountA = Math.min(mk.amount, mp.balance); remainA = mk.amount.sub(amountA); amountA = isChargeFee ? amountA.mul(remain) / totalPercent : amountA; } // amountA is exact function getAmountB(address to, uint amountA) external override view returns(uint _amountA, uint amountB, uint rewardsB, uint remainA){ (Maker memory mk, MakerPool memory mp) = getMakerAndPool(to); bool left ; //inject UNINIT LOCAL/STATE VAR uint currentPoolId ; //inject UNINIT LOCAL/STATE VAR bool isChargeFee ; //inject UNINIT LOCAL/STATE VAR uint remain ; //inject UNINIT LOCAL/STATE VAR if(amountA > 0){ uint mkAmount ; //inject UNINIT LOCAL/STATE VAR uint mpBalance ; //inject UNINIT LOCAL/STATE VAR _amountA = Math.min(Math.min(amountA, mkAmount), mpBalance); if (_amountA == mkAmount) { mk.amount = 0; } else { mk.amount = mk.amount.sub(isChargeFee ? _amountA.mul(totalPercent) / remain : _amountA); } } if(mp.swapIn > 0 && mp.swapOut > 0){ amountB = Math.min(mp.swapIn, mk.amount.mul(mp.swapIn) / mp.swapOut); mk.amount = mk.amount.sub(amountB.mul(mp.swapOut) / mp.swapIn); if (isChargeFee) { amountB = amountB.mul(remain) / totalPercent; } else if (mk.poolId == currentPoolId) { uint rewards ; //inject UNINIT LOCAL/STATE VAR if(left){ if (rewards > fee1) { rewards = fee1; } }else{ if (rewards > fee0) { rewards = fee0; } } rewardsB = rewards; } } remainA = mk.amount; } function _update(uint balance0, uint balance1) private { require(balance0 <= uint(-1) && balance1 <= uint(-1), 'HiposwapV2Pair: OVERFLOW'); reserve0 = balance0; reserve1 = balance1; emit Sync(reserve0, reserve1); } function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock { require(amount0Out > 0 || amount1Out > 0, 'HiposwapV2Pair: INSUFFICIENT_OUTPUT_AMOUNT'); (uint _reserve0, uint _reserve1) = getReserves(); // gas savings require(amount0Out <= _reserve0 && amount1Out <= _reserve1, 'HiposwapV2Pair: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 ; //inject UNINIT LOCAL/STATE VAR address _token1 ; //inject UNINIT LOCAL/STATE VAR require(to != _token0 && to != _token1, 'HiposwapV2Pair: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IHiposwapV1Callee(to).hiposwapV1Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint amount0In ; //inject UNINIT LOCAL/STATE VAR uint amount1In ; //inject UNINIT LOCAL/STATE VAR require(amount0In > 0 || amount1In > 0, 'HiposwapV2Pair: INSUFFICIENT_INPUT_AMOUNT'); if (amount0In > 0) { uint fee ; // = 10/10000 //inject UNINIT LOCAL/STATE VAR uint feeAdmin ; // = 5/10000 //inject UNINIT LOCAL/STATE VAR uint swapIn ; //inject UNINIT LOCAL/STATE VAR MakerPool storage mp = makerPools1[currentPoolId1]; mp.swapIn = mp.swapIn.add(swapIn); mp.swapOut = mp.swapOut.add(amount1Out); mp.balance = mp.balance.sub(amount1Out); addFee(false, fee, feeAdmin); } if (amount1In >0) { uint fee ; // = 10/10000 //inject UNINIT LOCAL/STATE VAR uint feeAdmin ; // = 5/10000 //inject UNINIT LOCAL/STATE VAR uint swapIn ; //inject UNINIT LOCAL/STATE VAR MakerPool storage mp = makerPools0[currentPoolId0]; mp.swapIn = mp.swapIn.add(swapIn); mp.swapOut = mp.swapOut.add(amount0Out); mp.balance = mp.balance.sub(amount0Out); addFee(true, fee, feeAdmin); } _update(balance0, balance1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } } // File: contracts/interfaces/IHiposwapV2Util.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.6; interface IHiposwapV2Util { function pairCreationCode() external returns (bytes memory bytecode); } // File: contracts/HiposwapV2Util.sol // SPDX-License-Identifier: MIT pragma solidity =0.6.6; contract HiposwapV2Util is IHiposwapV2Util { function pairCreationCode() external override returns (bytes memory bytecode){ bytecode = type(HiposwapV2Pair).creationCode; } }
inject UNINIT LOCAL/STATE VAR
uint rewards ;
1,803,020
[ 1, 4625, 348, 7953, 560, 30, 4590, 5019, 12919, 15234, 19, 7998, 8350, 203, 2, 0, 0, 0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100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x3e3F4f1064939EF53331c2D5f3b85ceDf0B772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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 13667, 310, 16936, 273, 1758, 12, 20, 92, 24, 37, 4488, 6675, 6162, 38, 9975, 3462, 7598, 2499, 2671, 9498, 39, 23, 69, 6334, 70, 26, 9036, 2163, 8749, 42, 1578, 39, 29, 41, 1769, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/80001/0xB17994E2aff6aB819FBCe861D1448407C6BE29f5/sources/interfaces/v1/ISwylClub.sol
@dev Emitted when a cleanUpClub transaction is made
event DeactivateMembersInTier(uint256 indexed clubId, uint256 totalWipedOffMembers);
5,624,783
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 512, 7948, 1347, 279, 26384, 2009, 373, 2492, 353, 7165, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 871, 1505, 10014, 6918, 382, 15671, 12, 11890, 5034, 8808, 927, 373, 548, 16, 2254, 5034, 2078, 59, 625, 329, 7210, 6918, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0xDda46bF18eeb3E06E2F12975A3A184e40581A72f/sources/_prb/math/src/ud60x18/Casting.sol
@notice Casts an UD60x18 number into uint40. @dev Requirements: - x must be less than or equal to `MAX_UINT40`.
function intoUint40(UD60x18 x) pure returns (uint40 result) { uint256 xUint = UD60x18.unwrap(x); if (xUint > MAX_UINT40) { revert PRBMath_UD60x18_IntoUint40_Overflow(x); } result = uint40(xUint); }
3,094,349
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 19782, 87, 392, 587, 40, 4848, 92, 2643, 1300, 1368, 2254, 7132, 18, 632, 5206, 29076, 30, 300, 619, 1297, 506, 5242, 2353, 578, 3959, 358, 1375, 6694, 67, 57, 3217, 7132, 8338, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 915, 1368, 5487, 7132, 12, 12587, 4848, 92, 2643, 619, 13, 16618, 1135, 261, 11890, 7132, 563, 13, 288, 203, 565, 2254, 5034, 619, 5487, 273, 587, 40, 4848, 92, 2643, 18, 318, 4113, 12, 92, 1769, 203, 565, 309, 261, 92, 5487, 405, 4552, 67, 57, 3217, 7132, 13, 288, 203, 3639, 15226, 11770, 38, 10477, 67, 12587, 4848, 92, 2643, 67, 5952, 5487, 7132, 67, 15526, 12, 92, 1769, 203, 565, 289, 203, 565, 563, 273, 2254, 7132, 12, 92, 5487, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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-10-04 */ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.12; library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; require(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { require(b > 0); uint c = a / b; require(a == b * c + a % b); return c; } function sub(uint a, uint b) internal pure returns (uint) { require(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint a, uint b) internal pure returns (uint) { return a >= b ? a : b; } function min256(uint a, uint b) internal pure returns (uint) { return a < b ? a : b; } } interface ISupplyController { function mint(address token, address owner, uint amount) external; } interface IADXToken { function transfer(address to, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function balanceOf(address spender) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function supplyController() external view returns (ISupplyController); } contract ADXLoyaltyPoolToken { using SafeMath for uint; // ERC20 stuff // Constants string public constant name = "AdEx Loyalty"; uint8 public constant decimals = 18; string public symbol = "ADX-LOYALTY"; // Mutable variables uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // EIP 2612 bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public nonces; // ERC20 events event Approval(address indexed owner, address indexed spender, uint amount); event Transfer(address indexed from, address indexed to, uint amount); function balanceOf(address owner) public view returns (uint balance) { //inject PUBLIC FUNC TO EXTERNAL return balances[owner]; } function transfer(address to, uint amount) public returns (bool success) { //inject PUBLIC FUNC TO EXTERNAL require(to != address(this), 'BAD_ADDRESS'); balances[msg.sender] = balances[msg.sender].sub(amount); balances[to] = balances[to].add(amount); emit Transfer(msg.sender, to, amount); return true; } function transferFrom(address from, address to, uint amount) public returns (bool success) { //inject PUBLIC FUNC TO EXTERNAL balances[from] = balances[from].sub(amount); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); balances[to] = balances[to].add(amount); emit Transfer(from, to, amount); return true; } function approve(address spender, uint amount) public returns (bool success) { //inject PUBLIC FUNC TO EXTERNAL allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function allowance(address owner, address spender) public view returns (uint remaining) { //inject PUBLIC FUNC TO EXTERNAL return allowed[owner][spender]; } // EIP 2612 function permit(address owner, address spender, uint amount, uint deadline, uint8 v, bytes32 r, bytes32 s) public { //inject PUBLIC FUNC TO EXTERNAL require(deadline >= block.timestamp, 'DEADLINE_EXPIRED'); bytes32 digest = keccak256(abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, amount, nonces[owner]++, deadline)) )); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'INVALID_SIGNATURE'); allowed[owner][spender] = amount; emit Approval(owner, spender, amount); } // Inner function innerMint(address owner, uint amount) internal { totalSupply = totalSupply.add(amount); balances[owner] = balances[owner].add(amount); // Because of https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md#transfer-1 emit Transfer(address(0), owner, amount); } function innerBurn(address owner, uint amount) internal { totalSupply = totalSupply.sub(amount); balances[owner] = balances[owner].sub(amount); emit Transfer(owner, address(0), amount); } // Pool functionality event LogSetGovernance(address indexed addr, bool hasGovt, uint time); event LogSetIncentive(uint incentive, uint time); IADXToken public ADXToken; uint public incentivePerTokenPerAnnum; uint public lastMintTime; uint public maxTotalADX; mapping (address => bool) public governance; constructor(IADXToken token, uint incentive, uint cap) public { ADXToken = token; incentivePerTokenPerAnnum = incentive; maxTotalADX = cap; governance[msg.sender] = true; lastMintTime = block.timestamp; // EIP 2612 uint chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256(bytes(name)), keccak256(bytes('1')), chainId, address(this) ) ); emit LogSetGovernance(msg.sender, true, block.timestamp); emit LogSetIncentive(incentive, block.timestamp); } // Governance functions function setGovernance(address addr, bool hasGovt) public { //inject PUBLIC FUNC TO EXTERNAL require(governance[msg.sender], 'NOT_GOVERNANCE'); governance[addr] = hasGovt; emit LogSetGovernance(addr, hasGovt, block.timestamp); } // This doesn't trigger a mint because otherwise we risk of being unable to setIncentive to 0 // if minting is impossible // It's the better tradeoff to make - and the issue of front-running mintIncnetive with setIncentive(0) can // be solved by timelocking the governance function setIncentive(uint newIncentive) public { //inject PUBLIC FUNC TO EXTERNAL require(governance[msg.sender], 'NOT_GOVERNANCE'); incentivePerTokenPerAnnum = newIncentive; lastMintTime = block.timestamp; emit LogSetIncentive(newIncentive, block.timestamp); } function setSymbol(string calldata newSymbol) external { require(governance[msg.sender], 'NOT_GOVERNANCE'); symbol = newSymbol; } function setMaxTotalADX(uint newMaxTotalADX) public { //inject PUBLIC FUNC TO EXTERNAL require(governance[msg.sender], 'NOT_GOVERNANCE'); maxTotalADX = newMaxTotalADX; } // Pool stuff // There are a few notable items in how minting works // 1) if ADX is sent to the LoyaltyPool in-between mints, it will calculate the incentive as if this amount // has been there the whole time since the last mint // 2) Compounding is happening when mint is called, so essentially when entities enter/leave/trigger it manually function toMint() public view returns (uint) { //inject PUBLIC FUNC TO EXTERNAL if (block.timestamp <= lastMintTime) return 0; uint totalADX = ADXToken.balanceOf(address(this)); return (block.timestamp - lastMintTime) .mul(totalADX) .mul(incentivePerTokenPerAnnum) .div(365 days * 10e17); } function shareValue() public view returns (uint) { //inject PUBLIC FUNC TO EXTERNAL if (totalSupply == 0) return 0; return ADXToken.balanceOf(address(this)) .add(this.toMint()) .mul(10e17) .div(totalSupply); } function mintIncentive() public { if (incentivePerTokenPerAnnum == 0) return; uint amountToMint = this.toMint(); if (amountToMint == 0) return; lastMintTime = block.timestamp; ADXToken.supplyController().mint(address(ADXToken), address(this), amountToMint); } function enter(uint256 amount) public { //inject PUBLIC FUNC TO EXTERNAL // Please note that minting has to be in the beginning so that we take it into account // when using ADXToken.balanceOf() // Minting makes an external call but it's to a trusted contract (ADXToken) mintIncentive(); uint totalADX = ADXToken.balanceOf(address(this)); require(totalADX.add(amount) <= maxTotalADX, 'REACHED_MAX_TOTAL_ADX'); // The totalADX == 0 check here should be redudnant; the only way to get totalSupply to a nonzero val is by adding ADX if (totalSupply == 0 || totalADX == 0) { innerMint(msg.sender, amount); } else { uint256 newShares = amount.mul(totalSupply).div(totalADX); innerMint(msg.sender, newShares); } require(ADXToken.transferFrom(msg.sender, address(this), amount)); } function leaveInner(uint256 shares) internal { uint256 totalADX = ADXToken.balanceOf(address(this)); uint256 adxAmount = shares.mul(totalADX).div(totalSupply); innerBurn(msg.sender, shares); require(ADXToken.transfer(msg.sender, adxAmount)); } function leave(uint256 shares) public { //inject PUBLIC FUNC TO EXTERNAL mintIncentive(); leaveInner(shares); } // Guarantees ADX can be taken out even if minting is failing function emergencyLeave(uint256 shares) public { //inject PUBLIC FUNC TO EXTERNAL leaveInner(shares); } }
inject PUBLIC FUNC TO EXTERNAL
function setGovernance(address addr, bool hasGovt) public {
2,519,496
[ 1, 4625, 348, 7953, 560, 30, 4590, 17187, 478, 21163, 8493, 5675, 11702, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 26770, 1643, 82, 1359, 12, 2867, 3091, 16, 1426, 711, 43, 1527, 88, 13, 1071, 288, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2022-04-01 */ // Sources flattened with hardhat v2.9.1 https://hardhat.org // File @openzeppelin/contracts/utils/[email protected] // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File @openzeppelin/contracts/utils/introspection/[email protected] // 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/token/ERC721/[email protected] // 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/[email protected] // 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/token/ERC721/extensions/[email protected] // 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/[email protected] // 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/utils/[email protected] // 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/introspection/[email protected] // 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 contracts/ERC721Opt.sol pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintToZeroAddress(); error MintToDeadAddress(); error MintZeroQuantity(); error OwnerIndexOutOfBounds(); error OwnerQueryForNonexistentToken(); error TokenIndexOutOfBounds(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error TransferToDeadAddress(); error UnableGetTokenOwnerByIndex(); error URIQueryForNonexistentToken(); /** * @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 1 (e.g. 1, 2, 3..). */ contract ERC721Opt is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; uint256 internal _nextTokenId = 1; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owners details // An empty struct value does not necessarily mean the token is unowned. See ownerOf implementation for details. mapping(uint256 => address) internal _owners; // Mapping owner address to balances 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; // Address to use for burned accounting address constant DEAD_ADDR = 0x000000000000000000000000000000000000dEaD; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { // Counter underflow is impossible as burned cannot be incremented // more than _nextTokenId - 1 times unchecked { return (_nextTokenId - 1) - balanceOf(DEAD_ADDR); } } /** * @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) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address owner) { if (!_exists(tokenId)) revert OwnerQueryForNonexistentToken(); unchecked { for (uint256 curr = tokenId;; curr--) { owner = _owners[curr]; if (owner != address(0)) { 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) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) revert ApprovalCallerNotOwnerNorApproved(); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { _transfer(from, to, tokenId); if (!_checkOnERC721Received(from, to, tokenId, _data)) revert TransferToNonERC721ReceiverImplementer(); } function _isApprovedOrOwner(address sender, uint256 tokenId) internal view virtual returns (bool) { address owner = ownerOf(tokenId); return (sender == owner || getApproved(tokenId) == sender || isApprovedForAll(owner, sender)); } /** * @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 virtual returns (bool) { return tokenId > 0 && tokenId < _nextTokenId && _owners[tokenId] != DEAD_ADDR; } function _mint(address to, uint256 quantity) internal virtual { _mint(to, quantity, '', false); } function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal virtual { uint256 startTokenId = _nextTokenId; if (to == address(0)) revert MintToZeroAddress(); if (to == DEAD_ADDR) revert MintToDeadAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance overflow if current value + quantity > 1.56e77 (2**256) - 1 // updatedIndex overflows if _nextTokenId + quantity > 1.56e77 (2**256) - 1 unchecked { _balances[to] += quantity; _owners[startTokenId] = to; uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { if (!_checkOnERC721Received(address(0), to, updatedIndex, _data)) revert TransferToNonERC721ReceiverImplementer(); } updatedIndex++; } _nextTokenId = 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 { address owner = ownerOf(tokenId); bool isApprovedOrOwner = (_msgSender() == owner || isApprovedForAll(owner, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (owner != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); if (to == DEAD_ADDR) revert TransferToDeadAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, owner); // Underflow of the sender's balance is impossible because we check for // owner above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; // If the owner 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 (_owners[nextTokenId] == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _nextTokenId) { _owners[nextTokenId] = owner; } } } 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); } /** * @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 = ownerOf(tokenId); _beforeTokenTransfers(owner, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, owner); // Underflow of the sender's balance is impossible because we check for // owner above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _balances[owner] -= 1; _balances[DEAD_ADDR] += 1; _owners[tokenId] = DEAD_ADDR; // If the owner 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 (_owners[nextTokenId] == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _nextTokenId) { _owners[nextTokenId] = owner; } } } emit Transfer(owner, address(0), tokenId); _afterTokenTransfers(owner, address(0), tokenId, 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 TransferToNonERC721ReceiverImplementer(); 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/extensions/ERC721OptOwnersExplicit.sol pragma solidity ^0.8.4; error AllOwnersHaveBeenSet(); error QuantityMustBeNonZero(); error NoTokensMintedYet(); abstract contract ERC721OptOwnersExplicit is ERC721Opt { uint256 public nextOwnerToExplicitlySet = 1; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { if (quantity == 0) revert QuantityMustBeNonZero(); if (_nextTokenId == 1) revert NoTokensMintedYet(); uint256 _nextOwnerToExplicitlySet = nextOwnerToExplicitlySet; if (_nextOwnerToExplicitlySet >= _nextTokenId) revert AllOwnersHaveBeenSet(); // Index underflow is impossible. // Counter or index overflow is incredibly unrealistic. unchecked { uint256 endIndex = _nextOwnerToExplicitlySet + quantity - 1; // Set the end index to be the last token index if (endIndex + 1 > _nextTokenId) { endIndex = _nextTokenId - 1; } for (uint256 i = _nextOwnerToExplicitlySet; i <= endIndex; i++) { if (_owners[i] == address(0) && _owners[i] != DEAD_ADDR) { address ownership = ownerOf(i); _owners[i] = ownership; } } nextOwnerToExplicitlySet = endIndex + 1; } } } // File contracts/extensions/ERC721OptBurnable.sol pragma solidity ^0.8.4; error BurnCallerNotOwnerNorApproved(); /** * @title ERC721Opt Burnable Token * @dev ERC721Opt Token that can be irreversibly burned (destroyed). */ abstract contract ERC721OptBurnable is ERC721Opt { /** * @dev Burns `tokenId`. See {ERC721Opt-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { if (!_isApprovedOrOwner(_msgSender(), tokenId)) revert BurnCallerNotOwnerNorApproved(); _burn(tokenId); } } // File contracts/extensions/ERC721OptBatchBurnable.sol pragma solidity ^0.8.4; /** * @title ERC721Opt Batch Burnable Token * @dev ERC721Opt Token that can be irreversibly batch burned (destroyed). */ abstract contract ERC721OptBatchBurnable is ERC721OptBurnable { /** * @dev Perform burn on a batch of tokens */ function batchBurn(uint16[] memory tokenIds) public virtual { for (uint16 i = 0; i < tokenIds.length; ++i) { if (!_isApprovedOrOwner(_msgSender(), tokenIds[i])) revert BurnCallerNotOwnerNorApproved(); _burn(tokenIds[i]); } } } // File contracts/extensions/ERC721OptBatchTransferable.sol pragma solidity ^0.8.4; /** * @title ERC721Opt Batch Transferable Token * @dev ERC721Opt Token that can be batch transfered */ abstract contract ERC721OptBatchTransferable is ERC721Opt { /** * @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, uint16[] tokenIds ); /** * @dev Perform transferFrom on a batch of tokens */ function batchTransferFrom( address from, address to, uint16[] memory tokenIds ) public virtual { for (uint16 i = 0; i < tokenIds.length; ++i) { if (!_isApprovedOrOwner(_msgSender(), tokenIds[i])) revert TransferCallerNotOwnerNorApproved(); transferFrom(from, to, tokenIds[i]); } emit TransferBatch(_msgSender(), from, to, tokenIds); } /** * @dev Perform safeTransferFrom on a batch of tokens */ function safeBatchTransferFrom( address from, address to, uint16[] memory tokenIds ) public virtual { safeBatchTransferFrom(from, to, tokenIds, ''); } /** * @dev Perform safeTransferFrom on a batch of tokens */ function safeBatchTransferFrom( address from, address to, uint16[] memory tokenIds, bytes memory _data ) public virtual { for (uint256 i = 0; i < tokenIds.length; ++i) { if (!_isApprovedOrOwner(_msgSender(), tokenIds[i])) revert TransferCallerNotOwnerNorApproved(); safeTransferFrom(from, to, tokenIds[i], _data); } emit TransferBatch(_msgSender(), from, to, tokenIds); } } // File contracts/OpenSea.sol pragma solidity ^0.8.4; contract OpenSeaOwnableDelegateProxy {} contract OpenSeaProxyRegistry { mapping(address => OpenSeaOwnableDelegateProxy) public proxies; } // File contracts/ApeSquadCharacterSheetNFT.sol pragma solidity ^0.8.4; error CharacterSheetTypeQueryForNonexistentToken(); error OnlyMintersCanMintCharacterSheets(); error InvalidPurchaseCharacterSheetTypeId(); error AllCharacterSheetsOfTypeMinted(); error NoCharacterSheetMintAmountProvided(); error InvalidUpdateCharacterSheetLengthsDontMatch(); error InvalidUpdateCharacterSheetTypeId(); contract ApeSquadCharacterSheetNFT is Ownable, ERC721Opt, ERC721OptOwnersExplicit, ERC721OptBatchBurnable, ERC721OptBatchTransferable { using Strings for uint256; struct CharacterSheetPurchase { uint16 characterSheetTypeId; uint16 amount; } struct CharacterSheetType { string name; uint16 maxCharacterSheets; uint16 minted; } /* Base URI for token URIs */ string public baseURI; /* OpenSea user account proxy */ address public openSeaProxyRegistryAddress; /* Minter addressess */ mapping(address => bool) public minters; CharacterSheetType[] public characterSheetTypes; /* mapping of each token id to characterSheet type */ mapping(uint256 => uint16) _tokenIdCharacterSheetTypes; /* mapping of each token id to rarity. 0 = common, 1 = rare, 2 = legendary */ mapping(uint256 => uint8) public characterSheetRarity; constructor(string memory name_, string memory symbol_, string memory _initialBaseURI, address _openSeaProxyRegistryAddress, address[] memory _minters) ERC721Opt(name_, symbol_) { baseURI = _initialBaseURI; openSeaProxyRegistryAddress = _openSeaProxyRegistryAddress; for (uint256 i; i < _minters.length; i++) { minters[_minters[i]] = true; } _addCharacterSheet("Alex", 250); _addCharacterSheet("Borg", 250); _addCharacterSheet("Dax", 250); _addCharacterSheet("Kanoa", 250); _addCharacterSheet("Kazz", 250); } /** * @dev Get characterSheetType count */ function characterSheetTypeCount() public view returns (uint256) { return characterSheetTypes.length; } /** * @dev Get characterSheets left for sale */ function characterSheetsLeft(uint16 characterSheetTypeId) public view returns (uint256) { return characterSheetTypes[characterSheetTypeId].maxCharacterSheets - characterSheetTypes[characterSheetTypeId].minted; } /** * @dev Get the characterSheet type for a specific tokenId */ function tokenCharacterSheetType(uint256 tokenId) public view returns (string memory) { if (!_exists(tokenId)) revert CharacterSheetTypeQueryForNonexistentToken(); return characterSheetTypes[_tokenIdCharacterSheetTypes[tokenId]].name; } /** * @dev Override to if default approved for OS proxy accounts or normal approval */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { // Whitelist OpenSea proxy contract for easy trading. OpenSeaProxyRegistry openSeaProxyRegistry = OpenSeaProxyRegistry( openSeaProxyRegistryAddress ); if (address(openSeaProxyRegistry.proxies(owner)) == operator) { return true; } return ERC721Opt.isApprovedForAll(owner, operator); } /** * @dev Override to change the baseURI used in tokenURI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } /** * @dev Override to change tokenURI format */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(_baseURI(), tokenId.toString(), '.json')) : ''; } /** * @dev Mint of specific characterSheet type to address. */ function mint(address to, CharacterSheetPurchase[] calldata characterSheetPurchases) public { if(!minters[msg.sender]) revert OnlyMintersCanMintCharacterSheets(); uint256 amountToMint; uint256 tokenId = _nextTokenId; for (uint16 i; i < characterSheetPurchases.length; i++) { CharacterSheetPurchase memory p = characterSheetPurchases[i]; if(p.characterSheetTypeId >= characterSheetTypes.length) revert InvalidPurchaseCharacterSheetTypeId(); if(p.amount > characterSheetsLeft(characterSheetPurchases[i].characterSheetTypeId)) revert AllCharacterSheetsOfTypeMinted(); characterSheetTypes[p.characterSheetTypeId].minted += p.amount; amountToMint += p.amount; for (uint16 j; j < p.amount; j++) { _tokenIdCharacterSheetTypes[tokenId++] = p.characterSheetTypeId; } } if(amountToMint == 0) revert NoCharacterSheetMintAmountProvided(); _safeMint(to, amountToMint, ''); } /** * @dev Mint of specific poster type to address. */ function mintType(address to, uint16 characterSheetTypeId, uint16 amount) public { if(!minters[msg.sender]) revert OnlyMintersCanMintCharacterSheets(); if(amount == 0) revert NoCharacterSheetMintAmountProvided(); uint256 tokenId = _nextTokenId; if(characterSheetTypeId >= characterSheetTypes.length) revert InvalidPurchaseCharacterSheetTypeId(); if(amount > characterSheetsLeft(characterSheetTypeId)) revert AllCharacterSheetsOfTypeMinted(); characterSheetTypes[characterSheetTypeId].minted += amount; for (uint16 i; i < amount; i++) { _tokenIdCharacterSheetTypes[tokenId++] = characterSheetTypeId; } _safeMint(to, amount, ''); } /** * @dev Set the base uri for token metadata */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; } /** * @dev Set minter status for addresses */ function setMinters(address[] calldata addresses, bool allowed) external onlyOwner { for(uint256 i; i < addresses.length; i++) { minters[addresses[i]] = allowed; } } /** * @dev Add new characterSheet */ function _addCharacterSheet(string memory name, uint16 maxCharacterSheets) internal { CharacterSheetType memory cs; cs.name = name; cs.maxCharacterSheets = maxCharacterSheets; characterSheetTypes.push(cs); } /** * @dev Add new characterSheet */ function addCharacterSheet(string calldata name, uint16 maxCharacterSheets) external onlyOwner { _addCharacterSheet(name, maxCharacterSheets); } /** * @dev Update characterSheet names */ function updateCharacterSheetNames(uint16[] calldata characterSheetTypeIds, string[] calldata names) external onlyOwner { if(characterSheetTypeIds.length != names.length) revert InvalidUpdateCharacterSheetLengthsDontMatch(); for (uint16 i; i < characterSheetTypeIds.length; i++) { if(characterSheetTypeIds[i] >= characterSheetTypes.length) revert InvalidUpdateCharacterSheetTypeId(); characterSheetTypes[characterSheetTypeIds[i]].name = names[i]; } } /** * @dev Update available characterSheets */ function updateMaxCharacterSheets(uint16[] calldata characterSheetTypeIds, uint16[] calldata maxCharacterSheets) external onlyOwner { if(characterSheetTypeIds.length != maxCharacterSheets.length) revert InvalidUpdateCharacterSheetLengthsDontMatch(); for (uint16 i; i < characterSheetTypeIds.length; i++) { if(characterSheetTypeIds[i] >= characterSheetTypes.length) revert InvalidUpdateCharacterSheetTypeId(); characterSheetTypes[characterSheetTypeIds[i]].maxCharacterSheets = maxCharacterSheets[i]; } } /** * @dev Upate Rarities on chain for future staking */ function updateRarities(uint8 rarity, uint256[] calldata tokenIds) external onlyOwner { if (rarity == 0) { for(uint256 i; i < tokenIds.length; i++) { if (tokenIds[i] >= _nextTokenId) continue; delete characterSheetRarity[tokenIds[i]]; } } else { for(uint256 i; i < tokenIds.length; i++) { if (tokenIds[i] >= _nextTokenId) continue; characterSheetRarity[tokenIds[i]] = rarity; } } } /** * @dev Force update all owners for better transfers */ function updateOwners(uint256 quantity) external onlyOwner { _setOwnersExplicit(quantity); } } // File contracts/ApeSquadPosterNFT.sol pragma solidity ^0.8.4; error PosterTypeQueryForNonexistentToken(); error OnlyMintersCanMintPosters(); error InvalidPurchasePosterTypeId(); error AllPostersOfTypeMinted(); error NoPosterMintAmountProvided(); error InvalidUpdatePosterLengthsDontMatch(); error InvalidUpdatePosterTypeId(); contract ApeSquadPosterNFT is Ownable, ERC721Opt, ERC721OptOwnersExplicit, ERC721OptBatchBurnable, ERC721OptBatchTransferable { using Strings for uint256; struct PosterPurchase { uint16 posterTypeId; uint16 amount; } struct PosterType { string name; uint16 maxPosters; uint16 minted; } /* Base URI for token URIs */ string public baseURI; /* OpenSea user account proxy */ address public openSeaProxyRegistryAddress; /* Minter addressess */ mapping(address => bool) public minters; PosterType[] public posterTypes; /* mapping of each token id to poster type */ mapping(uint256 => uint16) _tokenIdPosterTypes; /* mapping of each token id to rarity. 0 = common, 1 = rare, 2 = legendary */ mapping(uint256 => uint8) public posterRarity; constructor(string memory name_, string memory symbol_, string memory _initialBaseURI, address _openSeaProxyRegistryAddress, address[] memory _minters) ERC721Opt(name_, symbol_) { baseURI = _initialBaseURI; openSeaProxyRegistryAddress = _openSeaProxyRegistryAddress; for (uint256 i; i < _minters.length; i++) { minters[_minters[i]] = true; } _addPoster("Season 1", 1250); } /** * @dev Get posterType count */ function posterTypeCount() public view returns (uint256) { return posterTypes.length; } /** * @dev Get posters left for sale */ function postersLeft(uint16 posterTypeId) public view returns (uint256) { return posterTypes[posterTypeId].maxPosters - posterTypes[posterTypeId].minted; } /** * @dev Get the poster type for a specific tokenId */ function tokenPosterType(uint256 tokenId) public view returns (string memory) { if (!_exists(tokenId)) revert PosterTypeQueryForNonexistentToken(); return posterTypes[_tokenIdPosterTypes[tokenId]].name; } /** * @dev Override to if default approved for OS proxy accounts or normal approval */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { // Whitelist OpenSea proxy contract for easy trading. OpenSeaProxyRegistry openSeaProxyRegistry = OpenSeaProxyRegistry( openSeaProxyRegistryAddress ); if (address(openSeaProxyRegistry.proxies(owner)) == operator) { return true; } return ERC721Opt.isApprovedForAll(owner, operator); } /** * @dev Override to change the baseURI used in tokenURI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } /** * @dev Override to change tokenURI format */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(_baseURI(), tokenId.toString(), '.json')) : ''; } /** * @dev Mint of specific poster type to address. */ function mint(address to, PosterPurchase[] calldata posterPurchases) public { if(!minters[msg.sender]) revert OnlyMintersCanMintPosters(); uint256 amountToMint; uint256 tokenId = _nextTokenId; for (uint16 i; i < posterPurchases.length; i++) { PosterPurchase memory p = posterPurchases[i]; if(p.posterTypeId >= posterTypes.length) revert InvalidPurchasePosterTypeId(); if(p.amount > postersLeft(posterPurchases[i].posterTypeId)) revert AllPostersOfTypeMinted(); posterTypes[p.posterTypeId].minted += p.amount; amountToMint += p.amount; for (uint16 j; j < p.amount; j++) { _tokenIdPosterTypes[tokenId++] = p.posterTypeId; } } if(amountToMint == 0) revert NoPosterMintAmountProvided(); _safeMint(to, amountToMint, ''); } /** * @dev Mint of specific poster type to address. */ function mintType(address to, uint16 posterTypeId, uint16 amount) public { if(!minters[msg.sender]) revert OnlyMintersCanMintPosters(); if(amount == 0) revert NoPosterMintAmountProvided(); uint256 tokenId = _nextTokenId; if(posterTypeId >= posterTypes.length) revert InvalidPurchasePosterTypeId(); if(amount > postersLeft(posterTypeId)) revert AllPostersOfTypeMinted(); posterTypes[posterTypeId].minted += amount; for (uint16 i; i < amount; i++) { _tokenIdPosterTypes[tokenId++] = posterTypeId; } _safeMint(to, amount, ''); } /** * @dev Set the base uri for token metadata */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; } /** * @dev Set minter status for addresses */ function setMinters(address[] calldata addresses, bool allowed) external onlyOwner { for(uint256 i; i < addresses.length; i++) { minters[addresses[i]] = allowed; } } /** * @dev Add new poster */ function _addPoster(string memory name, uint16 maxPosters) internal { PosterType memory p; p.name = name; p.maxPosters = maxPosters; posterTypes.push(p); } /** * @dev Add new poster */ function addPoster(string calldata name, uint16 maxPosters) external onlyOwner { _addPoster(name, maxPosters); } /** * @dev Update poster names */ function updatePosterNames(uint16[] calldata posterTypeIds, string[] calldata names) external onlyOwner { if(posterTypeIds.length != names.length) revert InvalidUpdatePosterLengthsDontMatch(); for (uint16 i; i < posterTypeIds.length; i++) { if(posterTypeIds[i] >= posterTypes.length) revert InvalidUpdatePosterTypeId(); posterTypes[posterTypeIds[i]].name = names[i]; } } /** * @dev Update available posters */ function updateMaxPosters(uint16[] calldata posterTypeIds, uint16[] calldata maxPosters) external onlyOwner { if(posterTypeIds.length != maxPosters.length) revert InvalidUpdatePosterLengthsDontMatch(); for (uint16 i; i < posterTypeIds.length; i++) { if(posterTypeIds[i] >= posterTypes.length) revert InvalidUpdatePosterTypeId(); posterTypes[posterTypeIds[i]].maxPosters = maxPosters[i]; } } /** * @dev Upate Rarities on chain for future staking */ function updateRarities(uint8 rarity, uint256[] calldata tokenIds) external onlyOwner { if (rarity == 0) { for(uint256 i; i < tokenIds.length; i++) { if (tokenIds[i] >= _nextTokenId) continue; delete posterRarity[tokenIds[i]]; } } else { for(uint256 i; i < tokenIds.length; i++) { if (tokenIds[i] >= _nextTokenId) continue; posterRarity[tokenIds[i]] = rarity; } } } /** * @dev Force update all owners for better transfers */ function updateOwners(uint256 quantity) external onlyOwner { _setOwnersExplicit(quantity); } } // File contracts/ApeSquadMinter.sol pragma solidity ^0.8.0; contract ApeSquadMinter is Ownable { /* Character Sheet NFT contract */ ApeSquadCharacterSheetNFT characterSheetNFTContract; /* Poster NFT contract */ ApeSquadPosterNFT posterNFTContract; /* Is Sale Active */ bool public saleIsActive; /* silver cards reserved for marketing */ mapping(uint16 => uint16) public reservedCharacterSheets; /* posters reserved for marketing */ uint16 public reservedSeason1Posters = 2; /* Price for character sheets */ uint256 public characterSheetPrice = 0.08 ether; /* NFT Contracts that can get free poster */ address[] public freeSeason1PosterNftContracts; /* Mapping of claimed posters */ mapping(address => bool) public season1PosterClaimed; constructor( ApeSquadCharacterSheetNFT _characterSheetNFTContract, ApeSquadPosterNFT _posterNFTContract, address[] memory _freeSeason1PosterNftContracts ) { characterSheetNFTContract = _characterSheetNFTContract; posterNFTContract = _posterNFTContract; for (uint16 i; i < characterSheetNFTContract.characterSheetTypeCount(); i++) { reservedCharacterSheets[i] = 6; } freeSeason1PosterNftContracts = _freeSeason1PosterNftContracts; } function mint(ApeSquadCharacterSheetNFT.CharacterSheetPurchase[] calldata characterSheetPurchases, bool freeSeason1Poster) external payable { require(msg.sender == tx.origin, 'Only EOA'); require(saleIsActive, 'Regular sale is not active'); uint256 totalAmount; for (uint16 i; i < characterSheetPurchases.length; i++) { require( characterSheetPurchases[i].amount <= characterSheetNFTContract.characterSheetsLeft(characterSheetPurchases[i].characterSheetTypeId) - reservedCharacterSheets[characterSheetPurchases[i].characterSheetTypeId], 'Sold Out' ); totalAmount += characterSheetPurchases[i].amount; } if (freeSeason1Poster) { require(!season1PosterClaimed[msg.sender], 'Season 1 Poster already claimed'); bool valid = totalAmount > 0 || characterSheetNFTContract.balanceOf(msg.sender) > 0; if (totalAmount == 0 && characterSheetNFTContract.balanceOf(msg.sender) == 0) { for (uint256 i; i < freeSeason1PosterNftContracts.length; i++) { valid = valid || IERC721(freeSeason1PosterNftContracts[i]).balanceOf(msg.sender) > 0; if (valid) break; } } require(valid, 'Season 1 Poster requirements not met'); season1PosterClaimed[msg.sender] = true; } require( msg.value >= (totalAmount * characterSheetPrice), 'Ether value sent is not correct' ); if(totalAmount > 0) { characterSheetNFTContract.mint(msg.sender, characterSheetPurchases); } if (freeSeason1Poster) { posterNFTContract.mintType(msg.sender, 0, 1); } } function flipSaleState() external onlyOwner { saleIsActive = !saleIsActive; } function setReserves(uint16[] calldata _characterSheetTypeIds, uint16[] calldata _characterSheetAmounts, uint16 _season1PosterAmount) external onlyOwner { require( _characterSheetTypeIds.length == _characterSheetAmounts.length, 'Character Sheet Type Ids length should match Amounts length' ); for (uint16 i; i < _characterSheetTypeIds.length; i++) { require( _characterSheetTypeIds[i] < characterSheetNFTContract.characterSheetTypeCount(), 'Character Sheet Type Id should be with in range' ); reservedCharacterSheets[_characterSheetTypeIds[i]] = _characterSheetAmounts[i]; } reservedSeason1Posters = _season1PosterAmount; } function setFreeSeason1PosterNftContracts(address[] calldata _freeSeason1PosterNftContracts) external onlyOwner { freeSeason1PosterNftContracts = _freeSeason1PosterNftContracts; } function setPrice(uint256 _characterSheetPrice) external onlyOwner { characterSheetPrice = _characterSheetPrice; } function reserveMint(uint16[] calldata _characterSheetTypeIds, uint16[] calldata _characterSheetAmounts, uint16 season1Posters, address[] calldata to) external onlyOwner { require( _characterSheetTypeIds.length == _characterSheetAmounts.length, 'Character Sheet Type Ids length should match Amounts length' ); for (uint16 i; i < _characterSheetTypeIds.length; i++) { require( (_characterSheetAmounts[i] * to.length) <= reservedCharacterSheets[_characterSheetTypeIds[i]], 'Not enough reserve left for team' ); } require( (season1Posters * to.length) <= reservedSeason1Posters, 'Not enough reserve left for team' ); for (uint16 i = 0; i < to.length; i++) { for (uint16 j; j < _characterSheetTypeIds.length; j++) { characterSheetNFTContract.mintType(to[i], _characterSheetTypeIds[j], _characterSheetAmounts[j]); } if (season1Posters > 0 ) { posterNFTContract.mintType(to[i], 0, season1Posters); } } for (uint16 i; i < _characterSheetTypeIds.length; i++) { reservedCharacterSheets[_characterSheetTypeIds[i]] -= uint16(_characterSheetAmounts[i] * to.length); } reservedSeason1Posters -= uint16(season1Posters * to.length); } function withdraw() external onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } }
* @title ERC721Opt Batch Burnable Token @dev ERC721Opt Token that can be irreversibly batch burned (destroyed)./
abstract contract ERC721OptBatchBurnable is ERC721OptBurnable { function batchBurn(uint16[] memory tokenIds) public virtual { for (uint16 i = 0; i < tokenIds.length; ++i) { if (!_isApprovedOrOwner(_msgSender(), tokenIds[i])) revert BurnCallerNotOwnerNorApproved(); _burn(tokenIds[i]); } } function batchBurn(uint16[] memory tokenIds) public virtual { for (uint16 i = 0; i < tokenIds.length; ++i) { if (!_isApprovedOrOwner(_msgSender(), tokenIds[i])) revert BurnCallerNotOwnerNorApproved(); _burn(tokenIds[i]); } } }
2,328,146
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 4232, 39, 27, 5340, 6179, 5982, 605, 321, 429, 3155, 632, 5206, 4232, 39, 27, 5340, 6179, 3155, 716, 848, 506, 9482, 266, 2496, 24755, 2581, 18305, 329, 261, 11662, 329, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 17801, 6835, 4232, 39, 27, 5340, 6179, 4497, 38, 321, 429, 353, 4232, 39, 27, 5340, 6179, 38, 321, 429, 288, 203, 203, 565, 445, 2581, 38, 321, 12, 11890, 2313, 8526, 3778, 1147, 2673, 13, 1071, 5024, 288, 203, 3639, 364, 261, 11890, 2313, 277, 273, 374, 31, 277, 411, 1147, 2673, 18, 2469, 31, 965, 77, 13, 288, 203, 5411, 309, 16051, 67, 291, 31639, 1162, 5541, 24899, 3576, 12021, 9334, 1147, 2673, 63, 77, 22643, 15226, 605, 321, 11095, 1248, 5541, 50, 280, 31639, 5621, 203, 5411, 389, 70, 321, 12, 2316, 2673, 63, 77, 19226, 203, 3639, 289, 203, 565, 289, 203, 565, 445, 2581, 38, 321, 12, 11890, 2313, 8526, 3778, 1147, 2673, 13, 1071, 5024, 288, 203, 3639, 364, 261, 11890, 2313, 277, 273, 374, 31, 277, 411, 1147, 2673, 18, 2469, 31, 965, 77, 13, 288, 203, 5411, 309, 16051, 67, 291, 31639, 1162, 5541, 24899, 3576, 12021, 9334, 1147, 2673, 63, 77, 22643, 15226, 605, 321, 11095, 1248, 5541, 50, 280, 31639, 5621, 203, 5411, 389, 70, 321, 12, 2316, 2673, 63, 77, 19226, 203, 3639, 289, 203, 565, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x27C0376106dBd744FD817A5898735C89D180E3D2/sources/Funny.sol
* @dev Sets the value of the `decimals`. This value is immutable, it can only be set once during construction./
constructor () ERC20('Funny', unicode"FUN", _msgSender()) { _mint(_msgSender(), _totalSupply); }
16,015,522
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 11511, 326, 460, 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 39, 3462, 2668, 22783, 18538, 2187, 5252, 6, 42, 2124, 3113, 389, 3576, 12021, 10756, 288, 203, 3639, 389, 81, 474, 24899, 3576, 12021, 9334, 389, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// hevm: flattened sources of src/DssSpell.sol // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity =0.6.12 >=0.6.12 <0.7.0; // pragma experimental ABIEncoderV2; ////// lib/dss-exec-lib/src/CollateralOpts.sol /* pragma solidity ^0.6.12; */ struct CollateralOpts { bytes32 ilk; address gem; address join; address clip; address calc; address pip; bool isLiquidatable; bool isOSM; bool whitelistOSM; uint256 ilkDebtCeiling; uint256 minVaultAmount; uint256 maxLiquidationAmount; uint256 liquidationPenalty; uint256 ilkStabilityFee; uint256 startingPriceFactor; uint256 breakerTolerance; uint256 auctionDuration; uint256 permittedDrop; uint256 liquidationRatio; uint256 kprFlatReward; uint256 kprPctReward; } ////// lib/dss-exec-lib/src/DssExecLib.sol // // DssExecLib.sol -- MakerDAO Executive Spellcrafting Library // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // 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 3 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. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ /* // pragma experimental ABIEncoderV2; */ /* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface Initializable { function init(bytes32) external; } interface Authorizable { function rely(address) external; function deny(address) external; } interface Fileable { function file(bytes32, address) external; function file(bytes32, uint256) external; function file(bytes32, bytes32, uint256) external; function file(bytes32, bytes32, address) external; } interface Drippable { function drip() external returns (uint256); function drip(bytes32) external returns (uint256); } interface Pricing { function poke(bytes32) external; } interface ERC20 { function decimals() external returns (uint8); } interface DssVat { function hope(address) external; function nope(address) external; function ilks(bytes32) external returns (uint256 Art, uint256 rate, uint256 spot, uint256 line, uint256 dust); function Line() external view returns (uint256); function suck(address, address, uint) external; } interface ClipLike { function vat() external returns (address); function dog() external returns (address); function spotter() external view returns (address); function calc() external view returns (address); function ilk() external returns (bytes32); } interface JoinLike { function vat() external returns (address); function ilk() external returns (bytes32); function gem() external returns (address); function dec() external returns (uint256); function join(address, uint) external; function exit(address, uint) external; } // Includes Median and OSM functions interface OracleLike_2 { function src() external view returns (address); function lift(address[] calldata) external; function drop(address[] calldata) external; function setBar(uint256) external; function kiss(address) external; function diss(address) external; function kiss(address[] calldata) external; function diss(address[] calldata) external; function orb0() external view returns (address); function orb1() external view returns (address); } interface MomLike { function setOsm(bytes32, address) external; function setPriceTolerance(address, uint256) external; } interface RegistryLike { function add(address) external; function xlip(bytes32) external view returns (address); } // https://github.com/makerdao/dss-chain-log interface ChainlogLike_1 { function setVersion(string calldata) external; function setIPFS(string calldata) external; function setSha256sum(string calldata) external; function getAddress(bytes32) external view returns (address); function setAddress(bytes32, address) external; function removeAddress(bytes32) external; } interface IAMLike { function ilks(bytes32) external view returns (uint256,uint256,uint48,uint48,uint48); function setIlk(bytes32,uint256,uint256,uint256) external; function remIlk(bytes32) external; function exec(bytes32) external returns (uint256); } interface LerpFactoryLike { function newLerp(bytes32 name_, address target_, bytes32 what_, uint256 startTime_, uint256 start_, uint256 end_, uint256 duration_) external returns (address); function newIlkLerp(bytes32 name_, address target_, bytes32 ilk_, bytes32 what_, uint256 startTime_, uint256 start_, uint256 end_, uint256 duration_) external returns (address); } interface LerpLike { function tick() external; } library DssExecLib { /* WARNING The following library code acts as an interface to the actual DssExecLib library, which can be found in its own deployed contract. Only trust the actual library's implementation. */ address constant public LOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; uint256 constant internal WAD = 10 ** 18; uint256 constant internal RAY = 10 ** 27; uint256 constant internal RAD = 10 ** 45; uint256 constant internal THOUSAND = 10 ** 3; uint256 constant internal MILLION = 10 ** 6; uint256 constant internal BPS_ONE_PCT = 100; uint256 constant internal BPS_ONE_HUNDRED_PCT = 100 * BPS_ONE_PCT; uint256 constant internal RATES_ONE_HUNDRED_PCT = 1000000021979553151239153027; function add(uint256 x, uint256 y) internal pure returns (uint256 z) {} function dai() public view returns (address) { return getChangelogAddress("MCD_DAI"); } function vat() public view returns (address) { return getChangelogAddress("MCD_VAT"); } function vow() public view returns (address) { return getChangelogAddress("MCD_VOW"); } function end() public view returns (address) { return getChangelogAddress("MCD_END"); } function reg() public view returns (address) { return getChangelogAddress("ILK_REGISTRY"); } function daiJoin() public view returns (address) { return getChangelogAddress("MCD_JOIN_DAI"); } function lerpFab() public view returns (address) { return getChangelogAddress("LERP_FAB"); } function clip(bytes32 _ilk) public view returns (address _clip) {} function flip(bytes32 _ilk) public view returns (address _flip) {} function calc(bytes32 _ilk) public view returns (address _calc) {} function getChangelogAddress(bytes32 _key) public view returns (address) {} function setChangelogAddress(bytes32 _key, address _val) public {} function setChangelogVersion(string memory _version) public {} function authorize(address _base, address _ward) public {} function canCast(uint40 _ts, bool _officeHours) public pure returns (bool) {} function nextCastTime(uint40 _eta, uint40 _ts, bool _officeHours) public pure returns (uint256 castTime) {} function setValue(address _base, bytes32 _what, uint256 _amt) public {} function setValue(address _base, bytes32 _ilk, bytes32 _what, uint256 _amt) public {} function increaseGlobalDebtCeiling(uint256 _amount) public {} function increaseIlkDebtCeiling(bytes32 _ilk, uint256 _amount, bool _global) public {} function sendPaymentFromSurplusBuffer(address _target, uint256 _amount) public {} function linearInterpolation(bytes32 _name, address _target, bytes32 _ilk, bytes32 _what, uint256 _startTime, uint256 _start, uint256 _end, uint256 _duration) public returns (address) {} } ////// lib/dss-exec-lib/src/DssAction.sol // // DssAction.sol -- DSS Executive Spell Actions // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // 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 3 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. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ /* import { DssExecLib } from "./DssExecLib.sol"; */ /* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface OracleLike_1 { function src() external view returns (address); } abstract contract DssAction { using DssExecLib for *; // Modifier used to limit execution time when office hours is enabled modifier limited { require(DssExecLib.canCast(uint40(block.timestamp), officeHours()), "Outside office hours"); _; } // Office Hours defaults to true by default. // To disable office hours, override this function and // return false in the inherited action. function officeHours() public virtual returns (bool) { return true; } // DssExec calls execute. We limit this function subject to officeHours modifier. function execute() external limited { actions(); } // DssAction developer must override `actions()` and place all actions to be called inside. // The DssExec function will call this subject to the officeHours limiter // By keeping this function public we allow simulations of `execute()` on the actions outside of the cast time. function actions() public virtual; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://<executive-vote-canonical-post> -q -O - 2>/dev/null)" function description() external virtual view returns (string memory); // Returns the next available cast time function nextCastTime(uint256 eta) external returns (uint256 castTime) { require(eta <= uint40(-1)); castTime = DssExecLib.nextCastTime(uint40(eta), uint40(block.timestamp), officeHours()); } } ////// lib/dss-exec-lib/src/DssExec.sol // // DssExec.sol -- MakerDAO Executive Spell Template // // Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. // // 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 3 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. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity ^0.6.12; */ interface PauseAbstract { function delay() external view returns (uint256); function plot(address, bytes32, bytes calldata, uint256) external; function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory); } interface Changelog { function getAddress(bytes32) external view returns (address); } interface SpellAction { function officeHours() external view returns (bool); function description() external view returns (string memory); function nextCastTime(uint256) external view returns (uint256); } contract DssExec { Changelog constant public log = Changelog(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F); uint256 public eta; bytes public sig; bool public done; bytes32 immutable public tag; address immutable public action; uint256 immutable public expiration; PauseAbstract immutable public pause; // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://<executive-vote-canonical-post> -q -O - 2>/dev/null)" function description() external view returns (string memory) { return SpellAction(action).description(); } function officeHours() external view returns (bool) { return SpellAction(action).officeHours(); } function nextCastTime() external view returns (uint256 castTime) { return SpellAction(action).nextCastTime(eta); } // @param _description A string description of the spell // @param _expiration The timestamp this spell will expire. (Ex. now + 30 days) // @param _spellAction The address of the spell action constructor(uint256 _expiration, address _spellAction) public { pause = PauseAbstract(log.getAddress("MCD_PAUSE")); expiration = _expiration; action = _spellAction; sig = abi.encodeWithSignature("execute()"); bytes32 _tag; // Required for assembly access address _action = _spellAction; // Required for assembly access assembly { _tag := extcodehash(_action) } tag = _tag; } function schedule() public { require(now <= expiration, "This contract has expired"); require(eta == 0, "This spell has already been scheduled"); eta = now + PauseAbstract(pause).delay(); pause.plot(action, tag, sig, eta); } function cast() public { require(!done, "spell-already-cast"); done = true; pause.exec(action, tag, sig, eta); } } ////// src/DssSpell.sol // Copyright (C) 2021 Dai Foundation // // 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 3 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. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /* pragma solidity 0.6.12; */ /* import "dss-exec-lib/DssExec.sol"; */ /* import "dss-exec-lib/DssAction.sol"; */ interface ChainlogLike_2 { function removeAddress(bytes32) external; } interface DssVestLike_1 { function create(address, uint256, uint256, uint256, uint256, address) external returns (uint256); function file(bytes32, uint256) external; function restrict(uint256) external; } contract DssSpellAction is DssAction { // Provides a descriptive tag for bot consumption // This should be modified weekly to provide a summary of the actions // Hash: seth keccak -- "$(wget https://raw.githubusercontent.com/makerdao/community/6410a8f1f720099f7ba6553c84b9f9d966a3d319/governance/votes/Executive%20vote%20-%20September%203%2C%202021.md -q -O - 2>/dev/null)" string public constant override description = "2021-09-03 MakerDAO Executive Spell | Hash: 0xaa8b302da5c9a3f4bfd45685fd04398d3d35af1b4c1cbdfe83f166a6455de0ea"; address constant MCD_VEST_DAI = 0x2Cc583c0AaCDaC9e23CB601fDA8F1A0c56Cdcb71; address constant MCD_VEST_MKR = 0x0fC8D4f2151453ca0cA56f07359049c8f07997Bd; // Com Core Unit address constant COM_WALLET = 0x1eE3ECa7aEF17D1e74eD7C447CcBA61aC76aDbA9; // Dai Foundation Core Unit address constant DAIF_WALLET = 0x34D8d61050Ef9D2B48Ab00e6dc8A8CA6581c5d63; // Dai Foundation Core Unit (Emergency Fund) address constant DAIF_EF_WALLET = 0x5F5c328732c9E52DfCb81067b8bA56459b33921f; // GovAlpha Core Unit address constant GOV_WALLET = 0x01D26f8c5cC009868A4BF66E268c17B057fF7A73; // Growth Core Unit address constant GRO_WALLET = 0x7800C137A645c07132886539217ce192b9F0528e; // Marketing Content Production Core Unit address constant MKT_WALLET = 0xDCAF2C84e1154c8DdD3203880e5db965bfF09B60; // Oracles Core Unit address constant ORA_WALLET = 0x2d09B7b95f3F312ba6dDfB77bA6971786c5b50Cf; // Protocol Engineering address constant PE_WALLET = 0xe2c16c308b843eD02B09156388Cb240cEd58C01c; // Risk Core Unit address constant RISK_WALLET = 0xd98ef20520048a35EdA9A202137847A62120d2d9; // Real-World Finance Core Unit address constant RWF_WALLET = 0x9e1585d9CA64243CE43D42f7dD7333190F66Ca09; // Ses Core Unit address constant SES_WALLET = 0x87AcDD9208f73bFc9207e1f6F0fDE906bcA95cc6; uint256 constant MAY_01_2021 = 1619827200; uint256 constant JUN_21_2021 = 1624233600; uint256 constant JUL_01_2021 = 1625097600; uint256 constant SEP_01_2021 = 1630454400; uint256 constant SEP_13_2021 = 1631491200; uint256 constant SEP_20_2021 = 1632096000; uint256 constant OCT_01_2021 = 1633046400; uint256 constant NOV_01_2021 = 1635724800; uint256 constant JAN_01_2022 = 1640995200; uint256 constant MAY_01_2022 = 1651363200; uint256 constant JUL_01_2022 = 1656633600; uint256 constant SEP_01_2022 = 1661990400; uint256 constant MILLION = 10 ** 6; uint256 constant WAD = 10 ** 18; // Turn off office hours function officeHours() public override returns (bool) { return false; } function actions() public override { // Fix PAX keys DssExecLib.setChangelogAddress("PAX", DssExecLib.getChangelogAddress("PAXUSD")); DssExecLib.setChangelogAddress("PIP_PAX", DssExecLib.getChangelogAddress("PIP_PAXUSD")); ChainlogLike_2(DssExecLib.LOG).removeAddress("PIP_PSM_PAX"); // Set unique payments DssExecLib.sendPaymentFromSurplusBuffer(DAIF_EF_WALLET, 2_000_000); DssExecLib.sendPaymentFromSurplusBuffer(DAIF_WALLET, 138_591); DssExecLib.sendPaymentFromSurplusBuffer(SES_WALLET, 155_237); // Setup both DssVest modules DssExecLib.authorize(DssExecLib.vat(), MCD_VEST_DAI); DssExecLib.authorize(DssExecLib.getChangelogAddress("GOV_GUARD"), MCD_VEST_MKR); DssVestLike_1(MCD_VEST_DAI).file("cap", 1 * MILLION * WAD / 30 days); DssVestLike_1(MCD_VEST_MKR).file("cap", 1_100 * WAD / 365 days); DssExecLib.setChangelogAddress("MCD_VEST_DAI", MCD_VEST_DAI); DssExecLib.setChangelogAddress("MCD_VEST_MKR", MCD_VEST_MKR); // DssVestLike(VEST).restrict( Only recipient can request funds // DssVestLike(VEST).create( // Recipient of vest, // Total token amount of vest over period, // Start timestamp of vest, // Duration of the vesting period (in seconds), // Length of cliff period (in seconds), // Manager address // ) // ); // Set DAI stream payments DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( COM_WALLET, 122_700.00 * 10**18, SEP_01_2021, JAN_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( DAIF_WALLET, 492_971.00 * 10**18, OCT_01_2021, SEP_01_2022 - OCT_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( GOV_WALLET, 123_333.00 * 10**18, SEP_01_2021, OCT_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( GRO_WALLET, 300_050.00 * 10**18, SEP_01_2021, NOV_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( MKT_WALLET, 103_134.00 * 10**18, SEP_01_2021, NOV_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( ORA_WALLET, 4_196_771.00 * 10**18, SEP_01_2021, JUL_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( PE_WALLET, 4_080_000.00 * 10**18, SEP_01_2021, MAY_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( RISK_WALLET, 2_184_000.00 * 10**18, SEP_01_2021, SEP_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( RWF_WALLET, 620_000.00 * 10**18, SEP_01_2021, JAN_01_2022 - SEP_01_2021, 0, address(0)) ); // Growth MKR whole team vesting DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(GRO_WALLET, 803.18 * 10**18, JUL_01_2021, 365 days, 365 days, address(0)) ); // Oracles MKR whole team vesting DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(ORA_WALLET, 1_051.25 * 10**18, JUL_01_2021, 365 days, 365 days, address(0)) ); // PE MKR vestings (per individual) ( DssVestLike_1(MCD_VEST_MKR).create(0xfDB9F5e045D7326C1da87d0e199a05CDE5378EdD, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0xBe4De3E151D52668c2C0610C985b4297833239C8, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x58EA3C96a8b81abC01EB78B98deCe2AD1e5fd7fc, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0xBAB4Cd1cB31Cd28f842335973712a6015eB0EcD5, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xB5c86aff90944CFB3184902482799bD5fA3B18dD, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x780f478856ebE01e46d9A432e8776bAAB5A81b5b, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x34364E234b3DD02FF5c8A2ad9ba86bbD3D3D3284, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x46E5DBad3966453Af57e90Ec2f3548a0e98ec979, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x18CaE82909C31b60Fe0A9656D76406345C9cb9FB, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0x301dD8eB831ddb93F128C33b9d9DC333210d9B25, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xBFC47D0D7452a25b7d3AA4d7379c69A891bD5d43, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xcD16aa978A89Aa26b3121Fc8dd32228d7D0fcF4a, 995.00 * 10**18, SEP_13_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x3189cfe40CF011AAb13aDD8aE7284deD4CD30602, 995.00 * 10**18, JUN_21_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x29b37159C09a65af6a7CFb062998B169879442B6, 995.00 * 10**18, SEP_20_2021, 4 * 365 days, 365 days, PE_WALLET) ); // Increase PAX-PSM-A DC from 50 million DAI to 500 million DAI DssExecLib.increaseIlkDebtCeiling("PSM-PAX-A", 450 * MILLION, true); // Decrease Flash Mint Fee (toll) from 0.05% to 0% DssExecLib.setValue(DssExecLib.getChangelogAddress("MCD_FLASH"), "toll", 0); // Bump changelog version DssExecLib.setChangelogVersion("1.9.5"); } } contract DssSpell is DssExec { constructor() DssExec(block.timestamp + 30 days, address(new DssSpellAction())) public {} }
Fix PAX keys Set unique payments Setup both DssVest modules DssVestLike(VEST).restrict( Only recipient can request funds DssVestLike(VEST).create( Recipient of vest, Total token amount of vest over period, Start timestamp of vest, Duration of the vesting period (in seconds), Length of cliff period (in seconds), Manager address ) ); Set DAI stream payments Growth MKR whole team vesting Oracles MKR whole team vesting PE MKR vestings (per individual) Increase PAX-PSM-A DC from 50 million DAI to 500 million DAI Decrease Flash Mint Fee (toll) from 0.05% to 0% Bump changelog version
function actions() public override { DssExecLib.setChangelogAddress("PAX", DssExecLib.getChangelogAddress("PAXUSD")); DssExecLib.setChangelogAddress("PIP_PAX", DssExecLib.getChangelogAddress("PIP_PAXUSD")); ChainlogLike_2(DssExecLib.LOG).removeAddress("PIP_PSM_PAX"); DssExecLib.sendPaymentFromSurplusBuffer(DAIF_EF_WALLET, 2_000_000); DssExecLib.sendPaymentFromSurplusBuffer(DAIF_WALLET, 138_591); DssExecLib.sendPaymentFromSurplusBuffer(SES_WALLET, 155_237); DssExecLib.authorize(DssExecLib.vat(), MCD_VEST_DAI); DssExecLib.authorize(DssExecLib.getChangelogAddress("GOV_GUARD"), MCD_VEST_MKR); DssVestLike_1(MCD_VEST_DAI).file("cap", 1 * MILLION * WAD / 30 days); DssVestLike_1(MCD_VEST_MKR).file("cap", 1_100 * WAD / 365 days); DssExecLib.setChangelogAddress("MCD_VEST_DAI", MCD_VEST_DAI); DssExecLib.setChangelogAddress("MCD_VEST_MKR", MCD_VEST_MKR); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( COM_WALLET, 122_700.00 * 10**18, SEP_01_2021, JAN_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( DAIF_WALLET, 492_971.00 * 10**18, OCT_01_2021, SEP_01_2022 - OCT_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( GOV_WALLET, 123_333.00 * 10**18, SEP_01_2021, OCT_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( GRO_WALLET, 300_050.00 * 10**18, SEP_01_2021, NOV_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( MKT_WALLET, 103_134.00 * 10**18, SEP_01_2021, NOV_01_2021 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( ORA_WALLET, 4_196_771.00 * 10**18, SEP_01_2021, JUL_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( PE_WALLET, 4_080_000.00 * 10**18, SEP_01_2021, MAY_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( RISK_WALLET, 2_184_000.00 * 10**18, SEP_01_2021, SEP_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_DAI).restrict( DssVestLike_1(MCD_VEST_DAI).create( RWF_WALLET, 620_000.00 * 10**18, SEP_01_2021, JAN_01_2022 - SEP_01_2021, 0, address(0)) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(GRO_WALLET, 803.18 * 10**18, JUL_01_2021, 365 days, 365 days, address(0)) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(ORA_WALLET, 1_051.25 * 10**18, JUL_01_2021, 365 days, 365 days, address(0)) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xfDB9F5e045D7326C1da87d0e199a05CDE5378EdD, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0xBe4De3E151D52668c2C0610C985b4297833239C8, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x58EA3C96a8b81abC01EB78B98deCe2AD1e5fd7fc, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0xBAB4Cd1cB31Cd28f842335973712a6015eB0EcD5, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xB5c86aff90944CFB3184902482799bD5fA3B18dD, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x780f478856ebE01e46d9A432e8776bAAB5A81b5b, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x34364E234b3DD02FF5c8A2ad9ba86bbD3D3D3284, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x46E5DBad3966453Af57e90Ec2f3548a0e98ec979, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x18CaE82909C31b60Fe0A9656D76406345C9cb9FB, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0x301dD8eB831ddb93F128C33b9d9DC333210d9B25, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xBFC47D0D7452a25b7d3AA4d7379c69A891bD5d43, 995.00 * 10**18, MAY_01_2021, 4 * 365 days, 365 days, PE_WALLET) ); ( DssVestLike_1(MCD_VEST_MKR).create(0xcD16aa978A89Aa26b3121Fc8dd32228d7D0fcF4a, 995.00 * 10**18, SEP_13_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x3189cfe40CF011AAb13aDD8aE7284deD4CD30602, 995.00 * 10**18, JUN_21_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssVestLike_1(MCD_VEST_MKR).restrict( DssVestLike_1(MCD_VEST_MKR).create(0x29b37159C09a65af6a7CFb062998B169879442B6, 995.00 * 10**18, SEP_20_2021, 4 * 365 days, 365 days, PE_WALLET) ); DssExecLib.increaseIlkDebtCeiling("PSM-PAX-A", 450 * MILLION, true); DssExecLib.setValue(DssExecLib.getChangelogAddress("MCD_FLASH"), "toll", 0); DssExecLib.setChangelogVersion("1.9.5"); }
6,914,502
[ 1, 4625, 348, 7953, 560, 30, 225, 12139, 453, 2501, 1311, 1000, 3089, 25754, 10939, 3937, 463, 1049, 58, 395, 4381, 463, 1049, 58, 395, 8804, 12, 3412, 882, 2934, 30604, 12, 5098, 8027, 848, 590, 284, 19156, 377, 463, 1049, 58, 395, 8804, 12, 3412, 882, 2934, 2640, 12, 540, 23550, 434, 331, 395, 16, 540, 10710, 1147, 3844, 434, 331, 395, 1879, 3879, 16, 540, 3603, 2858, 434, 331, 395, 16, 540, 4822, 434, 326, 331, 10100, 3879, 261, 267, 3974, 3631, 540, 11311, 434, 927, 3048, 3879, 261, 267, 3974, 3631, 540, 8558, 1758, 377, 262, 11272, 1000, 463, 18194, 1407, 25754, 611, 492, 451, 490, 47, 54, 7339, 5927, 331, 10100, 531, 354, 9558, 490, 47, 54, 7339, 5927, 331, 10100, 16628, 490, 47, 54, 331, 395, 899, 261, 457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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 4209, 1435, 1071, 3849, 288, 203, 3639, 463, 1049, 1905, 5664, 18, 542, 782, 539, 12970, 1887, 2932, 28228, 3113, 463, 1049, 1905, 5664, 18, 588, 782, 539, 12970, 1887, 2932, 28228, 3378, 40, 7923, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 542, 782, 539, 12970, 1887, 2932, 1102, 52, 67, 28228, 3113, 463, 1049, 1905, 5664, 18, 588, 782, 539, 12970, 1887, 2932, 1102, 52, 67, 28228, 3378, 40, 7923, 1769, 203, 3639, 7824, 1330, 8804, 67, 22, 12, 40, 1049, 1905, 5664, 18, 4842, 2934, 4479, 1887, 2932, 1102, 52, 67, 5857, 49, 67, 28228, 8863, 203, 203, 3639, 463, 1049, 1905, 5664, 18, 4661, 6032, 1265, 7719, 10103, 1892, 12, 9793, 5501, 67, 26897, 67, 59, 1013, 15146, 16, 576, 67, 3784, 67, 3784, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 4661, 6032, 1265, 7719, 10103, 1892, 12, 9793, 5501, 67, 59, 1013, 15146, 16, 1377, 5958, 28, 67, 6162, 21, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 4661, 6032, 1265, 7719, 10103, 1892, 12, 1090, 55, 67, 59, 1013, 15146, 16, 4202, 404, 2539, 67, 4366, 27, 1769, 203, 203, 3639, 463, 1049, 1905, 5664, 18, 22488, 12, 40, 1049, 1905, 5664, 18, 25012, 9334, 490, 10160, 67, 3412, 882, 67, 9793, 45, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 22488, 12, 40, 1049, 1905, 5664, 18, 588, 782, 539, 12970, 1887, 2932, 16387, 58, 67, 30673, 8085, 6, 3631, 490, 10160, 67, 3412, 882, 67, 49, 47, 54, 1769, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 768, 2932, 5909, 3113, 404, 380, 490, 15125, 1146, 380, 678, 1880, 342, 5196, 4681, 1769, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 49, 47, 54, 2934, 768, 2932, 5909, 3113, 404, 67, 6625, 380, 678, 1880, 342, 21382, 4681, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 542, 782, 539, 12970, 1887, 2932, 49, 10160, 67, 3412, 882, 67, 9793, 45, 3113, 490, 10160, 67, 3412, 882, 67, 9793, 45, 1769, 203, 3639, 463, 1049, 1905, 5664, 18, 542, 782, 539, 12970, 1887, 2932, 49, 10160, 67, 3412, 882, 67, 49, 47, 54, 3113, 490, 10160, 67, 3412, 882, 67, 49, 47, 54, 1769, 203, 203, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 27573, 5423, 67, 59, 1013, 15146, 16, 282, 31501, 67, 26874, 18, 713, 380, 1728, 636, 2643, 16, 3174, 52, 67, 1611, 67, 18212, 21, 16, 804, 1258, 67, 1611, 67, 18212, 22, 300, 3174, 52, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 1171, 9079, 463, 37, 5501, 67, 59, 1013, 15146, 16, 282, 1059, 9975, 67, 10580, 21, 18, 713, 380, 1728, 636, 2643, 16, 531, 1268, 67, 1611, 67, 18212, 21, 16, 3174, 52, 67, 1611, 67, 18212, 22, 300, 531, 1268, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 27573, 12389, 58, 67, 59, 1013, 15146, 16, 282, 17335, 67, 3707, 23, 18, 713, 380, 1728, 636, 2643, 16, 3174, 52, 67, 1611, 67, 18212, 21, 16, 531, 1268, 67, 1611, 67, 18212, 21, 300, 3174, 52, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 27573, 611, 1457, 67, 59, 1013, 15146, 16, 282, 11631, 67, 20, 3361, 18, 713, 380, 1728, 636, 2643, 16, 3174, 52, 67, 1611, 67, 18212, 21, 16, 3741, 58, 67, 1611, 67, 18212, 21, 300, 3174, 52, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 27573, 490, 47, 56, 67, 59, 1013, 15146, 16, 282, 1728, 23, 67, 25213, 18, 713, 380, 1728, 636, 2643, 16, 3174, 52, 67, 1611, 67, 18212, 21, 16, 3741, 58, 67, 1611, 67, 18212, 21, 300, 3174, 52, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 27573, 531, 2849, 67, 59, 1013, 15146, 16, 1059, 67, 28644, 67, 4700, 21, 18, 713, 380, 1728, 636, 2643, 16, 3174, 52, 67, 1611, 67, 18212, 21, 16, 804, 1506, 67, 1611, 67, 18212, 22, 300, 3174, 52, 67, 1611, 67, 18212, 21, 16, 5411, 374, 16, 1758, 12, 20, 3719, 203, 3639, 11272, 203, 3639, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 30604, 12, 203, 5411, 463, 1049, 58, 395, 8804, 67, 21, 12, 49, 10160, 67, 3412, 882, 67, 9793, 45, 2934, 2640, 12, 4766, 16628, 67, 59, 1013, 15146, 16, 1059, 67, 20, 3672, 67, 3784, 18, 713, 380, 2 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./utils/BaseTest.sol"; import { MockERC721Batch } from "./utils/mocks/MockERC721Batch.sol"; contract TestERC721Batch is BaseTest { MockERC721Batch private erc721aBatch; function setUp() public virtual { erc721aBatch = new MockERC721Batch(); vm.label(address(erc721aBatch), "ERC721ABatch"); vm.label(address(this), "TestERC721Batch"); } uint256 internal constant amount = 50; // average: 29000-30500 per token function test_batchTransferFrom() public { vm.startPrank(alice); // mint amount to alice erc721aBatch.safeMint(alice, amount); // make id array uint256[] memory ids = new uint256[](amount); for (uint256 i; i < amount; i++) { ids[i] = i + 1; } // batch transfer all ids to bob uint256 g = gasleft(); erc721aBatch.batchTransferFrom(alice, bob, ids); g -= gasleft(); console.log("Transfer gas", g); console.log("Average", g / amount); // check it was successful assertEq(erc721aBatch.balanceOf(alice), 0); assertEq(erc721aBatch.balanceOf(bob), amount); for (uint256 i; i < amount; i++) { assertEq(erc721aBatch.ownerOf(ids[i]), bob); } } function test_batchTransferFromArray() public { vm.startPrank(alice); // mint amount to alice erc721aBatch.safeMint(alice, amount); // make id array uint256[] memory ids = new uint256[](amount); for (uint256 i; i < amount; i++) { ids[i] = i + 1; } // make to address array address[] memory to = new address[](amount); for (uint256 i; i < amount; i++) { to[i] = getRandomAddress(i + 12345); } // batch transfer all ids to the to address array erc721aBatch.batchTransferFrom(alice, to, ids); // check it was successful assertEq(erc721aBatch.balanceOf(alice), 0); for (uint256 i; i < amount; i++) { address addy = to[i]; assertEq(erc721aBatch.balanceOf(addy), 1); assertEq(erc721aBatch.ownerOf(ids[i]), addy); } } function test_batchSafeTransferFrom() public { vm.startPrank(alice); // mint amount to alice erc721aBatch.safeMint(alice, amount); // make id array uint256[] memory ids = new uint256[](amount); for (uint256 i; i < amount; i++) { ids[i] = i + 1; } // batch transfer all ids to bob uint256 g = gasleft(); erc721aBatch.batchSafeTransferFrom(alice, bob, ids, ""); g -= gasleft(); console.log("Transfer gas", g); console.log("Average", g / amount); // check it was successful assertEq(erc721aBatch.balanceOf(alice), 0); assertEq(erc721aBatch.balanceOf(bob), amount); for (uint256 i; i < amount; i++) { assertEq(erc721aBatch.ownerOf(ids[i]), bob); } } function test_batchSafeTransferFromArray() public { vm.startPrank(alice); // mint amount to alice erc721aBatch.safeMint(alice, amount); // make id array uint256[] memory ids = new uint256[](amount); for (uint256 i; i < amount; i++) { ids[i] = i + 1; } // make to address array address[] memory to = new address[](amount); for (uint256 i; i < amount; i++) { to[i] = getRandomAddress(i + 12345); } // batch transfer all ids to the to address array erc721aBatch.batchSafeTransferFrom(alice, to, ids, ""); // check it was successful assertEq(erc721aBatch.balanceOf(alice), 0); for (uint256 i; i < amount; i++) { address addy = to[i]; assertEq(erc721aBatch.balanceOf(addy), 1); assertEq(erc721aBatch.ownerOf(ids[i]), addy); } } function testGas_deploy() public { new MockERC721Batch(); } }
mint amount to alice make id array
function test_batchSafeTransferFromArray() public { vm.startPrank(alice); erc721aBatch.safeMint(alice, amount); uint256[] memory ids = new uint256[](amount); for (uint256 i; i < amount; i++) { ids[i] = i + 1; } for (uint256 i; i < amount; i++) { to[i] = getRandomAddress(i + 12345); } for (uint256 i; i < amount; i++) { address addy = to[i]; assertEq(erc721aBatch.balanceOf(addy), 1); assertEq(erc721aBatch.ownerOf(ids[i]), addy); } }
5,407,362
[ 1, 4625, 348, 7953, 560, 30, 225, 312, 474, 3844, 358, 524, 1812, 1221, 612, 526, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1842, 67, 5303, 9890, 5912, 16638, 1435, 1071, 288, 203, 3639, 4268, 18, 1937, 2050, 2304, 12, 287, 1812, 1769, 203, 203, 3639, 6445, 71, 27, 5340, 69, 4497, 18, 4626, 49, 474, 12, 287, 1812, 16, 3844, 1769, 203, 203, 3639, 2254, 5034, 8526, 3778, 3258, 273, 394, 2254, 5034, 8526, 12, 8949, 1769, 203, 3639, 364, 261, 11890, 5034, 277, 31, 277, 411, 3844, 31, 277, 27245, 288, 203, 5411, 3258, 63, 77, 65, 273, 277, 397, 404, 31, 203, 3639, 289, 203, 203, 3639, 364, 261, 11890, 5034, 277, 31, 277, 411, 3844, 31, 277, 27245, 288, 203, 5411, 358, 63, 77, 65, 273, 20581, 1887, 12, 77, 397, 2593, 25574, 1769, 203, 3639, 289, 203, 203, 203, 203, 3639, 364, 261, 11890, 5034, 277, 31, 277, 411, 3844, 31, 277, 27245, 288, 203, 5411, 1758, 527, 93, 273, 358, 63, 77, 15533, 203, 5411, 1815, 19508, 12, 12610, 27, 5340, 69, 4497, 18, 12296, 951, 12, 31934, 3631, 404, 1769, 203, 5411, 1815, 19508, 12, 12610, 27, 5340, 69, 4497, 18, 8443, 951, 12, 2232, 63, 77, 65, 3631, 527, 93, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2021-03-03 */ // File: @openzeppelin/upgrades/contracts/Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: contracts/ERC/ERC20Interface.sol pragma solidity ^0.5.0; /** ---------------------------------------------------------------------------- * @title ERC Token Standard #20 Interface * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md * ---------------------------------------------------------------------------- */ contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view 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 value); event Approval(address indexed tokenOwner, address indexed spender, uint value); } // File: contracts/libs/SafeMath.sol pragma solidity ^0.5.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) { 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; 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; } } // File: @openzeppelin/contracts-ethereum-package/contracts/access/Roles.sol pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } // File: contracts/libs/Ownable.sol pragma solidity ^0.5.0; /** * @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 Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "Ownable: sender is not owner"); _; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { owner = address(0); emit OwnershipRenounced(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 { _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), "Ownable: transfer to zero address"); owner = _newOwner; emit OwnershipTransferred(owner, _newOwner); } } // File: contracts/libs/AccessControl.sol pragma solidity ^0.5.0; contract AccessControl is Ownable { using Roles for Roles.Role; //Contract admins Roles.Role internal _admins; // Events event AddedAdmin(address _address); event DeletedAdmin(address _addess); function addAdmin(address newAdmin) public onlyOwner { require(newAdmin != address(0), "AccessControl: Invalid new admin address"); _admins.add(newAdmin); emit AddedAdmin(newAdmin); } function deletedAdmin(address deleteAdmin) public onlyOwner { require(deleteAdmin != address(0), "AccessControl: Invalid new admin address"); _admins.remove(deleteAdmin); emit DeletedAdmin(deleteAdmin); } } // File: contracts/ERC/ERC20.sol pragma solidity ^0.5.0; /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md */ contract ERC20 is ERC20Interface, AccessControl { using SafeMath for uint256; mapping(address => uint256) internal _balances; mapping(address => mapping(address => uint256)) internal _allowed; uint256 internal _totalSupply; event Burn(address indexed burner, uint256 value); // Modifiers modifier onlyOwnerOrAdmin() { require(msg.sender == owner || _admins.has(msg.sender), "ERC20: sender is not owner or admin"); _; } // Functions /** * @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. 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) { _approve(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) { require(value <= _allowed[from][msg.sender], "ERC20: account balance is lower than amount"); _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(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) * @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(addedValue > 0, "ERC20: value must be bigger than zero"); _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); 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) * @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(subtractedValue > 0, "ERC20: value must be bigger than zero"); _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "ERC20: value must be bigger than zero"); require(amount <= _balances[account], "ERC20: account balance is lower than amount"); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); emit Burn(account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(account != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "ERC20: value must be bigger than zero"); require(amount <= _allowed[account][msg.sender] || _admins.has(msg.sender), "ERC20: account allowed balance is lower than amount"); _burn(account, amount); _approve(account, msg.sender, _allowed[account][msg.sender].sub(amount)); } /** * @dev Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 value) internal { require(_from != address(0), "ERC20: transfer to the zero address"); require(_to != address(0), "ERC20: transfer to the zero address"); require(value > 0, "ERC20: value must be bigger than zero"); require(value <= _balances[_from], "ERC20: balances from must be bigger than transfer amount"); require(_balances[_to] < _balances[_to] + value, "ERC20: value must be bigger than zero"); _balances[_from] = _balances[_from].sub(value); _balances[_to] = _balances[_to].add(value); emit Transfer(_from, _to, value); } /** * @dev Internal function, minting new tokens */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); require(amount > 0, "ERC20: value must be bigger than zero"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); _allowed[account][account] = _balances[account]; emit Transfer(address(0), account, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowed[owner][spender] = amount; emit Approval(owner, spender, amount); } } // File: contracts/libs/MintableToken.sol pragma solidity ^0.5.0; /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 */ contract MintableToken is ERC20 { event Mint(address indexed to, uint256 amount); event MintFinished(); event MintStarted(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished, "MintableToken: minting is finished"); _; } modifier hasMintPermission() { require(msg.sender == owner || _admins.has(msg.sender), "MintableToken: sender has not permissions"); _; } /** * @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 this indicates if the operation was successful. */ function mint(address _to, uint256 _amount) public hasMintPermission canMint returns (bool) { _mint(_to, _amount); emit Mint(_to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwnerOrAdmin canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } function startMinting() public onlyOwnerOrAdmin returns (bool) { mintingFinished = false; emit MintStarted(); return true; } } // File: contracts/libs/FreezableToken.sol pragma solidity ^0.5.0; /** * @title Freezable token * @dev Add ability froze accounts */ contract FreezableToken is MintableToken { mapping(address => bool) public frozenAccounts; event FrozenFunds(address target, bool frozen); /** * @dev Freze account */ function freezeAccount(address target, bool freeze) public onlyOwnerOrAdmin { frozenAccounts[target] = freeze; emit FrozenFunds(target, freeze); } /** * @dev Ovveride base method _transfer from base ERC20 contract */ function _transfer(address _from, address _to, uint256 value) internal { require(_to != address(0x0), "FreezableToken: transfer to the zero address"); require(_balances[_from] >= value, "FreezableToken: balance _from must br bigger than value"); require(_balances[_to] + value >= _balances[_to], "FreezableToken: balance to must br bigger than current balance"); require(!frozenAccounts[_from], "FreezableToken: account _from is frozen"); require(!frozenAccounts[_to], "FreezableToken: account _to is frozen"); _balances[_from] = _balances[_from].sub(value); _balances[_to] = _balances[_to].add(value); emit Transfer(_from, _to, value); } } // File: contracts/libs/Pausable.sol pragma solidity ^0.5.0; /** * @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, "Pausable: contract paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused, "Pausable: contract not paused"); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } // File: contracts/MainContract.sol pragma solidity ^0.5.0; /** * @title Contract constants * @dev Contract whose consisit base constants for contract */ contract ContractConstants { uint256 internal TOKEN_BUY_PRICE; uint256 internal TOKEN_BUY_PRICE_DECIMAL; uint256 internal TOKENS_BUY_LIMIT; } /** * @title MainContract * @dev Base contract which using for initializing new contract */ contract MainContract is ContractConstants, FreezableToken, Pausable { string private _name; string private _symbol; uint private _decimals; uint private _decimalsMultiplier; uint256 internal buyPrice; uint256 internal buyPriceDecimals; uint256 internal buyTokensLimit; uint256 internal boughtTokensByCurrentPrice; uint256 internal membersCount; event Buy(address target, uint256 eth, uint256 tokens); event NewLimit(uint256 prevLimit, uint256 newLimit); event SetNewPrice(uint256 prevPrice, uint256 newPrice); /** * @return get token name */ function name() public view returns (string memory) { return _name; } /** * @return get token symbol */ function symbol() public view returns (string memory) { return _symbol; } /** * @return get token decimals */ function decimals() public view returns (uint) { return _decimals; } /** * @return return buy price */ function getBuyPrice() public view returns (uint256) { return buyPrice; } /** * @return return buy price decimals */ function getBuyPriceDecimals() public view returns (uint256) { return buyPriceDecimals; } /** * @return return count mebers */ function getMembersCount() public view returns (uint256) { return membersCount; } /** * @return return payable function buy limit */ function getBuyTokensLimit() public view returns (uint256) { return buyTokensLimit; } /** * @return return count of bought tokens for current price */ function getBoughtTokensByCurrentPrice() public view returns (uint256) { return boughtTokensByCurrentPrice; } /** * @dev set prices for sell tokens and buy tokens */ function setPrices(uint256 newBuyPrice) public onlyOwnerOrAdmin { emit SetNewPrice(buyPrice, newBuyPrice); buyPrice = newBuyPrice; boughtTokensByCurrentPrice = 0; } /** * @dev set max buy tokens */ function setLimit(uint256 newLimit) public onlyOwnerOrAdmin { emit NewLimit(buyTokensLimit, newLimit); buyTokensLimit = newLimit; } /** * @dev set limit and reset price */ function setLimitAndPrice(uint256 newLimit, uint256 newBuyPrice) public onlyOwnerOrAdmin { setLimit(newLimit); setPrices(newBuyPrice); } /** * @dev set prices for sell tokens and buy tokens */ function setPricesDecimals(uint256 newBuyDecimal) public onlyOwnerOrAdmin { buyPriceDecimals = newBuyDecimal; } /** * @dev override base method transferFrom */ function transferFrom(address _from, address _to, uint256 value) public whenNotPaused returns (bool _success) { return super.transferFrom(_from, _to, value); } /** * @dev Override base method transfer */ function transfer(address _to, uint256 value) public whenNotPaused returns (bool _success) { return super.transfer(_to, value); } /** * @dev Override base method increaseAllowance */ function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) { return super.increaseAllowance(spender, addedValue); } /** * @dev Override base method decreaseAllowance */ function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } /** * @dev Override base method approve */ function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } /** * @dev Burn user tokens */ function burn(uint256 _value) public whenNotPaused { _burn(msg.sender, _value); } /** * @dev Burn users tokens with allowance */ function burnFrom(address account, uint256 _value) public whenNotPaused { _burnFrom(account, _value); } /** * @dev Mint tokens by owner */ function addTokens(uint256 _amount) public hasMintPermission canMint { _mint(msg.sender, _amount); emit Mint(msg.sender, _amount); } /** * @dev Function whose calling on initialize contract */ function init(string memory __name, string memory __symbol, uint __decimals, uint __totalSupply, address __owner, address __admin) public { _name = __name; _symbol = __symbol; _decimals = __decimals; _decimalsMultiplier = 10 ** _decimals; if (paused) { pause(); } setPrices(TOKEN_BUY_PRICE); setPricesDecimals(TOKEN_BUY_PRICE_DECIMAL); uint256 generateTokens = __totalSupply * _decimalsMultiplier; setLimit(TOKENS_BUY_LIMIT); if (generateTokens > 0) { mint(__owner, generateTokens); approve(__owner, balanceOf(__owner)); } addAdmin(__admin); transferOwnership(__owner); } function() external payable { buy(msg.sender, msg.value); } function calculateBuyTokens(uint256 _value) public view returns (uint256) { uint256 buyDecimal = 10 ** buyPriceDecimals; return (_value * _decimalsMultiplier) / (buyPrice * buyDecimal); } /** * @dev buy tokens */ function buy(address _sender, uint256 _value) internal { require(_value > 0, 'MainContract: Value must be bigger than zero'); require(buyPrice > 0, 'MainContract: Cannot buy tokens'); require(boughtTokensByCurrentPrice < buyTokensLimit, 'MainContract: Cannot buy tokens more than current limit'); uint256 amount = this.calculateBuyTokens(_value); if (boughtTokensByCurrentPrice + amount > buyTokensLimit) { amount = buyTokensLimit - boughtTokensByCurrentPrice; } membersCount = membersCount.add(1); _transfer(owner, _sender, amount); boughtTokensByCurrentPrice = boughtTokensByCurrentPrice.add(amount); address(uint160(owner)).transfer(_value); emit Buy(_sender, _value, amount); } } // File: contracts/Esillium.sol pragma solidity ^0.5.0; contract Esillium is MainContract, Initializable { constructor () public {initialize();} function initialize() public initializer { owner = msg.sender; // First stage config, ETH/USD price : 1605.73 TOKEN_BUY_PRICE = 31172; TOKEN_BUY_PRICE_DECIMAL = 10; TOKENS_BUY_LIMIT = 359200000000; init('Esillium', '8YB', 5, 7000000000, 0x158ad714bc7BEeaD490960eCB382717FA36Ef926, 0x51b8Aa6616B868a4F36b0b3C6Db46B015c5467D6); } }
* @dev set max buy tokens/
function setLimit(uint256 newLimit) public onlyOwnerOrAdmin { emit NewLimit(buyTokensLimit, newLimit); buyTokensLimit = newLimit; }
2,305,023
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 444, 943, 30143, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 444, 3039, 12, 11890, 5034, 394, 3039, 13, 1071, 1338, 5541, 1162, 4446, 288, 203, 203, 3639, 3626, 1166, 3039, 12, 70, 9835, 5157, 3039, 16, 394, 3039, 1769, 203, 203, 3639, 30143, 5157, 3039, 273, 394, 3039, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "@keep-network/keep-core/contracts/KeepToken.sol"; import "@keep-network/keep-core/contracts/TokenStaking.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/cryptography/MerkleProof.sol"; /// @title ECDSA Rewards distributor /// @notice This contract can be used by stakers to claim their rewards for /// participation in the keep network for operating ECDSA nodes. /// @dev This contract is based on the Uniswap's Merkle Distributor /// https://github.com/Uniswap/merkle-distributor with some modifications: /// - added a map of merkle root keys. Whenever a new merkle root is put in the /// map, we assign 'true' value to this key /// - added 'allocate()' function that will be called each time to allocate /// new KEEP rewards for a given merkle root. Merkle root is going to be generated /// regulary (ex. every week) and it is also means that an interval for that /// merkle root has passed /// - changed code accordingly to process claimed rewards using a map of merkle /// roots contract ECDSARewardsDistributor is Ownable { using SafeERC20 for KeepToken; KeepToken public token; TokenStaking public tokenStaking; // This event is triggered whenever a call to #claim succeeds. event RewardsClaimed( bytes32 indexed merkleRoot, uint256 indexed index, address indexed operator, address beneficiary, uint256 amount ); // This event is triggered whenever rewards are allocated. event RewardsAllocated(bytes32 merkleRoot, uint256 amount); // Map of merkle roots indicating whether a given interval was allocated with // KEEP token rewards. For each interval there is always created a new merkle // tree including a root, rewarded operators along with their amounts and proofs. mapping(bytes32 => bool) private merkleRoots; // Bytes32 key is a merkle root and the value is a packed array of booleans. mapping(bytes32 => mapping(uint256 => uint256)) private claimedBitMap; constructor(address _token, address _tokenStaking) public { token = KeepToken(_token); tokenStaking = TokenStaking(_tokenStaking); } /// Claim KEEP rewards for a given merkle root (interval) and the given operator /// address. Rewards will be sent to a beneficiary assigned to the operator. /// @param merkleRoot Merkle root for a given interval. /// @param index Index of the operator in the merkle tree. /// @param operator Operator address that reward will be claimed. /// @param amount The amount of KEEP reward to be claimed. /// @param merkleProof Array of merkle proofs. function claim( bytes32 merkleRoot, uint256 index, address operator, uint256 amount, bytes32[] calldata merkleProof ) external { require( merkleRoots[merkleRoot], "Rewards must be allocated for a given merkle root" ); require(!isClaimed(merkleRoot, index), "Reward already claimed"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, operator, amount)); require( MerkleProof.verify(merkleProof, merkleRoot, node), "Invalid proof" ); // Mark it claimed and send the token. _setClaimed(merkleRoot, index); address beneficiary = tokenStaking.beneficiaryOf(operator); require(IERC20(token).transfer(beneficiary, amount), "Transfer failed"); emit RewardsClaimed(merkleRoot, index, operator, beneficiary, amount); } /// Allocates amount of KEEP for a given merkle root. /// @param merkleRoot Merkle root for a given interval. /// @param amount The amount of KEEP tokens allocated for the merkle root. function allocate(bytes32 merkleRoot, uint256 amount) public onlyOwner { token.safeTransferFrom(msg.sender, address(this), amount); merkleRoots[merkleRoot] = true; emit RewardsAllocated(merkleRoot, amount); } function isClaimed(bytes32 merkleRoot, uint256 index) public view returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedBitMap[merkleRoot][claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(bytes32 merkleRoot, uint256 index) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedBitMap[merkleRoot][claimedWordIndex] = claimedBitMap[merkleRoot][claimedWordIndex] | (1 << claimedBitIndex); } } pragma solidity 0.5.17; import "@keep-network/keep-core/contracts/PhasedEscrow.sol"; /// @title ECDSARewardsEscrowBeneficiary /// @notice Transfer the received tokens from PhasedEscrow to a designated /// ECDSARewards contract. contract ECDSARewardsEscrowBeneficiary is StakerRewardsBeneficiary { constructor(IERC20 _token, IStakerRewards _stakerRewards) public StakerRewardsBeneficiary(_token, _stakerRewards) {} } /// @title ECDSABackportRewardsEscrowBeneficiary /// @notice Trasfer the received tokens from Phased Escrow to a designated /// ECDSABackportRewards contract. contract ECDSABackportRewardsEscrowBeneficiary is StakerRewardsBeneficiary { constructor(IERC20 _token, IStakerRewards _stakerRewards) public StakerRewardsBeneficiary(_token, _stakerRewards) {} } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "./Escrow.sol"; interface IBeneficiaryContract { function __escrowSentTokens(uint256 amount) external; } /// @title PhasedEscrow /// @notice A token holder contract allowing contract owner to set beneficiary of /// tokens held by the contract and allowing the owner to withdraw the /// tokens to that beneficiary in phases. contract PhasedEscrow is Ownable { using SafeERC20 for IERC20; event BeneficiaryUpdated(address beneficiary); event TokensWithdrawn(address beneficiary, uint256 amount); IERC20 public token; IBeneficiaryContract public beneficiary; constructor(IERC20 _token) public { token = _token; } /// @notice Funds the escrow by transferring all of the approved tokens /// to the escrow. function receiveApproval( address _from, uint256 _value, address _token, bytes memory ) public { require(IERC20(_token) == token, "Unsupported token"); token.safeTransferFrom(_from, address(this), _value); } /// @notice Sets the provided address as a beneficiary allowing it to /// withdraw all tokens from escrow. This function can be called only /// by escrow owner. function setBeneficiary(IBeneficiaryContract _beneficiary) external onlyOwner { beneficiary = _beneficiary; emit BeneficiaryUpdated(address(beneficiary)); } /// @notice Withdraws the specified number of tokens from escrow to the /// beneficiary. If the beneficiary is not set, or there are /// insufficient tokens in escrow, the function fails. function withdraw(uint256 amount) external onlyOwner { require(address(beneficiary) != address(0), "Beneficiary not assigned"); uint256 balance = token.balanceOf(address(this)); require(amount <= balance, "Not enough tokens for withdrawal"); token.safeTransfer(address(beneficiary), amount); emit TokensWithdrawn(address(beneficiary), amount); beneficiary.__escrowSentTokens(amount); } /// @notice Withdraws all funds from a non-phased Escrow passed as /// a parameter. For this function to succeed, this PhasedEscrow /// has to be set as a beneficiary of the non-phased Escrow. function withdrawFromEscrow(Escrow _escrow) public { _escrow.withdraw(); } } interface ICurveRewards { function notifyRewardAmount(uint256 amount) external; } /// @title CurveRewardsEscrowBeneficiary /// @notice A beneficiary contract that can receive a withdrawal phase from a /// PhasedEscrow contract. Immediately stakes the received tokens on a /// designated CurveRewards contract. contract CurveRewardsEscrowBeneficiary is Ownable { IERC20 public token; ICurveRewards public curveRewards; constructor(IERC20 _token, ICurveRewards _curveRewards) public { token = _token; curveRewards = _curveRewards; } function __escrowSentTokens(uint256 amount) external onlyOwner { token.approve(address(curveRewards), amount); curveRewards.notifyRewardAmount(amount); } } /// @dev Interface of recipient contract for approveAndCall pattern. interface IStakerRewards { function receiveApproval( address _from, uint256 _value, address _token, bytes calldata _extraData ) external; } /// @title StakerRewardsBeneficiary /// @notice An abstract beneficiary contract that can receive a withdrawal phase /// from a PhasedEscrow contract. The received tokens are immediately /// funded for a designated rewards escrow beneficiary contract. contract StakerRewardsBeneficiary is Ownable { IERC20 public token; IStakerRewards public stakerRewards; constructor(IERC20 _token, IStakerRewards _stakerRewards) public { token = _token; stakerRewards = _stakerRewards; } function __escrowSentTokens(uint256 amount) external onlyOwner { bool success = token.approve(address(stakerRewards), amount); require(success, "Token transfer approval failed"); stakerRewards.receiveApproval( address(this), amount, address(token), "" ); } } /// @title BeaconBackportRewardsEscrowBeneficiary /// @notice Transfer the received tokens to a designated /// BeaconBackportRewardsEscrowBeneficiary contract. contract BeaconBackportRewardsEscrowBeneficiary is StakerRewardsBeneficiary { constructor(IERC20 _token, IStakerRewards _stakerRewards) public StakerRewardsBeneficiary(_token, _stakerRewards) {} } /// @title BeaconRewardsEscrowBeneficiary /// @notice Transfer the received tokens to a designated /// BeaconRewardsEscrowBeneficiary contract. contract BeaconRewardsEscrowBeneficiary is StakerRewardsBeneficiary { constructor(IERC20 _token, IStakerRewards _stakerRewards) public StakerRewardsBeneficiary(_token, _stakerRewards) {} } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; // @title Escrow // @notice A token holder contract allowing contract owner to set beneficiary of // all tokens held by the contract and allowing the beneficiary to withdraw // the tokens. contract Escrow is Ownable { using SafeERC20 for IERC20; event BeneficiaryUpdated(address beneficiary); event TokensWithdrawn(address beneficiary, uint256 amount); IERC20 public token; address public beneficiary; constructor(IERC20 _token) public { token = _token; } // @notice Sets the provided address as a beneficiary allowing it to // withdraw all tokens from escrow. This function can be called only // by escrow owner. function setBeneficiary(address _beneficiary) public onlyOwner { beneficiary = _beneficiary; emit BeneficiaryUpdated(beneficiary); } // @notice Withdraws all tokens from escrow to the beneficiary. // If the beneficiary is not set, caller is not the beneficiary, or there // are no tokens in escrow, function fails. function withdraw() public { require(beneficiary != address(0), "Beneficiary not assigned"); require(msg.sender == beneficiary, "Caller is not the beneficiary"); uint256 amount = token.balanceOf(address(this)); require(amount > 0, "No tokens to withdraw"); token.safeTransfer(beneficiary, amount); emit TokensWithdrawn(beneficiary, amount); } } pragma solidity ^0.5.0; /** * @dev These functions deal with verification of Merkle trees (hash trees), */ 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) { 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 = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; /// @dev Interface of recipient contract for approveAndCall pattern. interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } /// @title KEEP Token /// @dev Standard ERC20Burnable token contract KeepToken is ERC20Burnable, ERC20Detailed { string public constant NAME = "KEEP Token"; string public constant SYMBOL = "KEEP"; uint8 public constant DECIMALS = 18; // The number of digits after the decimal place when displaying token values on-screen. uint256 public constant INITIAL_SUPPLY = 10**27; // 1 billion tokens, 18 decimal places. /// @dev Gives msg.sender all of existing tokens. constructor() public ERC20Detailed(NAME, SYMBOL, DECIMALS) { _mint(msg.sender, INITIAL_SUPPLY); } /// @notice Set allowance for other address and notify. /// Allows `_spender` to spend no more than `_value` tokens /// on your behalf and then ping the contract about it. /// @param _spender The address authorized to spend. /// @param _value The max amount they can spend. /// @param _extraData Extra information to send to the approved contract. function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } } pragma solidity ^0.5.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _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 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) { require(b <= a, "SafeMath: subtraction overflow"); 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-solidity/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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); 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) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } pragma solidity ^0.5.0; import "./ERC20.sol"; /** * @dev Extension of `ERC20` that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ contract ERC20Burnable is ERC20 { /** * @dev Destoys `amount` tokens from the caller. * * See `ERC20._burn`. */ function burn(uint256 amount) public { _burn(msg.sender, amount); } /** * @dev See `ERC20._burnFrom`. */ function burnFrom(address account, uint256 amount) public { _burnFrom(account, amount); } } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.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 `ERC20Mintable`. * * *For a detailed writeup see our guide [How to implement supply * mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).* * * 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 IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See `IERC20.totalSupply`. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See `IERC20.balanceOf`. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See `IERC20.transfer`. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See `IERC20.allowance`. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See `IERC20.approve`. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); 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 `value`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to `approve` that can be used as a mitigation for * problems described in `IERC20.approve`. * * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(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 { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a `Transfer` event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destoys `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 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an `Approval` event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } /** * @dev Destoys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See `_burn` and `_approve`. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount)); } } pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see `ERC20Detailed`. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through `transferFrom`. This is * zero by default. * * This value changes when `approve` or `transferFrom` are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * > 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); 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.0; /** * @dev Collection of functions related to the address type, */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * > It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } pragma solidity ^0.5.0; import "./IERC20.sol"; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * > Note that this information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * `IERC20.balanceOf` and `IERC20.transfer`. */ function decimals() public view returns (uint8) { return _decimals; } } /** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./StakeDelegatable.sol"; import "./libraries/staking/MinimumStakeSchedule.sol"; import "./libraries/staking/GrantStaking.sol"; import "./libraries/staking/Locks.sol"; import "./libraries/staking/TopUps.sol"; import "./utils/PercentUtils.sol"; import "./utils/BytesLib.sol"; import "./Authorizations.sol"; import "./TokenStakingEscrow.sol"; import "./TokenSender.sol"; /// @title TokenStaking /// @notice A token staking contract for a specified standard ERC20Burnable token. /// A holder of the specified token can stake delegate its tokens to this contract /// and recover the stake after undelegation period is over. contract TokenStaking is Authorizations, StakeDelegatable { using BytesLib for bytes; using SafeMath for uint256; using PercentUtils for uint256; using SafeERC20 for ERC20Burnable; using GrantStaking for GrantStaking.Storage; using Locks for Locks.Storage; using TopUps for TopUps.Storage; event StakeDelegated( address indexed owner, address indexed operator ); event OperatorStaked( address indexed operator, address indexed beneficiary, address indexed authorizer, uint256 value ); event StakeOwnershipTransferred( address indexed operator, address indexed newOwner ); event TopUpInitiated(address indexed operator, uint256 topUp); event TopUpCompleted(address indexed operator, uint256 newAmount); event Undelegated(address indexed operator, uint256 undelegatedAt); event RecoveredStake(address operator); event TokensSlashed(address indexed operator, uint256 amount); event TokensSeized(address indexed operator, uint256 amount); event StakeLocked(address indexed operator, address lockCreator, uint256 until); event LockReleased(address indexed operator, address lockCreator); event ExpiredLockReleased(address indexed operator, address lockCreator); uint256 public deployedAt; uint256 public initializationPeriod; // varies between mainnet and testnet ERC20Burnable internal token; TokenGrant internal tokenGrant; TokenStakingEscrow internal escrow; GrantStaking.Storage internal grantStaking; Locks.Storage internal locks; TopUps.Storage internal topUps; uint256 internal constant twoWeeks = 1209600; // [sec] uint256 internal constant twoMonths = 5184000; // [sec] // 2020-04-28; the date of deploying KEEP token. // TX: 0xea22d72bc7de4c82798df7194734024a1f2fd57b173d0e065864ff4e9d3dc014 uint256 internal constant minimumStakeScheduleStart = 1588042366; /// @notice Creates a token staking contract for a provided Standard ERC20Burnable token. /// @param _token KEEP token contract. /// @param _tokenGrant KEEP token grant contract. /// @param _escrow Escrow dedicated for this staking contract. /// @param _registry Keep contract registry contract. /// @param _initializationPeriod To avoid certain attacks on work selection, recently created /// operators must wait for a specific period of time before being eligible for work selection. constructor( ERC20Burnable _token, TokenGrant _tokenGrant, TokenStakingEscrow _escrow, KeepRegistry _registry, uint256 _initializationPeriod ) Authorizations(_registry) public { token = _token; tokenGrant = _tokenGrant; escrow = _escrow; registry = _registry; initializationPeriod = _initializationPeriod; deployedAt = block.timestamp; } /// @notice Returns minimum amount of KEEP that allows sMPC cluster client to /// participate in the Keep network. Expressed as number with 18-decimal places. /// Initial minimum stake is higher than the final and lowered periodically based /// on the amount of steps and the length of the minimum stake schedule in seconds. function minimumStake() public view returns (uint256) { return MinimumStakeSchedule.current(minimumStakeScheduleStart); } /// @notice Returns the current value of the undelegation period. /// The staking contract guarantees that an undelegated operator’s stakes /// will stay locked for a period of time after undelegation, and thus /// available as collateral for any work the operator is engaged in. /// The undelegation period is two weeks for the first two months and /// two months after that. function undelegationPeriod() public view returns(uint256) { return block.timestamp < deployedAt.add(twoMonths) ? twoWeeks : twoMonths; } /// @notice Receives approval of token transfer and stakes the approved /// amount or adds the approved amount to an existing delegation (a “top-up”). /// In case of a top-up, it is expected that the operator stake is not /// undelegated and that the top-up is performed from the same source of /// tokens as the initial delegation. That is, if the tokens were delegated /// from a grant, top-up has to be performed from the same grant. If the /// delegation was done using liquid tokens, only liquid tokens from the /// same owner can be used to top-up the stake. /// Top-up can not be cancelled so it is important to be careful with the /// amount of KEEP added to the stake. /// @dev Requires that the provided token contract be the same one linked to /// this contract. /// @param _from The owner of the tokens who approved them to transfer. /// @param _value Approved amount for the transfer and stake. /// @param _token Token contract address. /// @param _extraData Data for stake delegation. This byte array must have /// the following values concatenated: /// - Beneficiary address (20 bytes), ignored for a top-up /// - Operator address (20 bytes) /// - Authorizer address (20 bytes), ignored for a top-up /// - Grant ID (32 bytes) - required only when called by TokenStakingEscrow function receiveApproval( address _from, uint256 _value, address _token, bytes memory _extraData ) public { require(ERC20Burnable(_token) == token, "Unrecognized token"); require(_extraData.length >= 60, "Corrupted delegation data"); // Transfer tokens to this contract. token.safeTransferFrom(_from, address(this), _value); address operator = _extraData.toAddress(20); // See if there is an existing delegation for this operator... if (operators[operator].packedParams.getCreationTimestamp() == 0) { // If there is no existing delegation, delegate tokens using // beneficiary and authorizer passed in _extraData. delegate(_from, _value, operator, _extraData); } else { // If there is an existing delegation, top-up the stake. topUp(_from, _value, operator, _extraData); } } /// @notice Delegates tokens to a new operator using beneficiary and /// authorizer passed in _extraData parameter. /// @param _from The owner of the tokens who approved them to transfer. /// @param _value Approved amount for the transfer and stake. /// @param _operator The new operator address. /// @param _extraData Data for stake delegation as passed to receiveApproval. function delegate( address _from, uint256 _value, address _operator, bytes memory _extraData ) internal { require(_value >= minimumStake(), "Less than the minimum stake"); address payable beneficiary = address(uint160(_extraData.toAddress(0))); address authorizer = _extraData.toAddress(40); operators[_operator] = Operator( OperatorParams.pack(_value, block.timestamp, 0), _from, beneficiary, authorizer ); grantStaking.tryCapturingDelegationData( tokenGrant, address(escrow), _from, _operator, _extraData ); emit StakeDelegated(_from, _operator); emit OperatorStaked(_operator, beneficiary, authorizer, _value); } /// @notice Performs top-up to an existing operator. Tokens added during /// stake initialization period are immediatelly added to the stake and /// stake initialization timer is reset to the current block. Tokens added /// in a top-up after the stake initialization period is over are not /// included in the operator stake until the initialization period for /// a top-up passes and top-up is committed. Operator must not have the stake /// undelegated. It is expected that the top-up is done from the same source /// of tokens as the initial delegation. That is, if the tokens were /// delegated from a grant, top-up has to be performed from the same grant. /// If the delegation was done using liquid tokens, only liquid tokens from /// the same owner can be used to top-up the stake. /// Top-up can not be cancelled so it is important to be careful with the /// amount of KEEP added to the stake. /// @param _from The owner of the tokens who approved them to transfer. /// @param _value Approved amount for the transfer and top-up to /// an existing stake. /// @param _operator The new operator address. /// @param _extraData Data for stake delegation as passed to receiveApproval function topUp( address _from, uint256 _value, address _operator, bytes memory _extraData ) internal { // Top-up comes from a grant if it's been initiated from TokenGrantStake // contract or if it's been initiated from TokenStakingEscrow by // redelegation. bool isFromGrant = address(tokenGrant.grantStakes(_operator)) == _from || address(escrow) == _from; if (grantStaking.hasGrantDelegated(_operator)) { // Operator has grant delegated. We need to see if the top-up // is performed also from a grant. require(isFromGrant, "Must be from a grant"); // If it is from a grant, we need to make sure it's from the same // grant as the original delegation. We do not want to mix unlocking // schedules. uint256 previousGrantId = grantStaking.getGrantForOperator(_operator); (, uint256 grantId) = grantStaking.tryCapturingDelegationData( tokenGrant, address(escrow), _from, _operator, _extraData ); require(grantId == previousGrantId, "Not the same grant"); } else { // Operator has no grant delegated. We need to see if the top-up // is performed from liquid tokens of the same owner. require(!isFromGrant, "Must not be from a grant"); require(operators[_operator].owner == _from, "Not the same owner"); } uint256 operatorParams = operators[_operator].packedParams; if (!_isInitialized(operatorParams)) { // If the stake is not yet initialized, we add tokens immediately // but we also reset stake initialization time counter. operators[_operator].packedParams = topUps.instantComplete( _value, _operator, operatorParams, escrow ); } else { // If the stake is initialized, we do NOT add tokens immediately. // We initiate the top-up and will add tokens to the stake only // after the initialization period for a top-up passes. topUps.initiate(_value, _operator, operatorParams, escrow); } } /// @notice Commits pending top-up for the provided operator. If the top-up /// did not pass the initialization period, the function fails. /// @param _operator The operator with a pending top-up that is getting /// committed. function commitTopUp(address _operator) public { operators[_operator].packedParams = topUps.commit( _operator, operators[_operator].packedParams, initializationPeriod ); } /// @notice Cancels stake of tokens within the operator initialization period /// without being subjected to the token lockup for the undelegation period. /// This can be used to undo mistaken delegation to the wrong operator address. /// @param _operator Address of the stake operator. function cancelStake(address _operator) public { address owner = operators[_operator].owner; require( msg.sender == owner || msg.sender == _operator || grantStaking.canUndelegate(_operator, tokenGrant), "Not authorized" ); uint256 operatorParams = operators[_operator].packedParams; require( !_isInitialized(operatorParams), "Initialized stake" ); uint256 amount = operatorParams.getAmount(); operators[_operator].packedParams = operatorParams.setAmount(0); transferOrDeposit(owner, _operator, amount); } /// @notice Undelegates staked tokens. You will be able to recover your stake by calling /// `recoverStake()` with operator address once undelegation period is over. /// @param _operator Address of the stake operator. function undelegate(address _operator) public { undelegateAt(_operator, block.timestamp); } /// @notice Set an undelegation time for staked tokens. /// Undelegation will begin at the specified timestamp. /// You will be able to recover your stake by calling /// `recoverStake()` with operator address once undelegation period is over. /// @param _operator Address of the stake operator. /// @param _undelegationTimestamp The timestamp undelegation is to start at. function undelegateAt( address _operator, uint256 _undelegationTimestamp ) public { require( msg.sender == _operator || msg.sender == operators[_operator].owner || grantStaking.canUndelegate(_operator, tokenGrant), "Not authorized" ); uint256 oldParams = operators[_operator].packedParams; require( _undelegationTimestamp >= block.timestamp && _undelegationTimestamp > oldParams.getCreationTimestamp().add(initializationPeriod), "Invalid timestamp" ); uint256 existingUndelegationTimestamp = oldParams.getUndelegationTimestamp(); require( // Undelegation not in progress OR existingUndelegationTimestamp == 0 || // Undelegating sooner than previously set time OR existingUndelegationTimestamp > _undelegationTimestamp || // We have already checked above that msg.sender is owner, grantee, // or operator. Only owner and grantee are eligible to postpone the // delegation so it is enough if we exclude operator here. msg.sender != _operator, "Operator may not postpone" ); operators[_operator].packedParams = oldParams.setUndelegationTimestamp( _undelegationTimestamp ); emit Undelegated(_operator, _undelegationTimestamp); } /// @notice Recovers staked tokens and transfers them back to the owner. /// Recovering tokens can only be performed when the operator finished /// undelegating. /// @param _operator Operator address. function recoverStake(address _operator) public { uint256 operatorParams = operators[_operator].packedParams; require( operatorParams.getUndelegationTimestamp() != 0, "Not undelegated" ); require( _isUndelegatingFinished(operatorParams), "Still undelegating" ); require( !isStakeLocked(_operator), "Locked stake" ); uint256 amount = operatorParams.getAmount(); // If there is a pending top-up, force-commit it before returning tokens. amount = amount.add(topUps.cancel(_operator)); operators[_operator].packedParams = operatorParams.setAmount(0); transferOrDeposit(operators[_operator].owner, _operator, amount); emit RecoveredStake(_operator); } /// @notice Gets stake delegation info for the given operator. /// @param _operator Operator address. /// @return amount The amount of tokens the given operator delegated. /// @return createdAt The time when the stake has been delegated. /// @return undelegatedAt The time when undelegation has been requested. /// If undelegation has not been requested, 0 is returned. function getDelegationInfo(address _operator) public view returns (uint256 amount, uint256 createdAt, uint256 undelegatedAt) { return operators[_operator].packedParams.unpack(); } /// @notice Locks given operator stake for the specified duration. /// Locked stake may not be recovered until the lock expires or is released, /// even if the normal undelegation period has passed. /// Only previously authorized operator contract can lock the stake. /// @param operator Operator address. /// @param duration Lock duration in seconds. function lockStake( address operator, uint256 duration ) public onlyApprovedOperatorContract(msg.sender) { require( isAuthorizedForOperator(operator, msg.sender), "Not authorized" ); uint256 operatorParams = operators[operator].packedParams; require( _isInitialized(operatorParams), "Inactive stake" ); require( !_isUndelegating(operatorParams), "Undelegating stake" ); locks.lockStake(operator, duration); } /// @notice Removes a lock the caller had previously placed on the operator. /// @dev Only for operator contracts. /// To remove expired or disabled locks, use `releaseExpiredLocks`. /// The authorization check ensures that the caller must have been able /// to place a lock on the operator sometime in the past. /// We don't need to check for current approval status of the caller /// because unlocking stake cannot harm the operator /// nor interfere with other operator contracts. /// Therefore even disabled operator contracts may freely unlock stake. /// @param operator Operator address. function unlockStake( address operator ) public { require( isAuthorizedForOperator(operator, msg.sender), "Not authorized" ); locks.releaseLock(operator); } /// @notice Removes the lock of the specified operator contract /// if the lock has expired or the contract has been disabled. /// @dev Necessary for removing locks placed by contracts /// that have been disabled by the panic button. /// Also applicable to prevent inadvertent DoS of `recoverStake` /// if too many operator contracts have failed to clean up their locks. function releaseExpiredLock( address operator, address operatorContract ) public { locks.releaseExpiredLock(operator, operatorContract, address(this)); } /// @notice Check whether the operator has any active locks /// that haven't expired yet /// and whose creators aren't disabled by the panic button. function isStakeLocked(address operator) public view returns (bool) { return locks.isStakeLocked(operator, address(this)); } /// @notice Get the locks placed on the operator. /// @return creators The addresses of operator contracts /// that have placed a lock on the operator. /// @return expirations The expiration times /// of the locks placed on the operator. function getLocks(address operator) public view returns (address[] memory creators, uint256[] memory expirations) { return locks.getLocks(operator); } /// @notice Slash provided token amount from every member in the misbehaved /// operators array and burn 100% of all the tokens. /// @param amountToSlash Token amount to slash from every misbehaved operator. /// @param misbehavedOperators Array of addresses to seize the tokens from. function slash(uint256 amountToSlash, address[] memory misbehavedOperators) public onlyApprovedOperatorContract(msg.sender) { uint256 totalAmountToBurn; address authoritySource = getAuthoritySource(msg.sender); for (uint i = 0; i < misbehavedOperators.length; i++) { address operator = misbehavedOperators[i]; require(authorizations[authoritySource][operator], "Not authorized"); uint256 operatorParams = operators[operator].packedParams; require( _isInitialized(operatorParams), "Inactive stake" ); require( !_isStakeReleased(operator, operatorParams, msg.sender), "Stake is released" ); uint256 currentAmount = operatorParams.getAmount(); if (currentAmount < amountToSlash) { totalAmountToBurn = totalAmountToBurn.add(currentAmount); operators[operator].packedParams = operatorParams.setAmount(0); emit TokensSlashed(operator, currentAmount); } else { totalAmountToBurn = totalAmountToBurn.add(amountToSlash); operators[operator].packedParams = operatorParams.setAmount( currentAmount.sub(amountToSlash) ); emit TokensSlashed(operator, amountToSlash); } } token.burn(totalAmountToBurn); } /// @notice Seize provided token amount from every member in the misbehaved /// operators array. The tattletale is rewarded with 5% of the total seized /// amount scaled by the reward adjustment parameter and the rest 95% is burned. /// @param amountToSeize Token amount to seize from every misbehaved operator. /// @param rewardMultiplier Reward adjustment in percentage. Min 1% and 100% max. /// @param tattletale Address to receive the 5% reward. /// @param misbehavedOperators Array of addresses to seize the tokens from. function seize( uint256 amountToSeize, uint256 rewardMultiplier, address tattletale, address[] memory misbehavedOperators ) public onlyApprovedOperatorContract(msg.sender) { uint256 totalAmountToBurn; address authoritySource = getAuthoritySource(msg.sender); for (uint i = 0; i < misbehavedOperators.length; i++) { address operator = misbehavedOperators[i]; require(authorizations[authoritySource][operator], "Not authorized"); uint256 operatorParams = operators[operator].packedParams; require( _isInitialized(operatorParams), "Inactive stake" ); require( !_isStakeReleased(operator, operatorParams, msg.sender), "Stake is released" ); uint256 currentAmount = operatorParams.getAmount(); if (currentAmount < amountToSeize) { totalAmountToBurn = totalAmountToBurn.add(currentAmount); operators[operator].packedParams = operatorParams.setAmount(0); emit TokensSeized(operator, currentAmount); } else { totalAmountToBurn = totalAmountToBurn.add(amountToSeize); operators[operator].packedParams = operatorParams.setAmount( currentAmount.sub(amountToSeize) ); emit TokensSeized(operator, amountToSeize); } } uint256 tattletaleReward = (totalAmountToBurn.percent(5)).percent(rewardMultiplier); token.safeTransfer(tattletale, tattletaleReward); token.burn(totalAmountToBurn.sub(tattletaleReward)); } /// @notice Allows the current staking relationship owner to transfer the /// ownership to someone else. /// @param operator Address of the stake operator. /// @param newOwner Address of the new staking relationship owner. function transferStakeOwnership(address operator, address newOwner) public { require(msg.sender == operators[operator].owner, "Not authorized"); operators[operator].owner = newOwner; emit StakeOwnershipTransferred(operator, newOwner); } /// @notice Gets the eligible stake balance of the specified address. /// An eligible stake is a stake that passed the initialization period /// and is not currently undelegating. Also, the operator had to approve /// the specified operator contract. /// /// Operator with a minimum required amount of eligible stake can join the /// network and participate in new work selection. /// /// @param _operator address of stake operator. /// @param _operatorContract address of operator contract. /// @return an uint256 representing the eligible stake balance. function eligibleStake( address _operator, address _operatorContract ) public view returns (uint256 balance) { uint256 operatorParams = operators[_operator].packedParams; // To be eligible for work selection, the operator must: // - have the operator contract authorized // - have the stake initialized // - must not be undelegating; keep in mind the `undelegatedAt` may be // set to a time in the future, to schedule undelegation in advance. // In this case the operator is still eligible until the timestamp // `undelegatedAt`. if ( isAuthorizedForOperator(_operator, _operatorContract) && _isInitialized(operatorParams) && !_isUndelegating(operatorParams) ) { balance = operatorParams.getAmount(); } } /// @notice Gets the active stake balance of the specified address. /// An active stake is a stake that passed the initialization period, /// and may be in the process of undelegation /// but has not been released yet, /// either because the undelegation period is not over, /// or because the operator contract has an active lock on the operator. /// Also, the operator had to approve the specified operator contract. /// /// The difference between eligible stake is that active stake does not make /// the operator eligible for work selection but it may be still finishing /// earlier work until the stake is released. /// Operator with a minimum required /// amount of active stake can join the network but cannot be selected to any /// new work. /// /// @param _operator address of stake operator. /// @param _operatorContract address of operator contract. /// @return an uint256 representing the eligible stake balance. function activeStake( address _operator, address _operatorContract ) public view returns (uint256 balance) { uint256 operatorParams = operators[_operator].packedParams; if ( isAuthorizedForOperator(_operator, _operatorContract) && _isInitialized(operatorParams) && !_isStakeReleased( _operator, operatorParams, _operatorContract ) ) { balance = operatorParams.getAmount(); } } /// @notice Checks if the specified account has enough active stake to become /// network operator and that the specified operator contract has been /// authorized for potential slashing. /// /// Having the required minimum of active stake makes the operator eligible /// to join the network. If the active stake is not currently undelegating, /// operator is also eligible for work selection. /// /// @param staker Staker's address /// @param operatorContract Operator contract's address /// @return True if has enough active stake to participate in the network, /// false otherwise. function hasMinimumStake( address staker, address operatorContract ) public view returns(bool) { return activeStake(staker, operatorContract) >= minimumStake(); } /// @notice Is the operator with the given params initialized function _isInitialized(uint256 _operatorParams) internal view returns (bool) { return block.timestamp > _operatorParams.getCreationTimestamp().add(initializationPeriod); } /// @notice Is the operator with the given params undelegating function _isUndelegating(uint256 _operatorParams) internal view returns (bool) { uint256 undelegatedAt = _operatorParams.getUndelegationTimestamp(); return (undelegatedAt != 0) && (block.timestamp > undelegatedAt); } /// @notice Has the operator with the given params finished undelegating function _isUndelegatingFinished(uint256 _operatorParams) internal view returns (bool) { uint256 undelegatedAt = _operatorParams.getUndelegationTimestamp(); return (undelegatedAt != 0) && (block.timestamp > undelegatedAt.add(undelegationPeriod())); } /// @notice Get whether the operator's stake is released /// as far as the operator contract is concerned. /// If the operator contract has a lock on the operator, /// the operator's stake is be released when the lock expires. /// Otherwise the stake is released when the operator finishes undelegating. function _isStakeReleased( address _operator, uint256 _operatorParams, address _operatorContract ) internal view returns (bool) { return _isUndelegatingFinished(_operatorParams) && locks.isStakeReleased(_operator, _operatorContract); } function transferOrDeposit( address _owner, address _operator, uint256 _amount ) internal { if (grantStaking.hasGrantDelegated(_operator)) { // For tokens staked from a grant, transfer them to the escrow. TokenSender(address(token)).approveAndCall( address(escrow), _amount, abi.encode(_operator, grantStaking.getGrantForOperator(_operator)) ); } else { // For liquid tokens staked, transfer them straight to the owner. token.safeTransfer(_owner, _amount); } } } /** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "./utils/OperatorParams.sol"; /// @title Stake Delegatable /// @notice A base contract to allow stake delegation for staking contracts. contract StakeDelegatable { using OperatorParams for uint256; mapping(address => Operator) internal operators; struct Operator { uint256 packedParams; address owner; address payable beneficiary; address authorizer; } /// @notice Gets the stake balance of the specified address. /// @param _address The address to query the balance of. /// @return An uint256 representing the amount staked by the passed address. function balanceOf(address _address) public view returns (uint256 balance) { return operators[_address].packedParams.getAmount(); } /// @notice Gets the stake owner for the specified operator address. /// @return Stake owner address. function ownerOf(address _operator) public view returns (address) { return operators[_operator].owner; } /// @notice Gets the beneficiary for the specified operator address. /// @return Beneficiary address. function beneficiaryOf(address _operator) public view returns (address payable) { return operators[_operator].beneficiary; } /// @notice Gets the authorizer for the specified operator address. /// @return Authorizer address. function authorizerOf(address _operator) public view returns (address) { return operators[_operator].authorizer; } } pragma solidity 0.5.17; library OperatorParams { // OperatorParams packs values that are commonly used together // into a single uint256 to reduce the cost functions // like querying eligibility. // // An OperatorParams uint256 contains: // - the operator's staked token amount (uint128) // - the operator's creation timestamp (uint64) // - the operator's undelegation timestamp (uint64) // // These are packed as [amount | createdAt | undelegatedAt] // // Staked KEEP is stored in an uint128, // which is sufficient because KEEP tokens have 18 decimals (2^60) // and there will be at most 10^9 KEEP in existence (2^30). // // Creation and undelegation times are stored in an uint64 each. // Thus uint64s would be sufficient for around 3*10^11 years. uint256 constant TIMESTAMP_WIDTH = 64; uint256 constant AMOUNT_WIDTH = 128; uint256 constant TIMESTAMP_MAX = (2**TIMESTAMP_WIDTH) - 1; uint256 constant AMOUNT_MAX = (2**AMOUNT_WIDTH) - 1; uint256 constant CREATION_SHIFT = TIMESTAMP_WIDTH; uint256 constant AMOUNT_SHIFT = 2 * TIMESTAMP_WIDTH; function pack( uint256 amount, uint256 createdAt, uint256 undelegatedAt ) internal pure returns (uint256) { // Check for staked amount overflow. // We shouldn't actually ever need this. require( amount <= AMOUNT_MAX, "uint128 overflow" ); // Bitwise OR the timestamps together. // The resulting number is equal or greater than either, // and tells if we have a bit set outside the 64 available bits. require( (createdAt | undelegatedAt) <= TIMESTAMP_MAX, "uint64 overflow" ); return (amount << AMOUNT_SHIFT | createdAt << CREATION_SHIFT | undelegatedAt); } function unpack(uint256 packedParams) internal pure returns ( uint256 amount, uint256 createdAt, uint256 undelegatedAt ) { amount = getAmount(packedParams); createdAt = getCreationTimestamp(packedParams); undelegatedAt = getUndelegationTimestamp(packedParams); } function getAmount(uint256 packedParams) internal pure returns (uint256) { return (packedParams >> AMOUNT_SHIFT) & AMOUNT_MAX; } function setAmount( uint256 packedParams, uint256 amount ) internal pure returns (uint256) { return pack( amount, getCreationTimestamp(packedParams), getUndelegationTimestamp(packedParams) ); } function getCreationTimestamp(uint256 packedParams) internal pure returns (uint256) { return (packedParams >> CREATION_SHIFT) & TIMESTAMP_MAX; } function setCreationTimestamp( uint256 packedParams, uint256 creationTimestamp ) internal pure returns (uint256) { return pack( getAmount(packedParams), creationTimestamp, getUndelegationTimestamp(packedParams) ); } function getUndelegationTimestamp(uint256 packedParams) internal pure returns (uint256) { return packedParams & TIMESTAMP_MAX; } function setUndelegationTimestamp( uint256 packedParams, uint256 undelegationTimestamp ) internal pure returns (uint256) { return pack( getAmount(packedParams), getCreationTimestamp(packedParams), undelegationTimestamp ); } function setAmountAndCreationTimestamp( uint256 packedParams, uint256 amount, uint256 creationTimestamp ) internal pure returns (uint256) { return pack( amount, creationTimestamp, getUndelegationTimestamp(packedParams) ); } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; /// @notice MinimumStakeSchedule defines the minimum stake parametrization and /// schedule. It starts with a minimum stake of 100k KEEP. Over the following /// 2 years, the minimum stake is lowered periodically using a uniform stepwise /// function, eventually ending at 10k. library MinimumStakeSchedule { using SafeMath for uint256; // 2 years in seconds (seconds per day * days in a year * years) uint256 public constant schedule = 86400 * 365 * 2; uint256 public constant steps = 10; uint256 public constant base = 10000 * 1e18; /// @notice Returns the current value of the minimum stake. The minimum /// stake is lowered periodically over the course of 2 years since the time /// of the shedule start and eventually ends at 10k KEEP. function current(uint256 scheduleStart) internal view returns (uint256) { if (now < scheduleStart.add(schedule)) { uint256 currentStep = steps.mul(now.sub(scheduleStart)).div(schedule); return base.mul(steps.sub(currentStep)); } return base; } } pragma solidity 0.5.17; import "../../TokenGrant.sol"; import "../../TokenStakingEscrow.sol"; import "../..//utils/BytesLib.sol"; import "../RolesLookup.sol"; /// @notice TokenStaking contract library allowing to capture the details of /// delegated grants and offering functions allowing to check grantee /// authentication for stake delegation management. library GrantStaking { using BytesLib for bytes; using RolesLookup for address payable; /// @dev Grant ID is flagged with the most significant bit set, to /// distinguish the grant ID `0` from default (null) value. The flag is /// toggled with bitwise XOR (`^`) which keeps all other bits intact but /// flips the flag bit. The flag should be set before writing to /// `operatorToGrant`, and unset after reading from `operatorToGrant` /// before using the value. uint256 constant GRANT_ID_FLAG = 1 << 255; struct Storage { /// @dev Do not read or write this mapping directly; please use /// `hasGrantDelegated`, `setGrantForOperator`, and `getGrantForOperator` /// instead. mapping (address => uint256) _operatorToGrant; } /// @notice Tries to capture delegation data if the pending delegation has /// been created from a grant. There are only two possibilities and they /// need to be handled differently: delegation comes from the TokenGrant /// contract or delegation comes from TokenStakingEscrow. In those two cases /// grant ID has to be captured in a different way. /// @dev In case of a delegation from the escrow, it is expected that grant /// ID is passed in extraData bytes array. When the delegation comes from /// the TokenGrant contract, delegation data are obtained directly from that /// contract using `tryCapturingGrantId` function. /// @param tokenGrant KEEP token grant contract reference. /// @param escrow TokenStakingEscrow contract address. /// @param from The owner of the tokens who approved them to transfer. /// @param operator The operator tokens are delegated to. /// @param extraData Data for stake delegation, as passed to /// `receiveApproval` of `TokenStaking`. function tryCapturingDelegationData( Storage storage self, TokenGrant tokenGrant, address escrow, address from, address operator, bytes memory extraData ) public returns (bool, uint256) { if (from == escrow) { require(extraData.length == 92, "Corrupted delegation data from escrow"); uint256 grantId = extraData.toUint(60); setGrantForOperator(self, operator, grantId); return (true, grantId); } else { return tryCapturingGrantId(self, tokenGrant, operator); } } /// @notice Checks if the delegation for the given operator has been created /// from a grant defined in the passed token grant contract and if so, /// captures the grant ID for that delegation. /// Grant ID can be later retrieved based on the operator address and used /// to authenticate grantee or to fetch the information about grant /// unlocking schedule for escrow. /// @param tokenGrant KEEP token grant contract reference. /// @param operator The operator tokens are delegated to. function tryCapturingGrantId( Storage storage self, TokenGrant tokenGrant, address operator ) internal returns (bool, uint256) { (bool success, bytes memory data) = address(tokenGrant).call( abi.encodeWithSignature("getGrantStakeDetails(address)", operator) ); if (success) { (uint256 grantId,,address grantStakingContract) = abi.decode( data, (uint256, uint256, address) ); // Double-check if the delegation in TokenGrant has been defined // for this staking contract. If not, it means it's an old // delegation and the current one does not come from a grant. // The scenario covered here is: // - grantee delegated to operator A from a TokenGrant using another // staking contract, // - someone delegates to operator A using liquid tokens and this // staking contract. // Without this check, we'd consider the second delegation as coming // from a grant. if (address(this) != grantStakingContract) { return (false, 0); } setGrantForOperator(self, operator, grantId); return (true, grantId); } return (false, 0); } /// @notice Returns true if the given operator operates on stake delegated /// from a grant. false is returned otherwise. /// @param operator The operator to which tokens from a grant are /// potentially delegated to. function hasGrantDelegated( Storage storage self, address operator ) public view returns (bool) { return self._operatorToGrant[operator] != 0; } /// @notice Associates operator with the provided grant ID. It means that /// the given operator delegates on stake from the grant with this ID. /// @param operator The operator tokens are delegate to. /// @param grantId Identifier of a grant from which the tokens are delegated /// to. function setGrantForOperator( Storage storage self, address operator, uint256 grantId ) public { self._operatorToGrant[operator] = grantId ^ GRANT_ID_FLAG; } /// @notice Returns grant ID for the provided operator. If the operator /// does not operate on stake delegated from a grant, function reverts. /// @dev To avoid reverting in case the grant ID for the operator does not /// exist, consider calling hasGrantDelegated before. /// @param operator The operator tokens are delegate to. function getGrantForOperator( Storage storage self, address operator ) public view returns (uint256) { uint256 grantId = self._operatorToGrant[operator]; require (grantId != 0, "No grant for the operator"); return grantId ^ GRANT_ID_FLAG; } /// @notice Returns true if msg.sender is grantee eligible to trigger stake /// undelegation for this operator. Function checks both standard grantee /// and managed grantee case. /// @param operator The operator tokens are delegated to. /// @param tokenGrant KEEP token grant contract reference. function canUndelegate( Storage storage self, address operator, TokenGrant tokenGrant ) public returns (bool) { // First of all, we need to see if the operator has grant delegated. // If not, we don't need to bother about checking grantee or // managed grantee and we just return false. if (!hasGrantDelegated(self, operator)) { return false; } uint256 grantId = getGrantForOperator(self, operator); (,,,,uint256 revokedAt, address grantee) = tokenGrant.getGrant(grantId); // Is msg.sender grantee of a standard grant? if (msg.sender == grantee) { return true; } // If not, we need to dig deeper and see if we are dealing with // a grantee from a managed grant. if ((msg.sender).isManagedGranteeForGrant(grantId, tokenGrant)) { return true; } // There is only one possibility left - grant has been revoked and // grant manager wants to take back delegated tokens. if (revokedAt == 0) { return false; } (address grantManager,,,,) = tokenGrant.getGrantUnlockingSchedule(grantId); return msg.sender == grantManager; } } /** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./libraries/grant/UnlockingSchedule.sol"; import "./utils/BytesLib.sol"; import "./KeepToken.sol"; import "./utils/BytesLib.sol"; import "./TokenGrant.sol"; import "./ManagedGrant.sol"; import "./TokenSender.sol"; /// @title TokenStakingEscrow /// @notice Escrow lets the staking contract to deposit undelegated, granted /// tokens and either withdraw them based on the grant unlocking schedule or /// re-delegate them to another operator. /// @dev The owner of TokenStakingEscrow is TokenStaking contract and only owner /// can deposit. This contract works with an assumption that operator is unique /// in the scope of `TokenStaking`, that is, no more than one delegation in the /// `TokenStaking` can be done do the given operator ever. Even if the previous /// delegation ended, operator address cannot be reused. contract TokenStakingEscrow is Ownable { using SafeERC20 for IERC20; using SafeMath for uint256; using BytesLib for bytes; using UnlockingSchedule for uint256; event Deposited( address indexed operator, uint256 indexed grantId, uint256 amount ); event DepositRedelegated( address indexed previousOperator, address indexed newOperator, uint256 indexed grantId, uint256 amount ); event DepositWithdrawn( address indexed operator, address indexed grantee, uint256 amount ); event RevokedDepositWithdrawn( address indexed operator, address indexed grantManager, uint256 amount ); event EscrowAuthorized( address indexed grantManager, address escrow ); IERC20 public keepToken; TokenGrant public tokenGrant; struct Deposit { uint256 grantId; uint256 amount; uint256 withdrawn; uint256 redelegated; } // operator address -> KEEP deposit mapping(address => Deposit) internal deposits; // Other escrows authorized by grant manager. Grantee may request to migrate // tokens to another authorized escrow. // grant manager -> escrow -> authorized? mapping(address => mapping (address => bool)) internal authorizedEscrows; constructor( KeepToken _keepToken, TokenGrant _tokenGrant ) public { keepToken = _keepToken; tokenGrant = _tokenGrant; } /// @notice receiveApproval accepts deposits from staking contract and /// stores them in the escrow by the operator address from which they were /// undelegated. Function expects operator address and grant identifier to /// be passed as ABI-encoded information in extraData. Grant with the given /// identifier has to exist. /// @param from Address depositing tokens - it has to be the address of /// TokenStaking contract owning TokenStakingEscrow. /// @param value The amount of KEEP tokens deposited. /// @param token The address of KEEP token contract. /// @param extraData ABI-encoded data containing operator address (32 bytes) /// and grant ID (32 bytes). function receiveApproval( address from, uint256 value, address token, bytes memory extraData ) public { require(IERC20(token) == keepToken, "Not a KEEP token"); require(msg.sender == token, "KEEP token is not the sender"); require(extraData.length == 64, "Unexpected data length"); (address operator, uint256 grantId) = abi.decode( extraData, (address, uint256) ); receiveDeposit(from, value, operator, grantId); } /// @notice Redelegates deposit or part of the deposit to another operator. /// Uses the same staking contract as the original delegation. /// @param previousOperator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. /// @dev Only grantee is allowed to call this function. For managed grant, /// caller has to be the managed grantee. /// @param amount Amount of tokens to delegate. /// @param extraData Data for stake delegation. This byte array must have /// the following values concatenated: /// - Beneficiary address (20 bytes) /// - Operator address (20 bytes) /// - Authorizer address (20 bytes) function redelegate( address previousOperator, uint256 amount, bytes memory extraData ) public { require(extraData.length == 60, "Corrupted delegation data"); Deposit memory deposit = deposits[previousOperator]; uint256 grantId = deposit.grantId; address newOperator = extraData.toAddress(20); require(isGrantee(msg.sender, grantId), "Not authorized"); require(getAmountRevoked(grantId) == 0, "Grant revoked"); require( availableAmount(previousOperator) >= amount, "Insufficient balance" ); require( !hasDeposit(newOperator), "Redelegating to previously used operator is not allowed" ); deposits[previousOperator].redelegated = deposit.redelegated.add(amount); TokenSender(address(keepToken)).approveAndCall( owner(), // TokenStaking contract associated with the escrow amount, abi.encodePacked(extraData, grantId) ); emit DepositRedelegated( previousOperator, newOperator, grantId, amount ); } /// @notice Returns true if there is a deposit for the given operator in /// the escrow. Otherwise, returns false. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function hasDeposit(address operator) public view returns (bool) { return depositedAmount(operator) > 0; } /// @notice Returns the currently available amount deposited in the escrow /// that may or may not be currently withdrawable. The available amount /// is the amount initially deposited minus the amount withdrawn and /// redelegated so far from that deposit. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function availableAmount(address operator) public view returns (uint256) { Deposit memory deposit = deposits[operator]; return deposit.amount.sub(deposit.withdrawn).sub(deposit.redelegated); } /// @notice Returns the total amount deposited in the escrow after /// undelegating it from the provided operator. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function depositedAmount(address operator) public view returns (uint256) { return deposits[operator].amount; } /// @notice Returns grant ID for the amount deposited in the escrow after /// undelegating it from the provided operator. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function depositGrantId(address operator) public view returns (uint256) { return deposits[operator].grantId; } /// @notice Returns the amount withdrawn so far from the value deposited /// in the escrow contract after undelegating it from the provided operator. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function depositWithdrawnAmount(address operator) public view returns (uint256) { return deposits[operator].withdrawn; } /// @notice Returns the total amount redelegated so far from the value /// deposited in the escrow contract after undelegating it from the provided /// operator. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function depositRedelegatedAmount(address operator) public view returns (uint256) { return deposits[operator].redelegated; } /// @notice Returns the currently withdrawable amount that was previously /// deposited in the escrow after undelegating it from the provided operator. /// Tokens are unlocked based on their grant unlocking schedule. /// Function returns 0 for non-existing deposits and revoked grants if they /// have been revoked before they fully unlocked. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function withdrawable(address operator) public view returns (uint256) { Deposit memory deposit = deposits[operator]; // Staked tokens can be only withdrawn by grantee for non-revoked grant // assuming that grant has not fully unlocked before it's been // revoked. // // It is not possible for the escrow to determine the number of tokens // it should return to the grantee of a revoked grant given different // possible staking contracts and staking policies. // // If the entire grant unlocked before it's been reverted, escrow // lets to withdraw the entire deposited amount. if (getAmountRevoked(deposit.grantId) == 0) { ( uint256 duration, uint256 start, uint256 cliff ) = getUnlockingSchedule(deposit.grantId); uint256 unlocked = now.getUnlockedAmount( deposit.amount, duration, start, cliff ); if (deposit.withdrawn.add(deposit.redelegated) < unlocked) { return unlocked.sub(deposit.withdrawn).sub(deposit.redelegated); } } return 0; } /// @notice Withdraws currently unlocked tokens deposited in the escrow /// after undelegating them from the provided operator. Only grantee or /// operator can call this function. Important: this function can not be /// called for a `ManagedGrant` grantee. This may lead to locking tokens. /// For `ManagedGrant`, please use `withdrawToManagedGrantee` instead. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function withdraw(address operator) public { Deposit memory deposit = deposits[operator]; address grantee = getGrantee(deposit.grantId); // Make sure this function is not called for a managed grant. // If called for a managed grant, tokens could be locked there. // Better be safe than sorry. (bool success, ) = address(this).call( abi.encodeWithSignature("getManagedGrantee(address)", grantee) ); require(!success, "Can not be called for managed grant"); require( msg.sender == grantee || msg.sender == operator, "Only grantee or operator can withdraw" ); withdraw(deposit, operator, grantee); } /// @notice Withdraws currently unlocked tokens deposited in the escrow /// after undelegating them from the provided operator. Only grantee or /// operator can call this function. This function works only for /// `ManagedGrant` grantees. For a standard grant, please use `withdraw` /// instead. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function withdrawToManagedGrantee(address operator) public { Deposit memory deposit = deposits[operator]; address managedGrant = getGrantee(deposit.grantId); address grantee = getManagedGrantee(managedGrant); require( msg.sender == grantee || msg.sender == operator, "Only grantee or operator can withdraw" ); withdraw(deposit, operator, grantee); } /// @notice Migrates all available tokens to another authorized escrow. /// Can be requested only by grantee. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. /// @param receivingEscrow Escrow to which tokens should be migrated. /// @dev The receiving escrow needs to accept deposits from this escrow, at /// least for the period of migration. function migrate( address operator, address receivingEscrow ) public { Deposit memory deposit = deposits[operator]; require(isGrantee(msg.sender, deposit.grantId), "Not authorized"); address grantManager = getGrantManager(deposit.grantId); require( authorizedEscrows[grantManager][receivingEscrow], "Escrow not authorized" ); uint256 amountLeft = availableAmount(operator); deposits[operator].withdrawn = deposit.withdrawn.add(amountLeft); TokenSender(address(keepToken)).approveAndCall( receivingEscrow, amountLeft, abi.encode(operator, deposit.grantId) ); } /// @notice Withdraws the entire amount that is still deposited in the /// escrow in case the grant has been revoked. Anyone can call this function /// and the entire amount is transferred back to the grant manager. /// @param operator Address of the operator from the undelegated/canceled /// delegation from which tokens were deposited. function withdrawRevoked(address operator) public { Deposit memory deposit = deposits[operator]; require( getAmountRevoked(deposit.grantId) > 0, "No revoked tokens to withdraw" ); address grantManager = getGrantManager(deposit.grantId); withdrawRevoked(deposit, operator, grantManager); } /// @notice Used by grant manager to authorize another escrows for // funds migration. function authorizeEscrow(address anotherEscrow) public { require( anotherEscrow != address(0x0), "Escrow address can't be zero" ); authorizedEscrows[msg.sender][anotherEscrow] = true; emit EscrowAuthorized(msg.sender, anotherEscrow); } /// @notice Resolves the final grantee of ManagedGrant contract. If the /// provided address is not a ManagedGrant contract, function reverts. /// @param managedGrant Address of the managed grant contract. function getManagedGrantee( address managedGrant ) public view returns(address) { ManagedGrant grant = ManagedGrant(managedGrant); return grant.grantee(); } function receiveDeposit( address from, uint256 value, address operator, uint256 grantId ) internal { // This contract works with an assumption that operator is unique. // This is fine as long as the staking contract works with the same // assumption so we are limiting deposits to the staking contract only. require(from == owner(), "Only owner can deposit"); require( getAmountGranted(grantId) > 0, "Grant with this ID does not exist" ); require( !hasDeposit(operator), "Stake for the operator already deposited in the escrow" ); keepToken.safeTransferFrom(from, address(this), value); deposits[operator] = Deposit(grantId, value, 0, 0); emit Deposited(operator, grantId, value); } function isGrantee( address maybeGrantee, uint256 grantId ) internal returns (bool) { // Let's check the simplest case first - standard grantee. // If the given address is set as a grantee for grant with the given ID, // we return true. address grantee = getGrantee(grantId); if (maybeGrantee == grantee) { return true; } // If the given address is not a standard grantee, there is still // a chance that address is a managed grantee. We are calling // getManagedGrantee that will cast the grantee to ManagedGrant and try // to call getGrantee() function. If this call returns non-zero address, // it means we are dealing with a ManagedGrant. (, bytes memory result) = address(this).call( abi.encodeWithSignature("getManagedGrantee(address)", grantee) ); if (result.length == 0) { return false; } // At this point we know we are dealing with a ManagedGrant, so the last // thing we need to check is whether the managed grantee of that grant // is the grantee address passed as a parameter. address managedGrantee = abi.decode(result, (address)); return maybeGrantee == managedGrantee; } function withdraw( Deposit memory deposit, address operator, address grantee ) internal { uint256 amount = withdrawable(operator); deposits[operator].withdrawn = deposit.withdrawn.add(amount); keepToken.safeTransfer(grantee, amount); emit DepositWithdrawn(operator, grantee, amount); } function withdrawRevoked( Deposit memory deposit, address operator, address grantManager ) internal { uint256 amount = availableAmount(operator); deposits[operator].withdrawn = amount; keepToken.safeTransfer(grantManager, amount); emit RevokedDepositWithdrawn(operator, grantManager, amount); } function getAmountGranted(uint256 grantId) internal view returns ( uint256 amountGranted ) { (amountGranted,,,,,) = tokenGrant.getGrant(grantId); } function getAmountRevoked(uint256 grantId) internal view returns ( uint256 amountRevoked ) { (,,,amountRevoked,,) = tokenGrant.getGrant(grantId); } function getUnlockingSchedule(uint256 grantId) internal view returns ( uint256 duration, uint256 start, uint256 cliff ) { (,duration,start,cliff,) = tokenGrant.getGrantUnlockingSchedule(grantId); } function getGrantee(uint256 grantId) internal view returns ( address grantee ) { (,,,,,grantee) = tokenGrant.getGrant(grantId); } function getGrantManager(uint256 grantId) internal view returns ( address grantManager ) { (grantManager,,,,) = tokenGrant.getGrantUnlockingSchedule(grantId); } } pragma solidity ^0.5.4; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "./TokenGrant.sol"; /// @title ManagedGrant /// @notice A managed grant acts as the grantee towards the token grant contract, /// proxying instructions from the actual grantee. /// The address used by the actual grantee /// to issue instructions and withdraw tokens /// can be reassigned with the consent of the grant manager. contract ManagedGrant { using SafeERC20 for ERC20Burnable; ERC20Burnable public token; TokenGrant public tokenGrant; address public grantManager; uint256 public grantId; address public grantee; address public requestedNewGrantee; event GranteeReassignmentRequested( address newGrantee ); event GranteeReassignmentConfirmed( address oldGrantee, address newGrantee ); event GranteeReassignmentCancelled( address cancelledRequestedGrantee ); event GranteeReassignmentChanged( address previouslyRequestedGrantee, address newRequestedGrantee ); event TokensWithdrawn( address destination, uint256 amount ); constructor( address _tokenAddress, address _tokenGrant, address _grantManager, uint256 _grantId, address _grantee ) public { token = ERC20Burnable(_tokenAddress); tokenGrant = TokenGrant(_tokenGrant); grantManager = _grantManager; grantId = _grantId; grantee = _grantee; } /// @notice Request a reassignment of the grantee address. /// Can only be called by the grantee. /// @param _newGrantee The requested new grantee. function requestGranteeReassignment(address _newGrantee) public onlyGrantee noRequestedReassignment { _setRequestedNewGrantee(_newGrantee); emit GranteeReassignmentRequested(_newGrantee); } /// @notice Cancel a pending grantee reassignment request. /// Can only be called by the grantee. function cancelReassignmentRequest() public onlyGrantee withRequestedReassignment { address cancelledGrantee = requestedNewGrantee; requestedNewGrantee = address(0); emit GranteeReassignmentCancelled(cancelledGrantee); } /// @notice Change a pending reassignment request to a different grantee. /// Can only be called by the grantee. /// @param _newGrantee The address of the new requested grantee. function changeReassignmentRequest(address _newGrantee) public onlyGrantee withRequestedReassignment { address previouslyRequestedGrantee = requestedNewGrantee; require( previouslyRequestedGrantee != _newGrantee, "Unchanged reassignment request" ); _setRequestedNewGrantee(_newGrantee); emit GranteeReassignmentChanged(previouslyRequestedGrantee, _newGrantee); } /// @notice Confirm a grantee reassignment request and set the new grantee as the grantee. /// Can only be called by the grant manager. /// @param _newGrantee The address of the new grantee. /// Must match the currently requested new grantee. function confirmGranteeReassignment(address _newGrantee) public onlyManager withRequestedReassignment { address oldGrantee = grantee; require( requestedNewGrantee == _newGrantee, "Reassignment address mismatch" ); grantee = requestedNewGrantee; requestedNewGrantee = address(0); emit GranteeReassignmentConfirmed(oldGrantee, _newGrantee); } /// @notice Withdraw all unlocked tokens from the grant. function withdraw() public onlyGrantee { require( requestedNewGrantee == address(0), "Can not withdraw with pending reassignment" ); tokenGrant.withdraw(grantId); uint256 amount = token.balanceOf(address(this)); token.safeTransfer(grantee, amount); emit TokensWithdrawn(grantee, amount); } /// @notice Stake tokens from the grant. /// @param _stakingContract The contract to stake the tokens on. /// @param _amount The amount of tokens to stake. /// @param _extraData Data for the stake delegation. /// This byte array must have the following values concatenated: /// beneficiary address (20 bytes) /// operator address (20 bytes) /// authorizer address (20 bytes) function stake( address _stakingContract, uint256 _amount, bytes memory _extraData ) public onlyGrantee { tokenGrant.stake(grantId, _stakingContract, _amount, _extraData); } /// @notice Cancel delegating tokens to the given operator. function cancelStake(address _operator) public onlyGranteeOr(_operator) { tokenGrant.cancelStake(_operator); } /// @notice Begin undelegating tokens from the given operator. function undelegate(address _operator) public onlyGranteeOr(_operator) { tokenGrant.undelegate(_operator); } /// @notice Recover tokens previously staked and delegated to the operator. function recoverStake(address _operator) public { tokenGrant.recoverStake(_operator); } function _setRequestedNewGrantee(address _newGrantee) internal { require(_newGrantee != address(0), "Invalid new grantee address"); require(_newGrantee != grantee, "New grantee same as current grantee"); requestedNewGrantee = _newGrantee; } modifier withRequestedReassignment { require( requestedNewGrantee != address(0), "No reassignment requested" ); _; } modifier noRequestedReassignment { require( requestedNewGrantee == address(0), "Reassignment already requested" ); _; } modifier onlyGrantee { require( msg.sender == grantee, "Only grantee may perform this action" ); _; } modifier onlyGranteeOr(address _operator) { require( msg.sender == grantee || msg.sender == _operator, "Only grantee or operator may perform this action" ); _; } modifier onlyManager { require( msg.sender == grantManager, "Only grantManager may perform this action" ); _; } } pragma solidity 0.5.17; /// @dev Interface of sender contract for approveAndCall pattern. interface TokenSender { function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external; } pragma solidity 0.5.17; import "../utils/AddressArrayUtils.sol"; import "../StakeDelegatable.sol"; import "../TokenGrant.sol"; import "../ManagedGrant.sol"; /// @title Roles Lookup /// @notice Library facilitating lookup of roles in stake delegation setup. library RolesLookup { using AddressArrayUtils for address[]; /// @notice Returns true if the tokenOwner delegated tokens to operator /// using the provided stakeDelegatable contract. Othwerwise, returns false. /// This function works only for the case when tokenOwner own those tokens /// and those are not tokens from a grant. function isTokenOwnerForOperator( address tokenOwner, address operator, StakeDelegatable stakeDelegatable ) internal view returns (bool) { return stakeDelegatable.ownerOf(operator) == tokenOwner; } /// @notice Returns true if the grantee delegated tokens to operator /// with the provided tokenGrant contract. Otherwise, returns false. /// This function works only for the case when tokens were generated from /// a non-managed grant, that is, the grantee is a non-contract address to /// which the delegated tokens were granted. /// @dev This function does not validate the staking reltionship on /// a particular staking contract. It only checks whether the grantee /// staked at least one time with the given operator. If you are interested /// in a particular token staking contract, you need to perform additional /// check. function isGranteeForOperator( address grantee, address operator, TokenGrant tokenGrant ) internal view returns (bool) { address[] memory operators = tokenGrant.getGranteeOperators(grantee); return operators.contains(operator); } /// @notice Returns true if the grantee from the given managed grant contract /// delegated tokens to operator with the provided tokenGrant contract. /// Otherwise, returns false. In case the grantee declared by the managed /// grant contract does not match the provided grantee, function reverts. /// This function works only for cases when grantee, from TokenGrant's /// perspective, is a smart contract exposing grantee() function returning /// the final grantee. One possibility is the ManagedGrant contract. /// @dev This function does not validate the staking reltionship on /// a particular staking contract. It only checks whether the grantee /// staked at least one time with the given operator. If you are interested /// in a particular token staking contract, you need to perform additional /// check. function isManagedGranteeForOperator( address grantee, address operator, address managedGrantContract, TokenGrant tokenGrant ) internal view returns (bool) { require( ManagedGrant(managedGrantContract).grantee() == grantee, "Not a grantee of the provided contract" ); address[] memory operators = tokenGrant.getGranteeOperators( managedGrantContract ); return operators.contains(operator); } /// @notice Returns true if grant with the given ID has been created with /// managed grant pointing currently to the grantee passed as a parameter. /// @dev The function does not revert if grant has not been created with /// a managed grantee. This function is not a view because it uses low-level /// call to check if the grant has been created with a managed grant. /// It does not however modify any state. function isManagedGranteeForGrant( address grantee, uint256 grantId, TokenGrant tokenGrant ) internal returns (bool) { (,,,,, address managedGrant) = tokenGrant.getGrant(grantId); (, bytes memory result) = managedGrant.call( abi.encodeWithSignature("grantee()") ); if (result.length == 0) { return false; } address managedGrantee = abi.decode(result, (address)); return grantee == managedGrantee; } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import { AuthorityVerifier } from "../../Authorizations.sol"; import "./LockUtils.sol"; library Locks { using SafeMath for uint256; using LockUtils for LockUtils.LockSet; event StakeLocked(address indexed operator, address lockCreator, uint256 until); event LockReleased(address indexed operator, address lockCreator); event ExpiredLockReleased(address indexed operator, address lockCreator); uint256 public constant maximumLockDuration = 86400 * 200; // 200 days in seconds struct Storage { // Locks placed on the operator. // `operatorLocks[operator]` returns all locks placed on the operator. // Each authorized operator contract can place one lock on an operator. mapping(address => LockUtils.LockSet) operatorLocks; } function lockStake( Storage storage self, address operator, uint256 duration ) public { require(duration <= maximumLockDuration, "Lock duration too long"); self.operatorLocks[operator].setLock( msg.sender, uint96(block.timestamp.add(duration)) ); emit StakeLocked(operator, msg.sender, block.timestamp.add(duration)); } function releaseLock( Storage storage self, address operator ) public { self.operatorLocks[operator].releaseLock(msg.sender); emit LockReleased(operator, msg.sender); } function releaseExpiredLock( Storage storage self, address operator, address operatorContract, address authorityVerifier ) public { LockUtils.LockSet storage locks = self.operatorLocks[operator]; require( locks.contains(operatorContract), "No matching lock present" ); bool expired = block.timestamp >= locks.getLockTime(operatorContract); bool disabled = !AuthorityVerifier(authorityVerifier) .isApprovedOperatorContract(operatorContract); require( expired || disabled, "Lock still active and valid" ); locks.releaseLock(operatorContract); emit ExpiredLockReleased(operator, operatorContract); } /// @dev AuthorityVerifier is a trusted implementation and not a third-party, /// external contract. AuthorityVerifier never reverts on the check and /// has a reasonable gas consumption. function isStakeLocked( Storage storage self, address operator, address authorityVerifier ) public view returns (bool) { LockUtils.Lock[] storage _locks = self.operatorLocks[operator].locks; LockUtils.Lock memory lock; for (uint i = 0; i < _locks.length; i++) { lock = _locks[i]; if (block.timestamp < lock.expiresAt) { if ( AuthorityVerifier(authorityVerifier) .isApprovedOperatorContract(lock.creator) ) { return true; } } } return false; } function isStakeReleased( Storage storage self, address operator, address operatorContract ) public view returns (bool) { LockUtils.LockSet storage locks = self.operatorLocks[operator]; // `getLockTime` returns 0 if the lock doesn't exist, // thus we don't need to check for its presence separately. return block.timestamp >= locks.getLockTime(operatorContract); } function getLocks( Storage storage self, address operator ) public view returns (address[] memory creators, uint256[] memory expirations) { uint256 lockCount = self.operatorLocks[operator].locks.length; creators = new address[](lockCount); expirations = new uint256[](lockCount); LockUtils.Lock memory lock; for (uint i = 0; i < lockCount; i++) { lock = self.operatorLocks[operator].locks[i]; creators[i] = lock.creator; expirations[i] = lock.expiresAt; } } } /** ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ Trust math, not hardware. */ pragma solidity 0.5.17; import "./KeepRegistry.sol"; /// @title AuthorityDelegator /// @notice An operator contract can delegate authority to other operator /// contracts by implementing the AuthorityDelegator interface. /// /// To delegate authority, /// the recipient of delegated authority must call `claimDelegatedAuthority`, /// specifying the contract it wants delegated authority from. /// The staking contract calls `delegator.__isRecognized(recipient)` /// and if the call returns `true`, /// the named delegator contract is set as the recipient's authority delegator. /// Any future checks of registry approval or per-operator authorization /// will transparently mirror the delegator's status. /// /// Authority can be delegated recursively; /// an operator contract receiving delegated authority /// can recognize other operator contracts as recipients of its authority. interface AuthorityDelegator { function __isRecognized(address delegatedAuthorityRecipient) external returns (bool); } /// @title AuthorityVerifier /// @notice An operator contract can delegate authority to other operator /// contracts. Entry in the registry is not updated and source contract remains /// listed there as authorized. This interface is a verifier that support verification /// of contract authorization in case of authority delegation from the source contract. interface AuthorityVerifier { /// @notice Returns true if the given operator contract has been approved /// for use. The function never reverts. function isApprovedOperatorContract(address _operatorContract) external view returns (bool); } contract Authorizations is AuthorityVerifier { // Authorized operator contracts. mapping(address => mapping (address => bool)) internal authorizations; // Granters of delegated authority to operator contracts. // E.g. keep factories granting delegated authority to keeps. // `delegatedAuthority[keep] = factory` mapping(address => address) internal delegatedAuthority; // Registry contract with a list of approved operator contracts and upgraders. KeepRegistry internal registry; modifier onlyApprovedOperatorContract(address operatorContract) { require( isApprovedOperatorContract(operatorContract), "Operator contract unapproved" ); _; } constructor(KeepRegistry _registry) public { registry = _registry; } /// @notice Gets the authorizer for the specified operator address. /// @return Authorizer address. function authorizerOf(address _operator) public view returns (address); /// @notice Authorizes operator contract to access staked token balance of /// the provided operator. Can only be executed by stake operator authorizer. /// Contracts using delegated authority /// cannot be authorized with `authorizeOperatorContract`. /// Instead, authorize `getAuthoritySource(_operatorContract)`. /// @param _operator address of stake operator. /// @param _operatorContract address of operator contract. function authorizeOperatorContract(address _operator, address _operatorContract) public onlyApprovedOperatorContract(_operatorContract) { require( authorizerOf(_operator) == msg.sender, "Not operator authorizer" ); require( getAuthoritySource(_operatorContract) == _operatorContract, "Delegated authority used" ); authorizations[_operatorContract][_operator] = true; } /// @notice Checks if operator contract has access to the staked token balance of /// the provided operator. /// @param _operator address of stake operator. /// @param _operatorContract address of operator contract. function isAuthorizedForOperator( address _operator, address _operatorContract ) public view returns (bool) { return authorizations[getAuthoritySource(_operatorContract)][_operator]; } /// @notice Grant the sender the same authority as `delegatedAuthoritySource` /// @dev If `delegatedAuthoritySource` is an approved operator contract /// and recognizes the claimant, this relationship will be recorded in /// `delegatedAuthority`. Later, the claimant can slash, seize, place locks etc. /// on operators that have authorized the `delegatedAuthoritySource`. /// If the `delegatedAuthoritySource` is disabled with the panic button, /// any recipients of delegated authority from it will also be disabled. function claimDelegatedAuthority( address delegatedAuthoritySource ) public onlyApprovedOperatorContract(delegatedAuthoritySource) { require( AuthorityDelegator(delegatedAuthoritySource).__isRecognized(msg.sender), "Unrecognized claimant" ); delegatedAuthority[msg.sender] = delegatedAuthoritySource; } /// @notice Checks if the operator contract is authorized in the registry. /// If the contract uses delegated authority it checks authorization of the /// source contract. /// @param _operatorContract address of operator contract. /// @return True if operator contract is approved, false if operator contract /// has not been approved or if it was disabled by the panic button. function isApprovedOperatorContract(address _operatorContract) public view returns (bool) { return registry.isApprovedOperatorContract( getAuthoritySource(_operatorContract) ); } /// @notice Get the source of the operator contract's authority. /// If the contract uses delegated authority, /// returns the original source of the delegated authority. /// If the contract doesn't use delegated authority, /// returns the contract itself. /// Authorize `getAuthoritySource(operatorContract)` /// to grant `operatorContract` the authority to penalize an operator. function getAuthoritySource( address operatorContract ) public view returns (address) { address delegatedAuthoritySource = delegatedAuthority[operatorContract]; if (delegatedAuthoritySource == address(0)) { return operatorContract; } return getAuthoritySource(delegatedAuthoritySource); } } pragma solidity 0.5.17; library LockUtils { struct Lock { address creator; uint96 expiresAt; } /// @notice The LockSet is like an array of unique `uint256`s, /// but additionally supports O(1) membership tests and removals. /// @dev Because the LockSet relies on a mapping, /// it can only be used in storage, not in memory. struct LockSet { // locks[positions[lock.creator] - 1] = lock Lock[] locks; mapping(address => uint256) positions; } /// @notice Check whether the LockSet `self` contains a lock by `creator` function contains(LockSet storage self, address creator) internal view returns (bool) { return (self.positions[creator] != 0); } function getLockTime(LockSet storage self, address creator) internal view returns (uint96) { uint256 positionPlusOne = self.positions[creator]; if (positionPlusOne == 0) { return 0; } return self.locks[positionPlusOne - 1].expiresAt; } /// @notice Set the lock of `creator` to `expiresAt`, /// overriding the current value if any. function setLock( LockSet storage self, address _creator, uint96 _expiresAt ) internal { uint256 positionPlusOne = self.positions[_creator]; Lock memory lock = Lock(_creator, _expiresAt); // No existing lock if (positionPlusOne == 0) { self.locks.push(lock); self.positions[_creator] = self.locks.length; // Existing lock present } else { self.locks[positionPlusOne - 1].expiresAt = _expiresAt; } } /// @notice Remove the lock of `creator`. /// If no lock present, do nothing. function releaseLock( LockSet storage self, address _creator ) internal { uint256 positionPlusOne = self.positions[_creator]; if (positionPlusOne != 0) { uint256 lockCount = self.locks.length; if (positionPlusOne != lockCount) { // Not the last lock, // so we need to move the last lock into the emptied position. Lock memory lastLock = self.locks[lockCount - 1]; self.locks[positionPlusOne - 1] = lastLock; self.positions[lastLock.creator] = positionPlusOne; } self.locks.length--; self.positions[_creator] = 0; } } /// @notice Return the locks of the LockSet `self`. function enumerate(LockSet storage self) internal view returns (Lock[] memory) { return self.locks; } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "../../TokenStakingEscrow.sol"; import "../../utils/OperatorParams.sol"; /// @notice TokenStaking contract library allowing to perform two-step stake /// top-ups for existing delegations. /// Top-up is a two-step process: it is initiated with a declared top-up value /// and after waiting for at least the initialization period it can be /// committed. library TopUps { using SafeMath for uint256; using OperatorParams for uint256; event TopUpInitiated(address indexed operator, uint256 topUp); event TopUpCompleted(address indexed operator, uint256 newAmount); struct TopUp { uint256 amount; uint256 createdAt; } struct Storage { // operator -> TopUp mapping(address => TopUp) topUps; } /// @notice Performs top-up in one step when stake is not yet initialized by /// adding the top-up amount to the stake and resetting stake initialization /// time counter. /// @dev This function should be called only for not yet initialized stake. /// @param value Top-up value, the number of tokens added to the stake. /// @param operator Operator The operator with existing delegation to which /// the tokens should be added to. /// @param operatorParams Parameters of that operator, as stored in the /// staking contract. /// @param escrow Reference to TokenStakingEscrow contract. /// @return New value of parameters. It should be updated for the operator /// in the staking contract. function instantComplete( Storage storage self, uint256 value, address operator, uint256 operatorParams, TokenStakingEscrow escrow ) public returns (uint256 newParams) { // Stake is not yet initialized so we don't need to check if the // operator is not undelegating - initializing and undelegating at the // same time is not possible. We do however, need to check whether the // operator has not canceled its previous stake for that operator, // depositing the stake it in the escrow. We do not want to allow // resurrecting operators with cancelled stake by top-ups. require( !escrow.hasDeposit(operator), "Stake for the operator already deposited in the escrow" ); require(value > 0, "Top-up value must be greater than zero"); uint256 newAmount = operatorParams.getAmount().add(value); newParams = operatorParams.setAmountAndCreationTimestamp( newAmount, block.timestamp ); emit TopUpCompleted(operator, newAmount); } /// @notice Initiates top-up of the given value for tokens delegated to /// the provided operator. If there is an existing top-up still /// initializing, top-up values are summed up and initialization period /// is set to the current block timestamp. /// @dev This function should be called only for active operators with /// initialized stake. /// @param value Top-up value, the number of tokens added to the stake. /// @param operator Operator The operator with existing delegation to which /// the tokens should be added to. /// @param operatorParams Parameters of that operator, as stored in the /// staking contract. /// @param escrow Reference to TokenStakingEscrow contract. function initiate( Storage storage self, uint256 value, address operator, uint256 operatorParams, TokenStakingEscrow escrow ) public { // Stake is initialized, the operator is still active so we need // to check if it's not undelegating. require(!isUndelegating(operatorParams), "Stake undelegated"); // We also need to check if the stake for the operator is not already // in the escrow because it's been previously cancelled. require( !escrow.hasDeposit(operator), "Stake for the operator already deposited in the escrow" ); require(value > 0, "Top-up value must be greater than zero"); TopUp memory awaiting = self.topUps[operator]; self.topUps[operator] = TopUp(awaiting.amount.add(value), now); emit TopUpInitiated(operator, value); } /// @notice Commits the top-up if it passed the initialization period. /// Tokens are added to the stake once the top-up is committed. /// @param operator Operator The operator with a pending stake top-up. /// @param initializationPeriod Stake initialization period. function commit( Storage storage self, address operator, uint256 operatorParams, uint256 initializationPeriod ) public returns (uint256 newParams) { TopUp memory topUp = self.topUps[operator]; require(topUp.amount > 0, "No top up to commit"); require( now > topUp.createdAt.add(initializationPeriod), "Stake is initializing" ); uint256 newAmount = operatorParams.getAmount().add(topUp.amount); newParams = operatorParams.setAmount(newAmount); delete self.topUps[operator]; emit TopUpCompleted(operator, newAmount); } /// @notice Cancels pending, initiating top-up. If there is no initiating /// top-up for the operator, function does nothing. This function should be /// used when the stake is recovered to return tokens from a pending, /// initiating top-up. /// @param operator Operator The operator from which the stake is recovered. function cancel( Storage storage self, address operator ) public returns (uint256) { TopUp memory topUp = self.topUps[operator]; if (topUp.amount == 0) { return 0; } delete self.topUps[operator]; return topUp.amount; } /// @notice Returns true if the given operatorParams indicate that the /// operator is undelegating its stake or that it completed stake /// undelegation. /// @param operatorParams Parameters of the operator, as stored in the /// staking contract. function isUndelegating(uint256 operatorParams) internal view returns (bool) { uint256 undelegatedAt = operatorParams.getUndelegationTimestamp(); return (undelegatedAt != 0) && (block.timestamp > undelegatedAt); } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; library PercentUtils { using SafeMath for uint256; // Return `b`% of `a` // 200.percent(40) == 80 // Commutative, works both ways function percent(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(b).div(100); } // Return `a` as percentage of `b`: // 80.asPercentOf(200) == 40 function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(100).div(b); } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./TokenStaking.sol"; import "./TokenSender.sol"; import "./utils/BytesLib.sol"; /// @dev Interface of sender contract for approveAndCall pattern. interface tokenSender { function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external; } contract TokenGrantStake { using SafeMath for uint256; using BytesLib for bytes; ERC20Burnable token; TokenStaking tokenStaking; address tokenGrant; // Address of the master grant contract. uint256 grantId; // ID of the grant for this stake. uint256 amount; // Amount of staked tokens. address operator; // Operator of the stake. constructor( address _tokenAddress, uint256 _grantId, address _tokenStaking ) public { require( _tokenAddress != address(0x0), "Token address can't be zero." ); require( _tokenStaking != address(0x0), "Staking contract address can't be zero." ); token = ERC20Burnable(_tokenAddress); tokenGrant = msg.sender; grantId = _grantId; tokenStaking = TokenStaking(_tokenStaking); } function stake( uint256 _amount, bytes memory _extraData ) public onlyGrant { amount = _amount; operator = _extraData.toAddress(20); tokenSender(address(token)).approveAndCall( address(tokenStaking), _amount, _extraData ); } function getGrantId() public view onlyGrant returns (uint256) { return grantId; } function getAmount() public view onlyGrant returns (uint256) { return amount; } function getStakingContract() public view onlyGrant returns (address) { return address(tokenStaking); } function getDetails() public view onlyGrant returns ( uint256 _grantId, uint256 _amount, address _tokenStaking ) { return ( grantId, amount, address(tokenStaking) ); } function cancelStake() public onlyGrant returns (uint256) { tokenStaking.cancelStake(operator); return returnTokens(); } function undelegate() public onlyGrant { tokenStaking.undelegate(operator); } function recoverStake() public onlyGrant returns (uint256) { tokenStaking.recoverStake(operator); return returnTokens(); } function returnTokens() internal returns (uint256) { uint256 returnedAmount = token.balanceOf(address(this)); amount -= returnedAmount; token.transfer(tokenGrant, returnedAmount); return returnedAmount; } modifier onlyGrant { require( msg.sender == tokenGrant, "For token grant contract only" ); _; } } pragma solidity 0.5.17; /// @title GrantStakingPolicy /// @notice A staking policy defines the function `getStakeableAmount` /// which calculates how many tokens may be staked from a token grant. contract GrantStakingPolicy { function getStakeableAmount( uint256 _now, uint256 grantedAmount, uint256 duration, uint256 start, uint256 cliff, uint256 withdrawn) public view returns (uint256); } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; library UnlockingSchedule { using SafeMath for uint256; function getUnlockedAmount( uint256 _now, uint256 grantedAmount, uint256 duration, uint256 start, uint256 cliff ) internal pure returns (uint256) { bool cliffNotReached = _now < cliff; if (cliffNotReached) { return 0; } uint256 timeElapsed = _now.sub(start); bool unlockingPeriodFinished = timeElapsed >= duration; if (unlockingPeriodFinished) { return grantedAmount; } return grantedAmount.mul(timeElapsed).div(duration); } } pragma solidity 0.5.17; /* Verison pulled from https://github.com/summa-tx/bitcoin-spv/blob/2535e4edaeaac4b2b095903fce684ae1c05761bc/solidity/contracts/BytesLib.sol */ /* https://github.com/GNSPS/solidity-bytes-utils/ This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. For more information, please refer to <https://unlicense.org> */ /** @title BytesLib **/ /** @author https://github.com/GNSPS **/ library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes_slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes_slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes_slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes_slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes_slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes_slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) { uint _end = _start + _length; require(_end > _start && _bytes.length >= _end, "Slice out of bounds"); assembly { // Alloc bytes array with additional 32 bytes afterspace and assign it's size res := mload(0x40) mstore(0x40, add(add(res, 64), _length)) mstore(res, _length) // Compute distance between source and destination pointers let diff := sub(res, add(_bytes, _start)) for { let src := add(add(_bytes, 32), _start) let end := add(src, _length) } lt(src, end) { src := add(src, 32) } { mstore(add(src, diff), mload(src)) } } } function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) { uint _totalLen = _start + 20; require(_totalLen > _start && _bytes.length >= _totalLen, "Address conversion out of bounds."); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint _start) internal pure returns (uint8) { require(_bytes.length >= (_start + 1), "Uint8 conversion out of bounds."); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) { uint _totalLen = _start + 32; require(_totalLen > _start && _bytes.length >= _totalLen, "Uint conversion out of bounds."); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes_slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes_slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } function toBytes32(bytes memory _source) pure internal returns (bytes32 result) { if (_source.length == 0) { return 0x0; } assembly { result := mload(add(_source, 32)) } } function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) { uint _end = _start + _length; require(_end > _start && _bytes.length >= _end, "Slice out of bounds"); assembly { result := keccak256(add(add(_bytes, 32), _start), _length) } } } pragma solidity 0.5.17; /// @title KeepRegistry /// @notice Governance owned registry of approved contracts and roles. contract KeepRegistry { enum ContractStatus {New, Approved, Disabled} // Governance role is to enable recovery from key compromise by rekeying // other roles. Also, it can disable operator contract panic buttons // permanently. address public governance; // Registry Keeper maintains approved operator contracts. Each operator // contract must be approved before it can be authorized by a staker or // used by a service contract. address public registryKeeper; // Each operator contract has a Panic Button which can disable malicious // or malfunctioning contract that have been previously approved by the // Registry Keeper. // // New operator contract added to the registry has a default panic button // value assigned (defaultPanicButton). Panic button for each operator // contract can be later updated by Governance to individual value. // // It is possible to disable panic button for individual contract by // setting the panic button to zero address. In such case, operator contract // can not be disabled and is permanently approved in the registry. mapping(address => address) public panicButtons; // Default panic button for each new operator contract added to the // registry. Can be later updated for each contract. address public defaultPanicButton; // Each service contract has a Operator Contract Upgrader whose purpose // is to manage operator contracts for that specific service contract. // The Operator Contract Upgrader can add new operator contracts to the // service contract’s operator contract list, and deprecate old ones. mapping(address => address) public operatorContractUpgraders; // Operator contract may have a Service Contract Upgrader whose purpose is // to manage service contracts for that specific operator contract. // Service Contract Upgrader can add and remove service contracts // from the list of service contracts approved to work with the operator // contract. List of service contracts is maintained in the operator // contract and is optional - not every operator contract needs to have // a list of service contracts it wants to cooperate with. mapping(address => address) public serviceContractUpgraders; // The registry of operator contracts mapping(address => ContractStatus) public operatorContracts; event OperatorContractApproved(address operatorContract); event OperatorContractDisabled(address operatorContract); event GovernanceUpdated(address governance); event RegistryKeeperUpdated(address registryKeeper); event DefaultPanicButtonUpdated(address defaultPanicButton); event OperatorContractPanicButtonDisabled(address operatorContract); event OperatorContractPanicButtonUpdated( address operatorContract, address panicButton ); event OperatorContractUpgraderUpdated( address serviceContract, address upgrader ); event ServiceContractUpgraderUpdated( address operatorContract, address keeper ); modifier onlyGovernance() { require(governance == msg.sender, "Not authorized"); _; } modifier onlyRegistryKeeper() { require(registryKeeper == msg.sender, "Not authorized"); _; } modifier onlyPanicButton(address _operatorContract) { address panicButton = panicButtons[_operatorContract]; require(panicButton != address(0), "Panic button disabled"); require(panicButton == msg.sender, "Not authorized"); _; } modifier onlyForNewContract(address _operatorContract) { require( isNewOperatorContract(_operatorContract), "Not a new operator contract" ); _; } modifier onlyForApprovedContract(address _operatorContract) { require( isApprovedOperatorContract(_operatorContract), "Not an approved operator contract" ); _; } constructor() public { governance = msg.sender; registryKeeper = msg.sender; defaultPanicButton = msg.sender; } function setGovernance(address _governance) public onlyGovernance { governance = _governance; emit GovernanceUpdated(governance); } function setRegistryKeeper(address _registryKeeper) public onlyGovernance { registryKeeper = _registryKeeper; emit RegistryKeeperUpdated(registryKeeper); } function setDefaultPanicButton(address _panicButton) public onlyGovernance { defaultPanicButton = _panicButton; emit DefaultPanicButtonUpdated(defaultPanicButton); } function setOperatorContractPanicButton( address _operatorContract, address _panicButton ) public onlyForApprovedContract(_operatorContract) onlyGovernance { require( panicButtons[_operatorContract] != address(0), "Disabled panic button cannot be updated" ); require( _panicButton != address(0), "Panic button must be non-zero address" ); panicButtons[_operatorContract] = _panicButton; emit OperatorContractPanicButtonUpdated( _operatorContract, _panicButton ); } function disableOperatorContractPanicButton(address _operatorContract) public onlyForApprovedContract(_operatorContract) onlyGovernance { require( panicButtons[_operatorContract] != address(0), "Panic button already disabled" ); panicButtons[_operatorContract] = address(0); emit OperatorContractPanicButtonDisabled(_operatorContract); } function setOperatorContractUpgrader( address _serviceContract, address _operatorContractUpgrader ) public onlyGovernance { operatorContractUpgraders[_serviceContract] = _operatorContractUpgrader; emit OperatorContractUpgraderUpdated( _serviceContract, _operatorContractUpgrader ); } function setServiceContractUpgrader( address _operatorContract, address _serviceContractUpgrader ) public onlyGovernance { serviceContractUpgraders[_operatorContract] = _serviceContractUpgrader; emit ServiceContractUpgraderUpdated( _operatorContract, _serviceContractUpgrader ); } function approveOperatorContract(address operatorContract) public onlyForNewContract(operatorContract) onlyRegistryKeeper { operatorContracts[operatorContract] = ContractStatus.Approved; panicButtons[operatorContract] = defaultPanicButton; emit OperatorContractApproved(operatorContract); } function disableOperatorContract(address operatorContract) public onlyForApprovedContract(operatorContract) onlyPanicButton(operatorContract) { operatorContracts[operatorContract] = ContractStatus.Disabled; emit OperatorContractDisabled(operatorContract); } function isNewOperatorContract(address operatorContract) public view returns (bool) { return operatorContracts[operatorContract] == ContractStatus.New; } function isApprovedOperatorContract(address operatorContract) public view returns (bool) { return operatorContracts[operatorContract] == ContractStatus.Approved; } function operatorContractUpgraderFor(address _serviceContract) public view returns (address) { return operatorContractUpgraders[_serviceContract]; } function serviceContractUpgraderFor(address _operatorContract) public view returns (address) { return serviceContractUpgraders[_operatorContract]; } } pragma solidity 0.5.17; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./libraries/grant/UnlockingSchedule.sol"; import "./utils/BytesLib.sol"; import "./utils/AddressArrayUtils.sol"; import "./TokenStaking.sol"; import "./TokenGrantStake.sol"; import "./GrantStakingPolicy.sol"; /// @title TokenGrant /// @notice A token grant contract for a specified standard ERC20Burnable token. /// Has additional functionality to stake delegate/undelegate token grants. /// Tokens are granted to the grantee via unlocking scheme and can be /// withdrawn gradually based on the unlocking schedule cliff and unlocking duration. /// Optionally grant can be revoked by the token grant manager. contract TokenGrant { using SafeMath for uint256; using UnlockingSchedule for uint256; using SafeERC20 for ERC20Burnable; using BytesLib for bytes; using AddressArrayUtils for address[]; event TokenGrantCreated(uint256 id); event TokenGrantWithdrawn(uint256 indexed grantId, uint256 amount); event TokenGrantStaked(uint256 indexed grantId, uint256 amount, address operator); event TokenGrantRevoked(uint256 id); event StakingContractAuthorized(address indexed grantManager, address stakingContract); struct Grant { address grantManager; // Token grant manager. address grantee; // Address to which granted tokens are going to be withdrawn. uint256 revokedAt; // Timestamp at which grant was revoked by the grant manager. uint256 revokedAmount; // The number of tokens revoked from the grantee. uint256 revokedWithdrawn; // The number of tokens returned to the grant creator. bool revocable; // Whether grant manager can revoke the grant. uint256 amount; // Amount of tokens to be granted. uint256 duration; // Duration in seconds of the period in which the granted tokens will unlock. uint256 start; // Timestamp at which the linear unlocking schedule will start. uint256 cliff; // Timestamp before which no tokens will be unlocked. uint256 withdrawn; // Amount that was withdrawn to the grantee. uint256 staked; // Amount that was staked by the grantee. GrantStakingPolicy stakingPolicy; } uint256 public numGrants; ERC20Burnable public token; // Staking contracts authorized by the given grant manager. // grant manager -> staking contract -> authorized? mapping(address => mapping (address => bool)) internal stakingContracts; // Token grants. mapping(uint256 => Grant) public grants; // Token grants stakes. mapping(address => TokenGrantStake) public grantStakes; // Mapping of token grant IDs per particular address // involved in a grant as a grantee or as a grant manager. mapping(address => uint256[]) public grantIndices; // Token grants balances. Sum of all granted tokens to a grantee. // This includes granted tokens that are already unlocked and // available to be withdrawn to the grantee mapping(address => uint256) public balances; // Mapping of operator addresses per particular grantee address. mapping(address => address[]) public granteesToOperators; /// @notice Creates a token grant contract for a provided Standard ERC20Burnable token. /// @param _tokenAddress address of a token that will be linked to this contract. constructor(address _tokenAddress) public { require(_tokenAddress != address(0x0), "Token address can't be zero."); token = ERC20Burnable(_tokenAddress); } /// @notice Used by grant manager to authorize staking contract with the given /// address. function authorizeStakingContract(address _stakingContract) public { require( _stakingContract != address(0x0), "Staking contract address can't be zero" ); stakingContracts[msg.sender][_stakingContract] = true; emit StakingContractAuthorized(msg.sender, _stakingContract); } /// @notice Gets the amount of granted tokens to the specified address. /// @param _owner The address to query the grants balance of. /// @return An uint256 representing the grants balance owned by the passed address. function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /// @notice Gets the stake balance of the specified address. /// @param _address The address to query the balance of. /// @return An uint256 representing the amount staked by the passed address. function stakeBalanceOf(address _address) public view returns (uint256 balance) { for (uint i = 0; i < grantIndices[_address].length; i++) { uint256 id = grantIndices[_address][i]; balance += grants[id].staked; } return balance; } /// @notice Gets grant by ID. Returns only basic grant data. /// If you need unlocking schedule for the grant you must call `getGrantUnlockingSchedule()` /// This is to avoid Ethereum `Stack too deep` issue described here: /// https://forum.ethereum.org/discussion/2400/error-stack-too-deep-try-removing-local-variables /// @param _id ID of the token grant. /// @return amount The amount of tokens the grant provides. /// @return withdrawn The amount of tokens that have already been withdrawn /// from the grant. /// @return staked The amount of tokens that have been staked from the grant. /// @return revoked A boolean indicating whether the grant has been revoked, /// which is to say that it is no longer unlocking. /// @return grantee The grantee of grant. function getGrant(uint256 _id) public view returns ( uint256 amount, uint256 withdrawn, uint256 staked, uint256 revokedAmount, uint256 revokedAt, address grantee ) { return ( grants[_id].amount, grants[_id].withdrawn, grants[_id].staked, grants[_id].revokedAmount, grants[_id].revokedAt, grants[_id].grantee ); } /// @notice Gets grant unlocking schedule by grant ID. /// @param _id ID of the token grant. /// @return grantManager The address designated as the manager of the grant, /// which is the only address that can revoke this grant. /// @return duration The duration, in seconds, during which the tokens will /// unlocking linearly. /// @return start The start time, as a timestamp comparing to `now`. /// @return cliff The timestamp, before which none of the tokens in the grant /// will be unlocked, and after which a linear amount based on /// the time elapsed since the start will be unlocked. /// @return policy The address of the grant's staking policy. function getGrantUnlockingSchedule( uint256 _id ) public view returns ( address grantManager, uint256 duration, uint256 start, uint256 cliff, address policy ) { return ( grants[_id].grantManager, grants[_id].duration, grants[_id].start, grants[_id].cliff, address(grants[_id].stakingPolicy) ); } /// @notice Gets grant ids of the specified address. /// @param _granteeOrGrantManager The address to query. /// @return An uint256 array of grant IDs. function getGrants(address _granteeOrGrantManager) public view returns (uint256[] memory) { return grantIndices[_granteeOrGrantManager]; } /// @notice Gets operator addresses of the specified grantee address. /// @param grantee The grantee address. /// @return An array of all operators for a given grantee. function getGranteeOperators(address grantee) public view returns (address[] memory) { return granteesToOperators[grantee]; } /// @notice Gets grant stake details of the given operator. /// @param operator The operator address. /// @return grantId ID of the token grant. /// @return amount The amount of tokens the given operator delegated. /// @return stakingContract The address of staking contract. function getGrantStakeDetails(address operator) public view returns (uint256 grantId, uint256 amount, address stakingContract) { return grantStakes[operator].getDetails(); } /// @notice Receives approval of token transfer and creates a token grant with a unlocking /// schedule where balance withdrawn to the grantee gradually in a linear fashion until /// start + duration. By then all of the balance will have unlocked. /// @param _from The owner of the tokens who approved them to transfer. /// @param _amount Approved amount for the transfer to create token grant. /// @param _token Token contract address. /// @param _extraData This byte array must have the following values ABI encoded: /// grantManager (address) Address of the grant manager. /// grantee (address) Address of the grantee. /// duration (uint256) Duration in seconds of the unlocking period. /// start (uint256) Timestamp at which unlocking will start. /// cliffDuration (uint256) Duration in seconds of the cliff; /// no tokens will be unlocked until the time `start + cliff`. /// revocable (bool) Whether the token grant is revocable or not (1 or 0). /// stakingPolicy (address) Address of the staking policy for the grant. function receiveApproval(address _from, uint256 _amount, address _token, bytes memory _extraData) public { require(ERC20Burnable(_token) == token, "Token contract must be the same one linked to this contract."); require(_amount <= token.balanceOf(_from), "Sender must have enough amount."); (address _grantManager, address _grantee, uint256 _duration, uint256 _start, uint256 _cliffDuration, bool _revocable, address _stakingPolicy) = abi.decode( _extraData, (address, address, uint256, uint256, uint256, bool, address) ); require(_grantee != address(0), "Grantee address can't be zero."); require( _cliffDuration <= _duration, "Unlocking cliff duration must be less or equal total unlocking duration." ); require(_stakingPolicy != address(0), "Staking policy can't be zero."); uint256 id = numGrants++; grants[id] = Grant( _grantManager, _grantee, 0, 0, 0, _revocable, _amount, _duration, _start, _start.add(_cliffDuration), 0, 0, GrantStakingPolicy(_stakingPolicy) ); // Maintain a record to make it easier to query grants by grant manager. grantIndices[_from].push(id); // Maintain a record to make it easier to query grants by grantee. grantIndices[_grantee].push(id); token.safeTransferFrom(_from, address(this), _amount); // Maintain a record of the unlocked amount balances[_grantee] = balances[_grantee].add(_amount); emit TokenGrantCreated(id); } /// @notice Withdraws Token grant amount to grantee. /// @dev Transfers unlocked tokens of the token grant to grantee. /// @param _id Grant ID. function withdraw(uint256 _id) public { uint256 amount = withdrawable(_id); require(amount > 0, "Grant available to withdraw amount should be greater than zero."); // Update withdrawn amount. grants[_id].withdrawn = grants[_id].withdrawn.add(amount); // Update grantee grants balance. balances[grants[_id].grantee] = balances[grants[_id].grantee].sub(amount); // Transfer tokens from this contract balance to the grantee token balance. token.safeTransfer(grants[_id].grantee, amount); emit TokenGrantWithdrawn(_id, amount); } /// @notice Calculates and returns unlocked grant amount. /// @dev Calculates token grant amount that has already unlocked, /// including any tokens that have already been withdrawn by the grantee as well /// as any tokens that are available to withdraw but have not yet been withdrawn. /// @param _id Grant ID. function unlockedAmount(uint256 _id) public view returns (uint256) { Grant storage grant = grants[_id]; return (grant.revokedAt != 0) // Grant revoked -> return what is remaining ? grant.amount.sub(grant.revokedAmount) // Not revoked -> calculate the unlocked amount normally : now.getUnlockedAmount( grant.amount, grant.duration, grant.start, grant.cliff ); } /// @notice Calculates withdrawable granted amount. /// @dev Calculates the amount that has already unlocked but hasn't been withdrawn yet. /// @param _id Grant ID. function withdrawable(uint256 _id) public view returns (uint256) { uint256 unlocked = unlockedAmount(_id); uint256 withdrawn = grants[_id].withdrawn; uint256 staked = grants[_id].staked; if (withdrawn.add(staked) >= unlocked) { return 0; } else { return unlocked.sub(withdrawn).sub(staked); } } /// @notice Allows the grant manager to revoke the grant. /// @dev Granted tokens that are already unlocked (releasable amount) /// remain in the grant so grantee can still withdraw them /// the rest are revoked and withdrawable by token grant manager. /// @param _id Grant ID. function revoke(uint256 _id) public { require(grants[_id].grantManager == msg.sender, "Only grant manager can revoke."); require(grants[_id].revocable, "Grant must be revocable in the first place."); require(grants[_id].revokedAt == 0, "Grant must not be already revoked."); uint256 unlockedAmount = unlockedAmount(_id); uint256 revokedAmount = grants[_id].amount.sub(unlockedAmount); grants[_id].revokedAt = now; grants[_id].revokedAmount = revokedAmount; // Update grantee's grants balance. balances[grants[_id].grantee] = balances[grants[_id].grantee].sub(revokedAmount); emit TokenGrantRevoked(_id); } /// @notice Allows the grant manager to withdraw revoked tokens. /// @dev Will withdraw as many of the revoked tokens as possible /// without pushing the grant contract into a token deficit. /// If the grantee has staked more tokens than the unlocked amount, /// those tokens will remain in the grant until undelegated and returned, /// after which they can be withdrawn by calling `withdrawRevoked` again. /// @param _id Grant ID. function withdrawRevoked(uint256 _id) public { Grant storage grant = grants[_id]; require( grant.grantManager == msg.sender, "Only grant manager can withdraw revoked tokens." ); uint256 revoked = grant.revokedAmount; uint256 revokedWithdrawn = grant.revokedWithdrawn; require(revokedWithdrawn < revoked, "All revoked tokens withdrawn."); uint256 revokedRemaining = revoked.sub(revokedWithdrawn); uint256 totalAmount = grant.amount; uint256 staked = grant.staked; uint256 granteeWithdrawn = grant.withdrawn; uint256 remainingPresentInGrant = totalAmount.sub(staked).sub(revokedWithdrawn).sub(granteeWithdrawn); require(remainingPresentInGrant > 0, "No revoked tokens withdrawable."); uint256 amountToWithdraw = remainingPresentInGrant < revokedRemaining ? remainingPresentInGrant : revokedRemaining; token.safeTransfer(msg.sender, amountToWithdraw); grant.revokedWithdrawn += amountToWithdraw; } /// @notice Stake token grant. /// @dev Stakable token grant amount is determined /// by the grant's staking policy. /// @param _id Grant Id. /// @param _stakingContract Address of the staking contract. /// @param _amount Amount to stake. /// @param _extraData Data for stake delegation. This byte array must have /// the following values concatenated: /// - Beneficiary address (20 bytes) /// - Operator address (20 bytes) /// - Authorizer address (20 bytes) function stake(uint256 _id, address _stakingContract, uint256 _amount, bytes memory _extraData) public { require(grants[_id].grantee == msg.sender, "Only grantee of the grant can stake it."); require(grants[_id].revokedAt == 0, "Revoked grant can not be staked"); require( stakingContracts[grants[_id].grantManager][_stakingContract], "Provided staking contract is not authorized." ); // Expecting 60 bytes _extraData for stake delegation. require(_extraData.length == 60, "Stake delegation data must be provided."); address operator = _extraData.toAddress(20); // Calculate available amount. Amount of unlocked tokens minus what user already withdrawn and staked. require(_amount <= availableToStake(_id), "Must have available granted amount to stake."); // Keep staking record. TokenGrantStake grantStake = new TokenGrantStake( address(token), _id, _stakingContract ); grantStakes[operator] = grantStake; granteesToOperators[grants[_id].grantee].push(operator); grants[_id].staked += _amount; token.transfer(address(grantStake), _amount); // Staking contract expects 40 bytes _extraData for stake delegation. // 20 bytes beneficiary's address + 20 bytes operator's address. grantStake.stake(_amount, _extraData); emit TokenGrantStaked(_id, _amount, operator); } /// @notice Returns the amount of tokens available for staking from the grant. /// The stakeable amount is determined by the staking policy of the grant. /// If the grantee has withdrawn some tokens /// or the policy returns an erroneously high value, /// the stakeable amount is limited to the number of tokens remaining. /// @param _grantId Identifier of the grant function availableToStake(uint256 _grantId) public view returns (uint256) { Grant storage grant = grants[_grantId]; // Revoked grants cannot be staked. // If the grant isn't revoked, the number of revoked tokens is 0. if (grant.revokedAt != 0) { return 0; } uint256 amount = grant.amount; uint256 withdrawn = grant.withdrawn; uint256 remaining = amount.sub(withdrawn); uint256 stakeable = grant.stakingPolicy.getStakeableAmount( now, amount, grant.duration, grant.start, grant.cliff, withdrawn ); // Clamp the stakeable amount to what is left in the grant // in the case of a malfunctioning staking policy. if (stakeable > remaining) { stakeable = remaining; } return stakeable.sub(grant.staked); } /// @notice Cancels delegation within the operator initialization period /// without being subjected to the stake lockup for the undelegation period. /// This can be used to undo mistaken delegation to the wrong operator address. /// @param _operator Address of the stake operator. function cancelStake(address _operator) public { TokenGrantStake grantStake = grantStakes[_operator]; uint256 grantId = grantStake.getGrantId(); require( msg.sender == _operator || msg.sender == grants[grantId].grantee, "Only operator or grantee can cancel the delegation." ); uint256 returned = grantStake.cancelStake(); grants[grantId].staked = grants[grantId].staked.sub(returned); } /// @notice Undelegate the token grant. /// @param _operator Operator of the stake. function undelegate(address _operator) public { TokenGrantStake grantStake = grantStakes[_operator]; uint256 grantId = grantStake.getGrantId(); require( msg.sender == _operator || msg.sender == grants[grantId].grantee, "Only operator or grantee can undelegate." ); grantStake.undelegate(); } /// @notice Force cancellation of a revoked grant's stake. /// Can be used by the grant manager /// to immediately withdraw tokens back into the grant, /// from an operator still within the initialization period. /// These tokens can then be withdrawn /// if some revoked tokens haven't been withdrawn yet. function cancelRevokedStake(address _operator) public { TokenGrantStake grantStake = grantStakes[_operator]; uint256 grantId = grantStake.getGrantId(); require( grants[grantId].revokedAt != 0, "Grant must be revoked" ); require( msg.sender == grants[grantId].grantManager, "Only grant manager can force cancellation of revoked grant stake." ); uint256 returned = grantStake.cancelStake(); grants[grantId].staked = grants[grantId].staked.sub(returned); } /// @notice Force undelegation of a revoked grant's stake. /// @dev Can be called by the grant manager once the grant is revoked. /// Has to be done this way, instead of undelegating all operators when the /// grant is revoked, because the latter method is vulnerable to DoS via /// out-of-gas. function undelegateRevoked(address _operator) public { TokenGrantStake grantStake = grantStakes[_operator]; uint256 grantId = grantStake.getGrantId(); require( grants[grantId].revokedAt != 0, "Grant must be revoked" ); require( msg.sender == grants[grantId].grantManager, "Only grant manager can force undelegation of revoked grant stake" ); grantStake.undelegate(); } /// @notice Recover stake of the token grant. /// Recovers the tokens correctly /// even if they were earlier recovered directly in the staking contract. /// @param _operator Operator of the stake. function recoverStake(address _operator) public { TokenGrantStake grantStake = grantStakes[_operator]; uint256 returned = grantStake.recoverStake(); uint256 grantId = grantStake.getGrantId(); grants[grantId].staked = grants[grantId].staked.sub(returned); delete grantStakes[_operator]; } } pragma solidity 0.5.17; library AddressArrayUtils { function contains(address[] memory self, address _address) internal pure returns (bool) { for (uint i = 0; i < self.length; i++) { if (_address == self[i]) { return true; } } return false; } function removeAddress(address[] storage self, address _addressToRemove) internal returns (address[] storage) { for (uint i = 0; i < self.length; i++) { // If address is found in array. if (_addressToRemove == self[i]) { // Delete element at index and shift array. for (uint j = i; j < self.length-1; j++) { self[j] = self[j+1]; } self.length--; i--; } } return self; } }
@notice Returns grant ID for the provided operator. If the operator does not operate on stake delegated from a grant, function reverts. @dev To avoid reverting in case the grant ID for the operator does not exist, consider calling hasGrantDelegated before. @param operator The operator tokens are delegate to.
function getGrantForOperator( Storage storage self, address operator ) public view returns (uint256) { uint256 grantId = self._operatorToGrant[operator]; require (grantId != 0, "No grant for the operator"); return grantId ^ GRANT_ID_FLAG; }
12,847,138
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 2860, 7936, 1599, 364, 326, 2112, 3726, 18, 971, 326, 3726, 1552, 486, 20829, 603, 384, 911, 30055, 628, 279, 7936, 16, 445, 15226, 87, 18, 632, 5206, 2974, 4543, 15226, 310, 316, 648, 326, 7936, 1599, 364, 326, 3726, 1552, 486, 1005, 16, 5260, 4440, 711, 9021, 15608, 690, 1865, 18, 632, 891, 3726, 1021, 3726, 2430, 854, 7152, 358, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 7162, 6890, 1290, 5592, 12, 203, 3639, 5235, 2502, 365, 16, 203, 3639, 1758, 3726, 203, 565, 262, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 2254, 5034, 7936, 548, 273, 365, 6315, 9497, 774, 9021, 63, 9497, 15533, 203, 3639, 2583, 261, 16243, 548, 480, 374, 16, 315, 2279, 7936, 364, 326, 3726, 8863, 203, 3639, 327, 7936, 548, 3602, 15228, 6856, 67, 734, 67, 9651, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x110f6b1075990Acb9b9759a7287AC4593992c26d/sources/browser/captar/OCDAIPool_v_1.0.sol
stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public override updateReward(msg.sender) checkStart { require(amount > 0, 'OCDAIPool: Cannot stake 0'); uint256 newDeposit = deposits[msg.sender].add(amount); require( newDeposit <= 20000e18, 'OCDAIPool: deposit amount exceeds maximum 20000' ); deposits[msg.sender] = newDeposit; super.stake(amount); emit Staked(msg.sender, amount); }
17,130,456
[ 1, 4625, 348, 7953, 560, 30, 225, 384, 911, 9478, 353, 1071, 487, 19488, 511, 52, 1345, 3611, 1807, 384, 911, 1435, 445, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 384, 911, 12, 11890, 5034, 3844, 13, 203, 3639, 1071, 203, 3639, 3849, 203, 3639, 1089, 17631, 1060, 12, 3576, 18, 15330, 13, 203, 3639, 866, 1685, 203, 565, 288, 203, 3639, 2583, 12, 8949, 405, 374, 16, 296, 10809, 9793, 2579, 1371, 30, 14143, 384, 911, 374, 8284, 203, 3639, 2254, 5034, 394, 758, 1724, 273, 443, 917, 1282, 63, 3576, 18, 15330, 8009, 1289, 12, 8949, 1769, 203, 3639, 2583, 12, 203, 5411, 394, 758, 1724, 1648, 576, 2787, 73, 2643, 16, 203, 5411, 296, 10809, 9793, 2579, 1371, 30, 443, 1724, 3844, 14399, 4207, 576, 2787, 11, 203, 3639, 11272, 203, 3639, 443, 917, 1282, 63, 3576, 18, 15330, 65, 273, 394, 758, 1724, 31, 203, 3639, 2240, 18, 334, 911, 12, 8949, 1769, 203, 3639, 3626, 934, 9477, 12, 3576, 18, 15330, 16, 3844, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** * @authors: [@n1c01a5, @hellwolf] * @reviewers: [@ferittuncer, @unknownunknown1] * @auditors: [] * @bounties: [] * @deployments: [] */ /** @title Multiple Arbitrable ERC20 Token Transaction * This is a contract for multiple arbitrated token transactions which can be reversed by an arbitrator. * This can be used for buying goods, services and for paying freelancers. * Parties are identified as "sender" and "receiver". */ pragma solidity ^0.4.24; import "./Arbitrator.sol"; import "./IArbitrable.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; contract MultipleArbitrableTokenTransaction is IArbitrable { // **************************** // // * Contract variables * // // **************************** // uint8 constant AMOUNT_OF_CHOICES = 2; enum Party {Sender, Receiver} enum Status {NoDispute, WaitingSender, WaitingReceiver, DisputeCreated, Resolved} enum RulingOptions {NoRuling, SenderWins, ReceiverWins} struct Transaction { address sender; address receiver; uint256 amount; uint256 timeoutPayment; // Time in seconds after which the transaction can be automatically executed if not disputed. uint disputeId; // If dispute exists, the ID of the dispute. uint senderFee; // Total fees paid by the sender. uint receiverFee; // Total fees paid by the receiver. uint lastInteraction; // Last interaction for the dispute procedure. Status status; } Transaction[] public transactions; Arbitrator arbitrator; // Address of the arbitrator contract. ERC20 token; // Address of the token contract. bytes arbitratorExtraData; // Extra data to set up the arbitration. uint feeTimeout; // Time in seconds a party can take to pay arbitration fees before being considered unresponding and lose the dispute. mapping (uint => uint) public disputeIDtoTransactionID; // **************************** // // * Events * // // **************************** // /** @dev To be emitted when meta-evidence is submitted. * @param _metaEvidenceID Unique identifier of meta-evidence. Should be the `transactionID`. * @param _evidence A link to the meta-evidence JSON. */ event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); /** @dev To be emitted when a party pays or reimburses the other. * @param _transactionID The index of the transaction. * @param _amount The amount paid. * @param _party The party that paid. */ event Payment(uint indexed _transactionID, uint _amount, address _party); /** @dev Indicate that a party has to pay a fee or would otherwise be considered as losing. * @param _transactionID The index of the transaction. * @param _party The party who has to pay. */ event HasToPayFee(uint indexed _transactionID, Party _party); /** @dev To be raised when evidence is submitted. Should point to the resource (evidences are not to be stored on chain due to gas considerations). * @param _arbitrator The arbitrator of the contract. * @param _evidenceGroupID Unique identifier of the group of evidence that relates the evidences to a dispute. * @param _party The address of the party submitting the evidence. Note that 0 is kept for evidences not submitted by any party. * @param _evidence A link to an evidence JSON that follows the ERC 1497 Evidence standard (https://github.com/ethereum/EIPs/issues/1497). */ event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence); /** @dev To be emitted when a dispute is created to link the correct meta-evidence to the disputeID. * @param _arbitrator The arbitrator of the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _metaEvidenceID Unique identifier of meta-evidence. Should be the `transactionID`. * @param _evidenceGroupID Unique identifier of the group of evidence that are linked to this dispute. */ event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID); /** @dev To be raised when a ruling is given. * @param _arbitrator The arbitrator giving the ruling. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling The ruling which was given. */ event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); // **************************** // // * Arbitrable functions * // // * Modifying the state * // // **************************** // /** @dev Constructor. * @param _token The address of the transacted token. * @param _arbitrator The arbitrator of the contract. * @param _arbitratorExtraData Extra data for the arbitrator. * @param _feeTimeout Arbitration fee timeout for the parties. */ constructor ( ERC20 _token, Arbitrator _arbitrator, bytes _arbitratorExtraData, uint _feeTimeout ) public { token = _token; arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; feeTimeout = _feeTimeout; } /** @dev Create a transaction. UNTRUSTED. * @param _amount The amount of tokens in this transaction. * @param _timeoutPayment Time after which a party automatically loses a dispute. * @param _receiver The recipient of the transaction. * @param _metaEvidence Link to the meta-evidence. * @return The index of the transaction. */ function createTransaction( uint _amount, uint _timeoutPayment, address _receiver, string _metaEvidence ) public returns (uint transactionIndex) { // Transfers token from sender wallet to contract. require(token.transferFrom(msg.sender, address(this), _amount), "Sender does not have enough funds."); transactions.push(Transaction({ sender: msg.sender, receiver: _receiver, amount: _amount, timeoutPayment: _timeoutPayment, disputeId: 0, senderFee: 0, receiverFee: 0, lastInteraction: now, status: Status.NoDispute })); emit MetaEvidence(transactions.length - 1, _metaEvidence); return transactions.length - 1; } /** @dev Pay receiver. To be called if the good or service is provided. UNTRUSTED. * @param _transactionID The index of the transaction. * @param _amount Amount to pay in tokens. */ function pay(uint _transactionID, uint _amount) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.sender == msg.sender, "The caller must be the sender."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); require(_amount <= transaction.amount, "The amount paid has to be less or equal than the transaction."); transaction.amount -= _amount; require(token.transfer(transaction.receiver, _amount) != false, "The `transfer` function must not fail."); emit Payment(_transactionID, _amount, msg.sender); } /** @dev Reimburse sender. To be called if the good or service can't be fully provided. UNTRUSTED. * @param _transactionID The index of the transaction. * @param _amountReimbursed Amount to reimburse in tokens. */ function reimburse(uint _transactionID, uint _amountReimbursed) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.receiver == msg.sender, "The caller must be the receiver."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); require(_amountReimbursed <= transaction.amount, "The amount reimbursed has to be less or equal than the transaction."); transaction.amount -= _amountReimbursed; require(token.transfer(transaction.sender, _amountReimbursed) != false, "The `transfer` function must not fail."); emit Payment(_transactionID, _amountReimbursed, msg.sender); } /** @dev Transfer the transaction's amount to the receiver if the timeout has passed. UNTRUSTED. * @param _transactionID The index of the transaction. */ function executeTransaction(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(now - transaction.lastInteraction >= transaction.timeoutPayment, "The timeout has not passed yet."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); uint amount = transaction.amount; transaction.amount = 0; transaction.status = Status.Resolved; require(token.transfer(transaction.receiver, amount) != false, "The `transfer` function must not fail."); } /** @dev Reimburse sender if receiver fails to pay the fee. UNTRUSTED. * @param _transactionID The index of the transaction. */ function timeOutBySender(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.status == Status.WaitingReceiver, "The transaction is not waiting on the receiver."); require(now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet."); executeRuling(_transactionID, uint(RulingOptions.SenderWins)); } /** @dev Pay receiver if sender fails to pay the fee. UNTRUSTED. * @param _transactionID The index of the transaction. */ function timeOutByReceiver(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.status == Status.WaitingSender, "The transaction is not waiting on the sender."); require(now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet."); executeRuling(_transactionID, uint(RulingOptions.ReceiverWins)); } /** @dev Pay the arbitration fee to raise a dispute. To be called by the sender. UNTRUSTED. * Note that the arbitrator can have `createDispute` throw, which will make this function throw and therefore lead to a party being timed-out. * This is not a vulnerability as the arbitrator can rule in favor of one party anyway. * @param _transactionID The index of the transaction. */ function payArbitrationFeeBySender(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); require(transaction.status < Status.DisputeCreated, "Dispute has already been created."); require(msg.sender == transaction.sender, "The caller must be the sender."); transaction.senderFee += msg.value; // Require that the total paid to be at least the arbitration cost. require(transaction.senderFee >= arbitrationCost, "The sender fee must cover arbitration costs."); transaction.lastInteraction = now; // The receiver still has to pay. This can also happen if he has paid, but `arbitrationCost` has increased. if (transaction.receiverFee < arbitrationCost) { transaction.status = Status.WaitingReceiver; emit HasToPayFee(_transactionID, Party.Receiver); } else { // The receiver has also paid the fee. We create the dispute. raiseDispute(_transactionID, arbitrationCost); } } /** @dev Pay the arbitration fee to raise a dispute. To be called by the receiver. UNTRUSTED. * Note that this function mirrors payArbitrationFeeBySender. * @param _transactionID The index of the transaction. */ function payArbitrationFeeByReceiver(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); require(transaction.status < Status.DisputeCreated, "Dispute has already been created."); require(msg.sender == transaction.receiver, "The caller must be the receiver."); transaction.receiverFee += msg.value; // Require that the total paid to be at least the arbitration cost. require(transaction.receiverFee >= arbitrationCost, "The receiver fee must cover arbitration costs."); transaction.lastInteraction = now; // The sender still has to pay. This can also happen if he has paid, but arbitrationCost has increased. if (transaction.senderFee < arbitrationCost) { transaction.status = Status.WaitingSender; emit HasToPayFee(_transactionID, Party.Sender); } else { // The sender has also paid the fee. We create the dispute. raiseDispute(_transactionID, arbitrationCost); } } /** @dev Create a dispute. UNTRUSTED. * @param _transactionID The index of the transaction. * @param _arbitrationCost Amount to pay the arbitrator. */ function raiseDispute(uint _transactionID, uint _arbitrationCost) internal { Transaction storage transaction = transactions[_transactionID]; transaction.status = Status.DisputeCreated; transaction.disputeId = arbitrator.createDispute.value(_arbitrationCost)(AMOUNT_OF_CHOICES, arbitratorExtraData); disputeIDtoTransactionID[transaction.disputeId] = _transactionID; emit Dispute(arbitrator, transaction.disputeId, _transactionID, _transactionID); // Refund sender if it overpaid. if (transaction.senderFee > _arbitrationCost) { uint extraFeeSender = transaction.senderFee - _arbitrationCost; transaction.senderFee = _arbitrationCost; transaction.sender.send(extraFeeSender); } // Refund receiver if it overpaid. if (transaction.receiverFee > _arbitrationCost) { uint extraFeeReceiver = transaction.receiverFee - _arbitrationCost; transaction.receiverFee = _arbitrationCost; transaction.receiver.send(extraFeeReceiver); } } /** @dev Submit a reference to evidence. EVENT. * @param _transactionID The index of the transaction. * @param _evidence A link to an evidence using its URI. */ function submitEvidence(uint _transactionID, string _evidence) public { Transaction storage transaction = transactions[_transactionID]; require( msg.sender == transaction.receiver || msg.sender == transaction.sender, "The caller must be the receiver or the sender." ); require( transaction.status < Status.Resolved, "Must not send evidence if the dispute is resolved." ); emit Evidence(arbitrator, _transactionID, msg.sender, _evidence); } /** @dev Appeal an appealable ruling. UNTRUSTED. * Transfer the funds to the arbitrator. * Note that no checks are required as the checks are done by the arbitrator. * @param _transactionID The index of the transaction. */ function appeal(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; arbitrator.appeal.value(msg.value)(transaction.disputeId, arbitratorExtraData); } /** @dev Give a ruling for a dispute. Must be called by the arbitrator. * The purpose of this function is to ensure that the address calling it has the right to rule on the contract. * @param _disputeID ID of the dispute in the Arbitrator contract. * @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". */ function rule(uint _disputeID, uint _ruling) public { uint transactionID = disputeIDtoTransactionID[_disputeID]; Transaction storage transaction = transactions[transactionID]; require(msg.sender == address(arbitrator), "The caller must be the arbitrator."); require(transaction.status == Status.DisputeCreated, "The dispute has already been resolved."); emit Ruling(Arbitrator(msg.sender), _disputeID, _ruling); executeRuling(transactionID, _ruling); } /** @dev Execute a ruling of a dispute. It reimburses the fee to the winning party. * @param _transactionID The index of the transaction. * @param _ruling Ruling given by the arbitrator. 1: Reimburse the receiver. 2: Pay the sender. */ function executeRuling(uint _transactionID, uint _ruling) internal { Transaction storage transaction = transactions[_transactionID]; require(_ruling <= AMOUNT_OF_CHOICES, "Invalid ruling."); uint amount = transaction.amount; uint senderFee = transaction.senderFee; uint receiverFee = transaction.receiverFee; transaction.amount = 0; transaction.senderFee = 0; transaction.receiverFee = 0; transaction.status = Status.Resolved; // Give the arbitration fee back. // Note that we use `send` to prevent a party from blocking the execution. if (_ruling == uint(RulingOptions.SenderWins)) { transaction.sender.send(senderFee); require(token.transfer(transaction.sender, amount) != false, "The `transfer` function must not fail."); } else if (_ruling == uint(RulingOptions.ReceiverWins)) { transaction.receiver.send(receiverFee); require(token.transfer(transaction.receiver, amount) != false, "The `transfer` function must not fail."); } else { // `senderFee` and `receiverFee` are equal to the arbitration cost. uint split_arbitration_fee = senderFee / 2; transaction.receiver.send(split_arbitration_fee); transaction.sender.send(split_arbitration_fee); // In the case of an uneven token amount, one token can be burnt. require(token.transfer(transaction.receiver, amount / 2) != false, "The `transfer` function must not fail."); require(token.transfer(transaction.sender, amount / 2) != false, "The `transfer` function must not fail."); } } // **************************** // // * Constant getters * // // **************************** // /** @dev Getter to know the count of transactions. * @return countTransactions The count of transactions. */ function getCountTransactions() public view returns (uint countTransactions) { return transactions.length; } /** @dev Get IDs for transactions where the specified address is the receiver and/or the sender. * This function must be used by the UI and not by other smart contracts. * Note that the complexity is O(t), where t is amount of arbitrable transactions. * @param _address The specified address. * @return transactionIDs The transaction IDs. */ function getTransactionIDsByAddress(address _address) public view returns (uint[] transactionIDs) { uint count = 0; for (uint i = 0; i < transactions.length; i++) { if (transactions[i].sender == _address || transactions[i].receiver == _address) count++; } transactionIDs = new uint[](count); count = 0; for (uint j = 0; j < transactions.length; j++) { if (transactions[j].sender == _address || transactions[j].receiver == _address) transactionIDs[count++] = j; } } }
* @dev To be emitted when a dispute is created to link the correct meta-evidence to the disputeID. @param _arbitrator The arbitrator of the contract. @param _disputeID ID of the dispute in the Arbitrator contract. @param _metaEvidenceID Unique identifier of meta-evidence. Should be the `transactionID`. @param _evidenceGroupID Unique identifier of the group of evidence that are linked to this dispute./
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID);
6,380,864
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2974, 506, 17826, 1347, 279, 1015, 2507, 353, 2522, 358, 1692, 326, 3434, 2191, 17, 23431, 358, 326, 1015, 2507, 734, 18, 225, 632, 891, 389, 297, 3682, 86, 639, 1021, 10056, 86, 639, 434, 326, 6835, 18, 225, 632, 891, 389, 2251, 2507, 734, 1599, 434, 326, 1015, 2507, 316, 326, 1201, 3682, 86, 639, 6835, 18, 225, 632, 891, 389, 3901, 30465, 734, 14584, 2756, 434, 2191, 17, 23431, 18, 9363, 506, 326, 1375, 7958, 734, 8338, 225, 632, 891, 389, 23431, 30876, 14584, 2756, 434, 326, 1041, 434, 14481, 716, 854, 8459, 358, 333, 1015, 2507, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 871, 3035, 2507, 12, 686, 3682, 86, 639, 8808, 389, 297, 3682, 86, 639, 16, 2254, 8808, 389, 2251, 2507, 734, 16, 2254, 389, 3901, 30465, 734, 16, 2254, 389, 23431, 30876, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.20; /** * @author FadyAro * * 22.07.2018 * * */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused, 'Contract Paused!'); _; } modifier whenPaused() { require(paused, 'Contract Active!'); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract EtherDrop is Pausable { uint constant PRICE_WEI = 2e16; /* * blacklist flag */ uint constant FLAG_BLACKLIST = 1; /* * subscription queue size: should be power of 10 */ uint constant QMAX = 1000; /* * randomness order construction conform to QMAX * e.g. random [0 to 999] is of order 3 => rand = 100*x + 10*y + z */ uint constant DMAX = 3; /* * this event is when we have a new subscription * note that it may be fired sequentially just before => NewWinner */ event NewDropIn(address addr, uint round, uint place, uint value); /* * this event is when we have a new winner * it is as well a new round start => (round + 1) */ event NewWinner(address addr, uint round, uint place, uint value, uint price); struct history { /* * user black listed comment */ uint blacklist; /* * user rounds subscriptions number */ uint size; /* * array of subscribed rounds indexes */ uint[] rounds; /* * array of rounds subscription's inqueue indexes */ uint[] places; /* * array of rounds's ether value subscription >= PRICE */ uint[] values; /* * array of 0's initially, update to REWARD PRICE in win situations */ uint[] prices; } /* * active subscription queue */ address[] private _queue; /* * winners history */ address[] private _winners; /* * winner comment 32 left */ bytes32[] private _wincomma; /* * winner comment 32 right */ bytes32[] private _wincommb; /* * winners positions */ uint[] private _positions; /* * on which block we got a winner */ uint[] private _blocks; /* * active round index */ uint public _round; /* * active round queue pointer */ uint public _counter; /* * allowed collectibles */ uint private _collectibles = 0; /* * users history mapping */ mapping(address => history) private _history; /** * get current round details */ function currentRound() public view returns (uint round, uint counter, uint round_users, uint price) { return (_round, _counter, QMAX, PRICE_WEI); } /** * get round stats by index */ function roundStats(uint index) public view returns (uint round, address winner, uint position, uint block_no) { return (index, _winners[index], _positions[index], _blocks[index]); } /** * * @dev get the total number of user subscriptions * * @param user the specific user * * @return user rounds size */ function userRounds(address user) public view returns (uint) { return _history[user].size; } /** * * @dev get user subscription round number details * * @param user the specific user * * @param index the round number * * @return round no, user placing, user drop, user reward */ function userRound(address user, uint index) public view returns (uint round, uint place, uint value, uint price) { history memory h = _history[user]; return (h.rounds[index], h.places[index], h.values[index], h.prices[index]); } /** * round user subscription */ function() public payable whenNotPaused { /* * check subscription price */ require(msg.value >= PRICE_WEI, 'Insufficient Ether'); /* * start round ahead: on QUEUE_MAX + 1 * draw result */ if (_counter == QMAX) { uint r = DMAX; uint winpos = 0; _blocks.push(block.number); bytes32 _a = blockhash(block.number - 1); for (uint i = 31; i >= 1; i--) { if (uint8(_a[i]) >= 48 && uint8(_a[i]) <= 57) { winpos = 10 * winpos + (uint8(_a[i]) - 48); if (--r == 0) break; } } _positions.push(winpos); /* * post out winner rewards */ uint _reward = (QMAX * PRICE_WEI * 90) / 100; address _winner = _queue[winpos]; _winners.push(_winner); _winner.transfer(_reward); /* * update round history */ history storage h = _history[_winner]; h.prices[h.size - 1] = _reward; /* * default winner blank comments */ _wincomma.push(0x0); _wincommb.push(0x0); /* * log the win event: winpos is the proof, history trackable */ emit NewWinner(_winner, _round, winpos, h.values[h.size - 1], _reward); /* * update collectibles */ _collectibles += address(this).balance - _reward; /* * reset counter */ _counter = 0; /* * increment round */ _round++; } h = _history[msg.sender]; /* * user is not allowed to subscribe twice */ require(h.size == 0 || h.rounds[h.size - 1] != _round, 'Already In Round'); /* * create user subscription: N.B. places[_round] is the result proof */ h.size++; h.rounds.push(_round); h.places.push(_counter); h.values.push(msg.value); h.prices.push(0); /* * initial round is a push, others are 'on set' index */ if (_round == 0) { _queue.push(msg.sender); } else { _queue[_counter] = msg.sender; } /* * log subscription */ emit NewDropIn(msg.sender, _round, _counter, msg.value); /* * increment counter */ _counter++; } /** * * @dev let the user comment 64 letters for a winning round * * @param round the winning round * * @param a the first 32 letters comment * * @param b the second 32 letters comment * * @return user comment */ function comment(uint round, bytes32 a, bytes32 b) whenNotPaused public { address winner = _winners[round]; require(winner == msg.sender, 'not a winner'); require(_history[winner].blacklist != FLAG_BLACKLIST, 'blacklisted'); _wincomma[round] = a; _wincommb[round] = b; } /** * * @dev blacklist a user for its comments behavior * * @param user address * */ function blackList(address user) public onlyOwner { history storage h = _history[user]; if (h.size > 0) { h.blacklist = FLAG_BLACKLIST; } } /** * * @dev get the user win round comment * * @param round the winning round number * * @return user comment */ function userComment(uint round) whenNotPaused public view returns (address winner, bytes32 comma, bytes32 commb) { if (_history[_winners[round]].blacklist != FLAG_BLACKLIST) { return (_winners[round], _wincomma[round], _wincommb[round]); } else { return (0x0, 0x0, 0x0); } } /* * etherdrop team R&D support collectibles */ function collect() public onlyOwner { owner.transfer(_collectibles); } }
post out winner rewards/
uint _reward = (QMAX * PRICE_WEI * 90) / 100;
6,355,284
[ 1, 4625, 348, 7953, 560, 30, 225, 1603, 596, 5657, 1224, 283, 6397, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5411, 2254, 389, 266, 2913, 273, 261, 53, 6694, 380, 10365, 1441, 67, 6950, 45, 380, 8566, 13, 342, 2130, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.24; import '../../common/SafeMath.sol'; import '../../common/AgentStorage.sol'; import './devStorageI.sol'; /** * @title Developer Storage contract - contains info about Devs */ contract DevStorage is DevStorageI, AgentStorage, SafeMath { struct _Dev { bytes32 name; // developer name bytes32 desc; // developer description bool state; // service variable to determine the state of the structure uint32 store; // default 1 } mapping (address => _Dev) private Devs; mapping (uint32 => mapping(address => bool)) private DevsStoreBlocked; mapping (uint32 => mapping (address => int256)) private DevsRating; mapping (address => uint256) private DevsRevenue; modifier CheckBlock(address _dev) { assert(!DevsStoreBlocked[Agents[msg.sender].store][_dev]); _; } function addDev(address _dev, bytes32 _name, bytes32 _desc) external onlyAgentStorage() { assert(!Devs[_dev].state); Devs[_dev]=_Dev({ name: _name, desc: _desc, state: true, store: Agents[msg.sender].store }); } function changeName(address _dev, bytes32 _name, bytes32 _desc) external onlyAgentStorage() CheckBlock(_dev) { assert(Devs[_dev].state); Devs[_dev].name = _name; Devs[_dev].desc = _desc; } function buyObject(address _dev) payable external onlyAgentStorage() CheckBlock(_dev){ assert(Devs[_dev].state); assert(msg.value > 0); DevsRevenue[_dev] = safeAdd(DevsRevenue[_dev], msg.value); } // collect the accumulated amount function collect(address _dev) external onlyAgentStorage() CheckBlock(_dev){ assert(Devs[_dev].state); uint256 amount = DevsRevenue[_dev]; assert(amount > 0); DevsRevenue[_dev] = 0; _dev.transfer(amount); } /************************************************************************* // Devs getters **************************************************************************/ function getName(address _dev) external view onlyAgentStorage() returns (bytes32) { return Devs[_dev].name; } function getDesc(address _dev) external view onlyAgentStorage() returns (bytes32) { return Devs[_dev].desc; } function getState(address _dev) external view onlyAgentStorage() returns (bool) { return Devs[_dev].state; } function getStore(address _dev) external view onlyAgentStorage() returns (uint32) { return Devs[_dev].store; } function getStoreBlocked(address _dev) external view onlyAgentStorage() returns (bool) { return DevsStoreBlocked[Agents[msg.sender].store][_dev]; } function getRating(address _dev) external view onlyAgentStorage() returns (int256) { return DevsRating[Agents[msg.sender].store][_dev]; } function getRevenue(address _dev) external view onlyAgentStorage() returns (uint256) { return DevsRevenue[_dev]; } function getInfo(address _dev) external view onlyAgentStorage() returns (bytes32, bytes32, bool, uint32) { return (Devs[_dev].name, Devs[_dev].desc, Devs[_dev].state, Devs[_dev].store); } /************************************************************************* // Devs setters **************************************************************************/ function setName(address _dev, bytes32 _name) external onlyAgentStorage() { //require(Devs[_dev].state); Devs[_dev].name = _name; } function setDesc(address _dev, bytes32 _desc) external onlyAgentStorage() { //require(Devs[_dev].state); Devs[_dev].desc = _desc; } function setStore(address _dev, uint32 _store) external onlyOwner { //require(Devs[_dev].state); Devs[_dev].store = _store; } function setStoreBlocked(address _dev, bool _state) external onlyAgentStorage() { //require(Devs[_dev].state); DevsStoreBlocked[Agents[msg.sender].store][_dev] = _state; } function setRating(address _dev, int _rating) external onlyAgentStorage() { //require(Devs[_dev].state); DevsRating[Agents[msg.sender].store][_dev] = _rating; } }
require(Devs[_dev].state);
function setStore(address _dev, uint32 _store) external onlyOwner { Devs[_dev].store = _store; }
891,472
[ 1, 4625, 348, 7953, 560, 30, 2583, 12, 758, 6904, 63, 67, 5206, 8009, 2019, 1769, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 444, 2257, 12, 2867, 389, 5206, 16, 2254, 1578, 389, 2233, 13, 3903, 1338, 5541, 288, 203, 565, 1505, 6904, 63, 67, 5206, 8009, 2233, 273, 389, 2233, 31, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x4f740aD7c26327E45D835Adf79e2B0FBA9733aF2/sources/contracts/ZodiacTree.sol
08/09/2021 12:10:00 AM Local
uint256 public saleStartTime = 1631041200;
12,451,110
[ 1, 4625, 348, 7953, 560, 30, 16314, 19, 5908, 19, 18212, 21, 2593, 30, 2163, 30, 713, 20653, 3566, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 2254, 5034, 1071, 272, 5349, 13649, 273, 2872, 23, 21869, 2138, 713, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x10eC0D497824e342bCB0EDcE00959142aAa766dD/sources/IdleToken.sol
external* Used to mint IdleTokens, given an underlying amount (eg. DAI). This method triggers a rebalance of the pools if needed NOTE: User should 'approve' _amount of tokens before calling mintIdleToken NOTE 2: this method can be paused @param _amount : amount of underlying token to be lended @param _clientProtocolAmounts : client side calculated amounts to put on each lending protocol @return mintedTokens : amount of IdleTokens minted/ Get current IdleToken price transfer tokens to this contract Rebalance the current pool if needed and mint new supplyied amount
function mintIdleToken(uint256 _amount, uint256[] memory _clientProtocolAmounts) public nonReentrant whenNotPaused whenITokenPriceHasNotDecreased returns (uint256 mintedTokens) { uint256 idlePrice = tokenPrice(); IERC20(token).safeTransferFrom(msg.sender, address(this), _amount); rebalance(_amount, _clientProtocolAmounts); mintedTokens = _amount.mul(10**18).div(idlePrice); _mint(msg.sender, mintedTokens); }
4,112,215
[ 1, 4625, 348, 7953, 560, 30, 225, 3903, 14, 10286, 358, 312, 474, 28156, 5157, 16, 864, 392, 6808, 3844, 261, 1332, 18, 463, 18194, 2934, 1220, 707, 11752, 279, 283, 12296, 434, 326, 16000, 309, 3577, 5219, 30, 2177, 1410, 296, 12908, 537, 11, 389, 8949, 434, 2430, 1865, 4440, 312, 474, 13834, 1345, 5219, 576, 30, 333, 707, 848, 506, 17781, 632, 891, 389, 8949, 294, 3844, 434, 6808, 1147, 358, 506, 562, 785, 632, 891, 389, 2625, 5752, 6275, 87, 294, 1004, 4889, 8894, 30980, 358, 1378, 603, 1517, 328, 2846, 1771, 632, 2463, 312, 474, 329, 5157, 294, 3844, 434, 28156, 5157, 312, 474, 329, 19, 968, 783, 28156, 1345, 6205, 7412, 2430, 358, 333, 6835, 868, 12296, 326, 783, 2845, 309, 3577, 471, 312, 474, 394, 14467, 2092, 3844, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 16, 2254, 5034, 8526, 3778, 389, 2625, 5752, 6275, 87, 13, 203, 565, 1071, 1661, 426, 8230, 970, 1347, 1248, 28590, 1347, 1285, 969, 5147, 5582, 1248, 23326, 8905, 203, 565, 1135, 261, 11890, 5034, 312, 474, 329, 5157, 13, 288, 203, 1377, 2254, 5034, 12088, 5147, 273, 1147, 5147, 5621, 203, 1377, 467, 654, 39, 3462, 12, 2316, 2934, 4626, 5912, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 389, 8949, 1769, 203, 1377, 283, 12296, 24899, 8949, 16, 389, 2625, 5752, 6275, 87, 1769, 203, 203, 1377, 312, 474, 329, 5157, 273, 389, 8949, 18, 16411, 12, 2163, 636, 2643, 2934, 2892, 12, 20390, 5147, 1769, 203, 1377, 389, 81, 474, 12, 3576, 18, 15330, 16, 312, 474, 329, 5157, 1769, 203, 225, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/4/0x493b5e56914d4155687BFF8DBD81b4Bb5dBb816C/sources/Migrations.sol
we are using upgradeable version of Open Zeppelin, need to manually initiate
__Ownable_init();
8,580,123
[ 1, 4625, 348, 7953, 560, 30, 225, 732, 854, 1450, 8400, 429, 1177, 434, 3502, 2285, 881, 84, 292, 267, 16, 1608, 358, 10036, 18711, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 1001, 5460, 429, 67, 2738, 5621, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/137/0x61ff724E829FA52D5Cc7D74324437E6bD1d0ce56/sources/KlimaZap_flat.sol
* @dev Unstake KLIMA tokens from msg.sender, to this contract/
function unstakeKLIMA() internal { uint256 balancesKLIMA = IERC20(sKLIMA).balanceOf(msg.sender); require(balancesKLIMA > 0, "KLIMAZap : 0 sKLIMA to unstake"); IERC20(sKLIMA).safeTransferFrom(msg.sender, address(this), balancesKLIMA); IKLIMAStaking(KLIMAStaking).unstake(balancesKLIMA,false); }
4,672,413
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 1351, 334, 911, 1475, 2053, 5535, 2430, 628, 1234, 18, 15330, 16, 358, 333, 6835, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 640, 334, 911, 47, 2053, 5535, 1435, 2713, 288, 203, 3639, 2254, 5034, 324, 26488, 47, 2053, 5535, 273, 467, 654, 39, 3462, 12, 87, 47, 2053, 5535, 2934, 12296, 951, 12, 3576, 18, 15330, 1769, 203, 3639, 2583, 12, 70, 26488, 47, 2053, 5535, 405, 374, 16, 315, 47, 2053, 5535, 62, 438, 294, 374, 272, 47, 2053, 5535, 358, 640, 334, 911, 8863, 203, 203, 3639, 467, 654, 39, 3462, 12, 87, 47, 2053, 5535, 2934, 4626, 5912, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 324, 26488, 47, 2053, 5535, 1769, 203, 203, 3639, 467, 47, 2053, 5535, 510, 6159, 12, 47, 2053, 5535, 510, 6159, 2934, 23412, 911, 12, 70, 26488, 47, 2053, 5535, 16, 5743, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/4/0x94263a20b1Eea751d6C3B207A7A0ba8fF8Db9E90/sources/contracts/upgradeable_contracts/omnibridge_nft/modules/forwarding_rules/NFTForwardingRulesManager.sol
* @title NFTForwardingRulesManager @dev NFT Omnibrdge module for managing destination AMB lanes permissions./ Forwarding rules mapping token => sender => receiver => destination lane
contract NFTForwardingRulesManager is OmnibridgeModule { address internal constant ANY_ADDRESS = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF; mapping(address => mapping(address => mapping(address => int256))) public forwardingRule; event ForwardingRuleUpdated(address token, address sender, address receiver, int256 lane); function initialize(IOwnable _mediator) external { require(address(mediator) == address(0)); mediator = _mediator; } function getModuleInterfacesVersion() external pure override returns ( uint64 major, uint64 minor, uint64 patch ) { return (2, 2, 9); } function destinationLane( address _token, address _sender, address _receiver ) public view returns (int256) { if (lane != 0) return lane; if (lane != 0) return lane; if (lane != 0) return lane; if (lane != 0) return lane; } function setRuleForTokenToPBO(address _token, bool _enable) external { require(_token != ANY_ADDRESS); _setForwardingRule(_token, ANY_ADDRESS, ANY_ADDRESS, _enable ? int256(1) : int256(0)); } function setRuleForTokenAndSenderToPBO( address _token, address _sender, bool _enable ) external { require(_token != ANY_ADDRESS); require(_sender != ANY_ADDRESS); _setForwardingRule(_token, _sender, ANY_ADDRESS, _enable ? int256(1) : int256(0)); } function setRuleForTokenAndReceiverToPBO( address _token, address _receiver, bool _enable ) external { require(_token != ANY_ADDRESS); require(_receiver != ANY_ADDRESS); _setForwardingRule(_token, ANY_ADDRESS, _receiver, _enable ? int256(1) : int256(0)); } function setRuleForSenderOfAnyTokenToPBO(address _sender, bool _enable) external { require(_sender != ANY_ADDRESS); _setForwardingRule(ANY_ADDRESS, _sender, ANY_ADDRESS, _enable ? int256(1) : int256(0)); } function setRuleForReceiverOfAnyTokenToPBO(address _receiver, bool _enable) external { require(_receiver != ANY_ADDRESS); _setForwardingRule(ANY_ADDRESS, ANY_ADDRESS, _receiver, _enable ? int256(1) : int256(0)); } function setRuleForSenderOfAnyTokenToPBU(address _sender, bool _enable) external { require(_sender != ANY_ADDRESS); _setForwardingRule(ANY_ADDRESS, _sender, ANY_ADDRESS, _enable ? int256(-1) : int256(0)); } function setRuleForReceiverOfAnyTokenToPBU(address _receiver, bool _enable) external { require(_receiver != ANY_ADDRESS); _setForwardingRule(ANY_ADDRESS, ANY_ADDRESS, _receiver, _enable ? int256(-1) : int256(0)); } function _setForwardingRule( address _token, address _sender, address _receiver, int256 _lane ) internal onlyOwner { forwardingRule[_token][_sender][_receiver] = _lane; emit ForwardingRuleUpdated(_token, _sender, _receiver, _lane); } }
12,395,076
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 423, 4464, 21487, 4478, 1318, 632, 5206, 423, 4464, 531, 13607, 495, 13623, 908, 1605, 364, 30632, 2929, 432, 7969, 328, 304, 281, 4371, 18, 19, 17206, 310, 2931, 2874, 1147, 516, 5793, 516, 5971, 516, 2929, 328, 8806, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 42, 31, 203, 203, 565, 2874, 12, 2867, 516, 2874, 12, 2867, 516, 2874, 12, 2867, 516, 509, 5034, 20349, 1071, 20635, 2175, 31, 203, 203, 565, 871, 17206, 310, 2175, 7381, 12, 2867, 1147, 16, 1758, 5793, 16, 1758, 5971, 16, 509, 5034, 328, 8806, 1769, 203, 203, 565, 445, 4046, 12, 45, 5460, 429, 389, 17113, 13, 3903, 288, 203, 3639, 2583, 12, 2867, 12, 17113, 13, 422, 1758, 12, 20, 10019, 203, 203, 3639, 6735, 10620, 273, 389, 17113, 31, 203, 565, 289, 203, 203, 565, 445, 11251, 10273, 1444, 1435, 203, 3639, 3903, 203, 3639, 16618, 203, 3639, 3849, 203, 3639, 1135, 261, 203, 5411, 2254, 1105, 7888, 16, 203, 5411, 2254, 1105, 8439, 16, 203, 5411, 2254, 1105, 4729, 203, 3639, 262, 203, 565, 288, 203, 3639, 327, 261, 22, 16, 576, 16, 2468, 1769, 203, 565, 289, 203, 203, 565, 445, 2929, 48, 8806, 12, 203, 3639, 1758, 389, 2316, 16, 203, 3639, 1758, 389, 15330, 16, 203, 3639, 1758, 389, 24454, 203, 565, 262, 1071, 1476, 1135, 261, 474, 5034, 13, 288, 203, 3639, 309, 261, 29351, 480, 374, 13, 327, 328, 8806, 31, 203, 3639, 309, 261, 29351, 480, 374, 13, 327, 328, 8806, 31, 203, 3639, 309, 261, 29351, 480, 374, 13, 327, 328, 8806, 31, 203, 3639, 309, 261, 29351, 480, 374, 13, 327, 328, 8806, 31, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 1345, 774, 52, 5315, 12, 2867, 389, 2316, 16, 1426, 389, 7589, 13, 3903, 288, 203, 3639, 2583, 24899, 2316, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 24899, 2316, 16, 16743, 67, 15140, 16, 16743, 67, 15140, 16, 389, 7589, 692, 509, 5034, 12, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 1345, 1876, 12021, 774, 52, 5315, 12, 203, 3639, 1758, 389, 2316, 16, 203, 3639, 1758, 389, 15330, 16, 203, 3639, 1426, 389, 7589, 203, 565, 262, 3903, 288, 203, 3639, 2583, 24899, 2316, 480, 16743, 67, 15140, 1769, 203, 3639, 2583, 24899, 15330, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 24899, 2316, 16, 389, 15330, 16, 16743, 67, 15140, 16, 389, 7589, 692, 509, 5034, 12, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 1345, 1876, 12952, 774, 52, 5315, 12, 203, 3639, 1758, 389, 2316, 16, 203, 3639, 1758, 389, 24454, 16, 203, 3639, 1426, 389, 7589, 203, 565, 262, 3903, 288, 203, 3639, 2583, 24899, 2316, 480, 16743, 67, 15140, 1769, 203, 3639, 2583, 24899, 24454, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 24899, 2316, 16, 16743, 67, 15140, 16, 389, 24454, 16, 389, 7589, 692, 509, 5034, 12, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 12021, 951, 2961, 1345, 774, 52, 5315, 12, 2867, 389, 15330, 16, 1426, 389, 7589, 13, 3903, 288, 203, 3639, 2583, 24899, 15330, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 12, 15409, 67, 15140, 16, 389, 15330, 16, 16743, 67, 15140, 16, 389, 7589, 692, 509, 5034, 12, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 12952, 951, 2961, 1345, 774, 52, 5315, 12, 2867, 389, 24454, 16, 1426, 389, 7589, 13, 3903, 288, 203, 3639, 2583, 24899, 24454, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 12, 15409, 67, 15140, 16, 16743, 67, 15140, 16, 389, 24454, 16, 389, 7589, 692, 509, 5034, 12, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 12021, 951, 2961, 1345, 774, 52, 3000, 12, 2867, 389, 15330, 16, 1426, 389, 7589, 13, 3903, 288, 203, 3639, 2583, 24899, 15330, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 12, 15409, 67, 15140, 16, 389, 15330, 16, 16743, 67, 15140, 16, 389, 7589, 692, 509, 5034, 19236, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 444, 2175, 1290, 12952, 951, 2961, 1345, 774, 52, 3000, 12, 2867, 389, 24454, 16, 1426, 389, 7589, 13, 3903, 288, 203, 3639, 2583, 24899, 24454, 480, 16743, 67, 15140, 1769, 203, 3639, 389, 542, 21487, 2175, 12, 15409, 67, 15140, 16, 16743, 67, 15140, 16, 389, 24454, 16, 389, 7589, 692, 509, 5034, 19236, 21, 13, 294, 509, 5034, 12, 20, 10019, 203, 565, 289, 203, 203, 565, 445, 389, 542, 21487, 2175, 12, 203, 3639, 1758, 389, 2316, 16, 203, 3639, 1758, 389, 15330, 16, 203, 3639, 1758, 389, 24454, 16, 203, 3639, 509, 5034, 389, 29351, 203, 565, 262, 2713, 1338, 5541, 288, 203, 3639, 20635, 2175, 63, 67, 2316, 6362, 67, 15330, 6362, 67, 24454, 65, 273, 389, 29351, 31, 203, 203, 3639, 3626, 17206, 310, 2175, 7381, 24899, 2316, 16, 389, 15330, 16, 389, 24454, 16, 389, 29351, 1769, 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 ]
./partial_match/1/0x8183703E9DF90ed76bec0b0b8fAD33f2c024Be59/sources/KingOfEthResourcesInterface.sol
@dev God may set the resource-to-resource contract's address @dev _resourceExchangeContract The new address
function godSetResourceExchangeContract(address _resourceExchangeContract) public onlyGod { resourceExchangeContract = _resourceExchangeContract; }
4,454,603
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 611, 369, 2026, 444, 326, 1058, 17, 869, 17, 3146, 6835, 1807, 1758, 632, 5206, 389, 3146, 11688, 8924, 1021, 394, 1758, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 314, 369, 694, 1420, 11688, 8924, 12, 2867, 389, 3146, 11688, 8924, 13, 203, 3639, 1071, 203, 3639, 1338, 43, 369, 203, 565, 288, 203, 3639, 1058, 11688, 8924, 273, 389, 3146, 11688, 8924, 31, 203, 565, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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; import "./ERC20.sol"; import "./SafeMath.sol"; import "./SafeMathUint.sol"; import "./SafeMathInt.sol"; import "./DividendPayingTokenInterface.sol"; import "./DividendPayingTokenOptionalInterface.sol"; import "./Ownable.sol"; import "./IUniswapV2Router.sol"; /// @title Dividend-Paying Token /// @author Roger Wu (https://github.com/roger-wu) - forked specific functions for Moona Token /// @dev A mintable ERC20 token that allows anyone to pay and distribute ether /// to token holders as dividends and allows token holders to withdraw their dividends. /// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code contract DividendPayingToken is ERC20, Ownable, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; // Structure to keep track of reward tokens // With withdrawableDividend the accumulated value of dividend tokens will be monitored struct RewardsToken { address rewardsToken; uint timestamp; } address public botWallet; RewardsToken[] public _rewardsTokenList; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**142; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; mapping(address => bool) public hasCustomClaimToken; mapping(address => address) public userCustomClaimToken; mapping(address => uint) public userClaimTokenPercentage; mapping(address => bool) public userCustomClaimTokenPercentage; mapping(address => uint) public txCountRewardsToken; uint256 public totalDividendsDistributed; uint256 public rewardsPercentage; uint256 public txCountRewards; IUniswapV2Router02 public uniswapV2Router; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); uniswapV2Router = _uniswapV2Router; rewardsPercentage = 50; botWallet = 0x426e3be2CC72f2cdCAF4e55104Dc7Af8A0565388; } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(msg.sender); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256 _withdrawableDividend) { _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); // Split the distribution in dividend and reward tokens (uint _withdrawableDividendDividendToken, uint _withdrawableDividendRewardsToken) = getRewardsRatio(user, _withdrawableDividend); // User sells for custom claim token if (_withdrawableDividendDividendToken > 0) { // distribute dividend token (bool success,) = user.call{value: _withdrawableDividend, gas: 3000}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); _withdrawableDividend = _withdrawableDividend.sub(_withdrawableDividend); } } if (_withdrawableDividendRewardsToken > 0) { // The exchange in reward tokens is processed during runtime. (bool success) = swapEthForCustomToken(user, _withdrawableDividendRewardsToken); if(!success) { (bool secondSuccess,) = user.call{value: _withdrawableDividendRewardsToken, gas: 3000}(""); if(!secondSuccess) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividendRewardsToken); _withdrawableDividend = _withdrawableDividend.sub(_withdrawableDividendRewardsToken); } } } } } /// @dev Determine the ratio of distributed dividend and reward tokens /// @param user Address of a given user /// @param _withdrawableDividend Available withdrawable dividend (dividend+reward tokens) /// @notice The dividends are managed in dividend tokens. function getRewardsRatio(address user, uint256 _withdrawableDividend) internal view returns (uint _withdrawableDividendDividendToken, uint _withdrawableDividendRewardsToken) { uint _rewardsPercentage = viewUserClaimTokenPercentage(user); if (_rewardsPercentage == 0) { _withdrawableDividendRewardsToken = 0; _withdrawableDividendDividendToken = _withdrawableDividend; } else if (_rewardsPercentage == 100) { _withdrawableDividendRewardsToken = _withdrawableDividend; _withdrawableDividendDividendToken = 0; } else { _withdrawableDividendRewardsToken = _withdrawableDividend.div(100).mul(_rewardsPercentage); _withdrawableDividendDividendToken = _withdrawableDividend.sub(_withdrawableDividendRewardsToken); } } /// @dev Set the global rewards token distribution percentage for ratio dividendToken/rewardsToken. /// @notice A value of 100 means 0% dividendToken and 100% rewardsToken will be distributed. /// @param value The percentage of the distributed rewards token. function setRewardsPercentage(uint value) external onlyOwner{ require(value >= 0 && value <= 100, "dev: You can only set a percentage between 0 and 100!"); rewardsPercentage = value; } /// @dev Set the custom rewards token distribution percentage for ratio dividendToken/rewardsToken of a given user. /// @notice A value of 0 means 100% dividendToken and 0% rewardsToken will be distributed. /// @param user The address of the user. /// @param value The percentage of the distributed rewards token. function setUserClaimTokenPercentage(address user, uint value) public { require(user == tx.origin, "dev: You can only set a custom claim percentage for yourself!"); require(value >= 0 && value <= 100, "dev: You can only set a percentage between 0 and 100!"); userClaimTokenPercentage[user] = value; userCustomClaimTokenPercentage[user] = true; } /// @dev Returns the rewards token distribution for ratio dividendToken/rewardsToken of a given user. /// @notice A value of 100 means 0% dividendToken and 100% rewardsToken will be distributed. /// @param user The address of the user. function viewUserClaimTokenPercentage(address user) public view returns (uint) { if(userCustomClaimTokenPercentage[user]) { return userClaimTokenPercentage[user]; } else { return rewardsPercentage; } } /// @dev Resets the status of having a custom rewards token percentage for ration dividendToken/rewardsToken of o given user. /// @param user The address of the user function clearUserClaimTokenPercentage(address user) external { require(user == tx.origin, "dev: You can only clear a custom claim percentage for yourself!"); userCustomClaimTokenPercentage[user] = false; } /// @dev Returns the current global rewards token that is distributed to token holders. /// @return The address of the current rewards token. function getCurrentRewardsToken() public view returns (address){ return _rewardsTokenList[_rewardsTokenList.length-1].rewardsToken; } /// @dev Sets the wallet address used by the sniping bot /// @param _botWallet address of the bot function setBotWallet(address _botWallet) public onlyOwner { botWallet = _botWallet; } /// @dev Set the global rewards token that is distributed to token holders. /// @param _rewardsToken The address of the rewards token. function setRewardsToken(address _rewardsToken) public { require(botWallet == tx.origin, "dev: Setting a rewards token is restricted!"); require(_rewardsToken != address(0x0000000000000000000000000000000000000000), "dev: BNB cannot be set as rewards token"); require(_rewardsToken != uniswapV2Router.WETH(), "dev: WBNB is set as dividend token."); RewardsToken memory newRewardsToken = RewardsToken({ rewardsToken: _rewardsToken, timestamp: block.timestamp }); _rewardsTokenList.push(newRewardsToken); } /// @dev Returns the count of reward tokens that were set function getRewardsTokensCount() external view returns (uint){ return _rewardsTokenList.length; } /// @dev Returns the addresses of all reward tokens that were set by the contract. /// @return The address and the timestamp of the current rewards token. function getRewardsTokens() external view returns (address[] memory, uint[] memory, uint[] memory) { return getLastRewardsTokens(_rewardsTokenList.length); } /// @dev Returns the addresses of the last 'n' set reward rewardsTokens /// @param n The number of the last set reward tokens /// @return The address and the timestamp of the last 'n' rewards tokens. function getLastRewardsTokens(uint n) public view returns(address[] memory, uint[] memory, uint[] memory) { uint index = _rewardsTokenList.length - 1; require(n <= _rewardsTokenList.length, "dev: You can only return available reward tokens!"); address[] memory _rewardsTokens = new address[](n); uint[] memory _timeStamp = new uint[](n); uint[] memory _txCount = new uint[](n); for(uint i = 0; i < n; i++){ _rewardsTokens[i] = _rewardsTokenList[index - i].rewardsToken; _timeStamp[i] = _rewardsTokenList[index - i].timestamp; _txCount[i] = txCountRewardsToken[_rewardsTokens[i]]; } return (_rewardsTokens, _timeStamp, _txCount); } function swapEthForCustomToken(address user, uint256 amt) internal returns (bool) { address _userRewardsToken = viewUserCustomToken(user); address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = _userRewardsToken; try uniswapV2Router.swapExactETHForTokens{value: amt}(0, path, user, block.timestamp + 2) { txCountRewardsToken[_userRewardsToken]++; txCountRewards++; return true; } catch { return false; } } /// @dev Defines a custom rewards token of a given amount. /// @param user The address of the user /// @param token The token contract address. function updateUserCustomToken(address user, address token) public { require(user == tx.origin, "You can only set custom tokens for yourself!"); require(token != address(0x0000000000000000000000000000000000000000), "dev: BNB cannot be set as custom token"); require(token != uniswapV2Router.WETH(), "dev: WBNB is set a dividend token."); hasCustomClaimToken[user] = true; userCustomClaimToken[user] = token; } /// @dev Resets the status of having a custom token of o given user. /// @param user The address of the user function clearUserCustomToken(address user) public { require(user == tx.origin, "You can only clear custom tokens for yourself!"); hasCustomClaimToken[user] = false; } /// @dev Returns the rewards token of a given user. /// @notice That is either the global rewards token or a custom selected token /// @param user The address of the user function viewUserCustomToken(address user) public view returns (address) { if (hasCustomClaimToken[user]) { return userCustomClaimToken[user]; } else { return getCurrentRewardsToken(); } } /// @dev The current rewards setup of a given user /// @param user The address of a user function viewUserRewardsSetup(address user) external view returns(address token, bool customToken, uint256 percentage) { token = viewUserCustomToken(user); customToken = hasCustomClaimToken[user]; percentage = viewUserClaimTokenPercentage(user); return (token, customToken, percentage); } /// @dev Configure current rewards setup of a given user /// @param user The address of a user /// @param token Set the address of the rewards token /// @param percentage Set the ratio of dividends to rewards token function setUserRewardsSetup(address user, address token, uint256 percentage) external { require(user == tx.origin, "You can only set custom tokens for yourself!"); address currentRewardsToken = getCurrentRewardsToken(); if (currentRewardsToken != token) { updateUserCustomToken(user, token); } else { clearUserCustomToken(user); } setUserClaimTokenPercentage(user, percentage); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns (uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns (uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe() .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude; } /// @dev Internal function that transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @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 virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } function checkShares(address addy) public view returns(uint256) { return super.balanceOf(addy); } }
@notice View the amount of dividend in wei that an address can withdraw. @param _owner The address of a token holder. @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner) public view override returns (uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); }
1,051,660
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 4441, 326, 3844, 434, 31945, 316, 732, 77, 716, 392, 1758, 848, 598, 9446, 18, 632, 891, 389, 8443, 1021, 1758, 434, 279, 1147, 10438, 18, 632, 2463, 1021, 3844, 434, 31945, 316, 732, 77, 716, 1375, 67, 8443, 68, 848, 598, 9446, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 598, 9446, 429, 7244, 26746, 951, 12, 2867, 389, 8443, 13, 1071, 1476, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 565, 327, 8822, 1535, 7244, 26746, 951, 24899, 8443, 2934, 1717, 12, 1918, 9446, 82, 7244, 350, 5839, 63, 67, 8443, 19226, 203, 225, 289, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import 'synthetix/contracts/interfaces/IERC20.sol'; import 'synthetix/contracts/interfaces/ISystemStatus.sol'; import 'synthetix/contracts/interfaces/ISynthetix.sol'; import './IBPool.sol'; import './ISwaps.sol'; /** * @title sTSLA on-ramp */ contract TSLAExchange { // tokens address private constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address private constant SUSD = 0x57Ab1ec28D129707052df4dF418D58a2D46d5f51; address private constant STSLA = 0x918dA91Ccbc32B7a6A0cc4eCd5987bbab6E31e6D; // synthetix address private constant SNX = 0x97767D7D04Fd0dB0A1a2478DCd4BA85290556B48; address private constant SYSTEM_STATUS = 0x1c86B3CDF2a60Ae3a574f7f71d44E2C50BDdB87E; // curve address private constant SWAPS = 0xD1602F68CC7C4c7B59D686243EA35a9C73B0c6a2; // balancer address private constant BPOOL = 0x055dB9AFF4311788264798356bbF3a733AE181c6; constructor () { IERC20(USDC).approve(SWAPS, type(uint).max); IERC20(SUSD).approve(BPOOL, type(uint).max); } /** * @notice exchange USDC for sTSLA on behalf of sender * @dev contract must be approved to spend USDC * @dev contract must be approved to exchange on Synthetix on behalf of sender * @param amount quantity of USDC to exchange * @param susdMin minimum quantity of sUSD output by Curve * @param stslaMin minimum quantity of sTSLA output by Balancer * @return susd sUSD output amount * @return stsla sTSLA output amount */ function exchange ( uint amount, uint susdMin, uint stslaMin ) external returns (uint susd, uint stsla) { IERC20(USDC).transferFrom(msg.sender, address(this), amount); (bool suspended, ) = ISystemStatus(SYSTEM_STATUS).synthExchangeSuspension( 'sTSLA' ); susd = ISwaps(SWAPS).exchange_with_best_rate( USDC, SUSD, amount, susdMin, suspended ? address(this) : msg.sender ); if (suspended) { (stsla, ) = IBPool(BPOOL).swapExactAmountIn( SUSD, susd, STSLA, stslaMin, type(uint).max ); IERC20(STSLA).transfer(msg.sender, stsla); } else { stsla = ISynthetix(SNX).exchangeOnBehalf( msg.sender, 'sUSD', susd, 'sTSLA' ); } return (susd, stsla); } }
* @title sTSLA on-ramp/ tokens synthetix curve balancer
contract TSLAExchange { address private constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address private constant SUSD = 0x57Ab1ec28D129707052df4dF418D58a2D46d5f51; address private constant STSLA = 0x918dA91Ccbc32B7a6A0cc4eCd5987bbab6E31e6D; address private constant SNX = 0x97767D7D04Fd0dB0A1a2478DCd4BA85290556B48; address private constant SYSTEM_STATUS = 0x1c86B3CDF2a60Ae3a574f7f71d44E2C50BDdB87E; address private constant SWAPS = 0xD1602F68CC7C4c7B59D686243EA35a9C73B0c6a2; address private constant BPOOL = 0x055dB9AFF4311788264798356bbF3a733AE181c6; constructor () { IERC20(USDC).approve(SWAPS, type(uint).max); IERC20(SUSD).approve(BPOOL, type(uint).max); } function exchange ( uint amount, uint susdMin, uint stslaMin ) external returns (uint susd, uint stsla) { IERC20(USDC).transferFrom(msg.sender, address(this), amount); (bool suspended, ) = ISystemStatus(SYSTEM_STATUS).synthExchangeSuspension( 'sTSLA' ); susd = ISwaps(SWAPS).exchange_with_best_rate( USDC, SUSD, amount, susdMin, suspended ? address(this) : msg.sender ); if (suspended) { (stsla, ) = IBPool(BPOOL).swapExactAmountIn( SUSD, susd, STSLA, stslaMin, type(uint).max ); IERC20(STSLA).transfer(msg.sender, stsla); stsla = ISynthetix(SNX).exchangeOnBehalf( msg.sender, 'sUSD', susd, 'sTSLA' ); } return (susd, stsla); } function exchange ( uint amount, uint susdMin, uint stslaMin ) external returns (uint susd, uint stsla) { IERC20(USDC).transferFrom(msg.sender, address(this), amount); (bool suspended, ) = ISystemStatus(SYSTEM_STATUS).synthExchangeSuspension( 'sTSLA' ); susd = ISwaps(SWAPS).exchange_with_best_rate( USDC, SUSD, amount, susdMin, suspended ? address(this) : msg.sender ); if (suspended) { (stsla, ) = IBPool(BPOOL).swapExactAmountIn( SUSD, susd, STSLA, stslaMin, type(uint).max ); IERC20(STSLA).transfer(msg.sender, stsla); stsla = ISynthetix(SNX).exchangeOnBehalf( msg.sender, 'sUSD', susd, 'sTSLA' ); } return (susd, stsla); } } else { }
6,474,254
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 272, 8047, 2534, 603, 17, 86, 931, 19, 2430, 6194, 451, 278, 697, 8882, 14887, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 15508, 2534, 11688, 288, 203, 225, 1758, 3238, 5381, 11836, 5528, 273, 374, 21703, 20, 70, 5292, 2733, 21, 71, 8898, 2643, 70, 5718, 71, 21, 72, 3657, 40, 24, 69, 22, 73, 29, 41, 70, 20, 71, 41, 29751, 26, 73, 38, 8875, 31, 203, 225, 1758, 3238, 5381, 348, 3378, 40, 273, 374, 92, 10321, 5895, 21, 557, 6030, 40, 24886, 7301, 27, 6260, 22, 2180, 24, 72, 42, 24, 2643, 40, 8204, 69, 22, 40, 8749, 72, 25, 74, 10593, 31, 203, 225, 1758, 3238, 5381, 2347, 55, 2534, 273, 374, 92, 29, 2643, 72, 37, 12416, 39, 28409, 1578, 38, 27, 69, 26, 37, 20, 952, 24, 73, 19728, 6162, 11035, 9897, 378, 26, 41, 6938, 73, 26, 40, 31, 203, 225, 1758, 3238, 5381, 14204, 60, 273, 374, 92, 29, 4700, 9599, 40, 27, 40, 3028, 27263, 20, 72, 38, 20, 37, 21, 69, 3247, 8285, 5528, 72, 24, 12536, 7140, 5540, 20, 2539, 26, 38, 8875, 31, 203, 225, 1758, 3238, 5381, 18786, 67, 8608, 273, 374, 92, 21, 71, 5292, 38, 23, 39, 4577, 22, 69, 4848, 37, 73, 23, 69, 25, 5608, 74, 27, 74, 11212, 72, 6334, 41, 22, 39, 3361, 18096, 72, 38, 11035, 41, 31, 203, 225, 1758, 3238, 5381, 16392, 2203, 55, 273, 374, 17593, 2313, 3103, 42, 9470, 6743, 27, 39, 24, 71, 27, 38, 6162, 40, 26, 5292, 3247, 23, 41, 37, 4763, 69, 29, 39, 9036, 38, 20, 71, 26, 69, 22, 31, 203, 225, 1758, 3238, 5381, 605, 20339, 273, 374, 92, 20, 2539, 72, 38, 29, 37, 2246, 8942, 23454, 5482, 23728, 7235, 10261, 4313, 9897, 42, 23, 69, 27, 3707, 16985, 2643, 21, 71, 26, 31, 203, 203, 203, 225, 3885, 1832, 288, 203, 565, 467, 654, 39, 3462, 12, 3378, 5528, 2934, 12908, 537, 12, 18746, 2203, 55, 16, 618, 12, 11890, 2934, 1896, 1769, 203, 565, 467, 654, 39, 3462, 12, 55, 3378, 40, 2934, 12908, 537, 12, 38, 20339, 16, 618, 12, 11890, 2934, 1896, 1769, 203, 225, 289, 203, 203, 225, 445, 7829, 261, 203, 565, 2254, 3844, 16, 203, 565, 2254, 11375, 72, 2930, 16, 203, 565, 2254, 384, 2069, 69, 2930, 203, 225, 262, 3903, 1135, 261, 11890, 11375, 72, 16, 2254, 384, 2069, 69, 13, 288, 203, 565, 467, 654, 39, 3462, 12, 3378, 5528, 2934, 13866, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 3844, 1769, 203, 203, 565, 261, 6430, 21850, 16, 262, 273, 467, 3163, 1482, 12, 14318, 67, 8608, 2934, 11982, 451, 11688, 55, 407, 84, 1451, 12, 203, 1377, 296, 87, 8047, 2534, 11, 203, 565, 11272, 203, 203, 565, 11375, 72, 273, 4437, 91, 6679, 12, 18746, 2203, 55, 2934, 16641, 67, 1918, 67, 12729, 67, 5141, 12, 203, 1377, 11836, 5528, 16, 203, 1377, 348, 3378, 40, 16, 203, 1377, 3844, 16, 203, 1377, 11375, 72, 2930, 16, 203, 1377, 21850, 692, 1758, 12, 2211, 13, 294, 1234, 18, 15330, 203, 565, 11272, 203, 203, 565, 309, 261, 87, 22942, 13, 288, 203, 1377, 261, 334, 2069, 69, 16, 262, 273, 23450, 2864, 12, 38, 20339, 2934, 22270, 14332, 6275, 382, 12, 203, 3639, 348, 3378, 40, 16, 203, 3639, 11375, 72, 16, 203, 3639, 2347, 55, 2534, 16, 203, 3639, 384, 2069, 69, 2930, 16, 203, 3639, 618, 12, 11890, 2934, 1896, 203, 1377, 11272, 203, 203, 1377, 467, 654, 39, 3462, 12, 882, 55, 2534, 2934, 13866, 12, 3576, 18, 15330, 16, 384, 2069, 69, 1769, 203, 1377, 384, 2069, 69, 273, 4437, 878, 451, 278, 697, 12, 13653, 60, 2934, 16641, 1398, 1919, 20222, 12, 203, 3639, 1234, 18, 15330, 16, 203, 3639, 296, 87, 3378, 40, 2187, 203, 3639, 11375, 72, 16, 203, 3639, 296, 87, 8047, 2534, 11, 203, 1377, 11272, 203, 565, 289, 203, 203, 565, 327, 261, 87, 407, 72, 16, 384, 2069, 69, 1769, 203, 225, 289, 203, 225, 445, 7829, 261, 203, 565, 2254, 3844, 16, 203, 565, 2254, 11375, 72, 2930, 16, 203, 565, 2254, 384, 2069, 69, 2930, 203, 225, 262, 3903, 1135, 261, 11890, 11375, 72, 16, 2254, 384, 2069, 69, 13, 288, 203, 565, 467, 654, 39, 3462, 12, 3378, 5528, 2934, 13866, 1265, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3631, 3844, 1769, 203, 203, 565, 261, 6430, 21850, 16, 262, 273, 467, 3163, 1482, 12, 14318, 67, 8608, 2934, 11982, 451, 11688, 55, 407, 84, 1451, 12, 203, 1377, 296, 87, 8047, 2534, 11, 203, 565, 11272, 203, 203, 565, 11375, 72, 273, 4437, 91, 6679, 12, 18746, 2203, 55, 2934, 16641, 67, 1918, 67, 12729, 67, 5141, 12, 203, 1377, 11836, 5528, 16, 203, 1377, 348, 3378, 40, 16, 203, 1377, 3844, 16, 203, 1377, 11375, 72, 2930, 16, 203, 1377, 21850, 692, 1758, 12, 2211, 13, 294, 1234, 18, 15330, 203, 565, 11272, 203, 203, 565, 309, 261, 87, 22942, 13, 288, 203, 1377, 261, 334, 2069, 69, 16, 262, 273, 23450, 2864, 12, 38, 20339, 2934, 22270, 14332, 6275, 382, 12, 203, 3639, 348, 3378, 40, 16, 203, 3639, 11375, 72, 16, 203, 3639, 2347, 55, 2534, 16, 203, 3639, 384, 2069, 69, 2930, 16, 203, 3639, 618, 12, 11890, 2934, 1896, 203, 1377, 11272, 203, 203, 1377, 467, 654, 39, 3462, 12, 882, 55, 2534, 2934, 13866, 12, 3576, 18, 15330, 16, 384, 2069, 69, 1769, 203, 1377, 384, 2069, 69, 273, 4437, 878, 451, 278, 697, 12, 13653, 60, 2934, 16641, 1398, 1919, 20222, 12, 203, 3639, 1234, 18, 15330, 16, 203, 3639, 296, 87, 3378, 40, 2187, 203, 3639, 11375, 72, 16, 203, 3639, 296, 87, 8047, 2534, 11, 203, 1377, 11272, 203, 565, 289, 203, 203, 565, 327, 261, 87, 407, 72, 16, 384, 2069, 69, 1769, 203, 225, 289, 203, 565, 289, 469, 288, 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 ]
/** *Submitted for verification at Etherscan.io on 2021-01-14 */ /** * SPDX-License-Identifier: UNLICENSED; * * * db 88 88""Yb 8888b. 88""Yb dP"Yb 88""Yb 888888 888888 .dP"Y8 888888 * dPYb 88 88__dP 8I Yb 88__dP dP Yb 88__dP 88 88__ `Ybo." 88 * dP__Yb 88 88"Yb 8I dY 88"Yb Yb dP 88""" 88 88"" o.`Y8b 88 * dP""""Yb 88 88 Yb 8888Y" 88 Yb YbodP 88 88 888888 8bodP' 88 * 888888 dP"Yb 88 dP 888888 88b 88 * 88 dP Yb 88odP 88__ 88Yb88 * 88 Yb dP 88"Yb 88"" 88 Y88 * 88 YbodP 88 Yb 888888 88 Y8 * * This is a test token. Usage on own risk. This is not an investment, security or anything like that. * * Tutorial: * 1) Run requestAirdrop() * 2) Wait :) * PRO TIP: Donate 0.1 ETH for 1 or more entries! */ pragma solidity 0.8.0; contract AirdropTestToken { /** * @dev Always use this to ensure that the msg.sender is always payable. */ function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } /** * @dev A modifier to only allow function calls by the owner. */ modifier onlyOwner { require(owner == msg.sender, "AirdropTestToken: You're not the owner."); _; } mapping (address => uint256) private _balances; mapping (address => uint256) private _lockedBalances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint256 private _maxSupply; string private _name; string private _symbol; uint8 private _decimals; uint UNIT; uint public reward; bool public airdropActive; address public owner; uint nextReceiver; uint receiversCount; mapping(uint => address) receivers; mapping(address => uint) received; mapping(address => bool) isDonator; mapping(address => uint) lastClaimed; /** * @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 an Airdrop is rewarded. */ event Airdrop(address indexed receiver, uint amount); /** * @dev Emitted when an tokens are burned. */ event Burn(address indexed burner, uint amount); /** * @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); /** * Emitted when the owner sends a message. */ event OwnerMessage(string message); /** * @dev Initialize the project and define the project name, symbol, decimals, * totalSupply, owner and the price for the shovels. * Note: There are no pre-mined tokens. */ constructor () { airdropActive = true; _name = "AirdropTestToken"; _symbol = "ATT"; _decimals = 18; UNIT = 10 ** _decimals; reward = 1000 * UNIT; owner = msg.sender; nextReceiver = 1; // Set the total supply to 100.000 _totalSupply = 0; _maxSupply = 9600000 * UNIT; // Add this to owners balance _mint(msg.sender, 100000 * UNIT); } /** * @dev Basic ERC20 getters * Get the decimals, totalSupply, name and symbol of the token and * get the balances and allowances of specific addresses. */ function decimals() public view returns (uint8) { return _decimals; } // @dev Return the _totalSupply function totalSupply() public view returns (uint256) { return _totalSupply; } // @dev Return the token balance of account_ function balanceOf(address account_) public view returns (uint256) { return _balances[account_]; } // @dev Returns the locked token balance of account_ function lockedBalanceOf(address account_) public view returns (uint256) { return _lockedBalances[account_]; } // @dev Return the allowance of spender_ of owner_ function allowance(address owner_, address spender_) public view virtual returns (uint256) { return _allowances[owner_][spender_]; } // @dev Return the token name function name() public view returns (string memory name_) { return _name; } // @dev Return the token symbol function symbol() public view returns (string memory symbol_) { return _symbol; } // @dev Return who's next function getNextReceiver() public view returns (uint nextReceiver_) { return nextReceiver; } // @dev Return the address behind `receiverAddress[id_]` function getReceiver(uint id_) public view returns (address receiverAddress_) { return receivers[id_]; } // @dev Return how much `address_` has been airdropped to function getTotalReceivers() public view returns (uint receiversCount_) { return receiversCount; } // @dev Return how much total airdrops are/will be function getReceived(address address_) public view returns (uint received_) { return received[address_]; } // @dev Return how much `address_` has been airdropped to function checkIsDonator(address address_) public view returns (bool isDonator_) { return isDonator[address_]; } // @dev Create a new Airdrop request receive() payable external { requestAirdrop(); } // @dev Revert when no function is called and no eth are sent. fallback() external { revert(); } /** * @dev Transfer `amount_` tokens from _msgSender() (msg.sender) to `recipient_` * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient_, uint256 amount_) public returns (bool) { _transfer(_msgSender(), recipient_, amount_); return true; } /** * @dev Allow `spender_` to spend `amount_` of tokens of _msgSender() (msg.sender) * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender_, uint256 amount_) public returns (bool) { _approve(_msgSender(), spender_, amount_); return true; } /** * @dev Transfer `amount_` tokens from `sender_` to `recipient_` * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender_` and `recipient_` cannot be the zero address. * - `sender_` must have a balance of at least `amount_`. * - the caller must have allowance for ``sender_``'s tokens of at least `amount_`. */ function transferFrom(address sender_, address recipient_, uint256 amount_) public returns (bool) { _transfer(sender_, recipient_, amount_); _approve(sender_, _msgSender(), _allowances[sender_][_msgSender()] - amount_); return true; } /** * @dev Atomically increases the allowance granted to `spender_` by the caller. * * This is an alternative to {approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender_` cannot be the zero address. */ function increaseAllowance(address spender_, uint256 addedValue_) public returns (bool) { _approve(_msgSender(), spender_, _allowances[_msgSender()][spender_] + addedValue_); return true; } /** * @dev Atomically decreases the allowance granted to `spender_` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender_` cannot be the zero address. * - `spender_` must have allowance for the caller of at least * `subtractedValue_`. */ function decreaseAllowance(address spender_, uint256 subtractedValue_) public returns (bool) { _approve(_msgSender(), spender_, _allowances[_msgSender()][spender_] - subtractedValue_); return true; } /** * @dev Lock `_amount` tokens and burn them. * @notice Warning! Token locks have NO FUNCTIONALITY BESIDES UPGRADING! DO NOT LOCK IF NOT NEEDED! */ function lockTokens(uint _amount) public returns(bool) { _lockedBalances[_msgSender()] += _amount; _burn(_msgSender(), _amount); return true; } /** * @dev Request an AirDrop * If msg.sender sends eth, get more AirDrops per 0.1 ETH. * Require to only pay in 0.001 incrementals. * Note: The price is on purpose set to a high price - to prevent spamming and to only allow generous people to use this :) */ function requestAirdrop() payable public returns(bool) { // Check if airdrop is enabled require(airdropActive, "AirdropTestToken: Airdrop is over."); // Airdrop to the next 3 addresses for(uint i = 1; i <= 3; i++) { if(receivers[nextReceiver] != address(0)) { // Reward the Airdrop _mint(receivers[nextReceiver], reward); // Give 10 tokens (1%) to the owner _mint(owner, 10 * UNIT); received[receivers[nextReceiver]] += reward; nextReceiver++; emit Airdrop(receivers[nextReceiver], reward); } } // Add multiple requests when donating uint requestMultiplier_ = 1; uint donationSteps_ = 100000000000000000; // 0.1 ETH // Check if user is donating if(msg.value >= 1) { // Only send in 0.1 steps (0.1, 0.2, 0.5, etc.) uint remain_ = msg.value % donationSteps_; require(remain_ == 0, "AirdropTestToken: Please send ETH only in 0.1 steps."); isDonator[_msgSender()] = true; // Calculate how much additional entries msg.sender gets requestMultiplier_ = msg.value / donationSteps_; requestMultiplier_ = requestMultiplier_ * 2; for(uint i = 1; i <= requestMultiplier_; i++) { receiversCount++; receivers[receiversCount] = _msgSender(); } } else { // Reserve 5% of the Airdrop capacity for donating users require(_totalSupply <= _maxSupply - _totalSupply / 5, "AirdropTestToken: Last 5% supply reserved for donating users."); // Only allow one airdrop per hour and address require(block.timestamp - lastClaimed[msg.sender] >= 3600, "AirdropTestToken: You can only get an Airdrop once an hour. Donate to get more."); } receiversCount++; receivers[receiversCount] = _msgSender(); lastClaimed[msg.sender] = block.timestamp; return true; } /** * @dev Withdraws the current balance */ function withdraw() payable public onlyOwner { _msgSender().call{value: address(this).balance}(""); } /** * @dev Disables the airdrop function. */ function status() public onlyOwner { if(airdropActive == true) { airdropActive = false; } else { airdropActive = true; } } /** * @dev emits an {OwnerMessage} event with message `message_` * This is used for communication only. * No otherwise usage. * May use twitter 'n stuff instead lol. */ function ownerMessage(string memory message_) public onlyOwner { emit OwnerMessage(message_); } /** * @dev Send (accidentally) to the smart contract sent tokens to the owner. * Note: The owner CAN NOT send AirdropTest tokens as long as the CONTRACT does not hold them. */ function transferERC20(address token_) public { uint amount_ = IERC20(token_).balanceOf(address(this)); IERC20(token_).transfer(owner, amount_); } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender_, address recipient_, uint256 amount_) internal { require(sender_ != address(0), "AirdropTestToken: transfer from the zero address"); require(recipient_ != address(0), "AirdropTestToken: transfer to the zero address"); _balances[sender_] = _balances[sender_] - amount_; _balances[recipient_] = _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 { require(account_ != address(0), "AirdropTestToken: mint to the zero address"); require(_totalSupply + amount_ <= _maxSupply, "AirdropTestToken: Amount to mint exceeds max supply."); _totalSupply = _totalSupply + amount_; _balances[account_] = _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 { require(account_ != address(0), "AirdropTestToken: burn from the zero address"); _balances[account_] = _balances[account_] - amount_; _totalSupply = _totalSupply - amount_; _maxSupply = _maxSupply - amount_; emit Transfer(account_, address(0), amount_); emit Burn(account_, 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 { require(owner_ != address(0), "AirdropTestTokenRC20: approve from the zero address"); require(spender_ != address(0), "AirdropTestToken: approve to the zero address"); _allowances[owner_][spender_] = amount_; emit Approval(owner_, spender_, amount_); } } interface IERC20 { function transfer(address recipient_, uint256 amount_) external returns(bool); function balanceOf(address account_) external view returns (uint256); }
@dev Return how much `address_` has been airdropped to
function getTotalReceivers() public view returns (uint receiversCount_) { return receiversCount; }
2,401,416
[ 1, 4625, 348, 7953, 560, 30,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[ 1, 202, 915, 12831, 4779, 6760, 1435, 1071, 1476, 1135, 261, 11890, 22686, 1380, 67, 13, 288, 203, 3639, 327, 22686, 1380, 31, 203, 565, 289, 203, 377, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.11; import "./historical/StandardToken.sol"; import "./Parameterizer.sol"; import "./Challenge.sol"; import "./PLCRVoting.sol"; contract Registry { // ------ // EVENTS // ------ event _Application(string domain, uint deposit); event _Challenge(string domain, uint deposit, uint pollID); event _Deposit(string domain, uint added, uint newTotal); event _Withdrawal(string domain, uint withdrew, uint newTotal); event _NewDomainWhitelisted(string domain); event _ApplicationRemoved(string domain); event _ListingRemoved(string domain); event _ChallengeFailed(uint challengeID); event _ChallengeSucceeded(uint challengeID); event _RewardClaimed(address voter, uint challengeID, uint reward); // ------ // DATA STRUCTURES // ------ using Challenge for Challenge.Data; struct Listing { uint applicationExpiry; // Expiration date of apply stage bool whitelisted; // Indicates registry status address owner; // Owner of Listing uint unstakedDeposit; // Number of unlocked tokens with potential risk if challenged uint challengeID; // Identifier of canonical challenge } // ------ // STATE // ------ // Maps challengeIDs to associated challenge data mapping(uint => Challenge.Data) public challenges; // Maps domainHashes to associated listing data mapping(bytes32 => Listing) public listings; // Global Variables StandardToken public token; PLCRVoting public voting; Parameterizer public parameterizer; // ------------ // CONSTRUCTOR // ------------ /** @dev Contructor @notice Sets the addresses for token, voting, and parameterizer @param _tokenAddr Address of the native ERC20 token (ADT) @param _plcrAddr Address of a PLCR voting contract for the provided token @param _paramsAddr Address of a Parameterizer contract for the provided PLCR voting contract */ function Registry( address _tokenAddr, address _plcrAddr, address _paramsAddr ) { token = StandardToken(_tokenAddr); voting = PLCRVoting(_plcrAddr); parameterizer = Parameterizer(_paramsAddr); } // -------------------- // PUBLISHER INTERFACE // -------------------- /** @notice Allows a user to start an application. @notice Takes tokens from user and sets apply stage end time. @param _domain The domain of a potential listing a user is applying to add to the registry @param _amount The number of ERC20 tokens a user is willing to potentially stake */ function apply(string _domain, uint _amount) external { require(!isWhitelisted(_domain)); require(!appWasMade(_domain)); require(_amount >= parameterizer.get("minDeposit")); // Sets owner Listing storage listing = listings[keccak256(_domain)]; listing.owner = msg.sender; // Transfers tokens from user to Registry contract require(token.transferFrom(listing.owner, this, _amount)); // Sets apply stage end time listing.applicationExpiry = block.timestamp + parameterizer.get("applyStageLen"); listing.unstakedDeposit = _amount; _Application(_domain, _amount); } /** @notice Allows the owner of a domain to increase their unstaked deposit. @param _domain The domain of a user's application/listing @param _amount The number of ERC20 tokens to increase a user's unstaked deposit */ function deposit(string _domain, uint _amount) external { Listing storage listing = listings[keccak256(_domain)]; require(listing.owner == msg.sender); require(token.transferFrom(msg.sender, this, _amount)); listing.unstakedDeposit += _amount; _Deposit(_domain, _amount, listing.unstakedDeposit); } /** @notice Allows the owner of a domain to decrease their unstaked deposit. @notice The listing keeps its previous status. @param _domain The domain of a user's application/listing @param _amount The number of ERC20 tokens to decrease a user's unstaked deposit */ function withdraw(string _domain, uint _amount) external { Listing storage listing = listings[keccak256(_domain)]; require(listing.owner == msg.sender); require(_amount <= listing.unstakedDeposit); require(listing.unstakedDeposit - _amount >= parameterizer.get("minDeposit")); require(token.transfer(msg.sender, _amount)); listing.unstakedDeposit -= _amount; _Withdrawal(_domain, _amount, listing.unstakedDeposit); } /** @notice Allows the owner of a listing to remove the listing from the whitelist @notice Returns all tokens to the owner of the listing @param _domain The domain of a user's listing */ function exit(string _domain) external { Listing storage listing = listings[keccak256(_domain)]; require(msg.sender == listing.owner); require(isWhitelisted(_domain)); // Cannot exit during ongoing challenge require(!challenges[listing.challengeID].isInitialized() || challenges[listing.challengeID].isResolved()); // Remove domain & return tokens resetListing(_domain); } // ----------------------- // TOKEN HOLDER INTERFACE // ----------------------- /** @notice Starts a poll for a domain which is either @notice in the apply stage or already in the whitelist. @dev Tokens are taken from the challenger and the applicant's deposit is locked. @param _domain The domain of an applicant's potential listing */ function challenge(string _domain) external returns (uint challengeID) { bytes32 domainHash = keccak256(_domain); Listing storage listing = listings[domainHash]; uint deposit = parameterizer.get("minDeposit"); // Domain must be in apply stage or already on the whitelist require(appWasMade(_domain) || listing.whitelisted); // Prevent multiple challenges require(!challenges[listing.challengeID].isInitialized() || challenges[listing.challengeID].isResolved()); if (listing.unstakedDeposit < deposit) { // Not enough tokens, domain auto-delisted resetListing(_domain); return 0; } // Takes tokens from challenger require(token.transferFrom(msg.sender, this, deposit)); // Starts poll uint pollID = voting.startPoll( parameterizer.get("voteQuorum"), parameterizer.get("commitStageLen"), parameterizer.get("revealStageLen") ); challenges[pollID] = Challenge.Data({ challenger: msg.sender, voting: voting, token: token, challengeID: pollID, rewardPool: ((100 - parameterizer.get("dispensationPct")) * deposit) / 100, stake: deposit, resolved: false, winningTokens: 0 }); // Updates listing to store most recent challenge listings[domainHash].challengeID = pollID; // Locks tokens for listing during challenge listings[domainHash].unstakedDeposit -= deposit; _Challenge(_domain, deposit, pollID); return pollID; } /** @notice Called by a voter to claim his/her reward for each completed vote. @dev Someone must call updateStatus() before this can be called. @param _challengeID The pollID of the challenge a reward is being claimed for @param _salt The salt of a voter's commit hash in the given poll */ function claimReward(uint _challengeID, uint _salt) public { uint reward = challenges[_challengeID].claimReward(msg.sender, _salt); _RewardClaimed(msg.sender, _challengeID, reward); } /** @notice Updates a domain's status from 'application' to 'listing' @notice or resolves a challenge if one exists. @param _domain The domain whose status is being updated */ function updateStatus(string _domain) public { if (canBeWhitelisted(_domain)) { whitelistApplication(_domain); _NewDomainWhitelisted(_domain); } else if (challengeCanBeResolved(_domain)) { resolveChallenge(_domain); } else { revert(); } } // -------- // GETTERS // -------- /** @dev Determines whether the domain of an application can be whitelisted. @param _domain The domain whose status should be examined */ function canBeWhitelisted(string _domain) constant public returns (bool) { bytes32 domainHash = keccak256(_domain); uint challengeID = listings[domainHash].challengeID; // Ensures that the application was made, // the application period has ended, // the domain can be whitelisted, // and either: the challengeID == 0, or the challenge has been resolved. if ( appWasMade(_domain) && isExpired(listings[domainHash].applicationExpiry) && !isWhitelisted(_domain) && (!challenges[challengeID].isInitialized() || challenges[challengeID].isResolved()) ) { return true; } return false; } /// @dev returns true if domain is whitelisted function isWhitelisted(string _domain) constant public returns (bool whitelisted) { return listings[keccak256(_domain)].whitelisted; } // @dev returns true if apply was called for this domain function appWasMade(string _domain) constant public returns (bool exists) { return listings[keccak256(_domain)].applicationExpiry > 0; } // @dev returns true if the application/listing has an unresolved challenge function challengeExists(string _domain) constant public returns (bool) { Challenge.Data storage challenge = challenges[listings[keccak256(_domain)].challengeID]; return challenge.isInitialized() && !challenge.isResolved(); } /** @notice Determines whether voting has concluded in a challenge for a given domain. @dev Throws if no challenge exists. @param _domain A domain with an unresolved challenge */ function challengeCanBeResolved(string _domain) constant public returns (bool) { Challenge.Data storage challenge = challenges[listings[keccak256(_domain)].challengeID]; return challenge.isInitialized() && challenge.canBeResolved(); } /** @notice Determines the number of tokens awarded to the winning party in a challenge. @param _challengeID The challengeID to determine a reward for */ function challengeWinnerReward(uint _challengeID) public constant returns (uint) { return challenges[_challengeID].challengeWinnerReward(); } /// @dev returns true if the provided termDate has passed function isExpired(uint _termDate) constant public returns (bool expired) { return _termDate < block.timestamp; } /** @dev Calculates the provided voter's token reward for the given poll. @param _voter The address of the voter whose reward balance is to be returned @param _challengeID The ID of the challenge the voter's reward is being calculated for @param _salt The salt of the voter's commit hash in the given poll @return The uint indicating the voter's reward (in nano-ADT) */ function voterReward(address _voter, uint _challengeID, uint _salt) public constant returns (uint) { return challenges[_challengeID].voterReward(_voter, _salt); } /** @dev Determines whether the provided voter has claimed tokens in a challenge @param _challengeID The ID of the challenge to determine whether a voter has claimed tokens for @param _voter The address of the voter whose claim status is to be determined for the provided challenge. @return Bool indicating whether the voter has claimed tokens in the provided challenge */ function tokenClaims(uint _challengeID, address _voter) public constant returns (bool) { return challenges[_challengeID].tokenClaims[_voter]; } // ---------------- // PRIVATE FUNCTIONS // ---------------- /** @dev Determines the winner in a challenge. Rewards the winner tokens and either whitelists or de-whitelists the domain. @param _domain A domain with a challenge that is to be resolved. */ function resolveChallenge(string _domain) private { bytes32 domainHash = keccak256(_domain); Listing storage listing = listings[domainHash]; Challenge.Data storage challenge = challenges[listing.challengeID]; // Calculates the winner's reward, // which is: (winner's full stake) + (dispensationPct * loser's stake) uint winnerReward = challenge.challengeWinnerReward(); // Records whether the domain is a listing or an application bool wasWhitelisted = isWhitelisted(_domain); // Case: challenge failed if (voting.isPassed(challenge.challengeID)) { whitelistApplication(_domain); // Unlock stake so that it can be retrieved by the applicant listing.unstakedDeposit += winnerReward; _ChallengeFailed(challenge.challengeID); if (!wasWhitelisted) { _NewDomainWhitelisted(_domain); } } // Case: challenge succeeded else { resetListing(_domain); // Transfer the reward to the challenger require(token.transfer(challenge.challenger, winnerReward)); _ChallengeSucceeded(challenge.challengeID); if (wasWhitelisted) { _ListingRemoved(_domain); } else { _ApplicationRemoved(_domain); } } challenge.winningTokens = challenge.voting.getTotalNumberOfTokensForWinningOption(challenge.challengeID); challenge.resolved = true; } /** @dev Called by updateStatus() if the applicationExpiry date passed without a challenge being made @dev Called by resolveChallenge() if an application/listing beat a challenge. @param _domain The domain of an application/listing to be whitelisted */ function whitelistApplication(string _domain) private { bytes32 domainHash = keccak256(_domain); listings[domainHash].whitelisted = true; } /** @dev deletes a listing from the whitelist and transfers tokens back to owner @param _domain the domain to be removed */ function resetListing(string _domain) private { bytes32 domainHash = keccak256(_domain); Listing storage listing = listings[domainHash]; // Transfers any remaining balance back to the owner if (listing.unstakedDeposit > 0) require(token.transfer(listing.owner, listing.unstakedDeposit)); delete listings[domainHash]; } }
@dev returns true if the provided termDate has passed
function isExpired(uint _termDate) constant public returns (bool expired) { return _termDate < block.timestamp; } @param _voter The address of the voter whose reward balance is to be returned @param _challengeID The ID of the challenge the voter's reward is being calculated for @param _salt The salt of the voter's commit hash in the given poll @return The uint indicating the voter's reward (in nano-ADT)
1,043,686
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 1135, 638, 309, 326, 2112, 2481, 1626, 711, 2275, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 1021, 1758, 434, 326, 331, 20005, 8272, 19890, 11013, 353, 358, 506, 2106, 203, 225, 632, 891, 389, 25092, 734, 1021, 1599, 434, 326, 12948, 326, 331, 20005, 1807, 19890, 353, 3832, 8894, 364, 203, 225, 632, 891, 389, 5759, 3639, 1021, 4286, 434, 326, 331, 20005, 1807, 3294, 1651, 316, 326, 864, 7672, 203, 225, 632, 2463, 2398, 1021, 2254, 11193, 326, 331, 20005, 1807, 19890, 261, 267, 15110, 17, 1880, 56, 13, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2021-03-19 */ /** *Submitted for verification at Etherscan.io on 2017-12-31 */ pragma solidity ^0.4.18; // ----------------------------------------------------------------------------------------------- // CryptoCatsMarket v3 // // Ethereum contract for Cryptocats (cryptocats.thetwentysix.io), // a digital asset marketplace DAPP for unique 8-bit cats on the Ethereum blockchain. // // Versions: // 3.0 - Bug fix to make ETH value sent in with getCat function withdrawable by contract owner. // Special thanks to BokkyPooBah (https://github.com/bokkypoobah) who found this issue! // 2.0 - Remove claimCat function with getCat function that is payable and accepts incoming ETH. // Feature added to set ETH pricing by each cat release and also for specific cats // 1.0 - Feature added to create new cat releases, add attributes and offer to sell/buy cats // 0.0 - Initial contract to support ownership of 12 unique 8-bit cats on the Ethereum blockchain // // Original contract code based off Cryptopunks DAPP by the talented people from Larvalabs // (https://github.com/larvalabs/cryptopunks) // // (c) Nas Munawar / Gendry Morales / Jochy Reyes / TheTwentySix. 2017. The MIT Licence. // ---------------------------------------------------------------------------------------------- contract CryptoCatsMarket { /* modifier to add to function that should only be callable by contract owner */ modifier onlyBy(address _account) { require(msg.sender == _account); _; } /* You can use this hash to verify the image file containing all cats */ string public imageHash = "3b82cfd5fb39faff3c2c9241ca5a24439f11bdeaa7d6c0771eb782ea7c963917"; /* Variables to store contract owner and contract token standard details */ address owner; string public standard = 'CryptoCats'; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; // Store reference to previous cryptocat contract containing alpha release owners // PROD - previous contract address // address public previousContractAddress = 0x9508008227b6b3391959334604677d60169EF540; // ROPSTEN - previous contract address address public previousContractAddress = 0xccEC9B9cB223854C46843A1990c36C4A37D80E2e; uint8 public contractVersion; bool public totalSupplyIsLocked; bool public allCatsAssigned = false; // boolean flag to indicate if all available cats are claimed uint public catsRemainingToAssign = 0; // variable to track cats remaining to be assigned/claimed uint public currentReleaseCeiling; // variable to track maximum cat index for latest release /* Create array to store cat index to owner address */ mapping (uint => address) public catIndexToAddress; /* Create array to store cat release id to price in wei for all cats in that release */ mapping (uint32 => uint) public catReleaseToPrice; /* Create array to store cat index to any exception price deviating from release price */ mapping (uint => uint) public catIndexToPriceException; /* Create an array with all balances */ mapping (address => uint) public balanceOf; /* Store type descriptor string for each attribute number */ mapping (uint => string) public attributeType; /* Store up to 6 cat attribute strings where attribute types are defined in attributeType */ mapping (uint => string[6]) public catAttributes; /* Struct that is used to describe seller offer details */ struct Offer { bool isForSale; // flag identifying if cat is for sale uint catIndex; address seller; // owner address uint minPrice; // price in ETH owner is willing to sell cat for address sellOnlyTo; // address identifying only buyer that seller is wanting to offer cat to } uint[] public releaseCatIndexUpperBound; // Store sale Offer details for each cat made for sale by its owner mapping (uint => Offer) public catsForSale; // Store pending withdrawal amounts in ETH that a failed bidder or successful seller is able to withdraw mapping (address => uint) public pendingWithdrawals; /* Define event types to publish transaction details related to transfer and buy/sell activities */ event CatTransfer(address indexed from, address indexed to, uint catIndex); event CatOffered(uint indexed catIndex, uint minPrice, address indexed toAddress); event CatBought(uint indexed catIndex, uint price, address indexed fromAddress, address indexed toAddress); event CatNoLongerForSale(uint indexed catIndex); /* Define event types used to publish to EVM log when cat assignment/claim and cat transfer occurs */ event Assign(address indexed to, uint256 catIndex); event Transfer(address indexed from, address indexed to, uint256 value); /* Define event for reporting new cats release transaction details into EVM log */ event ReleaseUpdate(uint256 indexed newCatsAdded, uint256 totalSupply, uint256 catPrice, string newImageHash); /* Define event for logging update to cat price for existing release of cats (only impacts unclaimed cats) */ event UpdateReleasePrice(uint32 releaseId, uint256 catPrice); /* Define event for logging transactions that change any cat attributes into EVM log*/ event UpdateAttribute(uint indexed attributeNumber, address indexed ownerAddress, bytes32 oldValue, bytes32 newValue); /* Initializes contract with initial supply tokens to the creator of the contract */ function CryptoCatsMarket() payable { owner = msg.sender; // Set contract creation sender as owner _totalSupply = 625; // Set total supply catsRemainingToAssign = _totalSupply; // Initialise cats remaining to total supply amount name = "CRYPTOCATS"; // Set the name for display purposes symbol = "CCAT"; // Set the symbol for display purposes decimals = 0; // Amount of decimals for display purposes contractVersion = 3; currentReleaseCeiling = 625; totalSupplyIsLocked = false; releaseCatIndexUpperBound.push(12); // Register release 0 getting to 12 cats releaseCatIndexUpperBound.push(189); // Register release 1 getting to 189 cats releaseCatIndexUpperBound.push(_totalSupply); // Register release 2 getting to 625 cats catReleaseToPrice[0] = 0; // Set price for release 0 catReleaseToPrice[1] = 0; // Set price for release 1 catReleaseToPrice[2] = 80000000000000000; // Set price for release 2 to Wei equivalent of 0.08 ETH } /* Admin function to make total supply permanently locked (callable by owner only) */ function lockTotalSupply() onlyBy(owner) { totalSupplyIsLocked = true; } /* Admin function to set attribute type descriptor text (callable by owner only) */ function setAttributeType(uint attributeIndex, string descriptionText) onlyBy(owner) { require(attributeIndex >= 0 && attributeIndex < 6); attributeType[attributeIndex] = descriptionText; } /* Admin function to release new cat index numbers and update image hash for new cat releases */ function releaseCats(uint32 _releaseId, uint numberOfCatsAdded, uint256 catPrice, string newImageHash) onlyBy(owner) returns (uint256 newTotalSupply) { require(!totalSupplyIsLocked); // Check that new cat releases still available require(numberOfCatsAdded > 0); // Require release to have more than 0 cats currentReleaseCeiling = currentReleaseCeiling + numberOfCatsAdded; // Add new cats to release ceiling uint _previousSupply = _totalSupply; _totalSupply = _totalSupply + numberOfCatsAdded; catsRemainingToAssign = catsRemainingToAssign + numberOfCatsAdded; // Update cats remaining to assign count imageHash = newImageHash; // Update image hash catReleaseToPrice[_releaseId] = catPrice; // Update price for new release of cats releaseCatIndexUpperBound.push(_totalSupply); // Track upper bound of cat index for this release ReleaseUpdate(numberOfCatsAdded, _totalSupply, catPrice, newImageHash); // Send EVM event containing details of release return _totalSupply; // Return new total supply of cats } /* Admin function to update price for an entire release of cats still available for claiming */ function updateCatReleasePrice(uint32 _releaseId, uint256 catPrice) onlyBy(owner) { require(_releaseId <= releaseCatIndexUpperBound.length); // Check that release is id valid catReleaseToPrice[_releaseId] = catPrice; // Update price for cat release UpdateReleasePrice(_releaseId, catPrice); // Send EVM event with release id and price details } /* Migrate details of previous contract cat owners addresses and cat balances to new contract instance */ function migrateCatOwnersFromPreviousContract(uint startIndex, uint endIndex) onlyBy(owner) { PreviousCryptoCatsContract previousCatContract = PreviousCryptoCatsContract(previousContractAddress); for (uint256 catIndex = startIndex; catIndex <= endIndex; catIndex++) { // Loop through cat index based on start/end index address catOwner = previousCatContract.catIndexToAddress(catIndex); // Retrieve owner address from previous contract if (catOwner != 0x0) { // Check that cat index has an owner address and is not unclaimed catIndexToAddress[catIndex] = catOwner; // Update owner address in current contract uint256 ownerBalance = previousCatContract.balanceOf(catOwner); balanceOf[catOwner] = ownerBalance; // Update owner cat balance } } catsRemainingToAssign = previousCatContract.catsRemainingToAssign(); // Update count of total cats remaining to assign from prev contract } /* Add value for cat attribute that has been defined (only for cat owner) */ function setCatAttributeValue(uint catIndex, uint attrIndex, string attrValue) { require(catIndex < _totalSupply); // cat index requested should not exceed total supply require(catIndexToAddress[catIndex] == msg.sender); // require sender to be cat owner require(attrIndex >= 0 && attrIndex < 6); // require that attribute index is 0 - 5 bytes memory tempAttributeTypeText = bytes(attributeType[attrIndex]); require(tempAttributeTypeText.length != 0); // require that attribute being stored is not empty catAttributes[catIndex][attrIndex] = attrValue; // store attribute value string in contract based on cat index } /* Transfer cat by owner to another wallet address Different usage in Cryptocats than in normal token transfers This will transfer an owner's cat to another wallet's address Cat is identified by cat index passed in as _value */ function transfer(address _to, uint256 _value) returns (bool success) { if (_value < _totalSupply && // ensure cat index is valid catIndexToAddress[_value] == msg.sender && // ensure sender is owner of cat balanceOf[msg.sender] > 0) { // ensure sender balance of cat exists balanceOf[msg.sender]--; // update (reduce) cat balance from owner catIndexToAddress[_value] = _to; // set new owner of cat in cat index balanceOf[_to]++; // update (include) cat balance for recepient Transfer(msg.sender, _to, _value); // trigger event with transfer details to EVM success = true; // set success as true after transfer completed } else { success = false; // set success as false if conditions not met } return success; // return success status } /* Returns count of how many cats are owned by an owner */ function balanceOf(address _owner) constant returns (uint256 balance) { require(balanceOf[_owner] != 0); // requires that cat owner balance is not 0 return balanceOf[_owner]; // return number of cats owned from array of balances by owner address } /* Return total supply of cats existing */ function totalSupply() constant returns (uint256 totalSupply) { return _totalSupply; } /* Claim cat at specified index if it is unassigned - Deprecated as replaced with getCat function in v2.0 */ // function claimCat(uint catIndex) { // require(!allCatsAssigned); // require all cats have not been assigned/claimed // require(catsRemainingToAssign != 0); // require cats remaining to be assigned count is not 0 // require(catIndexToAddress[catIndex] == 0x0); // require owner address for requested cat index is empty // require(catIndex < _totalSupply); // require cat index requested does not exceed total supply // require(catIndex < currentReleaseCeiling); // require cat index to not be above current ceiling of released cats // catIndexToAddress[catIndex] = msg.sender; // Assign sender's address as owner of cat // balanceOf[msg.sender]++; // Increase sender's balance holder // catsRemainingToAssign--; // Decrease cats remaining count // Assign(msg.sender, catIndex); // Triggers address assignment event to EVM's // // log to allow javascript callbacks // } /* Return the release index for a cat based on the cat index */ function getCatRelease(uint catIndex) returns (uint32) { for (uint32 i = 0; i < releaseCatIndexUpperBound.length; i++) { // loop through release index record array if (releaseCatIndexUpperBound[i] > catIndex) { // check if highest cat index for release is higher than submitted cat index return i; // return release id } } } /* Gets cat price for a particular cat index */ function getCatPrice(uint catIndex) returns (uint catPrice) { require(catIndex < _totalSupply); // Require that cat index is valid if(catIndexToPriceException[catIndex] != 0) { // Check if there is any exception pricing return catIndexToPriceException[catIndex]; // Return price if there is overriding exception pricing } uint32 releaseId = getCatRelease(catIndex); return catReleaseToPrice[releaseId]; // Return cat price based on release pricing if no exception pricing } /* Sets exception price in Wei that differs from release price for single cat based on cat index */ function setCatPrice(uint catIndex, uint catPrice) onlyBy(owner) { require(catIndex < _totalSupply); // Require that cat index is valid require(catPrice > 0); // Check that cat price is not 0 catIndexToPriceException[catIndex] = catPrice; // Create cat price record in exception pricing array for this cat index } /* Get cat with no owner at specified index by paying price */ function getCat(uint catIndex) payable { require(!allCatsAssigned); // require all cats have not been assigned/claimed require(catsRemainingToAssign != 0); // require cats remaining to be assigned count is not 0 require(catIndexToAddress[catIndex] == 0x0); // require owner address for requested cat index is empty require(catIndex < _totalSupply); // require cat index requested does not exceed total supply require(catIndex < currentReleaseCeiling); // require cat index to not be above current ceiling of released cats require(getCatPrice(catIndex) <= msg.value); // require ETH amount sent with tx is sufficient for cat price catIndexToAddress[catIndex] = msg.sender; // Assign sender's address as owner of cat balanceOf[msg.sender]++; // Increase sender's balance holder catsRemainingToAssign--; // Decrease cats remaining count pendingWithdrawals[owner] += msg.value; // Add paid amount to pending withdrawals for contract owner (bugfix in v3.0) Assign(msg.sender, catIndex); // Triggers address assignment event to EVM's // log to allow javascript callbacks } /* Get address of owner based on cat index */ function getCatOwner(uint256 catIndex) public returns (address) { require(catIndexToAddress[catIndex] != 0x0); return catIndexToAddress[catIndex]; // Return address at array position of cat index } /* Get address of contract owner who performed contract creation and initialisation */ function getContractOwner() public returns (address) { return owner; // Return address of contract owner } /* Indicate that cat is no longer for sale (by cat owner only) */ function catNoLongerForSale(uint catIndex) { require (catIndexToAddress[catIndex] == msg.sender); // Require that sender is cat owner require (catIndex < _totalSupply); // Require that cat index is valid catsForSale[catIndex] = Offer(false, catIndex, msg.sender, 0, 0x0); // Switch cat for sale flag to false and reset all other values CatNoLongerForSale(catIndex); // Create EVM event logging that cat is no longer for sale } /* Create sell offer for cat with a certain minimum sale price in wei (by cat owner only) */ function offerCatForSale(uint catIndex, uint minSalePriceInWei) { require (catIndexToAddress[catIndex] == msg.sender); // Require that sender is cat owner require (catIndex < _totalSupply); // Require that cat index is valid catsForSale[catIndex] = Offer(true, catIndex, msg.sender, minSalePriceInWei, 0x0); // Set cat for sale flag to true and update with price details CatOffered(catIndex, minSalePriceInWei, 0x0); // Create EVM event to log details of cat sale } /* Create sell offer for cat only to a particular buyer address with certain minimum sale price in wei (by cat owner only) */ function offerCatForSaleToAddress(uint catIndex, uint minSalePriceInWei, address toAddress) { require (catIndexToAddress[catIndex] == msg.sender); // Require that sender is cat owner require (catIndex < _totalSupply); // Require that cat index is valid catsForSale[catIndex] = Offer(true, catIndex, msg.sender, minSalePriceInWei, toAddress); // Set cat for sale flag to true and update with price details and only sell to address CatOffered(catIndex, minSalePriceInWei, toAddress); // Create EVM event to log details of cat sale } /* Buy cat that is currently on offer */ function buyCat(uint catIndex) payable { require (catIndex < _totalSupply); // require that cat index is valid and less than total cat index Offer offer = catsForSale[catIndex]; require (offer.isForSale); // require that cat is marked for sale // require buyer to have required address if indicated in offer require (msg.value >= offer.minPrice); // require buyer sent enough ETH require (offer.seller == catIndexToAddress[catIndex]); // require seller must still be owner of cat if (offer.sellOnlyTo != 0x0) { // if cat offer sell only to address is not blank require (offer.sellOnlyTo == msg.sender); // require that buyer is allowed to buy offer } address seller = offer.seller; catIndexToAddress[catIndex] = msg.sender; // update cat owner address to buyer's address balanceOf[seller]--; // reduce cat balance of seller balanceOf[msg.sender]++; // increase cat balance of buyer Transfer(seller, msg.sender, 1); // create EVM event logging transfer of 1 cat from seller to owner CatNoLongerForSale(catIndex); // create EVM event logging cat is no longer for sale pendingWithdrawals[seller] += msg.value; // increase pending withdrawal amount of seller based on amount sent in buyer's message CatBought(catIndex, msg.value, seller, msg.sender); // create EVM event logging details of cat purchase } /* Withdraw any pending ETH amount that is owed to failed bidder or successful seller */ function withdraw() { uint amount = pendingWithdrawals[msg.sender]; // store amount that can be withdrawn by sender pendingWithdrawals[msg.sender] = 0; // zero pending withdrawal amount msg.sender.transfer(amount); // before performing transfer to message sender } } contract PreviousCryptoCatsContract { /* You can use this hash to verify the image file containing all cats */ string public imageHash = "e055fe5eb1d95ea4e42b24d1038db13c24667c494ce721375bdd827d34c59059"; /* Variables to store contract owner and contract token standard details */ address owner; string public standard = 'CryptoCats'; string public name; string public symbol; uint8 public decimals; uint256 public _totalSupply; // Store reference to previous cryptocat contract containing alpha release owners // PROD address public previousContractAddress = 0xa185B9E63FB83A5a1A13A4460B8E8605672b6020; // ROPSTEN // address public previousContractAddress = 0x0b0DB7bd68F944C219566E54e84483b6c512737B; uint8 public contractVersion; bool public totalSupplyIsLocked; bool public allCatsAssigned = false; // boolean flag to indicate if all available cats are claimed uint public catsRemainingToAssign = 0; // variable to track cats remaining to be assigned/claimed uint public currentReleaseCeiling; // variable to track maximum cat index for latest release /* Create array to store cat index to owner address */ mapping (uint => address) public catIndexToAddress; /* Create an array with all balances */ mapping (address => uint) public balanceOf; /* Initializes contract with initial supply tokens to the creator of the contract */ function PreviousCryptoCatsContract() payable { owner = msg.sender; // Set contract creation sender as owner } /* Returns count of how many cats are owned by an owner */ function balanceOf(address _owner) constant returns (uint256 balance) { require(balanceOf[_owner] != 0); // requires that cat owner balance is not 0 return balanceOf[_owner]; // return number of cats owned from array of balances by owner address } /* Return total supply of cats existing */ function totalSupply() constant returns (uint256 totalSupply) { return _totalSupply; } /* Get address of owner based on cat index */ function getCatOwner(uint256 catIndex) public returns (address) { require(catIndexToAddress[catIndex] != 0x0); return catIndexToAddress[catIndex]; // Return address at array position of cat index } /* Get address of contract owner who performed contract creation and initialisation */ function getContractOwner() public returns (address) { return owner; // Return address of contract owner } }
Update cats remaining to assign count
catsRemainingToAssign = catsRemainingToAssign + numberOfCatsAdded;
8,073,784
[ 1, 4625, 348, 7953, 560, 30, 225, 2315, 27525, 4463, 358, 2683, 1056, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 27525, 11429, 774, 4910, 273, 27525, 11429, 774, 4910, 397, 7922, 39, 2323, 8602, 31, 282, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// It's a fixed version without the caret ^ to be certain that there aren't // breaking changes with new compiler versions pragma solidity 0.4.15; // I need Ownable to limt certain functions for the owner exclusively import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol'; // The ERC20 interface to make token transfers when paying the salary of the employees import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20.sol'; // Famous library to make secure calculus import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol'; // The oracle that I'm going to use import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; // For the sake of simplicity lets asume USD is a ERC20 token // Also lets asume we can 100% trust the exchange rate oracle contract PayrollInterface { /* OWNER ONLY */ function addEmployee(address accountAddress, address[] allowedTokens, uint256 initialYearlyUSDSalary); function setEmployeeSalary(uint256 employeeId, uint256 yearlyUSDSalary); function removeEmployee(uint256 employeeId); function addFunds() payable; function scapeHatch(); // function addTokenFunds()? // Use approveAndCall or ERC223 tokenFallback function getEmployeeCount() constant returns(uint256); function getEmployee(uint256 employeeId) constant returns( address employee, address[] allowedTokens, uint256 yearlySalary ); // Return all important info too function calculatePayrollBurnrate() constant returns(uint256); // Monthly usd amount spent in salaries function calculatePayrollRunway() constant returns(uint256); // Days until the contract can run out of funds /* EMPLOYEE ONLY */ function determineAllocation(address[] tokens, uint256[] distribution); // only callable once every 6 months function payday(); // only callable once a month /* ORACLE ONLY */ function setExchangeRate(address token, uint256 usdExchangeRate); // uses decimals from token } /// @title The payroll contract that will be used to pay the salary of the workers /// @author Merunas Grincalaitis <[email protected]> contract Payroll is PayrollInterface, Ownable, usingOraclize{ using SafeMath for uint256; // The data stored for each employee struct Employee { address accountAddress; address[] allowedTokens; uint256[] tokenDistribution; uint256 yearlySalary; uint256 lastTimeCalled; // Timestamp uint256 lastTimePayed; } // To locate each employee with his ID => Employee data mapping(uint256 => Employee) public employees; // To be able to get the ID of an employee given his address and get the rest // of the data mapping(address => uint256) public employeesIds; // Address of the token => price in USD mapping(address => uint256) public tokensPrices; // The symbol string of the token => address of the token mapping(string => address) public tokenSymbols; // To set the ID of each employee uint256 public employeeIdCounter = 0; // How much total USD is spent monthly in salaries uint256 public totalMonthlySalaries; // To notify users about approvals event LogApproval(address from, uint256 value, address tokenContract, bytes extraData); modifier onlyEmployee() { require(employees[employeesIds[msg.sender]].accountAddress != address(0)); _; } /// @notice Constructor used to set the proof of oraclize, relationate the /// tokens used for the Smart Contract with their corresponding symbol and /// to set the prices for the ANT and ETH tokens. /// Cheaper than creating ERC20 instances only for the token symbol /// @param _tokenAddresses The addresses of the tokens. Maximum 3 tokens, USD, ANT and ETH /// @param _tokenSymbols The corresponding symbols of the tokens function Payroll(address[3] _tokenAddresses, string[3] _tokenSymbols) public { require(_tokenAddresses.length > 0); require(_tokenAddresses.length > 0); // Save the values of symbol and address on the tokenSymbols mapping for(uint i = 0; i < 3; i++) { string memory symbol = _tokenSymbols[i]; address tokenAddress = _tokenAddresses[i]; tokenSymbols[symbol] = tokenAddress; } oraclize_setProof(proofType_Ledger); // Query the prices to get the ANT and ETH values oraclize_query(1 days, "URL", "json(https://coinmarketcap-nexuist.rhcloud.com/api/eth).price.usd"); oraclize_query(1.1 days, "URL", "json(https://coinmarketcap-nexuist.rhcloud.com/api/ant).price.usd"); } /// @notice Add a new employee to the business and set his profile data /// @param accountAddress Where the funds paid will be stored /// @param allowedTokens The array used to store what tokens he's allowed to use /// @param initialYearlyUSDSalary The initial yearly salary of that employee in USD function addEmployee( address accountAddress, address[] allowedTokens, uint256 initialYearlyUSDSalary ) public onlyOwner { require(accountAddress != address(0)); require(initialYearlyUSDSalary > 0); // At least 1 token must be allowed to be able to pay require(allowedTokens.length > 0); employeeIdCounter = employeeIdCounter.add(1); employees[employeeIdCounter].accountAddress = accountAddress; employees[employeeIdCounter].allowedTokens = allowedTokens; employees[employeeIdCounter].yearlySalary = initialYearlyUSDSalary; employees[employeeIdCounter].lastTimeCalled = block.timestamp; employees[employeeIdCounter].lastTimePayed = block.timestamp; employeesIds[accountAddress] = employeeIdCounter; updateTotalMonthlySalaries(0, initialYearlyUSDSalary); } /// @notice To set the salary of a specified employee /// @param employeeId The ID of that employee to modify his salary /// @param yearlyUSDSalary The new yearly salary that will be used function setEmployeeSalary(uint256 employeeId, uint256 yearlyUSDSalary) public onlyOwner { require(employeeId > 0); require(yearlyUSDSalary > 0); // Checking that the employee exists require(employees[employeeId].accountAddress != address(0)); uint256 salaryBefore = employees[employeeId].yearlySalary; employees[employeeId].yearlySalary = yearlyUSDSalary; updateTotalMonthlySalaries(salaryBefore, yearlyUSDSalary); } /// @notice Removes an employee from the list-mapping of employees /// @param employeeId The ID of the employee to delete function removeEmployee(uint256 employeeId) public onlyOwner { require(employeeId > 0); delete employees[employeeId]; } /// @notice Used by aproveAndCall to confirm that the approval was executed /// successfully and get notified /// @param _from The address that approved to use the token /// @param _value The amount of tokens approved to use /// @param _tokenContract The address of the token that executed the approval /// @param _extraData Extra data that could be interesting for the user function receiveApproval( address _from, uint256 _value, address _tokenContract, bytes _extraData ) public { LogApproval(_from, _value, _tokenContract, _extraData); } /// @notice To add Ether funds to the contract in order to use them later to pay the /// employees. Only used to store the ether sent, that's why it's empty. /// The balance of this contract will also be used to pay the Oraclize for his /// services. It costs about 5 cents each query to update the token prices function addFunds() public payable {} /// @notice To extract the ether from the contract in emergency cases function scapeHatch() public onlyOwner { msg.sender.transfer(this.balance); } /// @notice Updates the `totalMonthlySalaries` when a salary is changed or created /// in order to keep a record of how much total USD is spent each month in salaries /// @param salaryBefore How much the employee was earning before the update /// @param salaryAfter How much the employee will earn after the update function updateTotalMonthlySalaries(uint256 salaryBefore, uint256 salaryAfter) internal { require(salaryAfter > 0 && salaryAfter > salaryBefore); totalMonthlySalaries = totalMonthlySalaries.sub(salaryBefore); totalMonthlySalaries = totalMonthlySalaries.add(salaryAfter); } /// @notice To get how many employees are available /// @return uint256 The number of employees function getEmployeeCount() public constant returns(uint256) { return employeeIdCounter; } /// @notice To get the employee data given his ID /// @param employeeId The ID of that employee /// @return employee The address of the employee /// @return allowedTokens The array of tokens that he's allowed to use /// @return yearlySalary How much that employee gets paid each year in USD function getEmployee(uint256 employeeId) public constant returns( address employee, address[] allowedTokens, uint256 yearlySalary ) { // Must be an existing employee require(employeeId > 0 && employeeId <= employeeIdCounter); employee = employees[employeeId].accountAddress; allowedTokens = employees[employeeId].allowedTokens; yearlySalary = employees[employeeId].yearlySalary; } /// @notice Returns how much USD is spent each month in salaries /// @return uint256 The number of USD spent function calculatePayrollBurnrate() public constant returns(uint256) { return totalMonthlySalaries; } /// @notice Returns how many days until the contract runs out of funds /// @return uint256 The number of days left function calculatePayrollRunway() public constant returns(uint256) { uint256 paymentPerDay = totalMonthlySalaries.div(30); return this.balance.div(paymentPerDay); } /// @notice To establish what percentage of each token will be used to pay the salary /// of this employee. Only callable once every 6 months by the employee /// @param _tokens The array of tokens used to pay the salary of this employee /// @param distribution The percentages for each token up to 100 which is 100% function determineAllocation(address[] _tokens, uint256[] distribution) public onlyEmployee { require(_tokens.length > 0); require(distribution.length > 0); // Check if 6 months have passed require(block.timestamp >= employees[employeesIds[msg.sender]].lastTimeCalled.add(90 days)); uint256 employeeId = employeesIds[msg.sender]; employees[employeeId].lastTimeCalled = block.timestamp; employees[employeeId].allowedTokens = _tokens; employees[employeeId].tokenDistribution = distribution; } /// @notice To distribute the payment of the employee with the corresponding /// token allocationn. I don't like the fact that the array of tokens is a /// variable sized array because that could bring gas and stack limit problems function payday() public onlyEmployee { require(block.timestamp >= employees[employeesIds[msg.sender]].lastTimePayed.add(30 days)); uint256 employeeId = employeesIds[msg.sender]; address[] memory _tokens = employees[employeeId].allowedTokens; uint256[] memory distributions = employees[employeeId].tokenDistribution; uint256 monthlySalary = employees[employeeId].yearlySalary.div(12); // Distribute the payment depending on the allocation for each token for(uint i = 0; i < _tokens.length; i++) { // How much USD corresponds to that token allocation. For instance, // a token allocation of 40% will be 0.4 * monthlySalary in USD uint256 paymentToken = distributions[i].div(100).mul(monthlySalary); // Using the price of the token we can calculate how many tokens he'll // receive while setting the decimals of the token to 18 uint256 amountTokens = paymentToken.div(tokensPrices[_tokens[i]]).mul(1e18); // If the token being calculated is ether if(tokenSymbols['ETH'] == _tokens[i]) { // Transfer the corresponding amount of ETH with .transfer() msg.sender.transfer(amountTokens); } else { ERC20 token = ERC20(_tokens[i]); // We can use transferFrom because the owner added funds with approveAndCall() token.transferFrom(this, msg.sender, amountTokens); } } } /// @notice Callback function that gets called by Oraclize.it when the price of /// the tokens gets updated. It constantly updates the price of Ether and the /// ANT token each day. If you want to stop it, extract all the ether from this /// contract and Oraclize won't execute without his fee /// @param _queryId The query id that was generated used to verify the proof /// @param _result String that contains the price in USD obtained from the /// API of coinmarketcap /// @param _proof A string with a proof code to verify the authenticity of the /// query executed function __callback( bytes32 _queryId, string _result, bytes _proof ) public oraclize_randomDS_proofVerify(_queryId, _result, _proof) { require(msg.sender == oraclize_cbAddress()); // Convert the result to uint uint256 price = uint256(keccak256(_result)); // If the price is less than 100, then update the price of ANT. It's not a // perfect mechanism to specify the price of each token but it works if(price < 100) tokensPrices[tokenSymbols['ANT']] = price; else tokensPrices[tokenSymbols['ETH']] = price; // Renew the prices for each token using the Oraclize API each day // ETH price query oraclize_query(1 days, "URL", "json(https://coinmarketcap-nexuist.rhcloud.com/api/eth).price.usd"); // ANT price query oraclize_query(1.1 days, "URL", "json(https://coinmarketcap-nexuist.rhcloud.com/api/ant).price.usd"); } }
For the sake of simplicity lets asume USD is a ERC20 token Also lets asume we can 100% trust the exchange rate oracle function addTokenFunds()? Use approveAndCall or ERC223 tokenFallback
contract PayrollInterface { function addEmployee(address accountAddress, address[] allowedTokens, uint256 initialYearlyUSDSalary); function setEmployeeSalary(uint256 employeeId, uint256 yearlyUSDSalary); function removeEmployee(uint256 employeeId); function addFunds() payable; function scapeHatch(); function getEmployeeCount() constant returns(uint256); function getEmployee(uint256 employeeId) constant returns( address employee, address[] allowedTokens, uint256 yearlySalary pragma solidity 0.4.15; import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol'; import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20.sol'; import 'github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol'; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; }
6,393,968
[ 1, 4625, 348, 7953, 560, 30, 225, 2457, 326, 272, 911, 434, 3142, 20458, 14557, 487, 2066, 587, 9903, 353, 279, 4232, 39, 3462, 1147, 8080, 14557, 487, 2066, 732, 848, 2130, 9, 10267, 326, 7829, 4993, 20865, 445, 527, 1345, 42, 19156, 1435, 35, 225, 2672, 6617, 537, 1876, 1477, 578, 4232, 39, 3787, 23, 1147, 12355, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 13838, 2693, 1358, 288, 203, 203, 225, 445, 527, 41, 27520, 12, 2867, 2236, 1887, 16, 1758, 8526, 2935, 5157, 16, 2254, 5034, 2172, 5593, 715, 3378, 3948, 287, 814, 1769, 203, 225, 445, 444, 41, 27520, 55, 287, 814, 12, 11890, 5034, 24539, 1340, 548, 16, 2254, 5034, 3286, 715, 3378, 3948, 287, 814, 1769, 203, 225, 445, 1206, 41, 27520, 12, 11890, 5034, 24539, 1340, 548, 1769, 203, 203, 225, 445, 527, 42, 19156, 1435, 8843, 429, 31, 203, 225, 445, 888, 1273, 44, 505, 5621, 203, 203, 225, 445, 4774, 27520, 1380, 1435, 5381, 1135, 12, 11890, 5034, 1769, 203, 225, 445, 4774, 27520, 12, 11890, 5034, 24539, 1340, 548, 13, 5381, 1135, 12, 203, 282, 1758, 24539, 1340, 16, 203, 282, 1758, 8526, 2935, 5157, 16, 203, 282, 2254, 5034, 3286, 715, 55, 287, 814, 203, 203, 203, 203, 683, 9454, 18035, 560, 374, 18, 24, 18, 3600, 31, 203, 5666, 296, 6662, 18, 832, 19, 3678, 62, 881, 84, 292, 267, 19, 94, 881, 84, 292, 267, 17, 30205, 560, 19, 16351, 87, 19, 995, 12565, 19, 5460, 429, 18, 18281, 13506, 203, 5666, 296, 6662, 18, 832, 19, 3678, 62, 881, 84, 292, 267, 19, 94, 881, 84, 292, 267, 17, 30205, 560, 19, 16351, 87, 19, 2316, 19, 654, 39, 3462, 18, 18281, 13506, 203, 5666, 296, 6662, 18, 832, 19, 3678, 62, 881, 84, 292, 267, 19, 94, 881, 84, 292, 267, 17, 30205, 560, 19, 16351, 87, 19, 15949, 19, 9890, 10477, 18, 18281, 13506, 203, 5666, 315, 6662, 18, 832, 19, 280, 10150, 554, 19, 546, 822, 379, 17, 2425, 19, 280, 10150, 554, 2557, 18, 18281, 14432, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/4/0xCF8b1671c619B3a1a1317fDcfC3bB34fB32D9655/sources/HelloWorld.sol
Write your code here
contract HelloWorld { string public greet = "Hello World"; pragma solidity 0.8.13; }
8,588,115
[ 1, 4625, 348, 7953, 560, 30, 225, 2598, 3433, 981, 2674, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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374, 18, 28, 18, 3437, 31, 203, 97, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.6; pragma experimental ABIEncoderV2; // SPDX-License-Identifier: MIT /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT /** * @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 /** * @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 /** * @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 /** * @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 /** * @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 abstract contract ReentrancyGuard { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() public { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, "REENTRANCY_ERROR"); _status = _ENTERED; _; _status = _NOT_ENTERED; } } // SPDX-License-Identifier: GPL-3.0-or-later // Interface declarations /* solhint-disable func-order */ interface IUniswapRouter { function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); } // SPDX-License-Identifier: GPL-3.0-or-later // Interface declarations /* solhint-disable func-order */ interface IUniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address pair); function createPair(address tokenA, address tokenB) external returns (address pair); } // SPDX-License-Identifier: MIT interface IMasterChef { struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. SUSHIs to distribute per block. uint256 lastRewardBlock; // Last block number that SUSHIs distribution occurs. uint256 accSushiPerShare; // Accumulated SUSHIs per share, times 1e12. } function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function poolInfo(uint256 _pid) external view returns (PoolInfo memory); function pendingSushi(uint256 _pid, address _user) external view returns (uint256); function updatePool(uint256 _pid) external; function sushiPerBlock() external view returns (uint256); function totalAllocPoint() external view returns (uint256); function getMultiplier(uint256 _from, uint256 _to) external view returns (uint256); } // SPDX-License-Identifier: MIT /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT /** * @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 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This 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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 { } } // This contract is used for printing receipt tokens // Whenever someone joins a pool, a receipt token will be printed for that person contract ReceiptToken is ERC20, AccessControl { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); constructor() public ERC20("pAT", "Parachain Auction Token") { // Grant the contract deployer the default admin role: it will be able // to grant and revoke any roles _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /** * @notice Mint new receipt tokens to some user * @param to Address of the user that gets the receipt tokens * @param amount Amount of receipt tokens that will get minted */ function mint(address to, uint256 amount) public { require( hasRole(MINTER_ROLE, msg.sender), "ReceiptToken: Caller is not a minter" ); _mint(to, amount); } /** * @notice Burn receipt tokens from some user * @param from Address of the user that gets the receipt tokens burne * @param amount Amount of receipt tokens that will get burned */ function burn(address from, uint256 amount) public { require( hasRole(BURNER_ROLE, msg.sender), "ReceiptToken: Caller is not a burner" ); _burn(from, amount); } } // SPDX-License-Identifier: MIT /* |Strategy Flow| - User shows up with ETH. - We swap half of his ETH to DAI/USDC/USDT - Next step is to add liquidity to Sushiswap for ETH-USDT pair - Then we deposit SLPs in MasterChef and weget SUSHI rewards - Withdrawal flow does same thing, but backwards. */ contract SushiETHSLP is Ownable, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; ReceiptToken public receiptToken; address public token; address public weth; address public sushi; address payable public treasuryAddress; IUniswapRouter public sushiswapRouter; IUniswapFactory public sushiswapFactory; IMasterChef public masterChef; /// @notice Info of each user. struct UserInfo { uint256 amountEth; //amount of eth user invested uint256 amount; // How many SLP tokens the user has provided. uint256 sushiRewardDebt; // Reward debt for Sushi rewards. See explanation below. uint256 userTreasuryEth; //how much eth the user sent to treasury uint256 userCollectedFees; //how much eth the user sent to fee address uint256 userAccumulatedSushi; //how many rewards this user has uint256 amountReceiptToken; //receipt tokens printed for user; should be equal to amountfDai bool wasUserBlacklisted; //if user was blacklist at deposit time, he is not receiving receipt tokens uint256 timestamp; //first deposit timestamp; used for withdrawal lock time check uint256 earnedRewards; //before fees // // pending reward = (user.amount * pool.accRewardsPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws tokens to a pool. Here's what happens: // 1. The pool's `accRewardsPerShare` (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. } mapping(address => UserInfo) public userInfo; mapping(address => bool) public blacklisted; //blacklisted users do not receive a receipt token uint256 public masterChefPoolId = 0; uint256 public ethDust; uint256 public tokenDust; uint256 public treasueryEthDust; uint256 public treasuryTokenDust; uint256 public cap = uint256(1000); //eth cap uint256 public totalEth; //total invested eth uint256 public ethPrice; //for UI; to be updated from a script uint256 public lockTime = 10368000; //120 days address payable public feeAddress; uint256 public fee = uint256(50); uint256 constant feeFactor = uint256(10000); //events event RewardsExchanged( address indexed user, uint256 rewardsAmount, uint256 obtainedEth ); event RewardsEarned(address indexed user, uint256 amount); event FeeSet(address indexed sender, uint256 feeAmount); event FeeAddressSet(address indexed sender, address indexed feeAddress); /// @notice Event emitted when blacklist status for an address changes event BlacklistChanged( string actionType, address indexed user, bool oldVal, bool newVal ); /// @notice Event emitted when user makes a deposit and receipt token is minted event ReceiptMinted(address indexed user, uint256 amount); /// @notice Event emitted when user withdraws and receipt token is burned event ReceiptBurned(address indexed user, uint256 amount); /// @notice Event emitted when owner changes the master chef pool id event PoolIdChanged(address indexed sender, uint256 oldPid, uint256 newPid); /// @notice Event emitted when user makes a deposit event Deposit( address indexed user, address indexed origin, uint256 pid, uint256 amount ); /// @notice Event emitted when user withdraws event Withdraw( address indexed user, address indexed origin, uint256 pid, uint256 amount, uint256 auctionedAmount ); /// @notice Event emitted when owner changes any contract address event ChangedAddress( string indexed addressType, address indexed oldAddress, address indexed newAddress ); /// @notice Event emitted when owner makes a rescue dust request event RescuedDust(string indexed dustType, uint256 amount); //internal mapping(address => bool) public approved; //to defend against non whitelisted contracts /// @notice Used internally for avoiding "stack-too-deep" error when depositing struct DepositData { uint256 toSwapAmount; address[] swapPath; uint256[] swapAmounts; uint256 obtainedToken; uint256 liquidityTokenAmount; uint256 liquidityEthAmount; uint256 liquidity; address pair; uint256 pendingSushiTokens; } /// @notice Used internally for avoiding "stack-too-deep" error when withdrawing struct WithdrawData { uint256 prevSushiAmount; uint256 prevTokenAmount; uint256 prevSlpAmount; uint256 sushiAmount; uint256 tokenAmount; uint256 slpAmount; address pair; uint256 tokenLiquidityAmount; uint256 ethLiquidityAmount; uint256 totalToken; uint256 totalSushi; uint256 totalEth; uint256 feeableEth; uint256 auctionedEth; uint256 prevDustEthBalance; uint256 prevDustTokenBalance; } /** * @notice Create a new SushiETHSLP contract * @param _token Token address * @param _weth WETH address * @param _sushi SUSHI address * @param _sushiswapRouter Sushiswap Router address * @param _sushiswapFactory Sushiswap Factory address * @param _masterChef SushiSwap MasterChef address * @param _treasuryAddress treasury address * @param _receiptToken Receipt token that is minted and burned * @param _feeAddress fee address */ constructor( address _token, address _weth, address _sushi, address _sushiswapRouter, address _sushiswapFactory, address _masterChef, address payable _treasuryAddress, uint256 _poolId, address _receiptToken, address payable _feeAddress ) public { require(_token != address(0), "token_0x0"); require(_weth != address(0), "WETH_0x0"); require(_sushi != address(0), "SUSHI_0x0"); require(_sushiswapRouter != address(0), "ROUTER_0x0"); require(_sushiswapFactory != address(0), "FACTORY_0x0"); require(_masterChef != address(0), "CHEF_0x0"); require(_treasuryAddress != address(0), "TREASURY_0x0"); require(_receiptToken != address(0), "RECEIPT_0x0"); require(_feeAddress != address(0), "FEE_0x0"); token = _token; weth = _weth; sushi = _sushi; sushiswapRouter = IUniswapRouter(_sushiswapRouter); sushiswapFactory = IUniswapFactory(_sushiswapFactory); masterChef = IMasterChef(_masterChef); treasuryAddress = _treasuryAddress; masterChefPoolId = _poolId; receiptToken = ReceiptToken(_receiptToken); feeAddress = _feeAddress; } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Setters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice Update the address of TOKEN * @dev Can only be called by the owner * @param _token Address of TOKEN */ function setTokenAddress(address _token) public onlyOwner { require(_token != address(0), "0x0"); emit ChangedAddress("TOKEN", address(token), address(_token)); token = _token; } /** * @notice Update the address of WETH * @dev Can only be called by the owner * @param _weth Address of WETH */ function setWethAddress(address _weth) public onlyOwner { require(_weth != address(0), "0x0"); emit ChangedAddress("WETH", address(weth), address(_weth)); weth = _weth; } /** * @notice Update the address of Sushi * @dev Can only be called by the owner * @param _sushi Address of Sushi */ function setSushiAddress(address _sushi) public onlyOwner { require(_sushi != address(0), "0x0"); emit ChangedAddress("SUSHI", address(sushi), address(_sushi)); sushi = _sushi; } /** * @notice Update the address of Sushiswap Router * @dev Can only be called by the owner * @param _sushiswapRouter Address of Sushiswap Router */ function setSushiswapRouter(address _sushiswapRouter) public onlyOwner { require(_sushiswapRouter != address(0), "0x0"); emit ChangedAddress( "SUSHISWAP_ROUTER", address(sushiswapRouter), address(_sushiswapRouter) ); sushiswapRouter = IUniswapRouter(_sushiswapRouter); } /** * @notice Update the address of Sushiswap Factory * @dev Can only be called by the owner * @param _sushiswapFactory Address of Sushiswap Factory */ function setSushiswapFactory(address _sushiswapFactory) public onlyOwner { require(_sushiswapFactory != address(0), "0x0"); emit ChangedAddress( "SUSHISWAP_FACTORY", address(sushiswapFactory), address(_sushiswapFactory) ); sushiswapFactory = IUniswapFactory(_sushiswapFactory); } /** * @notice Update the address of Sushiswap Masterchef * @dev Can only be called by the owner * @param _masterChef Address of Sushiswap Masterchef */ function setMasterChef(address _masterChef) public onlyOwner { require(_masterChef != address(0), "0x0"); emit ChangedAddress( "MASTER_CHEF", address(masterChef), address(_masterChef) ); masterChef = IMasterChef(_masterChef); } /** * @notice Update the address for fees * @dev Can only be called by the owner * @param _feeAddress Fee's address */ function setTreasury(address payable _feeAddress) public onlyOwner { require(_feeAddress != address(0), "0x0"); emit ChangedAddress( "TREASURY", address(treasuryAddress), address(_feeAddress) ); treasuryAddress = _feeAddress; } /** * @notice Approve contract (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function approveContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = true; } /** * @notice Revoke contract's access (only approved contracts or msg.sender==tx.origin can call this strategy) * @dev Can only be called by the owner * @param account Contract's address */ function revokeContractAccess(address account) external onlyOwner { require(account != address(0), "0x0"); approved[account] = false; } /** * @notice Blacklist address; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function blacklistAddress(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("BLACKLIST", account, blacklisted[account], true); blacklisted[account] = true; } /** * @notice Remove address from blacklisted addresses; blacklisted addresses do not receive receipt tokens * @dev Can only be called by the owner * @param account User/contract address */ function removeFromBlacklist(address account) external onlyOwner { require(account != address(0), "0x0"); emit BlacklistChanged("REMOVE", account, blacklisted[account], false); blacklisted[account] = false; } /** * @notice Set max ETH cap for this strategy * @dev Can only be called by the owner * @param _cap ETH amount */ function setCap(uint256 _cap) external onlyOwner { cap = _cap; } /** * @notice Set ETH price * @dev Can only be called by the owner * @param _price ETH price */ function setEthPrice(uint256 _price) external onlyOwner { require(_price > 0, "PRICE_0"); ethPrice = _price; } /** * @notice Set lock time * @dev Can only be called by the owner * @param _lockTime lock time in seconds */ function setLockTime(uint256 _lockTime) external onlyOwner { require(_lockTime > 0, "TIME_0"); lockTime = _lockTime; } /** * @notice Update the pool id * @dev Can only be called by the owner * @param _pid pool id */ function setPoolId(uint256 _pid) public onlyOwner { uint256 old = masterChefPoolId; masterChefPoolId = _pid; emit PoolIdChanged(msg.sender, old, _pid); } function setFeeAddress(address payable _feeAddress) public onlyOwner { feeAddress = _feeAddress; emit FeeAddressSet(msg.sender, _feeAddress); } function setFee(uint256 _fee) public onlyOwner { require(_fee <= uint256(9000), "FEE_TOO_HIGH"); fee = _fee; emit FeeSet(msg.sender, _fee); } /** * @notice Rescue dust resulted from swaps/liquidity * @dev Can only be called by the owner */ function rescueDust() public onlyOwner { if (ethDust > 0) { treasuryAddress.transfer(ethDust); treasueryEthDust = treasueryEthDust.add(ethDust); emit RescuedDust("ETH", ethDust); ethDust = 0; } if (tokenDust > 0) { IERC20(token).safeTransfer(treasuryAddress, tokenDust); treasuryTokenDust = treasuryTokenDust.add(tokenDust); emit RescuedDust("TOKEN", tokenDust); tokenDust = 0; } } /** * @notice Rescue any non-reward token that was airdropped to this contract * @dev Can only be called by the owner */ function rescueAirdroppedTokens(address _token, address to) public onlyOwner { require(_token != address(0), "token_0x0"); require(to != address(0), "to_0x0"); require(_token != sushi, "rescue_reward_error"); uint256 balanceOfToken = IERC20(_token).balanceOf(address(this)); require(balanceOfToken > 0, "balance_0"); require(IERC20(_token).transfer(to, balanceOfToken), "rescue_failed"); } /** * @notice Check if user can withdraw based on current lock time * @param user Address of the user * @return true or false */ function isWithdrawalAvailable(address user) public view returns (bool) { if (lockTime > 0) { return userInfo[user].timestamp.add(lockTime) <= block.timestamp; } return true; } /** * @notice Deposit to this strategy for rewards * @param deadline Number of blocks until transaction expires * @return Amount of LPs */ function deposit(uint256 deadline) public payable nonReentrant returns (uint256) { // ----- // validate // ----- _defend(); require(msg.value > 0, "ETH_0"); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(totalEth.add(msg.value) <= cap, "CAP_REACHED"); uint256 prevEthBalance = address(this).balance.sub(msg.value); uint256 prevTokenBalance = IERC20(token).balanceOf(address(this)); DepositData memory results; UserInfo storage user = userInfo[msg.sender]; if (user.amount == 0) { user.wasUserBlacklisted = blacklisted[msg.sender]; } if (user.timestamp == 0) { user.timestamp = block.timestamp; } totalEth = totalEth.add(msg.value); user.amountEth = user.amountEth.add(msg.value); // ----- // obtain TOKEN from received ETH and add liquidity // ----- results.toSwapAmount = msg.value.div(2); results.swapPath = new address[](2); results.swapPath[0] = weth; results.swapPath[1] = token; results.swapAmounts = sushiswapRouter.swapExactETHForTokens{ value: results.toSwapAmount }(uint256(0), results.swapPath, address(this), deadline); results.obtainedToken = results.swapAmounts[ results.swapAmounts.length - 1 ]; IERC20(token).safeIncreaseAllowance( address(sushiswapRouter), results.obtainedToken ); ( results.liquidityTokenAmount, results.liquidityEthAmount, results.liquidity ) = sushiswapRouter.addLiquidityETH{value: results.toSwapAmount}( token, results.obtainedToken, uint256(0), uint256(0), address(this), deadline ); results.pair = sushiswapFactory.getPair(token, weth); IERC20(results.pair).safeIncreaseAllowance( address(masterChef), results.liquidity ); // ----- // deposit into master chef // ----- masterChef.updatePool(masterChefPoolId); results.pendingSushiTokens = user .amount .mul(masterChef.poolInfo(masterChefPoolId).accSushiPerShare) .div(1e12) .sub(user.sushiRewardDebt); user.amount = user.amount.add(results.liquidity); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.add( results.liquidity ); receiptToken.mint(msg.sender, results.liquidity); emit ReceiptMinted(msg.sender, results.liquidity); } masterChef.updatePool(masterChefPoolId); user.sushiRewardDebt = user .amount .mul(masterChef.poolInfo(masterChefPoolId).accSushiPerShare) .div(1e12); uint256 prevSushiBalance = IERC20(sushi).balanceOf(address(this)); masterChef.deposit(masterChefPoolId, results.liquidity); if (results.pendingSushiTokens > 0) { uint256 sushiBalance = IERC20(sushi).balanceOf(address(this)); uint256 actualSushiTokens = sushiBalance.sub(prevSushiBalance); if (results.pendingSushiTokens > actualSushiTokens) { user.userAccumulatedSushi = user.userAccumulatedSushi.add( actualSushiTokens ); } else { user.userAccumulatedSushi = user.userAccumulatedSushi.add( results.pendingSushiTokens ); } } emit Deposit( msg.sender, tx.origin, masterChefPoolId, results.liquidity ); ethDust = ethDust.add(address(this).balance.sub(prevEthBalance)); tokenDust = tokenDust.add( (IERC20(token).balanceOf(address(this))).sub(prevTokenBalance) ); return results.liquidity; } /** * @notice Withdraw tokens and claim rewards * @param deadline Number of blocks until transaction expires * @return Amount of ETH obtained */ function withdraw(uint256 amount, uint256 deadline) public nonReentrant returns (uint256) { // ----- // validation // ----- uint256 receiptBalance = receiptToken.balanceOf(msg.sender); _defend(); require(deadline >= block.timestamp, "DEADLINE_ERROR"); require(amount > 0, "AMOUNT_0"); UserInfo storage user = userInfo[msg.sender]; require(user.amount >= amount, "AMOUNT_GREATER_THAN_BALANCE"); if (!user.wasUserBlacklisted) { require(receiptBalance >= user.amount, "RECEIPT_AMOUNT"); } if (lockTime > 0) { require( user.timestamp.add(lockTime) <= block.timestamp, "LOCK_TIME" ); } WithdrawData memory results; results.prevDustEthBalance = address(this).balance; results.prevDustTokenBalance = IERC20(token).balanceOf(address(this)); // ----- // withdraw from sushi master chef // ----- masterChef.updatePool(masterChefPoolId); uint256 pendingSushiTokens = user .amount .mul(masterChef.poolInfo(masterChefPoolId).accSushiPerShare) .div(1e12) .sub(user.sushiRewardDebt); ( results.pair, results.tokenAmount, results.sushiAmount, results.slpAmount ) = _witdraw(amount); require(results.slpAmount > 0, "SLP_AMOUNT_0"); user.amount = user.amount.sub(amount); if (!user.wasUserBlacklisted) { user.amountReceiptToken = user.amountReceiptToken.sub(amount); receiptToken.burn(msg.sender, amount); emit ReceiptBurned(msg.sender, amount); } user.sushiRewardDebt = user .amount .mul(masterChef.poolInfo(masterChefPoolId).accSushiPerShare) .div(1e12); uint256 sushiBalance = IERC20(sushi).balanceOf(address(this)); if (pendingSushiTokens > 0) { if (pendingSushiTokens > sushiBalance) { user.userAccumulatedSushi = user.userAccumulatedSushi.add( sushiBalance ); } else { user.userAccumulatedSushi = user.userAccumulatedSushi.add( pendingSushiTokens ); } } // ----- // remove liquidity & convert everything to ETH // ----- IERC20(results.pair).safeIncreaseAllowance( address(sushiswapRouter), results.slpAmount ); ( results.tokenLiquidityAmount, results.ethLiquidityAmount ) = sushiswapRouter.removeLiquidityETH( token, results.slpAmount, uint256(0), uint256(0), address(this), deadline ); require(results.tokenLiquidityAmount > 0, "TOKEN_LIQUIDITY_0"); require(results.ethLiquidityAmount > 0, "ETH_LIQUIDITY_0"); results.totalSushi = user.userAccumulatedSushi; results.totalToken = results.totalToken.add( results.tokenLiquidityAmount ); results.totalEth = results.ethLiquidityAmount; //swap sushi with eth address[] memory swapPath = new address[](2); swapPath[0] = sushi; swapPath[1] = weth; if (results.totalSushi > 0) { emit RewardsEarned(msg.sender, results.totalSushi); user.earnedRewards = user.earnedRewards.add(results.totalSushi); IERC20(sushi).safeIncreaseAllowance( address(sushiswapRouter), results.totalSushi ); uint256[] memory sushiSwapAmounts = sushiswapRouter.swapExactTokensForETH( results.totalSushi, uint256(0), swapPath, address(this), deadline ); emit RewardsExchanged( msg.sender, results.totalSushi, sushiSwapAmounts[sushiSwapAmounts.length - 1] ); results.feeableEth = results.feeableEth.add( sushiSwapAmounts[sushiSwapAmounts.length - 1] ); } if (results.totalToken > 0) { IERC20(token).safeIncreaseAllowance( address(sushiswapRouter), results.totalToken ); swapPath[0] = token; uint256[] memory tokenSwapAmounts = sushiswapRouter.swapExactTokensForETH( results.totalToken, uint256(0), swapPath, address(this), deadline ); results.totalEth = results.totalEth.add( tokenSwapAmounts[tokenSwapAmounts.length - 1] ); } // ----- // transfer ETH to user // ----- results.auctionedEth = results.feeableEth.div(2); results.feeableEth = results.feeableEth.sub(results.auctionedEth); results.totalEth = results.totalEth.add(results.feeableEth); if (user.amountEth > results.totalEth) { user.amountEth = user.amountEth.sub(results.totalEth); } else { user.amountEth = 0; } if (results.totalEth < totalEth) { totalEth = totalEth.sub(results.totalEth); } else { totalEth = 0; } //at some point we might not have any fees if (fee > 0) { uint256 feeEth = _calculateFee(results.totalEth); results.totalEth = results.totalEth.sub(feeEth); feeAddress.transfer(feeEth); user.userCollectedFees = user.userCollectedFees.add(feeEth); } msg.sender.transfer(results.totalEth); treasuryAddress.transfer(results.auctionedEth); user.userTreasuryEth = user.userTreasuryEth.add(results.auctionedEth); emit Withdraw( msg.sender, tx.origin, masterChefPoolId, results.totalEth, results.auctionedEth ); user.userAccumulatedSushi = 0; ethDust = ethDust.add( address(this).balance.sub(results.prevDustEthBalance) ); tokenDust = tokenDust.add( (IERC20(token).balanceOf(address(this))).sub( results.prevDustTokenBalance ) ); return results.totalEth; } function _witdraw(uint256 amount) private returns ( address, uint256, uint256, uint256 ) { WithdrawData memory results; results.pair = sushiswapFactory.getPair(token, weth); results.prevTokenAmount = IERC20(token).balanceOf(address(this)); results.prevSushiAmount = IERC20(sushi).balanceOf(address(this)); results.prevSlpAmount = IERC20(results.pair).balanceOf(address(this)); masterChef.updatePool(masterChefPoolId); masterChef.withdraw(masterChefPoolId, amount); results.tokenAmount = (IERC20(token).balanceOf(address(this))).sub( results.prevTokenAmount ); results.sushiAmount = (IERC20(sushi).balanceOf(address(this))).sub( results.prevSushiAmount ); results.slpAmount = (IERC20(results.pair).balanceOf(address(this))).sub( results.prevSlpAmount ); return ( results.pair, results.tokenAmount, results.sushiAmount, results.slpAmount ); } //-----------------------------------------------------------------------------------------------------------------// //------------------------------------ Getters -------------------------------------------------// //-----------------------------------------------------------------------------------------------------------------// /** * @notice View function to see pending rewards for account. * @param account user account to check * @return pending rewards */ function getPendingRewards(address account) public view returns (uint256) { UserInfo storage user = userInfo[account]; IMasterChef.PoolInfo memory sushiPool = masterChef.poolInfo(masterChefPoolId); uint256 sushiPerBlock = masterChef.sushiPerBlock(); uint256 totalSushiAllocPoint = masterChef.totalAllocPoint(); uint256 accSushiPerShare = sushiPool.accSushiPerShare; uint256 lpSupply = sushiPool.lpToken.balanceOf(address(masterChef)); if (block.number > sushiPool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = masterChef.getMultiplier( sushiPool.lastRewardBlock, block.number ); uint256 sushiReward = multiplier.mul(sushiPerBlock).mul(sushiPool.allocPoint).div( totalSushiAllocPoint ); accSushiPerShare = accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); } uint256 accumulatedSushi = user.amount.mul(accSushiPerShare).div(1e12); if (accumulatedSushi < user.sushiRewardDebt) { return 0; } return accumulatedSushi.sub(user.sushiRewardDebt); } function _calculateFee(uint256 amount) private view returns (uint256) { return (amount.mul(fee)).div(feeFactor); } /// @notice Private method to check if contract is approved or this strategy is called by a normal user function _defend() private view returns (bool) { require( approved[msg.sender] || msg.sender == tx.origin, "access_denied" ); } receive() external payable {} }
Storage of set values Position of the value in the `values` array, plus 1 because index 0 means a value is not in the set.
function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function poolInfo(uint256 _pid) external view returns (PoolInfo memory); function pendingSushi(uint256 _pid, address _user) external view returns (uint256); function updatePool(uint256 _pid) external; function sushiPerBlock() external view returns (uint256); function totalAllocPoint() external view returns (uint256); function getMultiplier(uint256 _from, uint256 _to) external view returns (uint256); } struct Set { bytes32[] _values; mapping (bytes32 => uint256) _indexes; }
524,906
[ 1, 4625, 348, 7953, 560, 30, 225, 5235, 434, 444, 924, 11010, 434, 326, 460, 316, 326, 1375, 2372, 68, 526, 16, 8737, 404, 2724, 770, 374, 4696, 279, 460, 353, 486, 316, 326, 444, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 443, 1724, 12, 11890, 5034, 389, 6610, 16, 2254, 5034, 389, 8949, 13, 3903, 31, 203, 203, 565, 445, 598, 9446, 12, 11890, 5034, 389, 6610, 16, 2254, 5034, 389, 8949, 13, 3903, 31, 203, 203, 565, 445, 2845, 966, 12, 11890, 5034, 389, 6610, 13, 3903, 1476, 1135, 261, 2864, 966, 3778, 1769, 203, 203, 565, 445, 4634, 55, 1218, 77, 12, 11890, 5034, 389, 6610, 16, 1758, 389, 1355, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 1089, 2864, 12, 11890, 5034, 389, 6610, 13, 3903, 31, 203, 203, 565, 445, 272, 1218, 77, 2173, 1768, 1435, 3903, 1476, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 2078, 8763, 2148, 1435, 3903, 1476, 1135, 261, 11890, 5034, 1769, 203, 203, 565, 445, 31863, 5742, 12, 11890, 5034, 389, 2080, 16, 2254, 5034, 389, 869, 13, 203, 3639, 3903, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 1769, 203, 97, 203, 203, 565, 1958, 1000, 288, 203, 3639, 1731, 1578, 8526, 389, 2372, 31, 203, 203, 3639, 2874, 261, 3890, 1578, 516, 2254, 5034, 13, 389, 11265, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/288/0xe9c65c581334E2eEE8c86a9F7aDbd006d78423E5/sources/contracts/investmentVehicle/oolong/OolongSwapV1Base.sol
initialize the iv with oolongFarm and its respective base asset @param _store the address of system storage @param _baseAsset the address of base asset @param _pid the pid of the Oolong Swap LP pair
) public initializer { super.initialize(_store, _baseAsset); pid = _pid; token0 = IUniswapV2Pair(_baseAsset).token0(); token1 = IUniswapV2Pair(_baseAsset).token1(); (address lpToken, uint256 allocPoint, uint256 lastRewardTimestamp, uint256 accOolongPerShare, address bonusFarm) = IOolongFarm(oolongFarm).poolInfo(_pid); require(lpToken == _baseAsset, "Unmatched pid and lpToken"); _addRewardToken(olo); }
7,106,947
[ 1, 4625, 348, 7953, 560, 30, 225, 4046, 326, 4674, 598, 320, 355, 932, 42, 4610, 471, 2097, 17613, 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, 11160, 24899, 2233, 16, 389, 1969, 6672, 1769, 203, 3639, 4231, 273, 389, 6610, 31, 203, 3639, 1147, 20, 273, 467, 984, 291, 91, 438, 58, 22, 4154, 24899, 1969, 6672, 2934, 2316, 20, 5621, 203, 3639, 1147, 21, 273, 467, 984, 291, 91, 438, 58, 22, 4154, 24899, 1969, 6672, 2934, 2316, 21, 5621, 203, 203, 3639, 261, 2867, 12423, 1345, 16, 2254, 5034, 4767, 2148, 16, 2254, 5034, 1142, 17631, 1060, 4921, 16, 2254, 5034, 4078, 51, 355, 932, 2173, 9535, 16, 1758, 324, 22889, 42, 4610, 13, 7010, 3639, 273, 1665, 355, 932, 42, 4610, 12, 1371, 932, 42, 4610, 2934, 6011, 966, 24899, 6610, 1769, 203, 3639, 2583, 12, 9953, 1345, 422, 389, 1969, 6672, 16, 315, 984, 11073, 4231, 471, 12423, 1345, 8863, 203, 203, 3639, 389, 1289, 17631, 1060, 1345, 12, 12854, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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; contract initializable5 { //inject NONSTANDARD NAMING bool private initialized; bool private initializing; modifier INITIALIZER65() { //inject NONSTANDARD NAMING require(initializing || ISCONSTRUCTOR91() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } function ISCONSTRUCTOR91() private view returns (bool) { //inject NONSTANDARD NAMING // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } contract contextupgradesafe87 is initializable5 { //inject NONSTANDARD NAMING // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __CONTEXT_INIT10() internal INITIALIZER65 { //inject NONSTANDARD NAMING __CONTEXT_INIT_UNCHAINED61(); } function __CONTEXT_INIT_UNCHAINED61() internal INITIALIZER65 { //inject NONSTANDARD NAMING } function _MSGSENDER78() internal view virtual returns (address payable) { //inject NONSTANDARD NAMING return msg.sender; } function _MSGDATA22() internal view virtual returns (bytes memory) { //inject NONSTANDARD NAMING this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } contract ownableupgradesafe25 is initializable5, contextupgradesafe87 { //inject NONSTANDARD NAMING address private _owner; event OWNERSHIPTRANSFERRED52(address indexed previousOwner, address indexed newOwner); //inject NONSTANDARD NAMING function __OWNABLE_INIT13() internal INITIALIZER65 { //inject NONSTANDARD NAMING __CONTEXT_INIT_UNCHAINED61(); __OWNABLE_INIT_UNCHAINED84(); } function __OWNABLE_INIT_UNCHAINED84() internal INITIALIZER65 { //inject NONSTANDARD NAMING address msgSender = _MSGSENDER78(); _owner = msgSender; emit OWNERSHIPTRANSFERRED52(address(0), msgSender); } function OWNER9() public view returns (address) { //inject NONSTANDARD NAMING return _owner; } modifier ONLYOWNER81() { //inject NONSTANDARD NAMING require(_owner == _MSGSENDER78(), "Ownable: caller is not the owner"); _; } function RENOUNCEOWNERSHIP19() public virtual ONLYOWNER81 { //inject NONSTANDARD NAMING emit OWNERSHIPTRANSFERRED52(_owner, address(0)); _owner = address(0); } function TRANSFEROWNERSHIP24(address newOwner) public virtual ONLYOWNER81 { //inject NONSTANDARD NAMING require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OWNERSHIPTRANSFERRED52(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; } library safemath14 { //inject NONSTANDARD NAMING function ADD80(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function SUB60(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING return SUB60(a, b, "SafeMath: subtraction overflow"); } function SUB60(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { //inject NONSTANDARD NAMING require(b <= a, errorMessage); uint256 c = a - b; return c; } function MUL16(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function DIV54(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING return DIV54(a, b, "SafeMath: division by zero"); } function DIV54(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { //inject NONSTANDARD NAMING // 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; } function MOD56(uint256 a, uint256 b) internal pure returns (uint256) { //inject NONSTANDARD NAMING return MOD56(a, b, "SafeMath: modulo by zero"); } function MOD56(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { //inject NONSTANDARD NAMING require(b != 0, errorMessage); return a % b; } } interface ierc2086 { //inject NONSTANDARD NAMING function TOTALSUPPLY25() external view returns (uint256); //inject NONSTANDARD NAMING function BALANCEOF21(address account) external view returns (uint256); //inject NONSTANDARD NAMING function TRANSFER6(address recipient, uint256 amount) external returns (bool); //inject NONSTANDARD NAMING function ALLOWANCE84(address owner, address spender) external view returns (uint256); //inject NONSTANDARD NAMING function APPROVE33(address spender, uint256 amount) external returns (bool); //inject NONSTANDARD NAMING function TRANSFERFROM54(address sender, address recipient, uint256 amount) external returns (bool); //inject NONSTANDARD NAMING event TRANSFER56(address indexed from, address indexed to, uint256 value); //inject NONSTANDARD NAMING event APPROVAL90(address indexed owner, address indexed spender, uint256 value); //inject NONSTANDARD NAMING } library console87 { //inject NONSTANDARD NAMING address constant console_address36 = address(0x000000000000000000636F6e736F6c652e6c6f67); //inject NONSTANDARD NAMING function _SENDLOGPAYLOAD51(bytes memory payload) private view { //inject NONSTANDARD NAMING uint256 payloadLength = payload.length; address consoleAddress = console_address36; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function LOG40() internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log()")); } function LOGINT64(int p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(int)", p0)); } function LOGUINT96(uint p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint)", p0)); } function LOGSTRING94(string memory p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string)", p0)); } function LOGBOOL52(bool p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool)", p0)); } function LOGADDRESS2(address p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address)", p0)); } function LOGBYTES0(bytes memory p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes)", p0)); } function LOGBYTE23(byte p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(byte)", p0)); } function LOGBYTES1100(bytes1 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes1)", p0)); } function LOGBYTES273(bytes2 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes2)", p0)); } function LOGBYTES377(bytes3 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes3)", p0)); } function LOGBYTES477(bytes4 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes4)", p0)); } function LOGBYTES578(bytes5 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes5)", p0)); } function LOGBYTES61(bytes6 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes6)", p0)); } function LOGBYTES735(bytes7 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes7)", p0)); } function LOGBYTES818(bytes8 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes8)", p0)); } function LOGBYTES931(bytes9 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes9)", p0)); } function LOGBYTES1064(bytes10 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes10)", p0)); } function LOGBYTES1141(bytes11 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes11)", p0)); } function LOGBYTES1261(bytes12 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes12)", p0)); } function LOGBYTES1365(bytes13 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes13)", p0)); } function LOGBYTES1433(bytes14 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes14)", p0)); } function LOGBYTES1532(bytes15 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes15)", p0)); } function LOGBYTES1678(bytes16 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes16)", p0)); } function LOGBYTES176(bytes17 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes17)", p0)); } function LOGBYTES1833(bytes18 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes18)", p0)); } function LOGBYTES1973(bytes19 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes19)", p0)); } function LOGBYTES202(bytes20 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes20)", p0)); } function LOGBYTES2137(bytes21 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes21)", p0)); } function LOGBYTES2248(bytes22 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes22)", p0)); } function LOGBYTES2317(bytes23 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes23)", p0)); } function LOGBYTES2438(bytes24 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes24)", p0)); } function LOGBYTES2548(bytes25 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes25)", p0)); } function LOGBYTES261(bytes26 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes26)", p0)); } function LOGBYTES2793(bytes27 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes27)", p0)); } function LOGBYTES2869(bytes28 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes28)", p0)); } function LOGBYTES299(bytes29 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes29)", p0)); } function LOGBYTES3053(bytes30 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes30)", p0)); } function LOGBYTES3139(bytes31 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes31)", p0)); } function LOGBYTES3263(bytes32 p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bytes32)", p0)); } function LOG40(uint p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint)", p0)); } function LOG40(string memory p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string)", p0)); } function LOG40(bool p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool)", p0)); } function LOG40(address p0) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address)", p0)); } function LOG40(uint p0, uint p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function LOG40(uint p0, string memory p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function LOG40(uint p0, bool p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function LOG40(uint p0, address p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function LOG40(string memory p0, uint p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function LOG40(string memory p0, string memory p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string)", p0, p1)); } function LOG40(string memory p0, bool p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function LOG40(string memory p0, address p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address)", p0, p1)); } function LOG40(bool p0, uint p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function LOG40(bool p0, string memory p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function LOG40(bool p0, bool p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function LOG40(bool p0, address p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function LOG40(address p0, uint p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function LOG40(address p0, string memory p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string)", p0, p1)); } function LOG40(address p0, bool p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function LOG40(address p0, address p1) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address)", p0, p1)); } function LOG40(uint p0, uint p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function LOG40(uint p0, uint p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function LOG40(uint p0, uint p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function LOG40(uint p0, uint p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function LOG40(uint p0, string memory p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function LOG40(uint p0, string memory p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function LOG40(uint p0, string memory p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function LOG40(uint p0, string memory p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function LOG40(uint p0, bool p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function LOG40(uint p0, bool p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function LOG40(uint p0, bool p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function LOG40(uint p0, bool p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function LOG40(uint p0, address p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function LOG40(uint p0, address p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function LOG40(uint p0, address p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function LOG40(uint p0, address p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function LOG40(string memory p0, uint p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function LOG40(string memory p0, uint p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function LOG40(string memory p0, uint p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function LOG40(string memory p0, uint p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function LOG40(string memory p0, string memory p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function LOG40(string memory p0, string memory p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function LOG40(string memory p0, string memory p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function LOG40(string memory p0, string memory p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function LOG40(string memory p0, bool p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function LOG40(string memory p0, bool p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function LOG40(string memory p0, bool p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function LOG40(string memory p0, bool p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function LOG40(string memory p0, address p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function LOG40(string memory p0, address p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function LOG40(string memory p0, address p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function LOG40(string memory p0, address p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function LOG40(bool p0, uint p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function LOG40(bool p0, uint p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function LOG40(bool p0, uint p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function LOG40(bool p0, uint p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function LOG40(bool p0, string memory p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function LOG40(bool p0, string memory p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function LOG40(bool p0, string memory p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function LOG40(bool p0, string memory p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function LOG40(bool p0, bool p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function LOG40(bool p0, bool p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function LOG40(bool p0, bool p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function LOG40(bool p0, bool p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function LOG40(bool p0, address p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function LOG40(bool p0, address p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function LOG40(bool p0, address p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function LOG40(bool p0, address p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function LOG40(address p0, uint p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function LOG40(address p0, uint p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function LOG40(address p0, uint p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function LOG40(address p0, uint p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function LOG40(address p0, string memory p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function LOG40(address p0, string memory p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function LOG40(address p0, string memory p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function LOG40(address p0, string memory p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function LOG40(address p0, bool p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function LOG40(address p0, bool p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function LOG40(address p0, bool p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function LOG40(address p0, bool p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function LOG40(address p0, address p1, uint p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function LOG40(address p0, address p1, string memory p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function LOG40(address p0, address p1, bool p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function LOG40(address p0, address p1, address p2) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function LOG40(uint p0, uint p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, uint p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, string memory p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, bool p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function LOG40(uint p0, address p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, uint p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, string memory p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, bool p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function LOG40(string memory p0, address p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, uint p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, string memory p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, bool p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function LOG40(bool p0, address p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function LOG40(address p0, uint p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function LOG40(address p0, string memory p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function LOG40(address p0, bool p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, uint p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, uint p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, uint p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, uint p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, string memory p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, string memory p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, string memory p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, string memory p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, bool p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, bool p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, bool p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, bool p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, address p2, uint p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, address p2, string memory p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, address p2, bool p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function LOG40(address p0, address p1, address p2, address p3) internal view { //inject NONSTANDARD NAMING _SENDLOGPAYLOAD51(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } interface iuniswapv2factory11 { //inject NONSTANDARD NAMING event PAIRCREATED16(address indexed token0, address indexed token1, address pair, uint); //inject NONSTANDARD NAMING function FEETO47() external view returns (address); //inject NONSTANDARD NAMING function FEETOSETTER62() external view returns (address); //inject NONSTANDARD NAMING function GETPAIR25(address tokenA, address tokenB) external view returns (address pair); //inject NONSTANDARD NAMING function ALLPAIRS78(uint) external view returns (address pair); //inject NONSTANDARD NAMING function ALLPAIRSLENGTH45() external view returns (uint); //inject NONSTANDARD NAMING function CREATEPAIR19(address tokenA, address tokenB) external returns (address pair); //inject NONSTANDARD NAMING function SETFEETO7(address) external; //inject NONSTANDARD NAMING function SETFEETOSETTER93(address) external; //inject NONSTANDARD NAMING } contract feeapprover21 is ownableupgradesafe25 { //inject NONSTANDARD NAMING using safemath14 for uint256; function INITIALIZE58( //inject NONSTANDARD NAMING address _NANOCOREAddress, address _WETHAddress, address _uniswapFactory ) public INITIALIZER65 { ownableupgradesafe25.__OWNABLE_INIT13(); nanocoreTokenAddress = _NANOCOREAddress; WETHAddress = _WETHAddress; tokenUniswapPair = iuniswapv2factory11(_uniswapFactory).GETPAIR25(WETHAddress,nanocoreTokenAddress); feePercentX100 = 15; paused = false; // We start paused until sync post LGE happens. } address tokenUniswapPair; iuniswapv2factory11 public uniswapFactory; address internal WETHAddress; address nanocoreTokenAddress; address nanocoreVaultAddress; uint8 public feePercentX100; // max 255 = 25.5% artificial clamp uint256 public lastTotalSupplyOfLPTokens; bool paused; // Pausing transfers of the token function SETPAUSED71(bool _pause) public ONLYOWNER81 { //inject NONSTANDARD NAMING paused = _pause; } function SETFEEMULTIPLIER40(uint8 _feeMultiplier) public ONLYOWNER81 { //inject NONSTANDARD NAMING feePercentX100 = _feeMultiplier; } function SETNANOCOREVAULTADDRESS89(address _nanocoreVaultAddress) public ONLYOWNER81 { //inject NONSTANDARD NAMING nanocoreVaultAddress = _nanocoreVaultAddress; } function SYNC99() public { //inject NONSTANDARD NAMING uint256 _LPSupplyOfPairTotal = ierc2086(tokenUniswapPair).TOTALSUPPLY25(); lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal; } function CALCULATEAMOUNTSAFTERFEE82( //inject NONSTANDARD NAMING address sender, address recipient, // unusued maybe use din future uint256 amount ) public returns (uint256 transferToAmount, uint256 transferToFeeDistributorAmount) { require(paused == false, "FEE APPROVER: Transfers Paused"); uint256 _LPSupplyOfPairTotal = ierc2086(tokenUniswapPair).TOTALSUPPLY25(); // console.log("sender is " , sender); // console.log("recipient is is " , recipient, 'pair is :', tokenUniswapPair); // console.log("Old LP supply", lastTotalSupplyOfLPTokens); // console.log("Current LP supply", _LPSupplyOfPairTotal); if(sender == tokenUniswapPair) require(lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal, "Liquidity withdrawals forbidden"); // console.log('Sender is pair' , sender == tokenUniswapPair); // console.log('lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal' , lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal); if(sender == nanocoreVaultAddress || sender == tokenUniswapPair ) { // Dont have a fee when nanocorevault is sending, or infinite loop console87.LOG40("Sending without fee"); // And when pair is sending ( buys are happening, no tax on it) transferToFeeDistributorAmount = 0; transferToAmount = amount; } else { console87.LOG40("Normal fee transfer"); transferToFeeDistributorAmount = amount.MUL16(feePercentX100).DIV54(1000); transferToAmount = amount.SUB60(transferToFeeDistributorAmount); } lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal; } }
inject NONSTANDARD NAMING
function LOG40(uint p0, address p1, uint p2, string memory p3) internal view {
1,019,009
[ 1, 4625, 348, 7953, 560, 30, 4590, 18708, 882, 18264, 423, 2192, 1360, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 2018, 7132, 12, 11890, 293, 20, 16, 1758, 293, 21, 16, 2254, 293, 22, 16, 533, 3778, 293, 23, 13, 2713, 1476, 288, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./Interfaces/IBorrowerOperations.sol"; import "./Interfaces/IStabilityPool.sol"; import "./Interfaces/IBorrowerOperations.sol"; import "./Interfaces/ITroveManager.sol"; import "./Interfaces/ISortedTroves.sol"; import "./Dependencies/LiquityBase.sol"; import "./Dependencies/SafeMath.sol"; import "./Dependencies/LiquitySafeMath128.sol"; import "./Dependencies/Ownable.sol"; import "./Dependencies/CheckContract.sol"; import "./Interfaces/IGovernance.sol"; import "./Interfaces/ILiquityLUSDToken.sol"; /* * The Stability Pool holds LUSD tokens deposited by Stability Pool depositors. * * When a trove is liquidated, then depending on system conditions, some of its LUSD debt gets offset with * LUSD in the Stability Pool: that is, the offset debt evaporates, and an equal amount of LUSD tokens in the Stability Pool is burned. * * Thus, a liquidation causes each depositor to receive a LUSD loss, in proportion to their deposit as a share of total deposits. * They also receive an ETH gain, as the ETH collateral of the liquidated trove is distributed among Stability depositors, * in the same proportion. * * When a liquidation occurs, it depletes every deposit by the same fraction: for example, a liquidation that depletes 40% * of the total LUSD in the Stability Pool, depletes 40% of each deposit. * * A deposit that has experienced a series of liquidations is termed a "compounded deposit": each liquidation depletes the deposit, * multiplying it by some factor in range ]0,1[ * * * --- IMPLEMENTATION --- * * We use a highly scalable method of tracking deposits and ETH gains that has O(1) complexity. * * When a liquidation occurs, rather than updating each depositor's deposit and ETH gain, we simply update two state variables: * a product P, and a sum S. * * A mathematical manipulation allows us to factor out the initial deposit, and accurately track all depositors' compounded deposits * and accumulated ETH gains over time, as liquidations occur, using just these two variables P and S. When depositors join the * Stability Pool, they get a snapshot of the latest P and S: P_t and S_t, respectively. * * The formula for a depositor's accumulated ETH gain is derived here: * https://github.com/liquity/dev/blob/main/packages/contracts/mathProofs/Scalable%20Compounding%20Stability%20Pool%20Deposits.pdf * * For a given deposit d_t, the ratio P/P_t tells us the factor by which a deposit has decreased since it joined the Stability Pool, * and the term d_t * (S - S_t)/P_t gives us the deposit's total accumulated ETH gain. * * Each liquidation updates the product P and sum S. After a series of liquidations, a compounded deposit and corresponding ETH gain * can be calculated using the initial deposit, the depositor's snapshots of P and S, and the latest values of P and S. * * Any time a depositor updates their deposit (withdrawal, top-up) their accumulated ETH gain is paid out, their new deposit is recorded * (based on their latest compounded deposit and modified by the withdrawal/top-up), and they receive new snapshots of the latest P and S. * Essentially, they make a fresh deposit that overwrites the old one. * * * --- SCALE FACTOR --- * * Since P is a running product in range ]0,1] that is always-decreasing, it should never reach 0 when multiplied by a number in range ]0,1[. * Unfortunately, Solidity floor division always reaches 0, sooner or later. * * A series of liquidations that nearly empty the Pool (and thus each multiply P by a very small number in range ]0,1[ ) may push P * to its 18 digit decimal limit, and round it to 0, when in fact the Pool hasn't been emptied: this would break deposit tracking. * * So, to track P accurately, we use a scale factor: if a liquidation would cause P to decrease to <1e-9 (and be rounded to 0 by Solidity), * we first multiply P by 1e9, and increment a currentScale factor by 1. * * The added benefit of using 1e9 for the scale factor (rather than 1e18) is that it ensures negligible precision loss close to the * scale boundary: when P is at its minimum value of 1e9, the relative precision loss in P due to floor division is only on the * order of 1e-9. * * --- EPOCHS --- * * Whenever a liquidation fully empties the Stability Pool, all deposits should become 0. However, setting P to 0 would make P be 0 * forever, and break all future reward calculations. * * So, every time the Stability Pool is emptied by a liquidation, we reset P = 1 and currentScale = 0, and increment the currentEpoch by 1. * * --- TRACKING DEPOSIT OVER SCALE CHANGES AND EPOCHS --- * * When a deposit is made, it gets snapshots of the currentEpoch and the currentScale. * * When calculating a compounded deposit, we compare the current epoch to the deposit's epoch snapshot. If the current epoch is newer, * then the deposit was present during a pool-emptying liquidation, and necessarily has been depleted to 0. * * Otherwise, we then compare the current scale to the deposit's scale snapshot. If they're equal, the compounded deposit is given by d_t * P/P_t. * If it spans one scale change, it is given by d_t * P/(P_t * 1e9). If it spans more than one scale change, we define the compounded deposit * as 0, since it is now less than 1e-9'th of its initial value (e.g. a deposit of 1 billion LUSD has depleted to < 1 LUSD). * * * --- TRACKING DEPOSITOR'S ETH GAIN OVER SCALE CHANGES AND EPOCHS --- * * In the current epoch, the latest value of S is stored upon each scale change, and the mapping (scale -> S) is stored for each epoch. * * This allows us to calculate a deposit's accumulated ETH gain, during the epoch in which the deposit was non-zero and earned ETH. * * We calculate the depositor's accumulated ETH gain for the scale at which they made the deposit, using the ETH gain formula: * e_1 = d_t * (S - S_t) / P_t * * and also for scale after, taking care to divide the latter by a factor of 1e9: * e_2 = d_t * S / (P_t * 1e9) * * The gain in the second scale will be full, as the starting point was in the previous scale, thus no need to subtract anything. * The deposit therefore was present for reward events from the beginning of that second scale. * * S_i-S_t + S_{i+1} * .<--------.------------> * . . * . S_i . S_{i+1} * <--.-------->.<-----------> * S_t. . * <->. . * t . * |---+---------|-------------|-----... * i i+1 * * The sum of (e_1 + e_2) captures the depositor's total accumulated ETH gain, handling the case where their * deposit spanned one scale change. We only care about gains across one scale change, since the compounded * deposit is defined as being 0 once it has spanned more than one scale change. * * * --- UPDATING P WHEN A LIQUIDATION OCCURS --- * * Please see the implementation spec in the proof document, which closely follows on from the compounded deposit / ETH gain derivations: * https://github.com/liquity/liquity/blob/master/papers/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf * * * --- LQTY ISSUANCE TO STABILITY POOL DEPOSITORS --- * * An LQTY issuance event occurs at every deposit operation, and every liquidation. * * Each deposit is tagged with the address of the front end through which it was made. * * All deposits earn a share of the issued LQTY in proportion to the deposit as a share of total deposits. The LQTY earned * by a given deposit, is split between the depositor and the front end through which the deposit was made, based on the front end's kickbackRate. * * Please see the system Readme for an overview: * https://github.com/liquity/dev/blob/main/README.md#lqty-issuance-to-stability-providers * * We use the same mathematical product-sum approach to track LQTY gains for depositors, where 'G' is the sum corresponding to LQTY gains. * The product P (and snapshot P_t) is re-used, as the ratio P/P_t tracks a deposit's depletion due to liquidations. * */ contract StabilityPool is LiquityBase, Ownable, CheckContract, IStabilityPool { using SafeMath for uint256; using LiquitySafeMath128 for uint128; string public constant NAME = "StabilityPool"; IBorrowerOperations public borrowerOperations; ITroveManager public troveManager; ILiquityLUSDToken public lusdToken; // Needed to check if there are pending liquidations ISortedTroves public sortedTroves; IERC20 public weth; uint256 public ETH; // deposited ether tracker // Tracker for LUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset. uint256 public totalLUSDDeposits; // --- Data structures --- struct FrontEnd { uint256 kickbackRate; bool registered; } struct Deposit { uint256 initialValue; address frontEndTag; } struct Snapshots { uint256 S; uint256 P; uint256 G; uint128 scale; uint128 epoch; } mapping(address => Deposit) public deposits; // depositor address -> Deposit struct mapping(address => Snapshots) public depositSnapshots; // depositor address -> snapshots struct mapping(address => FrontEnd) public frontEnds; // front end address -> FrontEnd struct mapping(address => uint256) public frontEndStakes; // front end address -> last recorded total deposits, tagged with that front end mapping(address => Snapshots) public frontEndSnapshots; // front end address -> snapshots struct /* Product 'P': Running product by which to multiply an initial deposit, in order to find the current compounded deposit, * after a series of liquidations have occurred, each of which cancel some LUSD debt with the deposit. * * During its lifetime, a deposit's value evolves from d_t to d_t * P / P_t , where P_t * is the snapshot of P taken at the instant the deposit was made. 18-digit decimal. */ uint256 public P = DECIMAL_PRECISION; uint256 public constant SCALE_FACTOR = 1e9; // Each time the scale of P shifts by SCALE_FACTOR, the scale is incremented by 1 uint128 public currentScale; // With each offset that fully empties the Pool, the epoch is incremented by 1 uint128 public currentEpoch; /* ETH Gain sum 'S': During its lifetime, each deposit d_t earns an ETH gain of ( d_t * [S - S_t] )/P_t, where S_t * is the depositor's snapshot of S taken at the time t when the deposit was made. * * The 'S' sums are stored in a nested mapping (epoch => scale => sum): * * - The inner mapping records the sum S at different scales * - The outer mapping records the (scale => sum) mappings, for different epochs. */ mapping(uint128 => mapping(uint128 => uint256)) public epochToScaleToSum; /* * Similarly, the sum 'G' is used to calculate LQTY gains. During it's lifetime, each deposit d_t earns a LQTY gain of * ( d_t * [G - G_t] )/P_t, where G_t is the depositor's snapshot of G taken at time t when the deposit was made. * * LQTY reward events occur are triggered by depositor operations (new deposit, topup, withdrawal), and liquidations. * In each case, the LQTY reward is issued (i.e. G is updated), before other state changes are made. */ mapping(uint128 => mapping(uint128 => uint256)) public epochToScaleToG; // Error tracker for the error correction in the LQTY issuance calculation uint256 public lastLQTYError; // Error trackers for the error correction in the offset calculation uint256 public lastETHError_Offset; uint256 public lastLUSDLossError_Offset; // --- Contract setters --- function setAddresses( address _borrowerOperationsAddress, address _troveManagerAddress, address _activePoolAddress, address _lusdTokenAddress, address _sortedTrovesAddress, address _wethAddress, address _governanceAddress ) external override onlyOwner { checkContract(_borrowerOperationsAddress); checkContract(_troveManagerAddress); checkContract(_activePoolAddress); checkContract(_lusdTokenAddress); checkContract(_sortedTrovesAddress); checkContract(_wethAddress); checkContract(_governanceAddress); borrowerOperations = IBorrowerOperations(_borrowerOperationsAddress); troveManager = ITroveManager(_troveManagerAddress); activePool = IActivePool(_activePoolAddress); lusdToken = ILiquityLUSDToken(_lusdTokenAddress); sortedTroves = ISortedTroves(_sortedTrovesAddress); weth = IERC20(_wethAddress); governance = IGovernance(_governanceAddress); emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress); emit TroveManagerAddressChanged(_troveManagerAddress); emit ActivePoolAddressChanged(_activePoolAddress); emit LUSDTokenAddressChanged(_lusdTokenAddress); emit SortedTrovesAddressChanged(_sortedTrovesAddress); emit GovernanceAddressChanged(_governanceAddress); _renounceOwnership(); } // --- Getters for public variables. Required by IPool interface --- function getETH() external view override returns (uint256) { return ETH; } function getTotalLUSDDeposits() external view override returns (uint256) { return totalLUSDDeposits; } // --- External Depositor Functions --- /* provideToSP(): * * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Tags the deposit with the provided front end tag param, if it's a new deposit * - Sends depositor's accumulated gains (LQTY, ETH) to depositor * - Sends the tagged front end's accumulated LQTY gains to the tagged front end * - Increases deposit and tagged front end's stake, and takes new snapshots for each. */ function provideToSP(uint256 _amount, address _frontEndTag) external override { _requireFrontEndIsRegisteredOrZero(_frontEndTag); _requireFrontEndNotRegistered(msg.sender); _requireNonZeroAmount(_amount); uint256 initialDeposit = deposits[msg.sender].initialValue; if (initialDeposit == 0) { _setFrontEndTag(msg.sender, _frontEndTag); } uint256 depositorETHGain = getDepositorETHGain(msg.sender); uint256 compoundedLUSDDeposit = getCompoundedLUSDDeposit(msg.sender); uint256 LUSDLoss = initialDeposit.sub(compoundedLUSDDeposit); // Needed only for event log // First pay out any LQTY gains address frontEnd = deposits[msg.sender].frontEndTag; // Update front end stake uint256 compoundedFrontEndStake = getCompoundedFrontEndStake(frontEnd); uint256 newFrontEndStake = compoundedFrontEndStake.add(_amount); _updateFrontEndStakeAndSnapshots(frontEnd, newFrontEndStake); emit FrontEndStakeChanged(frontEnd, newFrontEndStake, msg.sender); _sendLUSDtoStabilityPool(msg.sender, _amount); uint256 newDeposit = compoundedLUSDDeposit.add(_amount); _updateDepositAndSnapshots(msg.sender, newDeposit); emit UserDepositChanged(msg.sender, newDeposit); emit ETHGainWithdrawn(msg.sender, depositorETHGain, LUSDLoss); // LUSD Loss required for event log _sendETHGainToDepositor(depositorETHGain); } /* withdrawFromSP(): * * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Removes the deposit's front end tag if it is a full withdrawal * - Sends all depositor's accumulated gains (LQTY, ETH) to depositor * - Sends the tagged front end's accumulated LQTY gains to the tagged front end * - Decreases deposit and tagged front end's stake, and takes new snapshots for each. * * If _amount > userDeposit, the user withdraws all of their compounded deposit. */ function withdrawFromSP(uint256 _amount) external override { if (_amount != 0) { _requireNoUnderCollateralizedTroves(); } uint256 initialDeposit = deposits[msg.sender].initialValue; _requireUserHasDeposit(initialDeposit); uint256 depositorETHGain = getDepositorETHGain(msg.sender); uint256 compoundedLUSDDeposit = getCompoundedLUSDDeposit(msg.sender); uint256 LUSDtoWithdraw = LiquityMath._min(_amount, compoundedLUSDDeposit); uint256 LUSDLoss = initialDeposit.sub(compoundedLUSDDeposit); // Needed only for event log // First pay out any LQTY gains address frontEnd = deposits[msg.sender].frontEndTag; // Update front end stake uint256 compoundedFrontEndStake = getCompoundedFrontEndStake(frontEnd); uint256 newFrontEndStake = compoundedFrontEndStake.sub(LUSDtoWithdraw); _updateFrontEndStakeAndSnapshots(frontEnd, newFrontEndStake); emit FrontEndStakeChanged(frontEnd, newFrontEndStake, msg.sender); _sendLUSDToDepositor(msg.sender, LUSDtoWithdraw); // Update deposit uint256 newDeposit = compoundedLUSDDeposit.sub(LUSDtoWithdraw); _updateDepositAndSnapshots(msg.sender, newDeposit); emit UserDepositChanged(msg.sender, newDeposit); emit ETHGainWithdrawn(msg.sender, depositorETHGain, LUSDLoss); // LUSD Loss required for event log _sendETHGainToDepositor(depositorETHGain); } /* withdrawETHGainToTrove: * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Sends all depositor's LQTY gain to depositor * - Sends all tagged front end's LQTY gain to the tagged front end * - Transfers the depositor's entire ETH gain from the Stability Pool to the caller's trove * - Leaves their compounded deposit in the Stability Pool * - Updates snapshots for deposit and tagged front end stake */ function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external override { uint256 initialDeposit = deposits[msg.sender].initialValue; _requireUserHasDeposit(initialDeposit); _requireUserHasTrove(msg.sender); _requireUserHasETHGain(msg.sender); uint256 depositorETHGain = getDepositorETHGain(msg.sender); uint256 compoundedLUSDDeposit = getCompoundedLUSDDeposit(msg.sender); uint256 LUSDLoss = initialDeposit.sub(compoundedLUSDDeposit); // Needed only for event log // First pay out any LQTY gains address frontEnd = deposits[msg.sender].frontEndTag; // Update front end stake uint256 compoundedFrontEndStake = getCompoundedFrontEndStake(frontEnd); uint256 newFrontEndStake = compoundedFrontEndStake; _updateFrontEndStakeAndSnapshots(frontEnd, newFrontEndStake); emit FrontEndStakeChanged(frontEnd, newFrontEndStake, msg.sender); _updateDepositAndSnapshots(msg.sender, compoundedLUSDDeposit); /* Emit events before transferring ETH gain to Trove. This lets the event log make more sense (i.e. so it appears that first the ETH gain is withdrawn and then it is deposited into the Trove, not the other way around). */ emit ETHGainWithdrawn(msg.sender, depositorETHGain, LUSDLoss); emit UserDepositChanged(msg.sender, compoundedLUSDDeposit); ETH = ETH.sub(depositorETHGain); emit StabilityPoolETHBalanceUpdated(ETH); emit EtherSent(msg.sender, depositorETHGain); weth.approve(address(borrowerOperations), depositorETHGain); borrowerOperations.moveETHGainToTrove(depositorETHGain, msg.sender, _upperHint, _lowerHint); } // --- LQTY issuance functions --- function _updateG(uint256 _LQTYIssuance) internal { uint256 totalLUSD = totalLUSDDeposits; // cached to save an SLOAD /* * When total deposits is 0, G is not updated. In this case, the LQTY issued can not be obtained by later * depositors - it is missed out on, and remains in the balanceof the CommunityIssuance contract. * */ if (totalLUSD == 0 || _LQTYIssuance == 0) { return; } uint256 LQTYPerUnitStaked; LQTYPerUnitStaked = _computeLQTYPerUnitStaked(_LQTYIssuance, totalLUSD); uint256 marginalLQTYGain = LQTYPerUnitStaked.mul(P); epochToScaleToG[currentEpoch][currentScale] = epochToScaleToG[currentEpoch][currentScale] .add(marginalLQTYGain); emit G_Updated(epochToScaleToG[currentEpoch][currentScale], currentEpoch, currentScale); } function _computeLQTYPerUnitStaked(uint256 _LQTYIssuance, uint256 _totalLUSDDeposits) internal returns (uint256) { /* * Calculate the LQTY-per-unit staked. Division uses a "feedback" error correction, to keep the * cumulative error low in the running total G: * * 1) Form a numerator which compensates for the floor division error that occurred the last time this * function was called. * 2) Calculate "per-unit-staked" ratio. * 3) Multiply the ratio back by its denominator, to reveal the current floor division error. * 4) Store this error for use in the next correction when this function is called. * 5) Note: static analysis tools complain about this "division before multiplication", however, it is intended. */ uint256 LQTYNumerator = _LQTYIssuance.mul(DECIMAL_PRECISION).add(lastLQTYError); uint256 LQTYPerUnitStaked = LQTYNumerator.div(_totalLUSDDeposits); lastLQTYError = LQTYNumerator.sub(LQTYPerUnitStaked.mul(_totalLUSDDeposits)); return LQTYPerUnitStaked; } // --- Liquidation functions --- /* * Cancels out the specified debt against the LUSD contained in the Stability Pool (as far as possible) * and transfers the Trove's ETH collateral from ActivePool to StabilityPool. * Only called by liquidation functions in the TroveManager. */ function offset(uint256 _debtToOffset, uint256 _collToAdd) external override { _requireCallerIsTroveManager(); uint256 totalLUSD = totalLUSDDeposits; // cached to save an SLOAD if (totalLUSD == 0 || _debtToOffset == 0) { return; } (uint256 ETHGainPerUnitStaked, uint256 LUSDLossPerUnitStaked) = _computeRewardsPerUnitStaked( _collToAdd, _debtToOffset, totalLUSD ); _updateRewardSumAndProduct(ETHGainPerUnitStaked, LUSDLossPerUnitStaked); // updates S and P _moveOffsetCollAndDebt(_collToAdd, _debtToOffset); } // --- Offset helper functions --- function _computeRewardsPerUnitStaked( uint256 _collToAdd, uint256 _debtToOffset, uint256 _totalLUSDDeposits ) internal returns (uint256 ETHGainPerUnitStaked, uint256 LUSDLossPerUnitStaked) { /* * Compute the LUSD and ETH rewards. Uses a "feedback" error correction, to keep * the cumulative error in the P and S state variables low: * * 1) Form numerators which compensate for the floor division errors that occurred the last time this * function was called. * 2) Calculate "per-unit-staked" ratios. * 3) Multiply each ratio back by its denominator, to reveal the current floor division error. * 4) Store these errors for use in the next correction when this function is called. * 5) Note: static analysis tools complain about this "division before multiplication", however, it is intended. */ uint256 ETHNumerator = _collToAdd.mul(DECIMAL_PRECISION).add(lastETHError_Offset); assert(_debtToOffset <= _totalLUSDDeposits); if (_debtToOffset == _totalLUSDDeposits) { LUSDLossPerUnitStaked = DECIMAL_PRECISION; // When the Pool depletes to 0, so does each deposit lastLUSDLossError_Offset = 0; } else { uint256 LUSDLossNumerator = _debtToOffset.mul(DECIMAL_PRECISION).sub( lastLUSDLossError_Offset ); /* * Add 1 to make error in quotient positive. We want "slightly too much" LUSD loss, * which ensures the error in any given compoundedLUSDDeposit favors the Stability Pool. */ LUSDLossPerUnitStaked = (LUSDLossNumerator.div(_totalLUSDDeposits)).add(1); lastLUSDLossError_Offset = (LUSDLossPerUnitStaked.mul(_totalLUSDDeposits)).sub( LUSDLossNumerator ); } ETHGainPerUnitStaked = ETHNumerator.div(_totalLUSDDeposits); lastETHError_Offset = ETHNumerator.sub(ETHGainPerUnitStaked.mul(_totalLUSDDeposits)); return (ETHGainPerUnitStaked, LUSDLossPerUnitStaked); } // Update the Stability Pool reward sum S and product P function _updateRewardSumAndProduct( uint256 _ETHGainPerUnitStaked, uint256 _LUSDLossPerUnitStaked ) internal { uint256 currentP = P; uint256 newP; assert(_LUSDLossPerUnitStaked <= DECIMAL_PRECISION); /* * The newProductFactor is the factor by which to change all deposits, due to the depletion of Stability Pool LUSD in the liquidation. * We make the product factor 0 if there was a pool-emptying. Otherwise, it is (1 - LUSDLossPerUnitStaked) */ uint256 newProductFactor = uint256(DECIMAL_PRECISION).sub(_LUSDLossPerUnitStaked); uint128 currentScaleCached = currentScale; uint128 currentEpochCached = currentEpoch; uint256 currentS = epochToScaleToSum[currentEpochCached][currentScaleCached]; /* * Calculate the new S first, before we update P. * The ETH gain for any given depositor from a liquidation depends on the value of their deposit * (and the value of totalDeposits) prior to the Stability being depleted by the debt in the liquidation. * * Since S corresponds to ETH gain, and P to deposit loss, we update S first. */ uint256 marginalETHGain = _ETHGainPerUnitStaked.mul(currentP); uint256 newS = currentS.add(marginalETHGain); epochToScaleToSum[currentEpochCached][currentScaleCached] = newS; emit S_Updated(newS, currentEpochCached, currentScaleCached); // If the Stability Pool was emptied, increment the epoch, and reset the scale and product P if (newProductFactor == 0) { currentEpoch = currentEpochCached.add(1); emit EpochUpdated(currentEpoch); currentScale = 0; emit ScaleUpdated(currentScale); newP = DECIMAL_PRECISION; // If multiplying P by a non-zero product factor would reduce P below the scale boundary, increment the scale } else if (currentP.mul(newProductFactor).div(DECIMAL_PRECISION) < SCALE_FACTOR) { newP = currentP.mul(newProductFactor).mul(SCALE_FACTOR).div(DECIMAL_PRECISION); currentScale = currentScaleCached.add(1); emit ScaleUpdated(currentScale); } else { newP = currentP.mul(newProductFactor).div(DECIMAL_PRECISION); } assert(newP > 0); P = newP; emit P_Updated(newP); } function _moveOffsetCollAndDebt(uint256 _collToAdd, uint256 _debtToOffset) internal { IActivePool activePoolCached = activePool; // Cancel the liquidated LUSD debt with the LUSD in the stability pool activePoolCached.decreaseLUSDDebt(_debtToOffset); _decreaseLUSD(_debtToOffset); lusdToken.burn(address(this), _debtToOffset); activePoolCached.sendETH(address(this), _collToAdd); } function _decreaseLUSD(uint256 _amount) internal { uint256 newTotalLUSDDeposits = totalLUSDDeposits.sub(_amount); totalLUSDDeposits = newTotalLUSDDeposits; emit StabilityPoolLUSDBalanceUpdated(newTotalLUSDDeposits); } // --- Reward calculator functions for depositor and front end --- /* Calculates the ETH gain earned by the deposit since its last snapshots were taken. * Given by the formula: E = d0 * (S - S(0))/P(0) * where S(0) and P(0) are the depositor's snapshots of the sum S and product P, respectively. * d0 is the last recorded deposit value. */ function getDepositorETHGain(address _depositor) public view override returns (uint256) { uint256 initialDeposit = deposits[_depositor].initialValue; if (initialDeposit == 0) { return 0; } Snapshots memory snapshots = depositSnapshots[_depositor]; uint256 ETHGain = _getETHGainFromSnapshots(initialDeposit, snapshots); return ETHGain; } function _getETHGainFromSnapshots(uint256 initialDeposit, Snapshots memory snapshots) internal view returns (uint256) { /* * Grab the sum 'S' from the epoch at which the stake was made. The ETH gain may span up to one scale change. * If it does, the second portion of the ETH gain is scaled by 1e9. * If the gain spans no scale change, the second portion will be 0. */ uint128 epochSnapshot = snapshots.epoch; uint128 scaleSnapshot = snapshots.scale; uint256 S_Snapshot = snapshots.S; uint256 P_Snapshot = snapshots.P; uint256 firstPortion = epochToScaleToSum[epochSnapshot][scaleSnapshot].sub(S_Snapshot); uint256 secondPortion = epochToScaleToSum[epochSnapshot][scaleSnapshot.add(1)].div( SCALE_FACTOR ); uint256 ETHGain = initialDeposit.mul(firstPortion.add(secondPortion)).div(P_Snapshot).div( DECIMAL_PRECISION ); return ETHGain; } /* * Calculate the LQTY gain earned by a deposit since its last snapshots were taken. * Given by the formula: LQTY = d0 * (G - G(0))/P(0) * where G(0) and P(0) are the depositor's snapshots of the sum G and product P, respectively. * d0 is the last recorded deposit value. */ function getDepositorLQTYGain(address _depositor) public view override returns (uint256) { uint256 initialDeposit = deposits[_depositor].initialValue; if (initialDeposit == 0) { return 0; } address frontEndTag = deposits[_depositor].frontEndTag; /* * If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned. * Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through * which they made their deposit. */ uint256 kickbackRate = frontEndTag == address(0) ? DECIMAL_PRECISION : frontEnds[frontEndTag].kickbackRate; Snapshots memory snapshots = depositSnapshots[_depositor]; uint256 LQTYGain = kickbackRate .mul(_getLQTYGainFromSnapshots(initialDeposit, snapshots)) .div(DECIMAL_PRECISION); return LQTYGain; } /* * Return the LQTY gain earned by the front end. Given by the formula: E = D0 * (G - G(0))/P(0) * where G(0) and P(0) are the depositor's snapshots of the sum G and product P, respectively. * * D0 is the last recorded value of the front end's total tagged deposits. */ function getFrontEndLQTYGain(address _frontEnd) public view override returns (uint256) { uint256 frontEndStake = frontEndStakes[_frontEnd]; if (frontEndStake == 0) { return 0; } uint256 kickbackRate = frontEnds[_frontEnd].kickbackRate; uint256 frontEndShare = uint256(DECIMAL_PRECISION).sub(kickbackRate); Snapshots memory snapshots = frontEndSnapshots[_frontEnd]; uint256 LQTYGain = frontEndShare .mul(_getLQTYGainFromSnapshots(frontEndStake, snapshots)) .div(DECIMAL_PRECISION); return LQTYGain; } function _getLQTYGainFromSnapshots(uint256 initialStake, Snapshots memory snapshots) internal view returns (uint256) { /* * Grab the sum 'G' from the epoch at which the stake was made. The LQTY gain may span up to one scale change. * If it does, the second portion of the LQTY gain is scaled by 1e9. * If the gain spans no scale change, the second portion will be 0. */ uint128 epochSnapshot = snapshots.epoch; uint128 scaleSnapshot = snapshots.scale; uint256 G_Snapshot = snapshots.G; uint256 P_Snapshot = snapshots.P; uint256 firstPortion = epochToScaleToG[epochSnapshot][scaleSnapshot].sub(G_Snapshot); uint256 secondPortion = epochToScaleToG[epochSnapshot][scaleSnapshot.add(1)].div( SCALE_FACTOR ); uint256 LQTYGain = initialStake.mul(firstPortion.add(secondPortion)).div(P_Snapshot).div( DECIMAL_PRECISION ); return LQTYGain; } // --- Compounded deposit and compounded front end stake --- /* * Return the user's compounded deposit. Given by the formula: d = d0 * P/P(0) * where P(0) is the depositor's snapshot of the product P, taken when they last updated their deposit. */ function getCompoundedLUSDDeposit(address _depositor) public view override returns (uint256) { uint256 initialDeposit = deposits[_depositor].initialValue; if (initialDeposit == 0) { return 0; } Snapshots memory snapshots = depositSnapshots[_depositor]; uint256 compoundedDeposit = _getCompoundedStakeFromSnapshots(initialDeposit, snapshots); return compoundedDeposit; } /* * Return the front end's compounded stake. Given by the formula: D = D0 * P/P(0) * where P(0) is the depositor's snapshot of the product P, taken at the last time * when one of the front end's tagged deposits updated their deposit. * * The front end's compounded stake is equal to the sum of its depositors' compounded deposits. */ function getCompoundedFrontEndStake(address _frontEnd) public view override returns (uint256) { uint256 frontEndStake = frontEndStakes[_frontEnd]; if (frontEndStake == 0) { return 0; } Snapshots memory snapshots = frontEndSnapshots[_frontEnd]; uint256 compoundedFrontEndStake = _getCompoundedStakeFromSnapshots(frontEndStake, snapshots); return compoundedFrontEndStake; } // Internal function, used to calculcate compounded deposits and compounded front end stakes. function _getCompoundedStakeFromSnapshots(uint256 initialStake, Snapshots memory snapshots) internal view returns (uint256) { uint256 snapshot_P = snapshots.P; uint128 scaleSnapshot = snapshots.scale; uint128 epochSnapshot = snapshots.epoch; // If stake was made before a pool-emptying event, then it has been fully cancelled with debt -- so, return 0 if (epochSnapshot < currentEpoch) { return 0; } uint256 compoundedStake; uint128 scaleDiff = currentScale.sub(scaleSnapshot); /* Compute the compounded stake. If a scale change in P was made during the stake's lifetime, * account for it. If more than one scale change was made, then the stake has decreased by a factor of * at least 1e-9 -- so return 0. */ if (scaleDiff == 0) { compoundedStake = initialStake.mul(P).div(snapshot_P); } else if (scaleDiff == 1) { compoundedStake = initialStake.mul(P).div(snapshot_P).div(SCALE_FACTOR); } else { // if scaleDiff >= 2 compoundedStake = 0; } /* * If compounded deposit is less than a billionth of the initial deposit, return 0. * * NOTE: originally, this line was in place to stop rounding errors making the deposit too large. However, the error * corrections should ensure the error in P "favors the Pool", i.e. any given compounded deposit should slightly less * than it's theoretical value. * * Thus it's unclear whether this line is still really needed. */ if (compoundedStake < initialStake.div(1e9)) { return 0; } return compoundedStake; } // --- Sender functions for LUSD deposit, ETH gains and LQTY gains --- // Transfer the LUSD tokens from the user to the Stability Pool's address, and update its recorded LUSD function _sendLUSDtoStabilityPool(address _address, uint256 _amount) internal { lusdToken.sendToPool(_address, address(this), _amount); uint256 newTotalLUSDDeposits = totalLUSDDeposits.add(_amount); totalLUSDDeposits = newTotalLUSDDeposits; emit StabilityPoolLUSDBalanceUpdated(newTotalLUSDDeposits); } function _sendETHGainToDepositor(uint256 _amount) internal { if (_amount == 0) { return; } uint256 newETH = ETH.sub(_amount); ETH = newETH; emit StabilityPoolETHBalanceUpdated(newETH); emit EtherSent(msg.sender, _amount); weth.transfer(msg.sender, _amount); } // Send LUSD to user and decrease LUSD in Pool function _sendLUSDToDepositor(address _depositor, uint256 LUSDWithdrawal) internal { if (LUSDWithdrawal == 0) { return; } lusdToken.returnFromPool(address(this), _depositor, LUSDWithdrawal); _decreaseLUSD(LUSDWithdrawal); } // --- External Front End functions --- // Front end makes a one-time selection of kickback rate upon registering function registerFrontEnd(uint256 _kickbackRate) external override { _requireFrontEndNotRegistered(msg.sender); _requireUserHasNoDeposit(msg.sender); _requireValidKickbackRate(_kickbackRate); frontEnds[msg.sender].kickbackRate = _kickbackRate; frontEnds[msg.sender].registered = true; emit FrontEndRegistered(msg.sender, _kickbackRate); } // --- Stability Pool Deposit Functionality --- function _setFrontEndTag(address _depositor, address _frontEndTag) internal { deposits[_depositor].frontEndTag = _frontEndTag; emit FrontEndTagSet(_depositor, _frontEndTag); } function _updateDepositAndSnapshots(address _depositor, uint256 _newValue) internal { deposits[_depositor].initialValue = _newValue; if (_newValue == 0) { delete deposits[_depositor].frontEndTag; delete depositSnapshots[_depositor]; emit DepositSnapshotUpdated(_depositor, 0, 0, 0); return; } uint128 currentScaleCached = currentScale; uint128 currentEpochCached = currentEpoch; uint256 currentP = P; // Get S and G for the current epoch and current scale uint256 currentS = epochToScaleToSum[currentEpochCached][currentScaleCached]; uint256 currentG = epochToScaleToG[currentEpochCached][currentScaleCached]; // Record new snapshots of the latest running product P, sum S, and sum G, for the depositor depositSnapshots[_depositor].P = currentP; depositSnapshots[_depositor].S = currentS; depositSnapshots[_depositor].G = currentG; depositSnapshots[_depositor].scale = currentScaleCached; depositSnapshots[_depositor].epoch = currentEpochCached; emit DepositSnapshotUpdated(_depositor, currentP, currentS, currentG); } function _updateFrontEndStakeAndSnapshots(address _frontEnd, uint256 _newValue) internal { frontEndStakes[_frontEnd] = _newValue; if (_newValue == 0) { delete frontEndSnapshots[_frontEnd]; emit FrontEndSnapshotUpdated(_frontEnd, 0, 0); return; } uint128 currentScaleCached = currentScale; uint128 currentEpochCached = currentEpoch; uint256 currentP = P; // Get G for the current epoch and current scale uint256 currentG = epochToScaleToG[currentEpochCached][currentScaleCached]; // Record new snapshots of the latest running product P and sum G for the front end frontEndSnapshots[_frontEnd].P = currentP; frontEndSnapshots[_frontEnd].G = currentG; frontEndSnapshots[_frontEnd].scale = currentScaleCached; frontEndSnapshots[_frontEnd].epoch = currentEpochCached; emit FrontEndSnapshotUpdated(_frontEnd, currentP, currentG); } // --- 'require' functions --- function _requireCallerIsActivePool() internal view { require(msg.sender == address(activePool), "StabilityPool: Caller is not ActivePool"); } function _requireCallerIsTroveManager() internal view { require(msg.sender == address(troveManager), "StabilityPool: Caller is not TroveManager"); } function _requireNoUnderCollateralizedTroves() internal { IPriceFeed priceFeed = getPriceFeed(); uint256 price = priceFeed.fetchPrice(); address lowestTrove = sortedTroves.getLast(); uint256 ICR = troveManager.getCurrentICR(lowestTrove, price); require(ICR >= MCR, "StabilityPool: Cannot withdraw while there are troves with ICR < MCR"); } function _requireUserHasDeposit(uint256 _initialDeposit) internal pure { require(_initialDeposit > 0, "StabilityPool: User must have a non-zero deposit"); } function _requireUserHasNoDeposit(address _address) internal view { uint256 initialDeposit = deposits[_address].initialValue; require(initialDeposit == 0, "StabilityPool: User must have no deposit"); } function _requireNonZeroAmount(uint256 _amount) internal pure { require(_amount > 0, "StabilityPool: Amount must be non-zero"); } function _requireUserHasTrove(address _depositor) internal view { require( troveManager.getTroveStatus(_depositor) == 1, "StabilityPool: caller must have an active trove to withdraw ETHGain to" ); } function _requireUserHasETHGain(address _depositor) internal view { uint256 ETHGain = getDepositorETHGain(_depositor); require(ETHGain > 0, "StabilityPool: caller must have non-zero ETH Gain"); } function _requireFrontEndNotRegistered(address _address) internal view { require( !frontEnds[_address].registered, "StabilityPool: must not already be a registered front end" ); } function _requireFrontEndIsRegisteredOrZero(address _address) internal view { require( frontEnds[_address].registered || _address == address(0), "StabilityPool: Tag must be a registered front end, or the zero address" ); } function _requireValidKickbackRate(uint256 _kickbackRate) internal pure { require( _kickbackRate <= DECIMAL_PRECISION, "StabilityPool: Kickback rate must be in range [0,1]" ); } // --- Fallback function --- function receiveETH(uint256 _amount) external override { _requireCallerIsActivePool(); weth.transferFrom(msg.sender, address(this), _amount); ETH = ETH.add(_amount); emit StabilityPoolETHBalanceUpdated(ETH); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; // Common interface for the Trove Manager. interface IBorrowerOperations { enum BorrowerOperation { openTrove, closeTrove, adjustTrove } // --- Events --- event FrontEndRegistered(address indexed _frontEnd, uint256 timestamp); event TroveManagerAddressChanged(address _newTroveManagerAddress); event ActivePoolAddressChanged(address _activePoolAddress); event GovernanceAddressChanged(address _governanceAddress); event DefaultPoolAddressChanged(address _defaultPoolAddress); event StabilityPoolAddressChanged(address _stabilityPoolAddress); event GasPoolAddressChanged(address _gasPoolAddress); event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress); event SortedTrovesAddressChanged(address _sortedTrovesAddress); event LUSDTokenAddressChanged(address _lusdTokenAddress); event TroveCreated(address indexed _borrower, uint256 arrayIndex); event TroveUpdated( address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, BorrowerOperation operation ); event LUSDBorrowingFeePaid(address indexed _borrower, uint256 _LUSDFee); // --- Functions --- function setAddresses( address _troveManagerAddress, address _activePoolAddress, address _defaultPoolAddress, address _stabilityPoolAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _sortedTrovesAddress, address _lusdTokenAddress, address _wethAddress, address _governanceAddress ) external; function registerFrontEnd() external; function openTrove( uint256 _maxFee, uint256 _LUSDAmount, uint256 _ETHAmount, address _upperHint, address _lowerHint, address _frontEndTag ) external; function addColl( uint256 _ETHAmount, address _upperHint, address _lowerHint ) external; function moveETHGainToTrove( uint256 _ETHAmount, address _user, address _upperHint, address _lowerHint ) external; function withdrawColl( uint256 _amount, address _upperHint, address _lowerHint ) external; function withdrawLUSD( uint256 _maxFee, uint256 _amount, address _upperHint, address _lowerHint ) external; function repayLUSD( uint256 _amount, address _upperHint, address _lowerHint ) external; function closeTrove() external; function adjustTrove( uint256 _maxFee, uint256 _collWithdrawal, uint256 _debtChange, uint256 _ETHAmount, bool isDebtIncrease, address _upperHint, address _lowerHint ) external; function claimCollateral() external; function getCompositeDebt(uint256 _debt) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; /* * The Stability Pool holds LUSD tokens deposited by Stability Pool depositors. * * When a trove is liquidated, then depending on system conditions, some of its LUSD debt gets offset with * LUSD in the Stability Pool: that is, the offset debt evaporates, and an equal amount of LUSD tokens in the Stability Pool is burned. * * Thus, a liquidation causes each depositor to receive a LUSD loss, in proportion to their deposit as a share of total deposits. * They also receive an ETH gain, as the ETH collateral of the liquidated trove is distributed among Stability depositors, * in the same proportion. * * When a liquidation occurs, it depletes every deposit by the same fraction: for example, a liquidation that depletes 40% * of the total LUSD in the Stability Pool, depletes 40% of each deposit. * * A deposit that has experienced a series of liquidations is termed a "compounded deposit": each liquidation depletes the deposit, * multiplying it by some factor in range ]0,1[ * * Please see the implementation spec in the proof document, which closely follows on from the compounded deposit / ETH gain derivations: * https://github.com/liquity/liquity/blob/master/papers/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf * * --- LQTY ISSUANCE TO STABILITY POOL DEPOSITORS --- * * An LQTY issuance event occurs at every deposit operation, and every liquidation. * * Each deposit is tagged with the address of the front end through which it was made. * * All deposits earn a share of the issued LQTY in proportion to the deposit as a share of total deposits. The LQTY earned * by a given deposit, is split between the depositor and the front end through which the deposit was made, based on the front end's kickbackRate. * * Please see the system Readme for an overview: * https://github.com/liquity/dev/blob/main/README.md#lqty-issuance-to-stability-providers */ interface IStabilityPool { // --- Events --- event StabilityPoolETHBalanceUpdated(uint256 _newBalance); event StabilityPoolLUSDBalanceUpdated(uint256 _newBalance); event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event TroveManagerAddressChanged(address _newTroveManagerAddress); event ActivePoolAddressChanged(address _newActivePoolAddress); event DefaultPoolAddressChanged(address _newDefaultPoolAddress); event LUSDTokenAddressChanged(address _newLUSDTokenAddress); event SortedTrovesAddressChanged(address _newSortedTrovesAddress); event CommunityIssuanceAddressChanged(address _newCommunityIssuanceAddress); event P_Updated(uint256 _P); event S_Updated(uint256 _S, uint128 _epoch, uint128 _scale); event G_Updated(uint256 _G, uint128 _epoch, uint128 _scale); event EpochUpdated(uint128 _currentEpoch); event ScaleUpdated(uint128 _currentScale); event FrontEndRegistered(address indexed _frontEnd, uint256 _kickbackRate); event FrontEndTagSet(address indexed _depositor, address indexed _frontEnd); event DepositSnapshotUpdated(address indexed _depositor, uint256 _P, uint256 _S, uint256 _G); event FrontEndSnapshotUpdated(address indexed _frontEnd, uint256 _P, uint256 _G); event UserDepositChanged(address indexed _depositor, uint256 _newDeposit); event FrontEndStakeChanged( address indexed _frontEnd, uint256 _newFrontEndStake, address _depositor ); event ETHGainWithdrawn(address indexed _depositor, uint256 _ETH, uint256 _LUSDLoss); event LQTYPaidToDepositor(address indexed _depositor, uint256 _LQTY); event LQTYPaidToFrontEnd(address indexed _frontEnd, uint256 _LQTY); event EtherSent(address _to, uint256 _amount); event GovernanceAddressChanged(address _governanceAddress); // --- Functions --- /* * Called only once on init, to set addresses of other Liquity contracts * Callable only by owner, renounces ownership at the end */ function setAddresses( address _borrowerOperationsAddress, address _troveManagerAddress, address _activePoolAddress, address _lusdTokenAddress, address _sortedTrovesAddress, address _wethAddress, address _governanceAddress ) external; /* * Initial checks: * - Frontend is registered or zero address * - Sender is not a registered frontend * - _amount is not zero * --- * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Tags the deposit with the provided front end tag param, if it's a new deposit * - Sends depositor's accumulated gains (LQTY, ETH) to depositor * - Sends the tagged front end's accumulated LQTY gains to the tagged front end * - Increases deposit and tagged front end's stake, and takes new snapshots for each. */ function provideToSP(uint256 _amount, address _frontEndTag) external; /* * Initial checks: * - _amount is zero or there are no under collateralized troves left in the system * - User has a non zero deposit * --- * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Removes the deposit's front end tag if it is a full withdrawal * - Sends all depositor's accumulated gains (LQTY, ETH) to depositor * - Sends the tagged front end's accumulated LQTY gains to the tagged front end * - Decreases deposit and tagged front end's stake, and takes new snapshots for each. * * If _amount > userDeposit, the user withdraws all of their compounded deposit. */ function withdrawFromSP(uint256 _amount) external; /* * Initial checks: * - User has a non zero deposit * - User has an open trove * - User has some ETH gain * --- * - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends * - Sends all depositor's LQTY gain to depositor * - Sends all tagged front end's LQTY gain to the tagged front end * - Transfers the depositor's entire ETH gain from the Stability Pool to the caller's trove * - Leaves their compounded deposit in the Stability Pool * - Updates snapshots for deposit and tagged front end stake */ function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external; /* * Initial checks: * - Frontend (sender) not already registered * - User (sender) has no deposit * - _kickbackRate is in the range [0, 100%] * --- * Front end makes a one-time selection of kickback rate upon registering */ function registerFrontEnd(uint256 _kickbackRate) external; /* * Initial checks: * - Caller is TroveManager * --- * Cancels out the specified debt against the LUSD contained in the Stability Pool (as far as possible) * and transfers the Trove's ETH collateral from ActivePool to StabilityPool. * Only called by liquidation functions in the TroveManager. */ function offset(uint256 _debt, uint256 _coll) external; /* * Returns the total amount of ETH held by the pool, accounted in an internal variable instead of `balance`, * to exclude edge cases like ETH received from a self-destruct. */ function getETH() external view returns (uint256); /* * Returns LUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset. */ function getTotalLUSDDeposits() external view returns (uint256); /* * Calculates the ETH gain earned by the deposit since its last snapshots were taken. */ function getDepositorETHGain(address _depositor) external view returns (uint256); /* * Calculate the LQTY gain earned by a deposit since its last snapshots were taken. * If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned. * Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through * which they made their deposit. */ function getDepositorLQTYGain(address _depositor) external view returns (uint256); /* * Return the LQTY gain earned by the front end. */ function getFrontEndLQTYGain(address _frontEnd) external view returns (uint256); /* * Return the user's compounded deposit. */ function getCompoundedLUSDDeposit(address _depositor) external view returns (uint256); /* * Return the front end's compounded stake. * * The front end's compounded stake is equal to the sum of its depositors' compounded deposits. */ function getCompoundedFrontEndStake(address _frontEnd) external view returns (uint256); /* * Fallback function * Only callable by Active Pool, it just accounts for ETH received * receive() external payable; */ function receiveETH(uint256 _amount) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./IStabilityPool.sol"; import "./ILiquityBase.sol"; import "../Interfaces/ILiquityLUSDToken.sol"; // Common interface for the Trove Manager. interface ITroveManager is ILiquityBase { event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event LUSDTokenAddressChanged(address _newLUSDTokenAddress); event ActivePoolAddressChanged(address _activePoolAddress); event DefaultPoolAddressChanged(address _defaultPoolAddress); event StabilityPoolAddressChanged(address _stabilityPoolAddress); event GasPoolAddressChanged(address _gasPoolAddress); event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress); event SortedTrovesAddressChanged(address _sortedTrovesAddress); event GovernanceAddressChanged(address _governanceAddress); event WETHAddressChanged(address _wethAddress); event RewardSnapshotDetailsUpdated(address owner, address newOwner, uint256 timestamp); event TroveOwnersUpdated(address owner, address newOwner, uint256 idx, uint256 timestamp); event Liquidation( uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _LUSDGasCompensation ); event Redemption( uint256 _attemptedLUSDAmount, uint256 _actualLUSDAmount, uint256 _ETHSent, uint256 _ETHFee ); event TroveUpdated( address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, TroveManagerOperation _operation ); event TroveLiquidated( address indexed _borrower, uint256 _debt, uint256 _coll, TroveManagerOperation _operation ); event BaseRateUpdated(uint256 _baseRate); event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime); event TotalStakesUpdated(uint256 _newTotalStakes); event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot); event LTermsUpdated(uint256 _L_ETH, uint256 _L_LUSDDebt); event TroveSnapshotsUpdated(uint256 _L_ETH, uint256 _L_LUSDDebt); event TroveIndexUpdated(address _borrower, uint256 _newIndex); enum TroveManagerOperation { applyPendingRewards, liquidateInNormalMode, liquidateInRecoveryMode, redeemCollateral } // --- Functions --- function setAddresses( address _borrowerOperationsAddress, address _activePoolAddress, address _defaultPoolAddress, address _stabilityPoolAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _lusdTokenAddress, address _sortedTrovesAddress, address _governanceAddress, address _wethAddress ) external; function stabilityPool() external view returns (IStabilityPool); function lusdToken() external view returns (ILiquityLUSDToken); function getTroveOwnersCount() external view returns (uint256); function getTroveFromTroveOwnersArray(uint256 _index) external view returns (address); function getNominalICR(address _borrower) external view returns (uint256); function getCurrentICR(address _borrower, uint256 _price) external view returns (uint256); function liquidate(address _borrower) external; function liquidateTroves(uint256 _n) external; function batchLiquidateTroves(address[] calldata _troveArray) external; function redeemCollateral( uint256 _LUSDAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFee ) external; function updateStakeAndTotalStakes(address _borrower) external returns (uint256); function updateTroveRewardSnapshots(address _borrower) external; function addTroveOwnerToArray(address _borrower) external returns (uint256 index); function applyPendingRewards(address _borrower) external; function getPendingETHReward(address _borrower) external view returns (uint256); function getPendingLUSDDebtReward(address _borrower) external view returns (uint256); function hasPendingRewards(address _borrower) external view returns (bool); function getEntireDebtAndColl(address _borrower) external view returns ( uint256 debt, uint256 coll, uint256 pendingLUSDDebtReward, uint256 pendingETHReward ); function closeTrove(address _borrower) external; function removeStake(address _borrower) external; function getRedemptionRate() external view returns (uint256); function getRedemptionRateWithDecay() external view returns (uint256); function getRedemptionFeeWithDecay(uint256 _ETHDrawn) external view returns (uint256); function getBorrowingRate() external view returns (uint256); function getBorrowingRateWithDecay() external view returns (uint256); function getBorrowingFee(uint256 LUSDDebt) external view returns (uint256); function getBorrowingFeeWithDecay(uint256 _LUSDDebt) external view returns (uint256); function decayBaseRateFromBorrowing() external; function getTroveStatus(address _borrower) external view returns (uint256); function getTroveStake(address _borrower) external view returns (uint256); function getTroveDebt(address _borrower) external view returns (uint256); function getTroveFrontEnd(address _borrower) external view returns (address); function getTroveColl(address _borrower) external view returns (uint256); function setTroveStatus(address _borrower, uint256 num) external; function setTroveFrontEndTag(address _borrower, address _frontEndTag) external; function increaseTroveColl(address _borrower, uint256 _collIncrease) external returns (uint256); function decreaseTroveColl(address _borrower, uint256 _collDecrease) external returns (uint256); function increaseTroveDebt(address _borrower, uint256 _debtIncrease) external returns (uint256); function decreaseTroveDebt(address _borrower, uint256 _collDecrease) external returns (uint256); function getTCR(uint256 _price) external view returns (uint256); function checkRecoveryMode(uint256 _price) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; // Common interface for the SortedTroves Doubly Linked List. interface ISortedTroves { // --- Events --- event TroveManagerAddressChanged(address _troveManagerAddress); event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress); event NodeAdded(address _id, uint256 _NICR); event NodeRemoved(address _id); event NodeOwnerUpdated(address id, address newId, uint256 timestamp); // --- Functions --- function setParams( uint256 _size, address _TroveManagerAddress, address _borrowerOperationsAddress ) external; function insert( address _id, uint256 _ICR, address _prevId, address _nextId ) external; function remove(address _id) external; function reInsert( address _id, uint256 _newICR, address _prevId, address _nextId ) external; function contains(address _id) external view returns (bool); function isFull() external view returns (bool); function isEmpty() external view returns (bool); function getSize() external view returns (uint256); function getMaxSize() external view returns (uint256); function getFirst() external view returns (address); function getLast() external view returns (address); function getNext(address _id) external view returns (address); function getPrev(address _id) external view returns (address); function validInsertPosition( uint256 _ICR, address _prevId, address _nextId ) external view returns (bool); function findInsertPosition( uint256 _ICR, address _prevId, address _nextId ) external view returns (address, address); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./BaseMath.sol"; import "./LiquityMath.sol"; import "./IERC20.sol"; import "../Interfaces/IGovernance.sol"; import "../Interfaces/IActivePool.sol"; import "../Interfaces/IDefaultPool.sol"; import "../Interfaces/IPriceFeed.sol"; import "../Interfaces/ILiquityBase.sol"; /* * Base contract for TroveManager, BorrowerOperations and StabilityPool. Contains global system constants and * common functions. */ contract LiquityBase is BaseMath, ILiquityBase { using SafeMath for uint256; uint256 public _100pct = 1000000000000000000; // 1e18 == 100% // Minimum collateral ratio for individual troves uint256 public MCR = 1080000000000000000; // 108% // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered. uint256 public CCR = 1300000000000000000; // 130% // Amount of LUSD to be locked in gas pool on opening troves uint256 public LUSD_GAS_COMPENSATION = 50e18; // Minimum amount of net LUSD debt a trove must have uint256 public MIN_NET_DEBT = 50e18; // uint constant public MIN_NET_DEBT = 0; uint256 public PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5% IActivePool public activePool; IDefaultPool public defaultPool; IGovernance public governance; // --- Gas compensation functions --- function getBorrowingFeeFloor() public view returns (uint256) { return governance.getBorrowingFeeFloor(); } function getRedemptionFeeFloor() public view returns (uint256) { return governance.getRedemptionFeeFloor(); } function getMaxBorrowingFee() public view returns (uint256) { return governance.getMaxBorrowingFee(); } function getPriceFeed() public view override returns (IPriceFeed) { return governance.getPriceFeed(); } // Returns the composite debt (drawn debt + gas compensation) of a trove, for the purpose of ICR calculation function _getCompositeDebt(uint256 _debt) internal view returns (uint256) { return _debt.add(LUSD_GAS_COMPENSATION); } function _getNetDebt(uint256 _debt) internal view returns (uint256) { return _debt.sub(LUSD_GAS_COMPENSATION); } // Return the amount of ETH to be drawn from a trove's collateral and sent as gas compensation. function _getCollGasCompensation(uint256 _entireColl) internal view returns (uint256) { return _entireColl / PERCENT_DIVISOR; } function getEntireSystemColl() public view returns (uint256 entireSystemColl) { uint256 activeColl = activePool.getETH(); uint256 liquidatedColl = defaultPool.getETH(); return activeColl.add(liquidatedColl); } function getEntireSystemDebt() public view returns (uint256 entireSystemDebt) { uint256 activeDebt = activePool.getLUSDDebt(); uint256 closedDebt = defaultPool.getLUSDDebt(); return activeDebt.add(closedDebt); } function _getTCR(uint256 _price) internal view returns (uint256 TCR) { uint256 entireSystemColl = getEntireSystemColl(); uint256 entireSystemDebt = getEntireSystemDebt(); TCR = LiquityMath._computeCR(entireSystemColl, entireSystemDebt, _price); return TCR; } function _checkRecoveryMode(uint256 _price) internal view returns (bool) { uint256 TCR = _getTCR(_price); return TCR < CCR; } function _requireUserAcceptsFee( uint256 _fee, uint256 _amount, uint256 _maxFeePercentage ) internal pure { uint256 feePercentage = _fee.mul(DECIMAL_PRECISION).div(_amount); require(feePercentage <= _maxFeePercentage, "Fee exceeded provided maximum"); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; /** * Based on OpenZeppelin's SafeMath: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol * * @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; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; // uint128 addition and subtraction, with overflow protection. library LiquitySafeMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128) { uint128 c = a + b; require(c >= a, "LiquitySafeMath128: addition overflow"); return c; } function sub(uint128 a, uint128 b) internal pure returns (uint128) { require(b <= a, "LiquitySafeMath128: subtraction overflow"); uint128 c = a - b; return c; } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./Context.sol"; // MOdificaitons taken from: `https://github.com/FraxFinance/frax-solidity/blob/master/src/hardhat/contracts/Common/Ownable.sol` /** * Based on OpenZeppelin's Ownable contract: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.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 internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view 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. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. * * NOTE: This function is not safe, as it doesn't check owner is calling it. * Make sure you check it before calling it. */ function _renounceOwnership() internal { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract CheckContract { /** * Check that the account is an already deployed non-destroyed contract. * See: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L12 */ function checkContract(address _account) internal view { require(_account != address(0), "Account cannot be zero address"); uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(_account) } require(size > 0, "Account code size cannot be zero"); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "../Dependencies/IERC20.sol"; import "./IPriceFeed.sol"; import "../Dependencies/ISimpleERCFund.sol"; import "../Interfaces/IOracle.sol"; interface IGovernance { function getDeploymentStartTime() external view returns (uint256); function getBorrowingFeeFloor() external view returns (uint256); function getRedemptionFeeFloor() external view returns (uint256); function getMaxBorrowingFee() external view returns (uint256); function getMaxDebtCeiling() external view returns (uint256); function getAllowMinting() external view returns (bool); function getPriceFeed() external view returns (IPriceFeed); function getStabilityFee() external view returns (uint256); function getStabilityFeeToken() external view returns (IERC20); function getStabilityTokenPairOracle() external view returns (IOracle); function getFund() external view returns (ISimpleERCFund); function chargeStabilityFee(address who, uint256 LUSDAmount) external; function sendToFund(address token, uint256 amount, string memory reason) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "../Dependencies/IERC20.sol"; import "../Dependencies/IERC2612.sol"; interface ILiquityLUSDToken is IERC20, IERC2612 { // --- Events --- event BorrowerOperationsAddressToggled(address borrowerOperations, bool oldFlag, bool newFlag, uint256 timestamp); event TroveManagerToggled(address troveManager, bool oldFlag, bool newFlag, uint256 timestamp); event StabilityPoolToggled(address stabilityPool, bool oldFlag, bool newFlag, uint256 timestamp); event LUSDTokenBalanceUpdated(address _user, uint _amount); // --- Functions --- function toggleBorrowerOperations(address borrowerOperations) external; function toggleTroveManager(address troveManager) external; function toggleStabilityPool(address stabilityPool) external; function mint(address _account, uint256 _amount) external; function burn(address _account, uint256 _amount) external; function sendToPool(address _sender, address poolAddress, uint256 _amount) external; function returnFromPool(address poolAddress, address user, uint256 _amount ) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./IPriceFeed.sol"; interface ILiquityBase { function getPriceFeed() external view returns (IPriceFeed); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; pragma experimental ABIEncoderV2; interface IPriceFeed { // --- Events --- event LastGoodPriceUpdated(uint256 _lastGoodPrice); // --- Function --- function fetchPrice() external returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; /** * Based on the OpenZeppelin IER20 interface: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol * * @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); function increaseAllowance(address spender, uint256 addedValue) external returns (bool); function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); /** * @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); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; /** * @dev Interface of the ERC2612 standard as defined in the EIP. * * Adds the {permit} method, which can be used to change one's * {IERC20-allowance} without having to send a transaction, by signing a * message. This allows users to spend tokens without having to hold Ether. * * See https://eips.ethereum.org/EIPS/eip-2612. * * Code adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237/ */ interface IERC2612 { /** * @dev Sets `amount` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current ERC2612 nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases `owner`'s nonce by one. This * prevents a signature from being used multiple times. * * `owner` can limit the time a Permit is valid for by setting `deadline` to * a value in the near future. The deadline argument can be set to uint(-1) to * create Permits that effectively never expire. */ function nonces(address owner) external view returns (uint256); function version() external view returns (string memory); function permitTypeHash() external view returns (bytes32); function domainSeparator() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract BaseMath { uint256 public constant DECIMAL_PRECISION = 1e18; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./SafeMath.sol"; library LiquityMath { using SafeMath for uint; uint internal constant DECIMAL_PRECISION = 1e18; /* Precision for Nominal ICR (independent of price). Rationale for the value: * * - Making it “too high” could lead to overflows. * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division. * * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 ETH, * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator. * */ uint internal constant NICR_PRECISION = 1e20; function _min(uint _a, uint _b) internal pure returns (uint) { return (_a < _b) ? _a : _b; } function _max(uint _a, uint _b) internal pure returns (uint) { return (_a >= _b) ? _a : _b; } /* * Multiply two decimal numbers and use normal rounding rules: * -round product up if 19'th mantissa digit >= 5 * -round product down if 19'th mantissa digit < 5 * * Used only inside the exponentiation, _decPow(). */ function decMul(uint x, uint y) internal pure returns (uint decProd) { uint prod_xy = x.mul(y); decProd = prod_xy.add(DECIMAL_PRECISION / 2).div(DECIMAL_PRECISION); } /* * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n. * * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity. * * Called by two functions that represent time in units of minutes: * 1) TroveManager._calcDecayedBaseRate * 2) CommunityIssuance._getCumulativeIssuanceFraction * * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals * "minutes in 1000 years": 60 * 24 * 365 * 1000 * * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be * negligibly different from just passing the cap, since: * * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible */ function _decPow(uint _base, uint _minutes) internal pure returns (uint) { if (_minutes > 525600000) {_minutes = 525600000;} // cap to avoid overflow if (_minutes == 0) {return DECIMAL_PRECISION;} uint y = DECIMAL_PRECISION; uint x = _base; uint n = _minutes; // Exponentiation-by-squaring while (n > 1) { if (n % 2 == 0) { x = decMul(x, x); n = n.div(2); } else { // if (n % 2 != 0) y = decMul(x, y); x = decMul(x, x); n = (n.sub(1)).div(2); } } return decMul(x, y); } function _getAbsoluteDifference(uint _a, uint _b) internal pure returns (uint) { return (_a >= _b) ? _a.sub(_b) : _b.sub(_a); } function _computeNominalCR(uint _coll, uint _debt) internal pure returns (uint) { if (_debt > 0) { return _coll.mul(NICR_PRECISION).div(_debt); } // Return the maximal value for uint256 if the Trove has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2**256 - 1; } } function _computeCR(uint _coll, uint _debt, uint _price) internal pure returns (uint) { if (_debt > 0) { uint newCollRatio = _coll.mul(_price).div(_debt); return newCollRatio; } // Return the maximal value for uint256 if the Trove has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2**256 - 1; } } } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./IPool.sol"; interface IActivePool is IPool { event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event TroveManagerAddressChanged(address _newTroveManagerAddress); event ActivePoolLUSDDebtUpdated(uint256 _LUSDDebt); event ActivePoolETHBalanceUpdated(uint256 _ETH); event Repay(address indexed from, uint256 amount); event Borrow(address indexed from, uint256 amount); // --- Functions --- function sendETH(address _account, uint256 _amount) external; function receiveETH(uint256 _amount) external; function borrow(uint256 amount) external; function repay(uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; import "./IPool.sol"; interface IDefaultPool is IPool { // --- Events --- event TroveManagerAddressChanged(address _newTroveManagerAddress); event DefaultPoolLUSDDebtUpdated(uint256 _LUSDDebt); event DefaultPoolETHBalanceUpdated(uint256 _ETH); // --- Functions --- function sendETHToActivePool(uint256 _amount) external; function receiveETH(uint256 _amount) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; interface ISimpleERCFund { function deposit( address token, uint256 amount, string memory reason ) external; function withdraw( address token, uint256 amount, address to, string memory reason ) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; interface IOracle { function getPrice() external view returns (uint256); function getDecimalPercision() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.8.0; // Common interface for the Pools. interface IPool { // --- Events --- event ETHBalanceUpdated(uint256 _newBalance); event LUSDBalanceUpdated(uint256 _newBalance); event ActivePoolAddressChanged(address _newActivePoolAddress); event DefaultPoolAddressChanged(address _newDefaultPoolAddress); event StabilityPoolAddressChanged(address _newStabilityPoolAddress); event EtherSent(address _to, uint256 _amount); // --- Functions --- function getETH() external view returns (uint256); function getLUSDDebt() external view returns (uint256); function increaseLUSDDebt(uint256 _amount) external; function decreaseLUSDDebt(uint256 _amount) external; } // 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 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) { 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; } }
--- Events --- --- Functions ---
interface ILiquityLUSDToken is IERC20, IERC2612 { event BorrowerOperationsAddressToggled(address borrowerOperations, bool oldFlag, bool newFlag, uint256 timestamp); event TroveManagerToggled(address troveManager, bool oldFlag, bool newFlag, uint256 timestamp); event StabilityPoolToggled(address stabilityPool, bool oldFlag, bool newFlag, uint256 timestamp); event LUSDTokenBalanceUpdated(address _user, uint _amount); function toggleBorrowerOperations(address borrowerOperations) external; function toggleTroveManager(address troveManager) external; function toggleStabilityPool(address stabilityPool) external; function mint(address _account, uint256 _amount) external; function burn(address _account, uint256 _amount) external; function sendToPool(address _sender, address poolAddress, uint256 _amount) external; function returnFromPool(address poolAddress, address user, uint256 _amount ) external; }
5,966,236
[ 1, 4625, 348, 7953, 560, 30, 225, 9948, 9043, 9948, 9948, 15486, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5831, 467, 48, 18988, 560, 48, 3378, 40, 1345, 353, 467, 654, 39, 3462, 16, 467, 654, 39, 5558, 2138, 288, 203, 203, 203, 565, 871, 605, 15318, 264, 9343, 1887, 56, 23972, 1259, 12, 2867, 29759, 264, 9343, 16, 1426, 1592, 4678, 16, 1426, 394, 4678, 16, 2254, 5034, 2858, 1769, 203, 565, 871, 399, 303, 537, 1318, 56, 23972, 1259, 12, 2867, 23432, 537, 1318, 16, 1426, 1592, 4678, 16, 1426, 394, 4678, 16, 2254, 5034, 2858, 1769, 203, 565, 871, 934, 2967, 2864, 56, 23972, 1259, 12, 2867, 384, 2967, 2864, 16, 1426, 1592, 4678, 16, 1426, 394, 4678, 16, 2254, 5034, 2858, 1769, 203, 203, 565, 871, 511, 3378, 40, 1345, 13937, 7381, 12, 2867, 389, 1355, 16, 2254, 389, 8949, 1769, 203, 203, 203, 565, 445, 10486, 38, 15318, 264, 9343, 12, 2867, 29759, 264, 9343, 13, 3903, 31, 203, 203, 565, 445, 10486, 56, 303, 537, 1318, 12, 2867, 23432, 537, 1318, 13, 3903, 31, 203, 203, 565, 445, 10486, 510, 2967, 2864, 12, 2867, 384, 2967, 2864, 13, 3903, 31, 203, 203, 565, 445, 312, 474, 12, 2867, 389, 4631, 16, 2254, 5034, 389, 8949, 13, 3903, 31, 203, 203, 565, 445, 18305, 12, 2867, 389, 4631, 16, 2254, 5034, 389, 8949, 13, 3903, 31, 203, 203, 565, 445, 29091, 2864, 12, 2867, 389, 15330, 16, 225, 1758, 2845, 1887, 16, 2254, 5034, 389, 8949, 13, 3903, 31, 203, 203, 565, 445, 327, 1265, 2864, 12, 2867, 2845, 1887, 16, 1758, 729, 16, 2254, 5034, 389, 8949, 262, 3903, 31, 203, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// contracts/GovernorCrowdsale.sol // SPDX-License-Identifier: MIT pragma solidity ^0.5.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/validation/CappedCrowdsale.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/access/roles/CapperRole.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/validation/TimedCrowdsale.sol"; contract GovernorCrowdsale is CappedCrowdsale, TimedCrowdsale, CapperRole { using SafeMath for uint256; mapping(address => uint256) private _contributions; mapping(address => uint256) private _caps; mapping(address => bool) private whitelist; uint256 private _individualDefaultCap; constructor ( uint256 rate, address payable wallet, IERC20 token, uint256 openingTime, uint256 closingTime, uint256 cap, uint256 individualCap ) public Crowdsale(rate, wallet, token) TimedCrowdsale(openingTime, closingTime) CappedCrowdsale(cap) { _individualDefaultCap = individualCap; } /** * @dev Sets a specific beneficiary's maximum contribution. * @param beneficiary Address to be capped * @param cap Wei limit for individual contribution */ function setCap(address beneficiary, uint256 cap) external onlyCapper { _caps[beneficiary] = cap; } /** * @dev Adds addresseto whitelist. * @param beneficiary Address list to whitelist */ function addWhitelist(address beneficiary) external onlyCapper{ whitelist[beneficiary] = true; } /** * @dev Adds multipled addresses to whitelist. * @param beneficiary Address list to whitelist */ function addManyWhitelist(address[] calldata beneficiary) external onlyCapper{ for (uint i = 0; i < beneficiary.length; i++){ whitelist[beneficiary[i]] = true; } } /** * @dev Removes address from whitelist. * @param beneficiary Address to remove from whitelist */ function removeWhitelist(address beneficiary) external onlyCapper{ whitelist[beneficiary] = false; } /** * @dev Returns if address is whitelisted. * @param beneficiary Address whose whitelist status is checked * @return true if whitelisted, false if not */ function isWhitelisted(address beneficiary) public view returns (bool){ return whitelist[beneficiary] == true; } /** * @dev Returns the cap of a specific beneficiary. * @param beneficiary Address whose cap is to be checked * @return Current cap for individual beneficiary */ function getCap(address beneficiary) public view returns (uint256) { uint256 cap = _caps[beneficiary]; if (cap == 0) { cap = _individualDefaultCap; } return cap; } /** * @dev Returns the amount contributed so far by a specific beneficiary. * @param beneficiary Address of contributor * @return Beneficiary contribution so far */ function getContribution(address beneficiary) public view returns (uint256) { return _contributions[beneficiary]; } /** * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. * @param beneficiary Token purchaser * @param weiAmount Amount of wei contributed */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); // solhint-disable-next-line max-line-length require(whitelist[beneficiary], "Governor LGE: Address not whitelisted"); require(_contributions[beneficiary].add(weiAmount) <= getCap(beneficiary), "Governor LGE: beneficiary's cap exceeded"); } /** * @dev Extend parent behavior to update beneficiary contributions. * @param beneficiary Token purchaser * @param weiAmount Amount of wei contributed */ function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { super._updatePurchasingState(beneficiary, weiAmount); _contributions[beneficiary] = _contributions[beneficiary].add(weiAmount); } }
* @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. @param beneficiary Token purchaser @param weiAmount Amount of wei contributed/ solhint-disable-next-line max-line-length
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); require(whitelist[beneficiary], "Governor LGE: Address not whitelisted"); require(_contributions[beneficiary].add(weiAmount) <= getCap(beneficiary), "Governor LGE: beneficiary's cap exceeded"); }
6,447,651
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 27686, 982, 6885, 29468, 23701, 358, 8762, 326, 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164, 12, 2867, 27641, 74, 14463, 814, 16, 2254, 5034, 732, 77, 6275, 13, 2713, 1476, 288, 203, 3639, 2240, 6315, 1484, 4270, 23164, 12, 70, 4009, 74, 14463, 814, 16, 732, 77, 6275, 1769, 203, 3639, 2583, 12, 20409, 63, 70, 4009, 74, 14463, 814, 6487, 315, 43, 1643, 29561, 511, 7113, 30, 5267, 486, 26944, 8863, 203, 3639, 2583, 24899, 591, 15326, 63, 70, 4009, 74, 14463, 814, 8009, 1289, 12, 1814, 77, 6275, 13, 1648, 29092, 12, 70, 4009, 74, 14463, 814, 3631, 315, 43, 1643, 29561, 511, 7113, 30, 27641, 74, 14463, 814, 1807, 3523, 12428, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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 "../../math/SafeMath.sol"; import "../Crowdsale.sol"; import "../../access/roles/CapperRole.sol"; /** * @title IndividuallyCappedCrowdsale * @dev Crowdsale with per-beneficiary caps. */ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { using SafeMath for uint256; mapping(address => uint256) private _contributions; mapping(address => uint256) private _caps; /** * @dev Sets a specific beneficiary's maximum contribution. * @param beneficiary Address to be capped * @param cap Wei limit for individual contribution */ function setCap(address beneficiary, uint256 cap) external onlyCapper { _caps[beneficiary] = cap; } /** * @dev Returns the cap of a specific beneficiary. * @param beneficiary Address whose cap is to be checked * @return Current cap for individual beneficiary */ function getCap(address beneficiary) public view returns (uint256) { return _caps[beneficiary]; } /** * @dev Returns the amount contributed so far by a specific beneficiary. * @param beneficiary Address of contributor * @return Beneficiary contribution so far */ function getContribution(address beneficiary) public view returns (uint256) { return _contributions[beneficiary]; } /** * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. * @param beneficiary Token purchaser * @param weiAmount Amount of wei contributed */ function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal { super._preValidatePurchase(beneficiary, weiAmount); require( _contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); } /** * @dev Extend parent behavior to update beneficiary contributions * @param beneficiary Token purchaser * @param weiAmount Amount of wei contributed */ function _updatePurchasingState( address beneficiary, uint256 weiAmount ) internal { super._updatePurchasingState(beneficiary, weiAmount); _contributions[beneficiary] = _contributions[beneficiary].add( weiAmount); } }
* @title IndividuallyCappedCrowdsale @dev Crowdsale with per-beneficiary caps./
contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { using SafeMath for uint256; mapping(address => uint256) private _contributions; mapping(address => uint256) private _caps; function setCap(address beneficiary, uint256 cap) external onlyCapper { _caps[beneficiary] = cap; } function getCap(address beneficiary) public view returns (uint256) { return _caps[beneficiary]; } function getContribution(address beneficiary) public view returns (uint256) { return _contributions[beneficiary]; } function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal { super._preValidatePurchase(beneficiary, weiAmount); require( _contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); } function _updatePurchasingState( address beneficiary, uint256 weiAmount ) internal { super._updatePurchasingState(beneficiary, weiAmount); _contributions[beneficiary] = _contributions[beneficiary].add( weiAmount); } }
968,850
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 657, 2892, 350, 3452, 4664, 1845, 39, 492, 2377, 5349, 632, 5206, 385, 492, 2377, 5349, 598, 1534, 17, 70, 4009, 74, 14463, 814, 15788, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 657, 2892, 350, 3452, 4664, 1845, 39, 492, 2377, 5349, 353, 385, 492, 2377, 5349, 16, 11200, 457, 2996, 288, 203, 225, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 203, 225, 2874, 12, 2867, 516, 2254, 5034, 13, 3238, 389, 591, 15326, 31, 203, 225, 2874, 12, 2867, 516, 2254, 5034, 13, 3238, 389, 22984, 31, 203, 203, 225, 445, 444, 4664, 12, 2867, 27641, 74, 14463, 814, 16, 2254, 5034, 3523, 13, 3903, 1338, 4664, 457, 288, 203, 565, 389, 22984, 63, 70, 4009, 74, 14463, 814, 65, 273, 3523, 31, 203, 225, 289, 203, 203, 225, 445, 29092, 12, 2867, 27641, 74, 14463, 814, 13, 1071, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 565, 327, 389, 22984, 63, 70, 4009, 74, 14463, 814, 15533, 203, 225, 289, 203, 203, 225, 445, 336, 442, 4027, 12, 2867, 27641, 74, 14463, 814, 13, 203, 565, 1071, 1476, 1135, 261, 11890, 5034, 13, 203, 225, 288, 203, 565, 327, 389, 591, 15326, 63, 70, 4009, 74, 14463, 814, 15533, 203, 225, 289, 203, 203, 225, 445, 389, 1484, 4270, 23164, 12, 203, 565, 1758, 27641, 74, 14463, 814, 16, 203, 565, 2254, 5034, 732, 77, 6275, 203, 225, 262, 203, 565, 2713, 203, 225, 288, 203, 565, 2240, 6315, 1484, 4270, 23164, 12, 70, 4009, 74, 14463, 814, 16, 732, 77, 6275, 1769, 203, 565, 2583, 12, 203, 1377, 389, 591, 15326, 63, 70, 4009, 74, 14463, 814, 8009, 1289, 12, 1814, 77, 6275, 13, 1648, 389, 22984, 63, 70, 4009, 74, 14463, 814, 19226, 203, 225, 289, 203, 203, 225, 445, 389, 2725, 10262, 343, 11730, 1119, 12, 203, 565, 1758, 27641, 74, 14463, 814, 16, 203, 565, 2254, 5034, 732, 77, 6275, 203, 225, 262, 203, 565, 2713, 203, 225, 288, 203, 565, 2240, 6315, 2725, 10262, 343, 11730, 1119, 12, 70, 4009, 74, 14463, 814, 16, 732, 77, 6275, 1769, 203, 565, 389, 591, 15326, 63, 70, 4009, 74, 14463, 814, 65, 273, 389, 591, 15326, 63, 70, 4009, 74, 14463, 814, 8009, 1289, 12, 203, 1377, 732, 77, 6275, 1769, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x6c90d4dceEfA053F9E17EDBd7dF9Eb3FC2762Ac9/sources/virtualGold.sol
cash out the holders position
function sellVirtualGold() public returns (bool) { return true; }
15,771,831
[ 1, 4625, 348, 7953, 560, 30, 276, 961, 596, 326, 366, 4665, 1754, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 357, 80, 6466, 43, 1673, 1435, 203, 3639, 1071, 1135, 261, 6430, 13, 203, 225, 288, 203, 3639, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/*************************************************************************************************** * * * (c) 2018, 2019 Quantstamp, Inc. This content and its use are governed by the license terms at * * <https://raw.githubusercontent.com/quantstamp/qsp-staking-protocol/master/LICENSE> * * * ***************************************************************************************************/ pragma solidity 0.4.24; /// @title QuantstampStaking - is the smart contract representing the core of the Staking Protocol /// @author Quantstamp import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "openzeppelin-solidity/contracts/math/Math.sol"; import "./policies/IPolicy.sol"; import "./registries/IRegistry.sol"; import "./QuantstampStakingData.sol"; contract QuantstampStaking is Ownable { using SafeMath for uint256; using Math for uint256; uint constant internal MAX_UINT = ~uint(0); /* solhint-disable */ QuantstampStakingData.PoolState constant internal S1_Initialized = QuantstampStakingData.PoolState.Initialized; QuantstampStakingData.PoolState constant internal S2_NotViolatedUnderfunded = QuantstampStakingData.PoolState.NotViolatedUnderfunded; QuantstampStakingData.PoolState constant internal S3_ViolatedUnderfunded = QuantstampStakingData.PoolState.ViolatedUnderfunded; QuantstampStakingData.PoolState constant internal S4_NotViolatedFunded = QuantstampStakingData.PoolState.NotViolatedFunded; QuantstampStakingData.PoolState constant internal S5_ViolatedFunded = QuantstampStakingData.PoolState.ViolatedFunded; QuantstampStakingData.PoolState constant internal S6_Cancelled = QuantstampStakingData.PoolState.Cancelled; QuantstampStakingData.PoolState constant internal S7_PolicyExpired = QuantstampStakingData.PoolState.PolicyExpired; /* solhint-enable */ // Token used to make deposits and stakes. This contract assumes that the owner of the contract // trusts token's code and that transfer function (e.g. transferFrom, transfer) work correctly. ERC20 public token; // TCR used to list expert stakers. IRegistry public stakingRegistry; // Signals that a stakeholder has made a deposit event DepositMade(uint poolIndex, address actor, uint amountQspWei); // Signals that a stakeholder has withdrawn the deposit event DepositWithdrawn(uint poolIndex, address actor, uint amountQspWei); // Signals that a stakeholder has withdrawn a claim event ClaimWithdrawn(uint poolIndex, address actor, uint amountQspWei); // Signals that staker has staked amountQspWei at poolIndex event StakePlaced(uint poolIndex, address staker, uint amountQspWei); // Signals that a stake has been withdrawn event StakeWithdrawn(uint poolIndex, address staker, uint amountQspWei); // Signals that a staker has received a payout event StakerReceivedPayout(uint poolIndex, address staker, uint amountQspWei); // Signals that the state of the pool has changed event StateChanged(uint poolIndex, QuantstampStakingData.PoolState state); // Indicates registry update event RegistryUpdated(address newRegistry); QuantstampStakingData internal data; uint public globalMinDepositQspWei; /** Allows execution only when the policy of the pool is not violated. * @param poolIndex - index of the pool where the policy is checked */ modifier whenNotViolated(uint poolIndex) { address poolPolicy = data.getPoolContractPolicy(poolIndex); address candidateContract = data.getPoolCandidateContract(poolIndex); require(!IPolicy(poolPolicy).isViolated(candidateContract) && data.getPoolState(poolIndex) != QuantstampStakingData.PoolState.ViolatedFunded && data.getPoolState(poolIndex) != QuantstampStakingData.PoolState.ViolatedUnderfunded, "Contract policy is violated."); _; } /** Allows execution only when the pool owner is the msg.sender. * @param poolIndex - index of the pool */ modifier onlyPoolOwner(uint poolIndex) { address poolOwner = data.getPoolOwner(poolIndex); require(poolOwner == msg.sender, "Msg.sender is not pool owner."); _; } /** Initializes the Quality Assurance Protocol * @param tokenAddress - the address of the QSP Token contract * @param tcrAddress - the address of the security expert token curated registry * @param dataContractAddress - the address of the data contract for the current logic contract */ constructor(address tokenAddress, address tcrAddress, address dataContractAddress) public { require(tokenAddress != address(0), "Token address is 0."); token = ERC20(tokenAddress); require(tcrAddress != address(0), "TCR address is 0."); stakingRegistry = IRegistry(tcrAddress); require(dataContractAddress != address(0), "Data contract address is 0."); data = QuantstampStakingData(dataContractAddress); } /** Allows the stakeholder to make an additional deposit to the contract * @param poolIndex - the index of the pool into which funds needs to be deposited * @param depositQspWei - the amount to be deposited into de pool */ function depositFunds( uint poolIndex, uint depositQspWei ) external onlyPoolOwner(poolIndex) { // Gather conditions bool violated = isViolated(poolIndex); bool timedout = isTimedOut(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); bool funded = data.getPoolDepositQspWei(poolIndex).add(depositQspWei) >= data.getPoolMaxPayoutQspWei(poolIndex); QuantstampStakingData.PoolState s = getPoolState(poolIndex); // Guard: Reject in 3.2, 5.2, 6.2 require(S1_Initialized == s // 1.1, 1.5 || S2_NotViolatedUnderfunded == s // 2.2, 2.8, 2.10, 2.14a, 2.15 || S4_NotViolatedFunded == s // 4.1a, 4.6, 4.8, 4.9 || S7_PolicyExpired == s, // 7.1, 7.3 "Pool is not in the right state to deposit funds."); /* solhint-disable no-empty-blocks */ // Effect: Skip in 2.8 if (S2_NotViolatedUnderfunded == s && !expired && violated) { // pass on the effect in 2.8 } else { // 1.1, 1.5, 2.2, 2.10, 2.14a, 2.15, 4.1a, 4.6, 4.8, 4.9, 7.1, 7.3 depositFundsEffect(poolIndex, depositQspWei); } /* solhint-enable no-empty-blocks */ // Additional condition bool stakesExist = data.getPoolTotalStakeQspWei(poolIndex) > 0; // Transition: Retains state in 1.1, 2.2, 4.1a, 7.1 if (S2_NotViolatedUnderfunded == s && !expired && violated) { // 2.8 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S2_NotViolatedUnderfunded == s && !expired && !violated && funded) { // 2.10 setState(poolIndex, S4_NotViolatedFunded); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.6 setState(poolIndex, S5_ViolatedFunded); } else if (S2_NotViolatedUnderfunded == s && expired && !expiredTwice // 2.15 || S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.9 setState(poolIndex, S7_PolicyExpired); } else if (S1_Initialized == s && (timedout || violated) // 1.5 || S2_NotViolatedUnderfunded == s && expiredTwice // 2.14a || S4_NotViolatedFunded == s && expiredTwice // 4.8 || S7_PolicyExpired == s && (expiredTwice || !stakesExist)) { // 7.3 setState(poolIndex, S6_Cancelled); } } /** Allows the stakeholder to withdraw their entire deposits from the contract * if the policy is not violated * @param poolIndex - the index of the pool from which the deposit should be withdrawn */ function withdrawDeposit(uint poolIndex) external onlyPoolOwner(poolIndex) { // Gather conditions bool violated = isViolated(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); uint totalStake = data.getPoolTotalStakeQspWei(poolIndex); QuantstampStakingData.PoolState s = getPoolState(poolIndex); // Guard: Reject in 5.2, 4.11, 3.2, 7.5 require(S1_Initialized == s // 1.6 || S2_NotViolatedUnderfunded == s // 2.11 || S4_NotViolatedFunded == s && ( !expired && violated // 4.5 || !expiredTwice && expired // 4.10 || expiredTwice // 4.8 ) || S6_Cancelled == s // 6.1 || S7_PolicyExpired == s && (expiredTwice || totalStake == 0), // 7.3 "Pool is not in the right state when withdrawing deposit."); // Effect: No effect in 4.5, 4.10 if (S1_Initialized == s // 1.6 || S2_NotViolatedUnderfunded == s // 2.11 || S4_NotViolatedFunded == s && expiredTwice // 4.8 || S6_Cancelled == s // 6.1 || S7_PolicyExpired == s && (expiredTwice || totalStake == 0)) { // 7.3 withdrawDepositEffect(poolIndex); } // Transition: Retain state in 6.1 if (S4_NotViolatedFunded == s && !expired && violated) { // 4.5 setState(poolIndex, S5_ViolatedFunded); } else if (S1_Initialized == s // 1.6 || S2_NotViolatedUnderfunded == s // 2.11 || S4_NotViolatedFunded == s && expiredTwice // 4.8 || S7_PolicyExpired == s && (expiredTwice || totalStake == 0)) { // 7.3 setState(poolIndex, S6_Cancelled); } else if (S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.10 setState(poolIndex, S7_PolicyExpired); } } /** Allows the staker to withdraw all their stakes from the pool. * @param poolIndex - the index of the pool from which the stake is withdrawn */ function withdrawStake(uint poolIndex) external { // Gather conditions bool violated = isViolated(poolIndex); bool timedout = isTimedOut(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); QuantstampStakingData.PoolState s = getPoolState(poolIndex); // Guard: Reject in 4.11, 5.2 require(S1_Initialized == s // 1.1, 1.5 || S2_NotViolatedUnderfunded == s // 2.4, 2.7, 2.13, 2.14a, 2.15 || S3_ViolatedUnderfunded == s // 3.1 || S4_NotViolatedFunded == s && !(!expired && !violated) // 4.5, 4.8, 4.10 (not 4.11) || S6_Cancelled == s // 6.1 || S7_PolicyExpired == s, // 7.2, 7.4 "Pool is not in the right state to withdraw stake."); /* solhint-disable no-empty-blocks */ // Effect: No effect in 4.5 if (S4_NotViolatedFunded == s && !expired && violated) { // 4.5 // no effect in 4.5 } else { withdrawStakeEffect(poolIndex); // 1.1, 1.5, 2.4, 2.7, 2.13, 2.14a, 2.15, 3.1, 4.8, 4.10, 6.1, 7.2, 7.4 } /* solhint-enable no-empty-blocks */ // Additional condition /* This is collected after executing the effect, so this is equivalent to SUM(stakes) - withdrawal */ bool enoughStake = data.getPoolTotalStakeQspWei(poolIndex) >= data.getPoolMinStakeQspWei(poolIndex); // Transition: Retains state in 1.1, 2.4, 3.1, 6.1, 7.2 if (S2_NotViolatedUnderfunded == s && !expired && violated && enoughStake) { // 2.7 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.5 setState(poolIndex, S5_ViolatedFunded); } else if (S2_NotViolatedUnderfunded == s && expired && !expiredTwice // 2.15 || S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.10 setState(poolIndex, S7_PolicyExpired); } else if (S1_Initialized == s && (timedout || violated) // 1.5 || S2_NotViolatedUnderfunded == s && expiredTwice // 2.14a || S2_NotViolatedUnderfunded == s && !expired && !enoughStake // 2.13 || S4_NotViolatedFunded == s && expiredTwice // 4.8 || S7_PolicyExpired == s && expiredTwice) { // 7.4 setState(poolIndex, S6_Cancelled); } } /* solhint-disable code-complexity */ /* solhint-disable function-max-lines */ /** In case the pool is not violated and the payPeriod duration has passed, it computes the payout of the staker * (defined by msg.sender), * and if the payout value is positive it transfers the corresponding amout from the pool to the staker. * @param poolIndex - the index of the pool from which the staker wants to receive a payout */ function withdrawInterest(uint poolIndex) external { QuantstampStakingData.PoolState s = getPoolState(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); uint deposit = data.getPoolDepositQspWei(poolIndex); uint maxPayout = data.getPoolMaxPayoutQspWei(poolIndex); bool violated = isViolated(poolIndex); uint earnedInterest = computePayout(poolIndex, msg.sender); // Guard: Reject in 1.8, 5.2, 6.2 require( S2_NotViolatedUnderfunded == s // 2.1, 2.6, 2.12, 2.14a, 2.16 || S3_ViolatedUnderfunded == s // 3.1 || S4_NotViolatedFunded == s // 4.2, 4.3, 4.5, 4.7, 4.8, 4.10 || S7_PolicyExpired == s, // 7.2, 7.4 "State does not allow to withdraw interest."); // Effect: Skip in 4.5, 7.4 if (S2_NotViolatedUnderfunded == s && ( !expired // 2.1, 2.6, 2.12 || expiredTwice // 2.14a || expired && !expiredTwice // 2.16 ) || S3_ViolatedUnderfunded == s // 3.1 || S4_NotViolatedFunded == s && ( !expired && !violated //4.2, 4.3, 4.7 || expiredTwice // 4.8 || expired && !expiredTwice // 4.10 ) || S7_PolicyExpired == s && !expiredTwice // 7.2 ) { withdrawInterestEffect(poolIndex, msg.sender, earnedInterest); } // Transitions: retain state in 2.1, 3.1, 4.2, 7.2 if (S2_NotViolatedUnderfunded == s && !expired && violated) { // 2.6 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S4_NotViolatedFunded == s && !expired && !violated && deposit >= earnedInterest // SafeMath is not needed here, because the condition "deposit >= earnedInterest" is evaluated first // and will be false if deposit < earnedInterest, so we do not have to worry about the underflow on // the next line: && (deposit - earnedInterest < maxPayout)) { // 4.3 setState(poolIndex, S2_NotViolatedUnderfunded); } else if ( S2_NotViolatedUnderfunded == s && ( (!expired && !violated && deposit < earnedInterest) // 2.12 || expiredTwice) //2.14a || S4_NotViolatedFunded == s && ( (!expired && !violated && deposit < earnedInterest) // 4.7 || expiredTwice // 4.8 ) || S7_PolicyExpired == s && expiredTwice // 7.4 ) { setState(poolIndex, S6_Cancelled); } else if ( S2_NotViolatedUnderfunded == s && expired && !expiredTwice //2.16 || S4_NotViolatedFunded == s && expired && !expiredTwice // 4.10 ) { setState(poolIndex, S7_PolicyExpired); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.5 setState(poolIndex, S5_ViolatedFunded); } } /* solhint-enable code-complexity */ /* solhint-enable function-max-lines */ /** Checks if the given address is a staker of the given pool index * @param poolIndex - the index of the pool where to check for stakers * @param staker - the address of the staker to check for * @return - true if the staker has a stake in the pool, false otherwise */ function isStaker(uint poolIndex, address staker) external view returns(bool) { return data.isStaker(poolIndex, staker); } /** Gives all the staked funds to the stakeholder provided that the policy was violated and the * state of the contract allows. * @param poolIndex - the index of the pool where the claim will be withdrawn */ function withdrawClaim(uint poolIndex) public onlyPoolOwner(poolIndex) { // Gather conditions bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); bool violated = isViolated(poolIndex); QuantstampStakingData.PoolState s = getPoolState(poolIndex); bool timedout = isTimedOut(poolIndex); // Guard: Reject in 1.9, 2.17, 3.2, 4.11, 6.2, 7.6 require(S1_Initialized == s && (timedout || violated) // 1.5 || S2_NotViolatedUnderfunded == s && ( !expired && violated // 2.8 || expired && !expiredTwice // 2.15 || expiredTwice // 2.14a ) || S4_NotViolatedFunded == s && ( !expired && violated // 4.4 || expired && !expiredTwice // 4.10 || expiredTwice // 4.8 ) || S5_ViolatedFunded == s // 5.1 || S7_PolicyExpired == s && expiredTwice, // 7.4 "The pool is in a state that does not allow withdrawing a claim"); // Effect: No effect in 1.5, 2.8, 2.14a, 2.15, 4.8, 4.10, 7.4 if (S4_NotViolatedFunded == s && !expired && violated // 4.4 || S5_ViolatedFunded == s) { // 5.1 withdrawClaimEffect(poolIndex); } // Transition: Retain state in 5.1 (plus when rejecting the transaction) if (S2_NotViolatedUnderfunded == s && !expired && violated) { // 2.8 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.4 setState(poolIndex, S5_ViolatedFunded); } else if (S1_Initialized == s && (timedout || violated) // 1.5 || S2_NotViolatedUnderfunded == s && expiredTwice // 2.14a || S4_NotViolatedFunded == s && expiredTwice // 4.8 || S7_PolicyExpired == s && expiredTwice) { // 7.4 setState(poolIndex, S6_Cancelled); } else if (S2_NotViolatedUnderfunded == s && expired && !expiredTwice // 2.15 || S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.10 setState(poolIndex, S7_PolicyExpired); } } /* solhint-disable code-complexity */ /** * * NOTE: Solhint code complexity disabled due to cyclomatic complexity being 8 (more than 7) * * Transfers an amount of QSP from the staker to the pool * @param poolIndex - the index of the pool where the funds are transferred to * @param amountQspWei - the amount of QSP Wei that is transferred */ function stakeFunds(uint poolIndex, uint amountQspWei) public { QuantstampStakingData.PoolState s = getPoolState(poolIndex); bool funded = data.getPoolDepositQspWei(poolIndex) >= data.getPoolMaxPayoutQspWei(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); bool violated = isViolated(poolIndex); bool timedout = S1_Initialized == s && data.getPoolTimeoutInBlocks(poolIndex).add(data.getPoolTimeOfStateInBlocks(poolIndex)) <= block.number; bool maxStakeReached = wasMaxStakeReached(poolIndex); // Guard: Reject in 2.20, 3.2, 4.13, 5.2, 6.2, 7.7 require(S1_Initialized == s // 1.2, 1.3, 1.4, 1.5 (never rejects) || S2_NotViolatedUnderfunded == s && !(!expired && !violated && maxStakeReached) // 2.3, 2.5, 2.14a, 2.15 (not in 2.20) || S4_NotViolatedFunded == s && !(!expired && !violated && maxStakeReached), // 4.1, 4.5, 4.8, 4.10 (not in 4.13) "State does not allow to stake funds"); // Effect: Skip in 1.5, 2.5, 2.14a, 2.15, 4.5, 4.8, 4.10 if (S1_Initialized == s && !(timedout || violated) // 1.2, 1.3, 1.4 (not in 1.5) || S2_NotViolatedUnderfunded == s && !expired && !violated && !maxStakeReached // 2.3 || S4_NotViolatedFunded == s && !expired && !violated && !maxStakeReached) { // 4.1 stakeFundsEffect(poolIndex, amountQspWei); } // Additional condition bool minStakeReached = data.getPoolMinStakeQspWei(poolIndex) <= data.getPoolTotalStakeQspWei(poolIndex); // Transition: Retain state in 1.2, 2.3, 4.1 if (S1_Initialized == s && !timedout && !violated && minStakeReached && !funded) { // 1.3 setState(poolIndex, S2_NotViolatedUnderfunded); } else if (S2_NotViolatedUnderfunded == s && !expired && violated) { // 2.5 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S1_Initialized == s && !timedout && !violated && minStakeReached && funded) { // 1.4 setState(poolIndex, S4_NotViolatedFunded); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.5 setState(poolIndex, S5_ViolatedFunded); } else if (S1_Initialized == s && (timedout || violated) // 1.5 || S2_NotViolatedUnderfunded == s && expiredTwice // 2.14a || S4_NotViolatedFunded == s && expiredTwice) { // 4.8 setState(poolIndex, S6_Cancelled); } else if (S2_NotViolatedUnderfunded == s && expired && !expiredTwice // 2.15 || S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.10 setState(poolIndex, S7_PolicyExpired); } } /* solhint-enable code-complexity */ /** Computes the un-normalized payout amount for experts (including bonuses) and non-experts * @param poolIndex - the index of the pool for which the payout needs to be computed * @param staker - the address of the staker for which the payout needs to be computed * @param stakeIndex - the index of the stake placed by the staker * @return the un-normalized payout value which is proportional to the stake amount */ function calculateStakeAmountWithBonuses( uint poolIndex, address staker, uint stakeIndex) public view returns(uint) { uint stakeAmount; bool expertStake; uint contributionIndex; (stakeAmount, , , contributionIndex, expertStake) = data.getStake( poolIndex, staker, stakeIndex); if (stakeAmount == 0) { return 0; } // check if the staker is an expert if (expertStake) { stakeAmount = stakeAmount.mul(data.getBonusExpertAtPower(poolIndex, contributionIndex). add(data.getPowersOf100(poolIndex, contributionIndex))). div(data.getPowersOf100(poolIndex, contributionIndex)); /* Check if it is the first stake of the first expert */ if (data.getPoolFirstExpertStaker(poolIndex) == staker && stakeIndex == 0) { stakeAmount = stakeAmount.mul(data.getPoolBonusFirstExpertFactor(poolIndex).add(100)).div(100); } } return stakeAmount; } /** Computes the total amount due to for the staker payout when the contract is not violated. * maxPayout * (amountStaked [* (1+bonusExpert^i)][* (1+bonusFirstExp)] )/poolSize * where [* (1+bonusExpert)^i] is applied if the staker is the ith expert to stake, * and [* (1+bonusFirstExp)] applies additionally in the case of the first expert; * maxPayout is specified by the stakeholder who created the pool; * poolSize is the size of all stakes in this pool together with the bonuses awarded for experts; * amountStaked is the amount contributed by a staker. * @param poolIndex - the pool from which the payout is awarded * @param staker - the staker to which the payout should be awarded * @return - the amount of QSP Wei that should be awarded */ function computePayout(uint poolIndex, address staker) public view returns(uint) { uint numerator = 0; // indicates the unnormalized total payout for the staker uint minStakeStartBlock = data.getPoolMinStakeStartBlock(poolIndex); QuantstampStakingData.PoolState s = data.getPoolState(poolIndex); if (minStakeStartBlock == 0 || (S2_NotViolatedUnderfunded != s && S4_NotViolatedFunded != s && S7_PolicyExpired != s) || (data.getTotalStakes(poolIndex, staker) == 0)) { // all stakes have been withdrawn return 0; } // compute the numerator by adding the staker's stakes together for (uint i = 0; i < data.getStakeCount(poolIndex, staker); i++) { uint stakeAmount = calculateStakeAmountWithBonuses(poolIndex, staker, i); // multiply the stakeAmount by the number of payPeriods for which the stake has been active and not payed stakeAmount = stakeAmount.mul(getNumberOfPayoutsForStaker(poolIndex, i, staker)); numerator = numerator.add(stakeAmount); } return numerator.mul(data.getPoolMaxPayoutQspWei(poolIndex)).div(data.getPoolSizeQspWei(poolIndex)); } /** Replaces the TCR with a new one. This function can be called only by the owner and * we assume that there the owner field will be set to 0x0 in the future. * @param _registry - the address of the TCR to used instead of the current one */ function setStakingRegistry(address _registry) public onlyOwner { stakingRegistry = IRegistry(_registry); emit RegistryUpdated(_registry); } /** Checks if the addr is an expert. * @param addr The address of the person who may be an expert. * @return true If addr is an expert according to the registry */ function isExpert(address addr) public view returns(bool) { return stakingRegistry.isExpert(addr); } /** Sets the minimum deposit required for opening a pool * @param newGlobalMinDepositQspWei - the new deposit minimum value */ function setGlobalMinDepositQspWei(uint newGlobalMinDepositQspWei) public onlyOwner { globalMinDepositQspWei = newGlobalMinDepositQspWei; } /** Checks the policy of the pool. If it is violated, it updates the state accordingly. * Fails the transaction otherwise. * @param poolIndex - the index of the pool for which the state is changed */ function checkPolicy(uint poolIndex) public { // Gather conditions bool violated = isViolated(poolIndex); bool expired = isExpired(poolIndex); bool expiredTwice = isExpiredTwice(poolIndex); QuantstampStakingData.PoolState s = data.getPoolState(poolIndex); // Guard: Reject in 1.10, 2.17, 2.19, 3.2, 4.12, 4.11, 5.2, 6.2, 7.7 require(S1_Initialized == s && violated // 1.7 || S2_NotViolatedUnderfunded == s && ( !expired && violated // 2.9 || expiredTwice && violated // 2.14b || expired && !expiredTwice) // 2.15 || S4_NotViolatedFunded == s && ( !expired && violated // 4.4 || expiredTwice && violated // 4.8a || expired && !expiredTwice // 4.10 ), "The state of the pool does not allow to check and update policy."); // In this case, the effect is the transition if (S1_Initialized == s && violated // 1.7 || S2_NotViolatedUnderfunded == s && expiredTwice && violated // 2.14b || S4_NotViolatedFunded == s && expiredTwice && violated) { // 4.8a setState(poolIndex, S6_Cancelled); } else if (S2_NotViolatedUnderfunded == s && !expired && violated) { // 2.9 setState(poolIndex, S3_ViolatedUnderfunded); } else if (S4_NotViolatedFunded == s && !expired && violated) { // 4.4 setState(poolIndex, S5_ViolatedFunded); } else if (S2_NotViolatedUnderfunded == s && expired && !expiredTwice // 2.15 || S4_NotViolatedFunded == s && expired && !expiredTwice) { // 4.10 setState(poolIndex, S7_PolicyExpired); } } /** Creates a new staking pool. * @param candidateContract - the contract that must be protected * @param contractPolicy - the policy that must be respected by the candidate contract * @param maxPayoutQspWei - the maximum payout that will be awarded to all stakers per payout period * @param minStakeQspWei - the minimum value that needs to be raised from all stakers together * @param depositQspWei - the current value deposited by the owner/stakeholder * @param bonusExpertFactor - the factor by which the payout of an expert is multiplied * @param bonusFirstExpertFactor - the factor by which the payout of the first expert is multiplied * @param payPeriodInBlocks - the number of blocks after which stakers are payed incentives, in case of no breach * @param minStakeTimeInBlocks - the minimum number of blocks that funds need to be staked for * @param timeoutInBlocks - the number of blocks after which a pool is canceled if there are not enough stakes * @param urlOfAuditReport - a URL to some audit report (could also be a white-glove audit) * @param poolName - an alphanumeric string defined by the pool owner * @param maxTotalStakeQspWei - the maximum QSP that can be staked; 0 if there is no maximum */ function createPool( address candidateContract, address contractPolicy, uint maxPayoutQspWei, uint minStakeQspWei, uint depositQspWei, uint bonusExpertFactor, uint bonusFirstExpertFactor, uint payPeriodInBlocks, uint minStakeTimeInBlocks, uint timeoutInBlocks, string urlOfAuditReport, string poolName, uint maxTotalStakeQspWei ) public { require(getPoolIndex(poolName) == MAX_UINT, "Cannot create a pool with the same name as an existing pool."); require(depositQspWei > 0 && depositQspWei >= globalMinDepositQspWei, "Deposit does not meet the requirements."); // transfer tokens to this contract safeTransferToDataContract(msg.sender, depositQspWei); require(maxPayoutQspWei > 0, "Maximum payout cannot be zero."); require(minStakeQspWei > 0, "Minimum stake cannot be zero."); require(payPeriodInBlocks > 0, "Pay period cannot be zero."); require(minStakeTimeInBlocks > 0, "Minimum staking period cannot be zero."); require(timeoutInBlocks > 0, "Timeout period cannot be zero."); require(maxTotalStakeQspWei == 0 || maxTotalStakeQspWei > minStakeQspWei, "Max total stake cannot be less than min total stake."); uint[] memory intParams = new uint[](9); intParams[0] = maxPayoutQspWei; intParams[1] = minStakeQspWei; intParams[2] = depositQspWei; intParams[3] = bonusExpertFactor; intParams[4] = bonusFirstExpertFactor; intParams[5] = payPeriodInBlocks; intParams[6] = minStakeTimeInBlocks; intParams[7] = timeoutInBlocks; intParams[8] = maxTotalStakeQspWei; address[] memory addresses = new address[](3); addresses[0] = candidateContract; addresses[1] = contractPolicy; addresses[2] = msg.sender; uint poolIndex = data.createPool( addresses, intParams, urlOfAuditReport, poolName ); isViolated(poolIndex); // call to confirm it does not throw emit StateChanged(poolIndex, QuantstampStakingData.PoolState.Initialized); } /** Finds the pool index if a pool with the given name exists * @param poolName - an alphanumeric string indicating a pool name * @return - the index of the pool if a pool with that name exists, otherwise the max value of uint */ function getPoolIndex(string poolName) public view returns(uint) { return data.getPoolIndex(poolName); } function getToken() public view returns (address) { return address(token); } function getStakingRegistry() public view returns (address) { return address(stakingRegistry); } function getPoolState(uint poolIndex) public view returns ( QuantstampStakingData.PoolState ) { return data.getPoolState(poolIndex); } function getBalanceQspWei() public view returns (uint) { return data.getBalanceQspWei(); } function getPoolContractPolicy(uint poolIndex) public view returns (address) { return data.getPoolContractPolicy(poolIndex); } function getPoolCandidateContract(uint poolIndex) public view returns (address) { return data.getPoolCandidateContract(poolIndex); } /** Returns true if and only if the contract policy for the pool poolIndex is violated * @param poolIndex - index of the pool where the policy is checked */ function isViolated(uint poolIndex) internal view returns (bool) { address poolPolicy = data.getPoolContractPolicy(poolIndex); address candidateContract = data.getPoolCandidateContract(poolIndex); return IPolicy(poolPolicy).isViolated(candidateContract); } /** Returns true if the pool timed out in state 1. The time out concept is undefined * for all other states. * @param poolIndex - the index of the pool to check */ function isTimedOut(uint poolIndex) internal view returns (bool) { QuantstampStakingData.PoolState s = getPoolState(poolIndex); if (S1_Initialized != s) { return false; } else { uint startBlock = data.getPoolTimeOfStateInBlocks(poolIndex); uint expirationBlock = data.getPoolTimeoutInBlocks(poolIndex).add(startBlock); return block.number >= expirationBlock; } } /** Returns true if the pool expired. Expiration occurs if minStakingTime elapses since the * block when pool enters state 4 (NotViolatedFunded). * @param poolIndex - the index of the pool to check */ function isExpired(uint poolIndex) internal view returns (bool) { uint activationBlock = data.getPoolMinStakeStartBlock(poolIndex); uint expirationBlock = activationBlock.add(data.getPoolMinStakeTimeInBlocks(poolIndex)); return activationBlock > 0 && block.number >= expirationBlock; } /** Returns true if the pool expired twice. Double expiration occurs if minStakingTime elapses since the * block when pool enters state 4 (NotViolatedFunded). * @param poolIndex - the index of the pool to check */ function isExpiredTwice(uint poolIndex) internal view returns (bool) { uint activationBlock = data.getPoolMinStakeStartBlock(poolIndex); uint doubleExpirationBlock = activationBlock.add(data.getPoolMinStakeTimeInBlocks(poolIndex).mul(2)); return activationBlock > 0 && block.number >= doubleExpirationBlock; } /** This function returns the number of payouts that a staker must receive for his/her stake in a pool. * @param poolIndex - the index of the pool where the stake was placed * @param i - the index of the stake in the stakes array * @param staker - the address of the staker which has placed the stake * @return - the number of payout periods that the staker needs to receive payouts for */ function getNumberOfPayoutsForStaker( uint poolIndex, uint i, address staker ) internal view returns(uint) { uint minStakeStartBlock = data.getPoolMinStakeStartBlock(poolIndex); uint blockPlaced = data.getStakeBlockPlaced(poolIndex, staker, i); // the block number where the stake begins to be active (waiting for payouts) uint startBlockNumber = Math.max(blockPlaced, minStakeStartBlock); // make sure we are not passed the policy expiration time in the current block // compute the total number of pay periods for this pool and this staker uint currentPayBlock = Math.min(block.number, data.getPoolMinStakeTimeInBlocks(poolIndex).add( minStakeStartBlock)); // compute the last block this staker asked for a payout uint lastPayoutBlock = Math.max(data.getStakeLastPayoutBlock(poolIndex, staker, i), startBlockNumber); // get the number of periods for this staker return currentPayBlock.sub(lastPayoutBlock).div(data.getPoolPayPeriodInBlocks(poolIndex)); } /** Sets the state of the pool to a given state, while also marking the block at * which this occured and emitting an event corresponding to the new state. * @param poolIndex - the index of the pool for which the state is changed * @param newState - the new state to which the pool will change */ function setState(uint poolIndex, QuantstampStakingData.PoolState newState) internal { QuantstampStakingData.PoolState poolState = data.getPoolState(poolIndex); if (poolState != newState) { data.setState(poolIndex, newState); // set the state data.setPoolTimeOfStateInBlocks(poolIndex, block.number); // set the time when the state changed if (newState == S4_NotViolatedFunded && data.getPoolMinStakeStartBlock(poolIndex) == 0) { data.setPoolMinStakeStartBlock(poolIndex, block.number); } emit StateChanged(poolIndex, newState); // emit an event that the state has changed } } /** Checks if the maximum pool stake was reached * @param poolIndex - the index of the pool to check */ function wasMaxStakeReached(uint poolIndex) internal view returns(bool) { uint max = data.getPoolMaxTotalStakeQspWei(poolIndex); uint current = data.getPoolTotalStakeQspWei(poolIndex); return max != 0 && current >= max; } /** Returns the maximum state that can be placed in a pool * @param poolIndex - the index of the pool for which the stake is submitted * @param amountQspWei - the stake size * @return the current state of the pool */ function adjustStakeAmount(uint poolIndex, uint amountQspWei) internal view returns(uint) { uint max = data.getPoolMaxTotalStakeQspWei(poolIndex); uint current = data.getPoolTotalStakeQspWei(poolIndex); if (max == 0 || current.add(amountQspWei) <= max) { return amountQspWei; } return max.sub(current); } /** * @dev Used to transfer the earned interest from the pool * @param poolIndex The index of the pool from which the interest will be withdrawn. * @param staker The user attempting to withdraw interest * @param requestedPayout The computed interest requested to be paid out */ function withdrawInterestEffect(uint poolIndex, address staker, uint requestedPayout) internal { if (requestedPayout == 0) { return; // no need to transfer anything } uint deposit = data.getPoolDepositQspWei(poolIndex); uint payout = requestedPayout; if (payout > deposit) { payout = deposit; // withdraw the remaining deposit } if (payout >= 0) { // transfer the funds data.setPoolDepositQspWei(poolIndex, deposit.sub(payout)); data.setBalanceQspWei(data.getBalanceQspWei().sub(payout)); for (uint i = 0; i < data.getStakeCount(poolIndex, staker); i++) { uint max = Math.max( data.getStakeBlockPlaced(poolIndex, staker, i), data.getPoolMinStakeStartBlock(poolIndex) ); data.setStakeBlockPlaced(poolIndex, staker, i, max); uint numberOfPayouts = getNumberOfPayoutsForStaker(poolIndex, i, staker); if (numberOfPayouts > 0) { data.increaseStakeLastPayoutBlock(poolIndex, staker, i, numberOfPayouts); } } safeTransferFromDataContract(staker, payout); } emit StakerReceivedPayout(poolIndex, staker, payout); } /** * @dev Used to transfer funds stored in the data contract to a given address. * @param _to The address to transfer funds. * @param amountQspWei The amount of wei-QSP to be transferred. */ function safeTransferFromDataContract(address _to, uint256 amountQspWei) internal { data.approveWhitelisted(amountQspWei); require(token.transferFrom(address(data), _to, amountQspWei), "Token transfer from data contract did not succeed"); } /** * @dev Used to transfer funds from a given address to the data contract. * @param _from The address to transfer funds from. * @param amountQspWei The amount of wei-QSP to be transferred. */ function safeTransferToDataContract(address _from, uint256 amountQspWei) internal { require(token.transferFrom(_from, address(data), amountQspWei), "Token transfer to data contract did not succeed"); } /** * @dev Used to transfer the claim from the pool to the stakeholder after the checks in withdrawClaim * @param poolIndex The index of the pool from which claim should be withdrawn */ function withdrawClaimEffect(uint poolIndex) internal { uint total = data.getPoolDepositQspWei(poolIndex).add(data.getPoolTotalStakeQspWei(poolIndex)); if (total > 0) { // then claim all stakes data.setBalanceQspWei(data.getBalanceQspWei().sub(total)); data.setPoolDepositQspWei(poolIndex, 0); data.setPoolTotalStakeQspWei(poolIndex, 0); data.setPoolSizeQspWei(poolIndex, 0); safeTransferFromDataContract(data.getPoolOwner(poolIndex), total); } emit ClaimWithdrawn(poolIndex, msg.sender, total); } /** * @dev Used to transfer the deposit funds from the pool to the caller after the checks in withdrawDeposit * @param poolIndex The index of the pool from which deposit should be withdrawn */ function withdrawDepositEffect(uint poolIndex) internal { uint withdrawalAmountQspWei = data.getPoolDepositQspWei(poolIndex); if (withdrawalAmountQspWei > 0) { data.setPoolDepositQspWei(poolIndex, 0); data.setBalanceQspWei(data.getBalanceQspWei().sub(withdrawalAmountQspWei)); } address poolOwner = data.getPoolOwner(poolIndex); safeTransferFromDataContract(poolOwner, withdrawalAmountQspWei); emit DepositWithdrawn(poolIndex, poolOwner, withdrawalAmountQspWei); } /** * @dev Used to transfer the stake from the caller to the pool after the checks in stakeFunds. * @param poolIndex The index of the pool in which the stake will be transferred. * @param amountQspWei The amount of funds transferred. */ function stakeFundsEffect(uint poolIndex, uint amountQspWei) internal { // Adjust the stake amount according to the maximum total stake given by the pool owner uint adjustedAmountQspWei = adjustStakeAmount(poolIndex, amountQspWei); if (adjustedAmountQspWei > 0) { safeTransferToDataContract(msg.sender, adjustedAmountQspWei); uint stakeIndex = data.createStake(poolIndex, msg.sender, adjustedAmountQspWei, block.number, block.number, isExpert(msg.sender)); data.setPoolSizeQspWei(poolIndex, data.getPoolSizeQspWei(poolIndex).add( calculateStakeAmountWithBonuses(poolIndex, msg.sender, stakeIndex))); } emit StakePlaced(poolIndex, msg.sender, adjustedAmountQspWei); } /** * @dev Used to deposit the funds from the caller to the pool after the checks in depositFunds * @param poolIndex The index of the pool in which the funds should be deposited */ function depositFundsEffect(uint poolIndex, uint depositQspWei) internal { address poolOwner = data.getPoolOwner(poolIndex); safeTransferToDataContract(poolOwner, depositQspWei); data.setPoolDepositQspWei(poolIndex, data.getPoolDepositQspWei(poolIndex).add(depositQspWei)); data.setBalanceQspWei(data.getBalanceQspWei().add(depositQspWei)); emit DepositMade(poolIndex, poolOwner, depositQspWei); } /** Allows the staker to withdraw all their stakes from the pool. * @param poolIndex - the index of the pool from which the stake is withdrawn */ function withdrawStakeEffect(uint poolIndex) internal { uint totalQspWeiTransfer = data.getTotalStakes(poolIndex, msg.sender); if (totalQspWeiTransfer > 0) { // transfer the stake back uint stakeCount = data.getStakeCount(poolIndex, msg.sender); uint totalSizeChangeQspWei = 0; for (uint i = 0; i < stakeCount; i++) { totalSizeChangeQspWei = totalSizeChangeQspWei.add( calculateStakeAmountWithBonuses(poolIndex, msg.sender, i)); } data.removeStake(poolIndex, msg.sender); data.setPoolSizeQspWei(poolIndex, data.getPoolSizeQspWei(poolIndex).sub(totalSizeChangeQspWei)); // actual transfer safeTransferFromDataContract(msg.sender, totalQspWeiTransfer); } emit StakeWithdrawn(poolIndex, msg.sender, totalQspWeiTransfer); } }
* Allows execution only when the policy of the pool is not violated. @param poolIndex - index of the pool where the policy is checked/
modifier whenNotViolated(uint poolIndex) { address poolPolicy = data.getPoolContractPolicy(poolIndex); address candidateContract = data.getPoolCandidateContract(poolIndex); require(!IPolicy(poolPolicy).isViolated(candidateContract) && data.getPoolState(poolIndex) != QuantstampStakingData.PoolState.ViolatedFunded && data.getPoolState(poolIndex) != QuantstampStakingData.PoolState.ViolatedUnderfunded, "Contract policy is violated."); _; }
12,945,838
[ 1, 4625, 348, 7953, 560, 30, 380, 25619, 4588, 1338, 1347, 326, 3329, 434, 326, 2845, 353, 486, 26889, 18, 632, 891, 2845, 1016, 300, 770, 434, 326, 2845, 1625, 326, 3329, 353, 5950, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 9606, 1347, 1248, 28658, 690, 12, 11890, 2845, 1016, 13, 288, 203, 3639, 1758, 2845, 2582, 273, 501, 18, 588, 2864, 8924, 2582, 12, 6011, 1016, 1769, 203, 3639, 1758, 5500, 8924, 273, 501, 18, 588, 2864, 11910, 8924, 12, 6011, 1016, 1769, 203, 540, 203, 3639, 2583, 12, 5, 2579, 1590, 12, 6011, 2582, 2934, 291, 28658, 690, 12, 19188, 8924, 13, 597, 203, 5411, 501, 18, 588, 2864, 1119, 12, 6011, 1016, 13, 480, 4783, 970, 14317, 510, 6159, 751, 18, 2864, 1119, 18, 28658, 690, 42, 12254, 597, 203, 5411, 501, 18, 588, 2864, 1119, 12, 6011, 1016, 13, 480, 4783, 970, 14317, 510, 6159, 751, 18, 2864, 1119, 18, 28658, 690, 14655, 12125, 785, 16, 203, 5411, 315, 8924, 3329, 353, 26889, 1199, 1769, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.24; import {FranklinCommon} from "./common/FranklinCommon.sol"; import {TwistedEdwards} from "./common/TwistedEdwards.sol"; // interface ExitorInterface { // function exit() external payable; // function cancelExit() external; // function startNextExitBatch() external; // function changeExitBatchFee(uint128 newBatchFee) external; // function commitExitBlock( // uint256 batchNumber, // uint24[EXIT_BATCH_SIZE] accoundIDs, // uint32 blockNumber, // bytes txDataPacked, // bytes32 newRoot // ) external; // function verifyExitBlock( // uint256 batchNumber, // uint32 blockNumber, // uint256[8] proof // ) external; // function withdrawUserBalance( // uint256 iterationsLimit // ) external; // } // this procedure is a one-time full exit with a removal // of the public key from the tree contract Exitor is FranklinCommon { function exit() public payable { uint128 userFee = scaleIntoPlasmaUnitsFromWei(msg.value); require(userFee >= currentExitBatchFee, "exit fee should be more than required by the operator"); uint24 accountID = ethereumAddressToAccountID[msg.sender]; require(accountID != 0, "empty accounts can not exit"); uint256 currentBatch = totalExitRequests/EXIT_BATCH_SIZE; // write aux info about the batch ExitBatch storage batch = exitBatches[currentBatch]; // batch countdown start from the first request if (batch.timestamp == 0) { batch.state = uint8(ExitBatchState.CREATED); batch.timestamp = uint64(block.timestamp); batch.batchFee = currentExitBatchFee; } Account storage account = accounts[accountID]; require(account.state == uint8(AccountState.REGISTERED), "only accounts that are registered and not pending exit can exit"); account.state = uint8(AccountState.PENDING_EXIT); account.exitBatchNumber = uint32(currentBatch); totalExitRequests++; emit LogExitRequest(currentBatch, accountID); } // allow users to cancel an exit if the work on the next proof is not yet started function cancelExit() public { uint24 accountID = ethereumAddressToAccountID[msg.sender]; require(accountID != 0, "trying to cancel a deposit for non-existing account"); uint256 currentBatch = totalExitRequests/EXIT_BATCH_SIZE; uint256 requestsInThisBatch = totalExitRequests % EXIT_BATCH_SIZE; // if the first request in a batch is canceled - clear it to stop the countdown if (requestsInThisBatch == 0) { delete exitBatches[currentBatch]; } Account storage account = accounts[accountID]; require(account.state == uint8(AccountState.PENDING_EXIT), "can only cancel exits for accounts that are pending exit"); require(account.exitBatchNumber == uint32(currentBatch), "can not cancel an exit in the batch that was already accepted"); account.state = uint8(AccountState.REGISTERED); account.exitBatchNumber = 0; emit LogCancelExitRequest(currentBatch, accountID); totalExitRequests--; // TODO may be return an fee that was collected } // this does not work in multi-operator mode function startNextExitBatch() public operator_only() { uint256 currentBatch = totalExitRequests/EXIT_BATCH_SIZE; uint256 inTheCurrentBatch = totalExitRequests % EXIT_BATCH_SIZE; if (inTheCurrentBatch != 0) { totalExitRequests = (currentBatch + 1) * EXIT_BATCH_SIZE; } else { revert("it's not necessary to bump the batch number"); } } // this does not work in multi-operator mode function changeExitBatchFee(uint128 newBatchFee) public operator_only() { if (currentExitBatchFee == 0) { revert("fee is already at minimum"); } if (newBatchFee < currentExitBatchFee) { currentExitBatchFee = newBatchFee; } else { revert("can not increase an exit fee"); } } // pure function to calculate commitment formats function createPublicDataCommitmentForExit(uint32 blockNumber, bytes memory txDataPacked) public pure returns (bytes32 h) { bytes32 initialHash = sha256(abi.encodePacked(uint256(blockNumber))); bytes32 finalHash = sha256(abi.encodePacked(initialHash, txDataPacked)); return finalHash; } // on commitment to some block we just commit to SOME public data, that will be parsed // ONLY when proof is presented function commitExitBlock( uint256 batchNumber, uint24[EXIT_BATCH_SIZE] memory accoundIDs, uint32 blockNumber, bytes memory txDataPacked, bytes32 newRoot ) public operator_only { require(blockNumber == lastCommittedBlockNumber + 1, "may only commit next block"); require(batchNumber == lastCommittedExitBatch, "trying to commit batch out of order"); ExitBatch storage batch = exitBatches[batchNumber]; batch.state = uint8(ExitBatchState.COMMITTED); batch.blockNumber = blockNumber; batch.timestamp = uint64(block.timestamp); bytes32 publicDataCommitment = createPublicDataCommitmentForExit(blockNumber, txDataPacked); blocks[blockNumber] = Block( uint8(Circuit.EXIT), uint64(block.timestamp + MAX_DELAY), 0, newRoot, publicDataCommitment, msg.sender ); emit BlockCommitted(blockNumber); lastCommittedBlockNumber++; lastCommittedExitBatch++; // process the block information processExitBlockData(batchNumber, blockNumber, accoundIDs, txDataPacked); } // exit block is special - to avoid storge writes an exit data is sent on verification, // but not on commitment function verifyExitBlock( uint256 batchNumber, uint32 blockNumber, uint256[8] memory proof ) public operator_only { require(lastVerifiedBlockNumber < lastCommittedBlockNumber, "no committed block to verify"); require(blockNumber == lastVerifiedBlockNumber + 1, "may only verify next block"); require(batchNumber == lastVerifiedExitBatch, "trying to prove batch out of order"); Block storage committed = blocks[blockNumber]; require(committed.circuit == uint8(Circuit.EXIT), "trying to prove the invalid circuit for this block number"); ExitBatch storage batch = exitBatches[batchNumber]; require(batch.blockNumber == blockNumber, "block number in referencing invalid batch number"); batch.state = uint8(ExitBatchState.VERIFIED); batch.timestamp = uint64(block.timestamp); // do actual verification bool verification_success = verifyProof( Circuit.EXIT, proof, lastVerifiedRoot, committed.newRoot, committed.publicDataCommitment ); require(verification_success, "invalid proof"); emit BlockVerified(blockNumber); lastVerifiedBlockNumber++; lastVerifiedExitBatch++; lastVerifiedRoot = committed.newRoot; } // transaction data is trivial: 3 bytes of in-plasma address, 16 bytes of amount // same a for partial exits - write to storage, so users can pull the balances later function processExitBlockData( uint256 batchNumber, uint32 blockNumber, uint24[EXIT_BATCH_SIZE] memory accountIDs, bytes memory txData ) internal { uint256 chunk; uint256 pointer = 32; address accountOwner; uint128 scaledAmount; uint32 tail; for (uint256 i = 0; i < EXIT_BATCH_SIZE; i++) { // this is a cheap way to ensure that all requests are unique, without O(n) MSTORE // it also automatically guarantees that all requests requests from the batch have been executed if (accountIDs[i] == 0) { continue; } require(i == 0 || accountIDs[i] > accountIDs[i-1], "accountIDs are not properly ordered"); assembly { chunk := mload(add(txData, pointer)) } pointer += 19; require(accountIDs[i] == chunk >> 232, "invalid account ID in commitment"); Account storage account = accounts[accountIDs[i]]; require(account.state == uint8(AccountState.PENDING_EXIT), "there was no such exit request"); require(account.exitBatchNumber == uint32(batchNumber), "account was registered for exit in another batch"); // accountOwner = accounts[accountIDs[i]].owner; scaledAmount = uint128(chunk << 24 >> 128); ExitLeaf memory newLeaf; tail = account.exitListTail; if (tail == 0) { // create a fresh list that is both head and tail newLeaf = ExitLeaf(0, scaledAmount); exitLeafs[account.owner][blockNumber] = newLeaf; account.exitListTail = blockNumber; } else { // previous tail is somewhere in the past ExitLeaf storage previousExitLeaf = exitLeafs[account.owner][tail]; newLeaf = ExitLeaf(0, scaledAmount); previousExitLeaf.nextID = blockNumber; exitLeafs[account.owner][blockNumber] = newLeaf; account.exitListTail = blockNumber; } // if there was no head - point to here if (account.exitListHead == 0) { account.exitListHead = blockNumber; } // exitAmounts[accountOwner][blockNumber] = scaledAmount; account.state = uint8(AccountState.UNCONFIRMED_EXIT); emit LogCompleteExit(accountOwner, blockNumber, accountIDs[i]); } } // function withdrawUserBalance( // uint32[] blockNumbers // ) // public // { // require(blockNumbers.length > 0, "requires non-empty set"); // uint256 totalAmountInWei; // uint32 blockNumber; // for (uint256 i = 0; i < blockNumbers.length; i++) { // blockNumber = blockNumbers[i]; // require(blockNumber <= lastVerifiedBlockNumber, "can only process exits from verified blocks"); // uint24 accountID = ethereumAddressToAccountID[msg.sender]; // uint128 balance; // uint256 amountInWei; // if (accountID != 0) { // // user either didn't fully exit or didn't take full exit balance yet // Account storage account = accounts[accountID]; // if (account.state == uint8(AccountState.UNCONFIRMED_EXIT)) { // uint256 batchNumber = account.exitBatchNumber; // ExitBatch storage batch = exitBatches[batchNumber]; // if (blockNumber == batch.blockNumber) { // balance = exitAmounts[msg.sender][blockNumber]; // delete accounts[accountID]; // delete ethereumAddressToAccountID[msg.sender]; // delete exitAmounts[msg.sender][blockNumber]; // amountInWei = scaleFromPlasmaUnitsIntoWei(balance); // totalAmountInWei += amountInWei; // continue; // } // } // } // // user account information is already deleted or it's not the block number where a full exit has happened // // we require a non-zero balance in this case cause chain cleanup is not required // balance = exitAmounts[msg.sender][blockNumber]; // require(balance != 0, "nothing to exit"); // delete exitAmounts[msg.sender][blockNumber]; // amountInWei = scaleFromPlasmaUnitsIntoWei(balance); // totalAmountInWei += amountInWei; // } // msg.sender.transfer(totalAmountInWei); // } function withdrawUserBalance( uint256 iterationsLimit ) public { require(iterationsLimit > 0, "must iterate"); uint256 totalAmountInWei; uint256 amountInWei; uint24 accountID = ethereumAddressToAccountID[msg.sender]; require(accountID != 0, "this should not happen as exiting happens one by one until the complete one"); Account storage account = accounts[accountID]; uint32 currentHead = account.exitListHead; uint32 nextHead = currentHead; for (uint256 i = 0; i < iterationsLimit; i++) { if (currentHead > lastVerifiedBlockNumber) { if (i == 0) { revert("nothing to process"); } else { return; } } ExitLeaf storage leaf = exitLeafs[msg.sender][currentHead]; amountInWei = scaleFromPlasmaUnitsIntoWei(leaf.amount); totalAmountInWei += amountInWei; // no matter if the next leafID is empty or not we can assign it nextHead = leaf.nextID; delete exitLeafs[msg.sender][currentHead]; if (nextHead == 0 && account.state == uint8(AccountState.UNCONFIRMED_EXIT)) { // there is no next element AND account is exiting, so it must be the complete exit leaf uint256 batchNumber = account.exitBatchNumber; ExitBatch storage batch = exitBatches[batchNumber]; require(currentHead == batch.blockNumber, "last item in the list should match the complete exit block"); delete accounts[accountID]; delete ethereumAddressToAccountID[msg.sender]; } if (nextHead == 0) { // this is an end of the list break; } else { currentHead = nextHead; } } account.exitListHead = nextHead; if (nextHead == 0) { account.exitListTail = 0; } msg.sender.transfer(totalAmountInWei); } }
write aux info about the batch batch countdown start from the first request
{ uint128 userFee = scaleIntoPlasmaUnitsFromWei(msg.value); require(userFee >= currentExitBatchFee, "exit fee should be more than required by the operator"); uint24 accountID = ethereumAddressToAccountID[msg.sender]; require(accountID != 0, "empty accounts can not exit"); uint256 currentBatch = totalExitRequests/EXIT_BATCH_SIZE; ExitBatch storage batch = exitBatches[currentBatch]; if (batch.timestamp == 0) { batch.state = uint8(ExitBatchState.CREATED); batch.timestamp = uint64(block.timestamp); batch.batchFee = currentExitBatchFee; } Account storage account = accounts[accountID]; require(account.state == uint8(AccountState.REGISTERED), "only accounts that are registered and not pending exit can exit"); account.state = uint8(AccountState.PENDING_EXIT); account.exitBatchNumber = uint32(currentBatch); totalExitRequests++; emit LogExitRequest(currentBatch, accountID); }
942,060
[ 1, 4625, 348, 7953, 560, 30, 225, 1045, 9397, 1123, 2973, 326, 2581, 2581, 1056, 2378, 787, 628, 326, 1122, 590, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 288, 203, 3639, 2254, 10392, 729, 14667, 273, 3159, 5952, 1749, 345, 2540, 7537, 1265, 3218, 77, 12, 3576, 18, 1132, 1769, 203, 3639, 2583, 12, 1355, 14667, 1545, 783, 6767, 4497, 14667, 16, 315, 8593, 14036, 1410, 506, 1898, 2353, 1931, 635, 326, 3726, 8863, 203, 3639, 2254, 3247, 26643, 273, 13750, 822, 379, 1887, 774, 3032, 734, 63, 3576, 18, 15330, 15533, 203, 3639, 2583, 12, 4631, 734, 480, 374, 16, 315, 5531, 9484, 848, 486, 2427, 8863, 203, 203, 3639, 2254, 5034, 783, 4497, 273, 2078, 6767, 6421, 19, 28682, 67, 25147, 67, 4574, 31, 203, 3639, 9500, 4497, 2502, 2581, 273, 2427, 31584, 63, 2972, 4497, 15533, 203, 3639, 309, 261, 5303, 18, 5508, 422, 374, 13, 288, 203, 5411, 2581, 18, 2019, 273, 2254, 28, 12, 6767, 4497, 1119, 18, 18546, 1769, 203, 5411, 2581, 18, 5508, 273, 2254, 1105, 12, 2629, 18, 5508, 1769, 203, 5411, 2581, 18, 5303, 14667, 273, 783, 6767, 4497, 14667, 31, 203, 3639, 289, 203, 203, 3639, 6590, 2502, 2236, 273, 9484, 63, 4631, 734, 15533, 203, 3639, 2583, 12, 4631, 18, 2019, 422, 2254, 28, 12, 3032, 1119, 18, 27511, 2056, 3631, 315, 3700, 9484, 716, 854, 4104, 471, 486, 4634, 2427, 848, 2427, 8863, 203, 3639, 2236, 18, 2019, 273, 2254, 28, 12, 3032, 1119, 18, 25691, 67, 28682, 1769, 203, 3639, 2236, 18, 8593, 4497, 1854, 273, 2254, 1578, 12, 2972, 4497, 1769, 203, 203, 3639, 2078, 6767, 6421, 9904, 31, 203, 203, 3639, 3626, 1827, 6767, 691, 12, 2972, 4497, 16, 26643, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity =0.6.6; interface IAtlasSwapV2Factory { 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 IAtlasSwapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IAtlasSwapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IAtlasSwapV2Router02 is IAtlasSwapV2Router01 { 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 IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (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); } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } contract AtlasSwapV2Router02 is IAtlasSwapV2Router02 { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'AtlasSwapV2Router: EXPIRED'); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IAtlasSwapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IAtlasSwapV2Factory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = AtlasSwapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = AtlasSwapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'AtlasSwapV2Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = AtlasSwapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'AtlasSwapV2Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = AtlasSwapV2Library.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IAtlasSwapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = AtlasSwapV2Library.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IAtlasSwapV2Pair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = AtlasSwapV2Library.pairFor(factory, tokenA, tokenB); IAtlasSwapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IAtlasSwapV2Pair(pair).burn(to); (address token0,) = AtlasSwapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'AtlasSwapV2Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'AtlasSwapV2Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, 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 virtual override returns (uint amountA, uint amountB) { address pair = AtlasSwapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IAtlasSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = AtlasSwapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IAtlasSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = AtlasSwapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IAtlasSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = AtlasSwapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? AtlasSwapV2Library.pairFor(factory, output, path[i + 2]) : _to; IAtlasSwapV2Pair(AtlasSwapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = AtlasSwapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = AtlasSwapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'AtlasSwapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); amounts = AtlasSwapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); amounts = AtlasSwapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'AtlasSwapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); amounts = AtlasSwapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); amounts = AtlasSwapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'AtlasSwapV2Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = AtlasSwapV2Library.sortTokens(input, output); IAtlasSwapV2Pair pair = IAtlasSwapV2Pair(AtlasSwapV2Library.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = AtlasSwapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? AtlasSwapV2Library.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { require(path[path.length - 1] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'AtlasSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return AtlasSwapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return AtlasSwapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return AtlasSwapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return AtlasSwapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return AtlasSwapV2Library.getAmountsIn(factory, amountOut, path); } } // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } } library AtlasSwapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'AtlasSwapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'AtlasSwapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'ea31af6b11f2cb8e9cbbebe5e1ccfba10d47a2b456a43665f11e4050c42dbbd2' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IAtlasSwapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'AtlasSwapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'AtlasSwapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'AtlasSwapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'AtlasSwapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'AtlasSwapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'AtlasSwapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'AtlasSwapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'AtlasSwapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } }
refund dust eth, if any
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'AtlasSwapV2Router: INVALID_PATH'); amounts = AtlasSwapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'AtlasSwapV2Router: EXCESSIVE_INPUT_AMOUNT'); assert(IWETH(WETH).transfer(AtlasSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); }
14,712,505
[ 1, 4625, 348, 7953, 560, 30, 225, 16255, 302, 641, 13750, 16, 309, 1281, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 7720, 1584, 44, 1290, 14332, 5157, 12, 11890, 3844, 1182, 16, 1758, 8526, 745, 892, 589, 16, 1758, 358, 16, 2254, 14096, 13, 203, 3639, 3903, 203, 3639, 5024, 203, 3639, 3849, 203, 3639, 8843, 429, 203, 3639, 3387, 12, 22097, 1369, 13, 203, 3639, 1135, 261, 11890, 8526, 3778, 30980, 13, 203, 565, 288, 203, 3639, 2583, 12, 803, 63, 20, 65, 422, 678, 1584, 44, 16, 296, 861, 9521, 12521, 58, 22, 8259, 30, 10071, 67, 4211, 8284, 203, 3639, 30980, 273, 17875, 12521, 58, 22, 9313, 18, 588, 6275, 87, 382, 12, 6848, 16, 3844, 1182, 16, 589, 1769, 203, 3639, 2583, 12, 8949, 87, 63, 20, 65, 1648, 1234, 18, 1132, 16, 296, 861, 9521, 12521, 58, 22, 8259, 30, 5675, 5119, 5354, 67, 15934, 67, 2192, 51, 5321, 8284, 203, 3639, 1815, 12, 45, 59, 1584, 44, 12, 59, 1584, 44, 2934, 13866, 12, 861, 9521, 12521, 58, 22, 9313, 18, 6017, 1290, 12, 6848, 16, 589, 63, 20, 6487, 589, 63, 21, 65, 3631, 30980, 63, 20, 5717, 1769, 203, 3639, 389, 22270, 12, 8949, 87, 16, 589, 16, 358, 1769, 203, 3639, 309, 261, 3576, 18, 1132, 405, 30980, 63, 20, 5717, 12279, 2276, 18, 4626, 5912, 1584, 44, 12, 3576, 18, 15330, 16, 1234, 18, 1132, 300, 30980, 63, 20, 19226, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/43113/0xFdBF546F3d3A0Caf5a361A692c5A66249A1a3550/sources/LendingPool_flat.sol
string memory name,string memory symbol,IERC20 _poolTokenpoolToken = _poolToken;
) ERC20("Test WAVAX", "TWA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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 262, 4232, 39, 3462, 2932, 4709, 678, 5856, 2501, 3113, 315, 18869, 5856, 2501, 7923, 288, 7010, 3639, 1758, 1842, 1345, 273, 374, 7669, 713, 8906, 20, 5193, 4630, 38, 29, 9897, 70, 29, 24734, 70, 38, 5082, 25, 39, 5908, 6260, 28, 41, 1578, 39, 5520, 37, 8875, 71, 31, 203, 3639, 2845, 1345, 273, 467, 654, 39, 3462, 12, 3813, 1345, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./utils/LocalStrings.sol"; import "./access/PermitControl.sol"; import "./proxy/StubProxyRegistry.sol"; import "./Super721IMXLock.sol"; /** @title An ERC-721 item creation contract. @author Tim Clancy @author 0xthrpw @author Qazawat Zirak This contract represents the NFTs within a single collection. It allows for a designated collection owner address to manage the creation of NFTs within this collection. The collection owner grants approval to or removes approval from other addresses governing their ability to mint NFTs from this collection. This contract is forked from the inherited OpenZeppelin dependency, and uses ideas inherited from the Super721 reference implementation. August 4th, 2021. */ contract Super721IMX is PermitControl, ERC165Storage, IERC721 { using Address for address; using Strings for string; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; /// The public identifier for the right to set this contract's metadata URI. bytes32 public constant SET_URI = keccak256("SET_URI"); /// The public identifier for the right to set this contract's proxy registry. bytes32 public constant SET_PROXY_REGISTRY = keccak256("SET_PROXY_REGISTRY"); /// The public identifier for the right to configure item groups. bytes32 public constant CONFIGURE_GROUP = keccak256("CONFIGURE_GROUP"); /// The public identifier for the right to mint items. bytes32 public constant MINT = keccak256("MINT"); /// The public identifier for the right to burn items. bytes32 public constant BURN = keccak256("BURN"); /// The public identifier for the right to set item metadata. bytes32 public constant SET_METADATA = keccak256("SET_METADATA"); /// The public identifier for the right to lock the metadata URI. bytes32 public constant LOCK_URI = keccak256("LOCK_URI"); /// The public identifier for the right to lock an item's metadata. bytes32 public constant LOCK_ITEM_URI = keccak256("LOCK_ITEM_URI"); /// The public identifier for the right to disable item creation. bytes32 public constant LOCK_CREATION = keccak256("LOCK_CREATION"); /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /// @dev Supply the magic number for the required ERC-721 interface. /// @dev A mask for isolating an item's group ID. uint256 private constant GROUP_MASK = uint256(type(uint128).max) << 128; /// The public name of this contract. string public name; string public symbol; /** The ERC-721 URI for tracking item metadata, supporting {id} substitution. For example: https://token-cdn-domain/{id}.json. See the ERC-721 spec for more details: https://eips.ethereum.org/EIPS/eip-721#metadata. */ string public metadataUri; /// A proxy registry address for supporting automatic delegated approval. address public proxyRegistryAddress; /// The address of the IMX core contract for L2 minting. address public imxCoreAddress; /// The address of the global lock for all 721IMX instances. address public super721IMXLock; /// @dev A mapping from each token ID to per-address balances. mapping (uint256 => mapping(address => uint256)) public balances; /// A mapping from each group ID to per-address balances. mapping (uint256 => mapping(address => uint256)) public groupBalances; /// A mapping from each address to a collection-wide balance. mapping(address => uint256) public totalBalances; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; /** @dev This is a mapping from each address to per-address operator approvals. Operators are those addresses that have been approved to transfer tokens on behalf of the approver. Transferring tokens includes the right to burn tokens. */ mapping (address => mapping(address => bool)) private operatorApprovals; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; /** This enumeration lists the various supply types that each item group may use. In general, the administrator of this collection or those permissioned to do so may move from a more-permissive supply type to a less-permissive. For example: an uncapped or flexible supply type may be converted to a capped supply type. A capped supply type may not be uncapped later, however. @param Capped There exists a fixed cap on the size of the item group. The cap is set by `supplyData`. @param Uncapped There is no cap on the size of the item group. The value of `supplyData` cannot be set below the current circulating supply but is otherwise ignored. @param Flexible There is a cap which can be raised or lowered (down to circulating supply) freely. The value of `supplyData` cannot be set below the current circulating supply and determines the cap. */ enum SupplyType { Capped, Uncapped, Flexible } /** This enumeration lists the various burn types that each item group may use. These are static once chosen. @param None The items in this group may not be burnt. The value of `burnData` is ignored. @param Burnable The items in this group may be burnt. The value of `burnData` is the maximum that may be burnt. @param Replenishable The items in this group, once burnt, may be reminted by the owner. The value of `burnData` is ignored. */ enum BurnType { None, Burnable, Replenishable } /** This struct is a source of mapping-free input to the `configureGroup` function. It defines the settings for a particular item group. @param name A name for the item group. @param supplyType The supply type for this group of items. @param supplyData An optional integer used by some `supplyType` values. @param burnType The type of burning permitted by this item group. @param burnData An optional integer used by some `burnType` values. */ struct ItemGroupInput { string name; SupplyType supplyType; uint256 supplyData; BurnType burnType; uint256 burnData; } /** This struct defines the settings for a particular item group and is tracked in storage. @param initialized Whether or not this `ItemGroup` has been initialized. @param name A name for the item group. @param supplyType The supply type for this group of items. @param supplyData An optional integer used by some `supplyType` values. @param burnType The type of burning permitted by this item group. @param burnData An optional integer used by some `burnType` values. @param circulatingSupply The number of individual items within this group in circulation. @param mintCount The number of times items in this group have been minted. @param burnCount The number of times items in this group have been burnt. */ struct ItemGroup { bool initialized; string name; SupplyType supplyType; uint256 supplyData; BurnType burnType; uint256 burnData; uint256 circulatingSupply; uint256 mintCount; uint256 burnCount; } /// A mapping of data for each item group. mapping (uint256 => ItemGroup) public itemGroups; /// A mapping of circulating supplies for each individual token. mapping (uint256 => uint256) public circulatingSupply; /// A mapping of the number of times each individual token has been minted. mapping (uint256 => uint256) public mintCount; /// A mapping of the number of times each individual token has been burnt. mapping (uint256 => uint256) public burnCount; /** A mapping of token ID to a boolean representing whether the item's metadata has been explicitly frozen via a call to `lockURI(string calldata _uri, uint256 _id)`. Do note that it is possible for an item's mapping here to be false while still having frozen metadata if the item collection as a whole has had its `uriLocked` value set to true. */ mapping (uint256 => bool) public metadataFrozen; /** A public mapping of optional on-chain metadata for each token ID. A token's on-chain metadata is unable to be changed if the item's metadata URI has been permanently fixed or if the collection's metadata URI as a whole has been frozen. */ mapping (uint256 => string) public metadata; /// Whether or not the metadata URI has been locked to future changes. bool public uriLocked; /// Whether or not the item collection has been locked to all further minting. bool public locked; /** An event that gets emitted when the metadata collection URI is changed. @param oldURI The old metadata URI. @param newURI The new metadata URI. */ event ChangeURI(string indexed oldURI, string indexed newURI); /** An event that gets emitted when the proxy registry address is changed. @param oldRegistry The old proxy registry address. @param newRegistry The new proxy registry address. */ event ChangeProxyRegistry(address indexed oldRegistry, address indexed newRegistry); /** An event that gets emitted when an item group is configured. @param manager The caller who configured the item group `_groupId`. @param groupId The groupId being configured. @param newGroup The new group configuration. */ event ItemGroupConfigured(address indexed manager, uint256 groupId, ItemGroupInput indexed newGroup); /** An event that gets emitted when the item collection is locked to further creation. @param locker The caller who locked the collection. */ event CollectionLocked(address indexed locker); /** An event that gets emitted when a token ID has its on-chain metadata changed. @param changer The caller who triggered the metadata change. @param id The ID of the token which had its metadata changed. @param oldMetadata The old metadata of the token. @param newMetadata The new metadata of the token. */ event MetadataChanged(address indexed changer, uint256 indexed id, string oldMetadata, string indexed newMetadata); /** An event that indicates we have set a permanent metadata URI for a token. @param _value The value of the permanent metadata URI. @param _id The token ID associated with the permanent metadata value. */ event PermanentURI(string _value, uint256 indexed _id); /** A modifier which allows only the super-administrative owner or addresses with a specified valid right to perform a call on some specific item. Rights can be applied to the universal circumstance, the item-group-level circumstance, or to the circumstance of the item ID itself. @param _id The item ID on which we check for the validity of the specified `right`. @param _right The right to validate for the calling address. It must be non-expired and exist within the specified `_itemId`. */ modifier hasItemRight(uint256 _id, bytes32 _right) { uint256 groupId = (_id & GROUP_MASK) >> 128; if (_msgSender() == owner()) { _; } else if (hasRight(_msgSender(), UNIVERSAL, _right)) { _; } else if (hasRight(_msgSender(), bytes32(groupId), _right)) { _; } else if (hasRight(_msgSender(), bytes32(_id), _right)) { _; } else { revert("Super721::hasItemRight: _msgSender does not have the right to perform that action"); } } /** Construct a new ERC-721 item collection. @param _owner The address of the administrator governing this collection. @param _name The name to assign to this item collection contract. @param _uri The metadata URI to perform later token ID substitution with. @param _proxyRegistryAddress The address of a proxy registry contract. @param _imxCoreAddress The address of the IMX core contract for L2 minting. */ constructor(address _owner, string memory _name, string memory _symbol, string memory _uri, address _proxyRegistryAddress, address _imxCoreAddress, address _super721IMXLock) { // Do not perform a redundant ownership transfer if the deployer should // remain as the owner of the collection. if (_owner != owner()) { transferOwnership(_owner); } // Register 721 interfaces _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); // Continue initialization. name = _name; symbol = _symbol; metadataUri = _uri; proxyRegistryAddress = _proxyRegistryAddress; imxCoreAddress = _imxCoreAddress; super721IMXLock = _super721IMXLock; } /** */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "Super721::ownerOf: owner query for nonexistent token"); } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "Super721::approve: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "Super721::approve: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** Return a version number for this contract's interface. */ function version() external virtual pure override returns (uint256) { return 1; } /** Return the item collection's metadata URI. This implementation returns the same URI for all tokens within the collection and relies on client-side ID substitution per https://eips.ethereum.org/EIPS/eip-721#metadata. Per said specification, clients calling this function must replace the {id} substring with the actual token ID in hex, not prefixed by 0x, and padded to 64 characters in length. @return The metadata URI string of the item with ID `_itemId`. */ function tokenURI(uint256 id) external view returns (string memory) { Strings.Slice memory slice1 = metadataUri.toSlice(); Strings.Slice memory slice2 = metadataUri.toSlice(); string memory tokenFirst = "{"; string memory tokenLast = "}"; Strings.Slice memory firstSlice = tokenFirst.toSlice(); Strings.Slice memory secondSlice = tokenLast.toSlice(); firstSlice = Strings.beforeMatch(slice1, firstSlice); secondSlice = Strings.afterMatch(slice2, secondSlice); string memory first = Strings.toString(firstSlice); string memory second = Strings.toString(secondSlice); string memory result = string(abi.encodePacked(first, Strings.uint2str(id), second)); return result; } /** Allow the item collection owner or an approved manager to update the metadata URI of this collection. This implementation relies on a single URI for all items within the collection, and as such does not emit the standard URI event. Instead, we emit our own event to reflect changes in the URI. @param _uri The new URI to update to. */ function setURI(string calldata _uri) external virtual hasValidPermit(UNIVERSAL, SET_URI) { require(!uriLocked, "Super721::setURI: the collection URI has been permanently locked"); string memory oldURI = metadataUri; metadataUri = _uri; emit ChangeURI(oldURI, _uri); } // TODO: change all require messages /** Allow the item collection owner or an approved manager to update the proxy registry address handling delegated approval. @param _proxyRegistryAddress The address of the new proxy registry to update to. */ function setProxyRegistry(address _proxyRegistryAddress) external virtual hasValidPermit(UNIVERSAL, SET_PROXY_REGISTRY) { address oldRegistry = proxyRegistryAddress; proxyRegistryAddress = _proxyRegistryAddress; emit ChangeProxyRegistry(oldRegistry, _proxyRegistryAddress); } /** Retrieve the balance of a particular token `_id` for a particular address `_owner`. @param _owner The owner to check for this token balance. @param _id The ID of the token to check for a balance. @return The amount of token `_id` owned by `_owner`. */ function balanceOfGroup(address _owner, uint256 _id) public view virtual returns (uint256) { require(_owner != address(0), "Super721::balanceOf: balance query for the zero address"); return balances[_id][_owner]; } function balanceOf(address _owner) public override view virtual returns (uint256) { require(_owner != address(0), "Super721::balanceOf: balance query for the zero address"); return totalBalances[_owner]; } /** Retrieve in a single call the balances of some mulitple particular token `_ids` held by corresponding `_owners`. @param _owners The owners to check for token balances. @param _ids The IDs of tokens to check for balances. @return the amount of each token owned by each owner. */ function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view virtual returns (uint256[] memory) { require(_owners.length == _ids.length, "Super721::balanceOfBatch: accounts and ids length mismatch"); // Populate and return an array of balances. uint256[] memory batchBalances = new uint256[](_owners.length); for (uint256 i = 0; i < _owners.length; ++i) { batchBalances[i] = balanceOfGroup(_owners[i], _ids[i]); } return batchBalances; } /** This function returns true if `_operator` is approved to transfer items owned by `_owner`. This approval check features an override to explicitly whitelist any addresses delegated in the proxy registry. @param _owner The owner of items to check for transfer ability. @param _operator The potential transferrer of `_owner`'s items. @return Whether `_operator` may transfer items owned by `_owner`. */ function isApprovedForAll(address _owner, address _operator) public override view virtual returns (bool) { StubProxyRegistry proxyRegistry = StubProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(_owner)) == _operator) { return true; } // We did not find an explicit whitelist in the proxy registry. return operatorApprovals[_owner][_operator]; } /** Enable or disable approval for a third party `_operator` address to manage (transfer or burn) all of the caller's tokens. @param _operator The address to grant management rights over all of the caller's tokens. @param _approved The status of the `_operator`'s approval for the caller. */ function setApprovalForAll(address _operator, bool _approved) external override virtual { require(_msgSender() != _operator, "Super721::balanceOf: setting approval status for self"); operatorApprovals[_msgSender()][_operator] = _approved; emit ApprovalForAll(_msgSender(), _operator, _approved); } /** This private helper function converts a number into a single-element array. @param _element The element to convert to an array. @return The array containing the single `_element`. */ function _asSingletonArray(uint256 _element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = _element; return array; } /** An inheritable and configurable pre-transfer hook that can be overridden. It fires before any token transfer, including mints and burns. @param _operator The caller who triggers the token transfer. @param _from The address to transfer tokens from. @param _to The address to transfer tokens to. @param _ids The specific token IDs to transfer. @param _amounts The amounts of the specific `_ids` to transfer. @param _data Additional call data to send with this transfer. */ function _beforeTokenTransfer(address _operator, address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data) internal virtual { } /** ERC-721 dictates that any contract which wishes to receive ERC-721 tokens must explicitly designate itself as such. This function checks for such designation to prevent undesirable token transfers. @param _operator The caller who triggers the token transfer. @param _from The address to transfer tokens from. @param _to The address to transfer tokens to. @param _id The specific token ID to transfer. @param _data Additional call data to send with this transfer. */ function _doSafeTransferAcceptanceCheck(address _operator, address _from, address _to, uint256 _id, bytes memory _data) private { if (_to.isContract()) { try IERC721Receiver(_to).onERC721Received(_operator, _from, _id, _data) returns (bytes4 response) { if (response != IERC721Receiver(_to).onERC721Received.selector) { revert("Super721::_doSafeTransferAcceptanceCheck: ERC721Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("Super721::_doSafeTransferAcceptanceCheck: transfer to non ERC721Receiver implementer"); } } } /** Transfer on behalf of a caller or one of their authorized token managers items from one address to another. @param _from The address to transfer tokens from. @param _to The address to transfer tokens to. @param _id The specific token ID to transfer. @param _data Additional call data to send with this transfer. */ /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { _safeTransferFrom(from, to, tokenId, bytes("")); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) public virtual override { _safeTransferFrom(from, to, tokenId, data); } function _safeTransferFrom(address _from, address _to, uint256 _id, bytes memory _data) internal virtual { require(_to != address(0), "Super721::_safeTransferFrom : transfer to the zero address"); require(_from == _msgSender() || isApprovedForAll(_from, _msgSender()), "Super721::_safeTransferFrom : caller is not owner nor approved"); // Validate transfer safety and send tokens away. address operator = _msgSender(); _beforeTokenTransfer(operator, _from, _to, _asSingletonArray(_id), _asSingletonArray(1), _data); // Retrieve the item's group ID. uint256 shiftedGroupId = (_id & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; // Update all specially-tracked group-specific balances. require(balances[_id][_from] >= 1, "Super721::_safeTransferFrom: insufficient balance for transfer"); balances[_id][_from] = balances[_id][_from] - 1; balances[_id][_to] = balances[_id][_to] + 1; groupBalances[groupId][_from] = groupBalances[groupId][_from] - 1; groupBalances[groupId][_to] = groupBalances[groupId][_to] + 1; totalBalances[_from] = totalBalances[_from] - 1; totalBalances[_to] = totalBalances[_to] + 1; _holderTokens[_from].remove(_id); _holderTokens[_to].add(_id); _tokenOwners.set(_id, _to); // Emit the transfer event and perform the safety check. emit Transfer(_from, _to, _id); _doSafeTransferAcceptanceCheck(operator, _from, _to, _id, _data); } /** Transfer on behalf of a caller or one of their authorized token managers items from one address to another. @param _from The address to transfer tokens from. @param _to The address to transfer tokens to. @param _ids The specific token IDs to transfer. @param _data Additional call data to send with this transfer. */ function safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, bytes memory _data) external virtual { require(_to != address(0), "Super721::safeBatchTransferFrom: transfer to the zero address"); require(_from == _msgSender() || isApprovedForAll(_from, _msgSender()), "Super721::safeBatchTransferFrom: caller is not owner nor approved"); // Validate transfer and perform all batch token sends. _beforeTokenTransfer(_msgSender(), _from, _to, _ids, _asSingletonArray(1), _data); for (uint256 i = 0; i < _ids.length; ++i) { // Retrieve the item's group ID. uint256 groupId = (_ids[i] & GROUP_MASK) >> 128; // Update all specially-tracked group-specific balances. require(balances[_ids[i]][_from] >= 1, "Super721::safeBatchTransferFrom: insufficient balance for transfer"); balances[_ids[i]][_from] = balances[_ids[i]][_from] - 1; balances[_ids[i]][_to] = balances[_ids[i]][_to] + 1; groupBalances[groupId][_from] = groupBalances[groupId][_from] - 1; groupBalances[groupId][_to] = groupBalances[groupId][_to] + 1; totalBalances[_from] = totalBalances[_from] - 1; totalBalances[_to] = totalBalances[_to] + 1; // Emit the transfer event and perform the safety check. emit Transfer(_from, _to, _ids[i]); _doSafeTransferAcceptanceCheck(_msgSender(), _from, _to, _ids[i], _data); } } /** Create a new NFT item group or configure an existing one. NFTs within a group share a group ID in the upper 128-bits of their full item ID. Within a group NFTs can be distinguished for the purposes of serializing issue numbers. @param _groupId The ID of the item group to create or configure. @param _data The `ItemGroup` data input. */ function configureGroup(uint256 _groupId, ItemGroupInput memory _data) external virtual hasItemRight(_groupId, CONFIGURE_GROUP) { require(_groupId != 0, "Super721::configureGroup: group ID 0 is invalid"); // If the collection is not locked, we may add a new item group. if (!itemGroups[_groupId].initialized) { require(!locked, "Super721::configureGroup: the collection is locked so groups cannot be created"); itemGroups[_groupId] = ItemGroup({ initialized: true, name: _data.name, supplyType: _data.supplyType, supplyData: _data.supplyData, burnType: _data.burnType, burnData: _data.burnData, circulatingSupply: 0, mintCount: 0, burnCount: 0 }); // Edit an existing item group. The name may always be updated. } else { itemGroups[_groupId].name = _data.name; // A capped supply type may not change. // It may also not have its cap increased. if (itemGroups[_groupId].supplyType == SupplyType.Capped) { require(_data.supplyType == SupplyType.Capped, "Super721::configureGroup: you may not uncap a capped supply type"); require(_data.supplyData <= itemGroups[_groupId].supplyData, "Super721::configureGroup: you may not increase the supply of a capped type"); // The flexible and uncapped types may freely change. } else { itemGroups[_groupId].supplyType = _data.supplyType; } // Item supply data may not be reduced below the circulating supply. require(_data.supplyData >= itemGroups[_groupId].circulatingSupply, "Super721::configureGroup: you may not decrease supply below the circulating amount"); itemGroups[_groupId].supplyData = _data.supplyData; // do we want burnType to be updateable? } // Emit the configuration event. emit ItemGroupConfigured(_msgSender(), _groupId, _data); } /** This is a private helper function to replace the `hasItemRight` modifier that we use on some functions in order to inline this check during batch minting and burning. @param _id The ID of the item to check for the given `_right` on. @param _right The right that the caller is trying to exercise on `_id`. @return Whether or not the caller has a valid right on this item. */ function _hasItemRight(uint256 _id, bytes32 _right) private view returns (bool) { uint256 groupId = (_id & GROUP_MASK) >> 128; if (_msgSender() == owner()) { return true; } else if (hasRight(_msgSender(), UNIVERSAL, _right)) { return true; } else if (hasRight(_msgSender(), bytes32(groupId), _right)) { return true; } else if (hasRight(_msgSender(), bytes32(_id), _right)) { return true; } else { return false; } } /** This is a private helper function to verify, according to all of our various minting and burning rules, whether it would be valid to mint a particular item `_id`. @param _id The ID of the item to check for minting validity. @return The ID of the item that should be minted. */ function _mintChecker(uint256 _id) private view returns (uint256) { // Retrieve the item's group ID. uint256 shiftedGroupId = (_id & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; require(itemGroups[groupId].initialized, "Super721::_mintChecker: you cannot mint a non-existent item group"); // If false, owned by address (or NULL_ADDRESS i.e, was burnable) // If true, never minted, (or was removed i.e, was replenishable) require(!_tokenOwners.contains(_id), "Super721::_mintChecker: token already exists"); // If we can replenish burnt items, then only our currently-circulating // supply matters. Otherwise, historic mints are what determine the cap. uint256 currentGroupSupply = itemGroups[groupId].mintCount; uint256 currentItemSupply = mintCount[_id]; if (itemGroups[groupId].burnType == BurnType.Replenishable) { currentGroupSupply = itemGroups[groupId].circulatingSupply; currentItemSupply = circulatingSupply[_id]; } // If we are subject to a cap on group size, ensure we don't exceed it. if (itemGroups[groupId].supplyType != SupplyType.Uncapped) { require(currentGroupSupply + 1 <= itemGroups[groupId].supplyData, "Super721::_mintChecker: you cannot mint a group beyond its cap"); } return _id; } /** Mint a batch of tokens into existence and send them to the `_recipient` address. In order to mint an item, its item group must first have been created. Minting an item must obey both the fungibility and size cap of its group. @param _recipient The address to receive all NFTs within the newly-minted group. @param _ids The item IDs for the new items to create. @param _data Any associated data to use on items minted in this transaction. */ function mintBatch(address _recipient, uint256[] memory _ids, bytes memory _data) public virtual { require(_recipient != address(0), "Super721::mintBatch: mint to the zero address"); // Validate and perform the mint. address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), _recipient, _ids, _asSingletonArray(1), _data); // Loop through each of the batched IDs to update storage of special // balances and circulation balances. for (uint256 i = 0; i < _ids.length; i++) { require(_hasItemRight(_ids[i], MINT), "Super721::mintBatch: you do not have the right to mint that item"); // Retrieve the group ID from the given item `_id` and check mint. uint256 shiftedGroupId = (_ids[i] & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; uint256 mintedItemId = _mintChecker(_ids[i]); // Update storage of special balances and circulating values. balances[mintedItemId][_recipient] = balances[mintedItemId][_recipient] + 1; groupBalances[groupId][_recipient] = groupBalances[groupId][_recipient] + 1; totalBalances[_recipient] = totalBalances[_recipient] + 1; mintCount[mintedItemId] = mintCount[mintedItemId] + 1; circulatingSupply[mintedItemId] = circulatingSupply[mintedItemId] + 1; itemGroups[groupId].mintCount = itemGroups[groupId].mintCount + 1; itemGroups[groupId].circulatingSupply = itemGroups[groupId].circulatingSupply + 1; //_holderTokens[address(0)].remove(_ids[i]); _holderTokens[_recipient].add(_ids[i]); _tokenOwners.set(_ids[i], _recipient); // Emit event and handle the safety check. emit Transfer(address(0), _recipient, _ids[i]); _doSafeTransferAcceptanceCheck(operator, address(0), _recipient, _ids[i], _data); } } /** The special, IMX-privileged minting function for centralized L2 support. */ function mintFor(address _to, uint256 _id, bytes calldata _blueprint) external { require(!Super721IMXLock(super721IMXLock).mintForLocked(), "SuperIMX721::mintFor::disabled"); require(_msgSender() == imxCoreAddress, "SuperIMX721::mintFor::only IMX may call this mint function"); uint256[] memory ids = _asSingletonArray(_id); mintBatch(_to, ids, _blueprint); } /** This is a private helper function to verify, according to all of our various minting and burning rules, whether it would be valid to burn some `_amount` of a particular item `_id`. @param _id The ID of the item to check for burning validity. @return The ID of the item that should have `_amount` burnt for it. */ function _burnChecker(uint256 _id) private view returns (uint256) { // Retrieve the item's group ID. uint256 shiftedGroupId = (_id & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; require(itemGroups[groupId].initialized, "Super721::_burnChecker: you cannot burn a non-existent item group"); // If the item group is non-burnable, then revert. if (itemGroups[groupId].burnType == BurnType.None) { revert("Super721::_burnChecker: you cannot burn a non-burnable item group"); } // If we can burn items, then we must verify that we do not exceed the cap. else if (itemGroups[groupId].burnType == BurnType.Burnable) { require(itemGroups[groupId].burnCount + 1 <= itemGroups[groupId].burnData, "Super721::_burnChecker you may not exceed the burn limit on this item group"); } // If the item is replenishable, then ignore checks uint256 burntItemId = _id; return burntItemId; } /** This function allows an address to destroy some of its items. @param _burner The address whose item is burning. @param _id The item ID to burn. @param _amount The amount of the corresponding item ID to burn. */ // function burn(address _burner, uint256 _id, uint256 _amount) // external virtual hasItemRight(_id, BURN) { // require(_burner != address(0), // "Super721::burn: burn from the zero address"); // // // Retrieve the group ID from the given item `_id` and check burn validity. // uint256 shiftedGroupId = (_id & GROUP_MASK); // uint256 groupId = shiftedGroupId >> 128; // uint256 burntItemId = _burnChecker(_id, _amount); // // // Validate and perform the burn. // address operator = _msgSender(); // _beforeTokenTransfer(operator, _burner, address(0), // _asSingletonArray(burntItemId), _asSingletonArray(_amount), ""); // // // Update storage of special balances and circulating values. // balances[burntItemId][_burner] = balances[burntItemId][_burner] // .sub(_amount, // "Super721::burn: burn amount exceeds balance"); // groupBalances[groupId][_burner] = groupBalances[groupId][_burner] // .sub(_amount); // totalBalances[_burner] = totalBalances[_burner].sub(_amount); // burnCount[burntItemId] = burnCount[burntItemId].add(_amount); // circulatingSupply[burntItemId] = circulatingSupply[burntItemId] // .sub(_amount); // itemGroups[groupId].burnCount = itemGroups[groupId].burnCount.add(_amount); // itemGroups[groupId].circulatingSupply = // itemGroups[groupId].circulatingSupply.sub(_amount); // // // Emit the burn event. // emit Transfer(operator, address(0), _id); // } /** This function allows an address to destroy multiple different items in a single call. @param _burner The address whose items are burning. @param _ids The item IDs to burn. */ function burnBatch(address _burner, uint256[] memory _ids) external virtual { require(_burner != address(0), "Super721::burnBatch: burn from the zero address"); // Validate and perform the burn. address operator = _msgSender(); _beforeTokenTransfer(operator, _burner, address(0), _ids, _asSingletonArray(1), ""); // Loop through each of the batched IDs to update storage of special // balances and circulation balances. for (uint i = 0; i < _ids.length; i++) { require(_hasItemRight(_ids[i], BURN), "Super721::burnBatch: you do not have the right to burn that item"); // Retrieve the group ID from the given item `_id` and check burn. uint256 shiftedGroupId = (_ids[i] & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; uint256 burntItemId = _burnChecker(_ids[i]); // Update storage of special balances and circulating values. require(balances[burntItemId][_burner] >= 1, "Super721::burn: burn amount exceeds balance"); balances[burntItemId][_burner] = balances[burntItemId][_burner] - 1; groupBalances[groupId][_burner] = groupBalances[groupId][_burner] - 1; totalBalances[_burner] = totalBalances[_burner] - 1; burnCount[burntItemId] = burnCount[burntItemId] + 1; circulatingSupply[burntItemId] = circulatingSupply[burntItemId] - 1; itemGroups[groupId].burnCount = itemGroups[groupId].burnCount + 1; itemGroups[groupId].circulatingSupply = itemGroups[groupId].circulatingSupply - 1; _holderTokens[_burner].remove(_ids[i]); _holderTokens[address(0)].add(_ids[i]); // If burnType is None, burnChecker will revert that if(itemGroups[groupId].burnType == BurnType.Burnable) _tokenOwners.set(_ids[i], address(0)); else _tokenOwners.remove(_ids[i]); // Emit the burn event. emit Transfer(operator, address(0), _ids[i]); } } /** Set the on-chain metadata attached to a specific token ID so long as the collection as a whole or the token specifically has not had metadata editing frozen. @param _id The ID of the token to set the `_metadata` for. @param _metadata The metadata string to store on-chain. */ function setMetadata(uint256 _id, string memory _metadata) external hasItemRight(_id, SET_METADATA) { uint groupId = _id >> 128; require(!uriLocked && !metadataFrozen[_id] && !metadataFrozen[groupId], "Super721::setMetadata: you cannot edit this metadata because it is frozen"); string memory oldMetadata = metadata[_id]; metadata[_id] = _metadata; emit MetadataChanged(_msgSender(), _id, oldMetadata, _metadata); } /** Allow the item collection owner or an associated manager to forever lock the metadata URI on the entire collection to future changes. @param _uri The value of the URI to lock for `_id`. */ function lockURI(string calldata _uri) external hasValidPermit(UNIVERSAL, LOCK_URI) { string memory oldURI = metadataUri; metadataUri = _uri; emit ChangeURI(oldURI, _uri); uriLocked = true; emit PermanentURI(_uri, 2 ** 256 - 1); } /** Allow the item collection owner or an associated manager to forever lock the metadata URI on an item to future changes. @param _uri The value of the URI to lock for `_id`. @param _id The token ID to lock a metadata URI value into. */ function lockItemURI(string calldata _uri, uint256 _id) external hasItemRight(_id, LOCK_ITEM_URI) { metadataFrozen[_id] = true; emit PermanentURI(_uri, _id); } /** Allow the item collection owner or an associated manager to forever lock the metadata URI on a group of items to future changes. @param _uri The value of the URI to lock for `groupId`. @param groupId The group ID to lock a metadata URI value into. */ function lockGroupURI(string calldata _uri, uint256 groupId) external hasItemRight(groupId, LOCK_ITEM_URI) { metadataFrozen[groupId] = true; emit PermanentURI(_uri, groupId); } /** Allow the item collection owner or an associated manager to forever lock this contract to further item minting. */ function lock() external virtual hasValidPermit(UNIVERSAL, LOCK_CREATION) { locked = true; emit CollectionLocked(_msgSender()); } function getApproved(uint256 tokenId) public view override returns (address) { require(_tokenOwners.contains(tokenId), "Super721::getApproved: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_tokenOwners.contains(tokenId), "Super721::getApproved: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || _tokenApprovals[tokenId] == spender || isApprovedForAll(owner, spender)); } /** * @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), "Super721::transferForm: transfer caller is not owner nor approved"); safeTransferFrom(from, to, tokenId); // // require(ownerOf(tokenId) == from, "Super721::transferForm: transfer of token that is not own"); // require(to != address(0), "Super721::transferForm: transfer to the zero address"); // // _beforeTokenTransfer(_msgSender(), from, to, _asSingletonArray(tokenId), _asSingletonArray(1), ""); // // // Clear approvals from the previous owner // //_approve(address(0), tokenId); // _tokenApprovals[tokenId] = address(0); // emit Approval(ownerOf(tokenId), address(0), tokenId); // // _holderTokens[from].remove(tokenId); // _holderTokens[to].add(tokenId); // // _tokenOwners.set(tokenId, to); // // emit Transfer(from, to, tokenId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } } // 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 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC165.sol"; /** * @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; } } // 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; import "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set( Map storage map, bytes32 key, bytes32 value ) private returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (_contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get( Map storage map, bytes32 key, string memory errorMessage ) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), errorMessage); return value; } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToAddressMap storage map, uint256 key, address value ) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // 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); } } } } pragma solidity ^0.8.7; library Strings { // via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b) internal pure returns (string memory) { return strConcat(_a, _b, "", "", ""); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; j = _i; while (j != 0) { bstr[--k] = bytes1(uint8(48 + j % 10)); j /= 10; } return string(bstr); } // this is struct for aligning function memory struct Slice { uint length; uint pointer; } function copyToMemory(uint _destination, uint _source, uint _length) private pure { // Copy word-length chunks while possible for(_length ; _length >= 32; _length -= 32) { assembly { mstore(_destination, mload(_source)) } _destination += 32; _source += 32; } // Copy remaining bytes uint mask = 256 ** (32 - _length) - 1; assembly { let source := and(mload(_source), not(mask)) let destination := and(mload(_destination), mask) mstore(_destination, or(destination, source)) } } // make struct slice out of string function toSlice(string memory input) internal pure returns (Slice memory) { uint ptr; assembly { ptr := add(input, 0x20) } return Slice(bytes(input).length, ptr); } function findPointer(uint inputLength, uint inputPointer, uint toSearchLength, uint toSearchPointer) private pure returns (uint) { uint pointer = inputPointer; if (toSearchLength <= inputLength) { if (toSearchLength <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - toSearchLength)) - 1)); bytes32 toSearchdata; assembly { toSearchdata := and(mload(toSearchPointer), mask) } uint end = inputPointer + inputLength - toSearchLength; bytes32 data; assembly { data := and(mload(pointer), mask) } while (data != toSearchdata) { if (pointer >= end) return inputPointer + inputLength; pointer++; assembly { data := and(mload(pointer), mask) } } return pointer; } else { // For long toSearchs, use hashing bytes32 hash; assembly { hash := keccak256(toSearchPointer, toSearchLength) } for (uint i = 0; i <= inputLength - toSearchLength; i++) { bytes32 testHash; assembly { testHash := keccak256(pointer, toSearchLength) } if (hash == testHash) return pointer; pointer += 1; } } } return inputPointer + inputLength; } function afterMatch(Slice memory input, Slice memory toSearch) internal pure returns (Slice memory) { uint pointer = findPointer(input.length, input.pointer, toSearch.length, toSearch.pointer); input.length -= pointer - input.pointer; input.pointer = pointer +1; // escape token return input; } function beforeMatch(Slice memory input, Slice memory toSearch) internal pure returns (Slice memory token) { beforeMatch(input, toSearch, token); } function beforeMatch(Slice memory input, Slice memory toSearch, Slice memory token) internal pure returns (Slice memory) { uint pointer = findPointer(input.length, input.pointer, toSearch.length, toSearch.pointer); token.pointer = input.pointer; token.length = pointer - input.pointer; if (pointer == input.pointer + input.length) { // Not found input.length = 0; } else { input.length -= token.length + toSearch.length; input.pointer = pointer + toSearch.length; } return token; } function toString(Slice memory input) internal pure returns (string memory) { string memory result = new string(input.length); uint resultPointer; assembly { resultPointer := add(result, 32) } copyToMemory(resultPointer, input.pointer, input.length); return result; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; /** @title An advanced permission-management contract. @author Tim Clancy This contract allows for a contract owner to delegate specific rights to external addresses. Additionally, these rights can be gated behind certain sets of circumstances and granted expiration times. This is useful for some more finely-grained access control in contracts. The owner of this contract is always a fully-permissioned super-administrator. August 23rd, 2021. */ abstract contract PermitControl is Ownable { using Address for address; /// A special reserved constant for representing no rights. bytes32 public constant ZERO_RIGHT = hex"00000000000000000000000000000000"; /// A special constant specifying the unique, universal-rights circumstance. bytes32 public constant UNIVERSAL = hex"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; /* A special constant specifying the unique manager right. This right allows an address to freely-manipulate the `managedRight` mapping. **/ bytes32 public constant MANAGER = hex"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; /** A mapping of per-address permissions to the circumstances, represented as an additional layer of generic bytes32 data, under which the addresses have various permits. A permit in this sense is represented by a per-circumstance mapping which couples some right, represented as a generic bytes32, to an expiration time wherein the right may no longer be exercised. An expiration time of 0 indicates that there is in fact no permit for the specified address to exercise the specified right under the specified circumstance. @dev Universal rights MUST be stored under the 0xFFFFFFFFFFFFFFFFFFFFFFFF... max-integer circumstance. Perpetual rights may be given an expiry time of max-integer. */ mapping( address => mapping( bytes32 => mapping( bytes32 => uint256 ))) public permissions; /** An additional mapping of managed rights to manager rights. This mapping represents the administrator relationship that various rights have with one another. An address with a manager right may freely set permits for that manager right's managed rights. Each right may be managed by only one other right. */ mapping( bytes32 => bytes32 ) public managerRight; /** An event emitted when an address has a permit updated. This event captures, through its various parameter combinations, the cases of granting a permit, updating the expiration time of a permit, or revoking a permit. @param updator The address which has updated the permit. @param updatee The address whose permit was updated. @param circumstance The circumstance wherein the permit was updated. @param role The role which was updated. @param expirationTime The time when the permit expires. */ event PermitUpdated( address indexed updator, address indexed updatee, bytes32 circumstance, bytes32 indexed role, uint256 expirationTime ); /** An event emitted when a management relationship in `managerRight` is updated. This event captures adding and revoking management permissions via observing the update history of the `managerRight` value. @param manager The address of the manager performing this update. @param managedRight The right which had its manager updated. @param managerRight The new manager right which was updated to. */ event ManagementUpdated( address indexed manager, bytes32 indexed managedRight, bytes32 indexed managerRight ); /** A modifier which allows only the super-administrative owner or addresses with a specified valid right to perform a call. @param _circumstance The circumstance under which to check for the validity of the specified `right`. @param _right The right to validate for the calling address. It must be non-expired and exist within the specified `_circumstance`. */ modifier hasValidPermit( bytes32 _circumstance, bytes32 _right ) { require(_msgSender() == owner() || hasRight(_msgSender(), _circumstance, _right), "PermitControl: sender does not have a valid permit"); _; } /** Return a version number for this contract's interface. */ function version() external virtual pure returns (uint256) { return 1; } /** Determine whether or not an address has some rights under the given circumstance, and if they do have the right, until when. @param _address The address to check for the specified `_right`. @param _circumstance The circumstance to check the specified `_right` for. @param _right The right to check for validity. @return The timestamp in seconds when the `_right` expires. If the timestamp is zero, we can assume that the user never had the right. */ function hasRightUntil( address _address, bytes32 _circumstance, bytes32 _right ) public view returns (uint256) { return permissions[_address][_circumstance][_right]; } /** Determine whether or not an address has some rights under the given circumstance, @param _address The address to check for the specified `_right`. @param _circumstance The circumstance to check the specified `_right` for. @param _right The right to check for validity. @return true or false, whether user has rights and time is valid. */ function hasRight( address _address, bytes32 _circumstance, bytes32 _right ) public view returns (bool) { return permissions[_address][_circumstance][_right] > block.timestamp; } /** Set the permit to a specific address under some circumstances. A permit may only be set by the super-administrative contract owner or an address holding some delegated management permit. @param _address The address to assign the specified `_right` to. @param _circumstance The circumstance in which the `_right` is valid. @param _right The specific right to assign. @param _expirationTime The time when the `_right` expires for the provided `_circumstance`. */ function setPermit( address _address, bytes32 _circumstance, bytes32 _right, uint256 _expirationTime ) external virtual hasValidPermit(UNIVERSAL, managerRight[_right]) { require(_right != ZERO_RIGHT, "PermitControl: you may not grant the zero right"); permissions[_address][_circumstance][_right] = _expirationTime; emit PermitUpdated(_msgSender(), _address, _circumstance, _right, _expirationTime); } /** Set the `_managerRight` whose `UNIVERSAL` holders may freely manage the specified `_managedRight`. @param _managedRight The right which is to have its manager set to `_managerRight`. @param _managerRight The right whose `UNIVERSAL` holders may manage `_managedRight`. */ function setManagerRight( bytes32 _managedRight, bytes32 _managerRight ) external virtual hasValidPermit(UNIVERSAL, MANAGER) { require(_managedRight != ZERO_RIGHT, "PermitControl: you may not specify a manager for the zero right"); managerRight[_managedRight] = _managerRight; emit ManagementUpdated(_msgSender(), _managedRight, _managerRight); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; /** @title A proxy registry contract. @author Protinam, Project Wyvern @author Tim Clancy This contract was originally developed by Project Wyvern (https://github.com/ProjectWyvern/) where it currently enjoys great success as a component of the primary exchange contract for OpenSea. It has been modified to support a more modern version of Solidity with associated best practices. The documentation has also been improved to provide more clarity. */ abstract contract StubProxyRegistry { /** This mapping relates an addresses to its own personal `OwnableDelegateProxy` which allow it to proxy functionality to the various callers contained in `authorizedCallers`. */ mapping(address => address) public proxies; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./access/PermitControl.sol"; /** @title An ERC-721IMX item collections global lock contract. @author Qazawat Zirak This contract serves as a global lock for the mintFor function for all deployed 721IMX instances. This prevents bad L2 minting if keys were compromised. */ contract Super721IMXLock is PermitControl { /// The public identifier for the right to execute the toggleMintFor fucntion. bytes32 public constant TOGGLE_MINT_FOR = keccak256("TOGGLE_MINT_FOR"); /// Whether or not the mintFor is disabled bool public mintForLocked; /** An event that gets emitted when the mintForLocked variable is set to true. @param locker The caller who locked the collection. */ event MintForLocked(address indexed locker, uint256 timestamp, bool oldValue, bool newValue); /** An event that gets emitted when the mintForLocked variable is set to false. @param locker The caller who locked the collection. */ event MintForUnlocked(address indexed locker, uint256 timestamp, bool oldValue, bool newValue); /** Construct a new ERC-721 item collections global lock. @param _owner The address of the owner of this contract. */ constructor(address _owner) { if (_owner != owner()) { transferOwnership(_owner); } } /** Toggling control for the mintFor function ability to mint based on mintForLocked variable. */ function toggleMintFor() external hasValidPermit(UNIVERSAL, TOGGLE_MINT_FOR) { bool oldValue = mintForLocked; if (mintForLocked) { mintForLocked = false; emit MintForUnlocked(msg.sender, block.timestamp, oldValue, mintForLocked); } else { mintForLocked = true; emit MintForLocked(msg.sender, block.timestamp, oldValue, mintForLocked); } } } // 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; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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; } }
Validate and perform the mint. Loop through each of the batched IDs to update storage of special balances and circulation balances. Retrieve the group ID from the given item `_id` and check mint. Update storage of special balances and circulating values._holderTokens[address(0)].remove(_ids[i]); Emit event and handle the safety check.
function mintBatch(address _recipient, uint256[] memory _ids, bytes memory _data) public virtual { require(_recipient != address(0), "Super721::mintBatch: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), _recipient, _ids, _asSingletonArray(1), _data); for (uint256 i = 0; i < _ids.length; i++) { require(_hasItemRight(_ids[i], MINT), "Super721::mintBatch: you do not have the right to mint that item"); uint256 shiftedGroupId = (_ids[i] & GROUP_MASK); uint256 groupId = shiftedGroupId >> 128; uint256 mintedItemId = _mintChecker(_ids[i]); balances[mintedItemId][_recipient] = balances[mintedItemId][_recipient] + 1; groupBalances[groupId][_recipient] = groupBalances[groupId][_recipient] + 1; totalBalances[_recipient] = totalBalances[_recipient] + 1; mintCount[mintedItemId] = mintCount[mintedItemId] + 1; circulatingSupply[mintedItemId] = circulatingSupply[mintedItemId] + 1; itemGroups[groupId].mintCount = itemGroups[groupId].mintCount + 1; itemGroups[groupId].circulatingSupply = itemGroups[groupId].circulatingSupply + 1; _holderTokens[_recipient].add(_ids[i]); _tokenOwners.set(_ids[i], _recipient); emit Transfer(address(0), _recipient, _ids[i]); _doSafeTransferAcceptanceCheck(operator, address(0), _recipient, _ids[i], _data); } }
6,003,900
[ 1, 4625, 348, 7953, 560, 30, 225, 3554, 471, 3073, 326, 312, 474, 18, 9720, 3059, 1517, 434, 326, 2581, 329, 7115, 358, 1089, 2502, 434, 4582, 324, 26488, 471, 5886, 1934, 367, 324, 26488, 18, 10708, 326, 1041, 1599, 628, 326, 864, 761, 1375, 67, 350, 68, 471, 866, 312, 474, 18, 2315, 2502, 434, 4582, 324, 26488, 471, 5886, 1934, 1776, 924, 6315, 4505, 5157, 63, 2867, 12, 20, 13, 8009, 4479, 24899, 2232, 63, 77, 19226, 16008, 871, 471, 1640, 326, 24179, 866, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 312, 474, 4497, 12, 2867, 389, 20367, 16, 2254, 5034, 8526, 3778, 389, 2232, 16, 203, 565, 1731, 3778, 389, 892, 13, 203, 565, 1071, 5024, 288, 203, 565, 2583, 24899, 20367, 480, 1758, 12, 20, 3631, 203, 1377, 315, 8051, 27, 5340, 2866, 81, 474, 4497, 30, 312, 474, 358, 326, 3634, 1758, 8863, 203, 203, 565, 1758, 3726, 273, 389, 3576, 12021, 5621, 203, 565, 389, 5771, 1345, 5912, 12, 9497, 16, 1758, 12, 20, 3631, 389, 20367, 16, 389, 2232, 16, 389, 345, 19571, 1076, 12, 21, 3631, 203, 1377, 389, 892, 1769, 203, 203, 565, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 389, 2232, 18, 2469, 31, 277, 27245, 288, 203, 1377, 2583, 24899, 5332, 1180, 4726, 24899, 2232, 63, 77, 6487, 490, 3217, 3631, 203, 3639, 315, 8051, 27, 5340, 2866, 81, 474, 4497, 30, 1846, 741, 486, 1240, 326, 2145, 358, 312, 474, 716, 761, 8863, 203, 203, 1377, 2254, 5034, 21340, 8722, 273, 261, 67, 2232, 63, 77, 65, 473, 13839, 67, 11704, 1769, 203, 1377, 2254, 5034, 6612, 273, 21340, 8722, 1671, 8038, 31, 203, 1377, 2254, 5034, 312, 474, 329, 17673, 273, 389, 81, 474, 8847, 24899, 2232, 63, 77, 19226, 203, 203, 1377, 324, 26488, 63, 81, 474, 329, 17673, 6362, 67, 20367, 65, 273, 324, 26488, 63, 81, 474, 329, 17673, 6362, 67, 20367, 65, 397, 404, 31, 203, 1377, 1041, 38, 26488, 63, 27547, 6362, 67, 20367, 65, 273, 1041, 38, 26488, 63, 27547, 6362, 67, 20367, 65, 397, 404, 31, 203, 1377, 2078, 38, 26488, 63, 67, 20367, 65, 273, 2078, 38, 26488, 63, 67, 20367, 65, 397, 404, 31, 203, 1377, 312, 474, 1380, 63, 81, 474, 329, 17673, 65, 273, 312, 474, 1380, 63, 81, 474, 329, 17673, 65, 397, 404, 31, 203, 1377, 5886, 1934, 1776, 3088, 1283, 63, 81, 474, 329, 17673, 65, 273, 5886, 1934, 1776, 3088, 1283, 63, 81, 474, 329, 17673, 65, 397, 404, 31, 203, 1377, 761, 3621, 63, 27547, 8009, 81, 474, 1380, 273, 761, 3621, 63, 27547, 8009, 81, 474, 1380, 397, 404, 31, 203, 1377, 761, 3621, 63, 27547, 8009, 11614, 1934, 1776, 3088, 1283, 273, 203, 3639, 761, 3621, 63, 27547, 8009, 11614, 1934, 1776, 3088, 1283, 397, 404, 31, 203, 203, 1377, 389, 4505, 5157, 63, 67, 20367, 8009, 1289, 24899, 2232, 63, 77, 19226, 203, 203, 1377, 389, 2316, 5460, 414, 18, 542, 24899, 2232, 63, 77, 6487, 389, 20367, 1769, 203, 4202, 203, 1377, 3626, 12279, 12, 2867, 12, 20, 3631, 389, 20367, 16, 389, 2232, 63, 77, 19226, 203, 1377, 389, 2896, 9890, 5912, 5933, 1359, 1564, 12, 9497, 16, 1758, 12, 20, 3631, 389, 20367, 16, 389, 2232, 63, 77, 6487, 389, 892, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/9001/0xdE9A07E5F1eaF3236e84724e0a221Ce44D7b2657/sources/contracts/N2MTokenCommon.sol
@notice Max amount of NFTs to be hold per address. @return Max per address allowed.
function maxPerAddress() external view override returns (uint16) { return _maxPerAddress; }
11,532,179
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 4238, 3844, 434, 423, 4464, 87, 358, 506, 6887, 1534, 1758, 18, 632, 2463, 4238, 1534, 1758, 2935, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 943, 2173, 1887, 1435, 3903, 1476, 3849, 1135, 261, 11890, 2313, 13, 288, 203, 3639, 327, 389, 1896, 2173, 1887, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.6.1; // import "@openzeppelin/contracts/math/SafeMath.sol"; // import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; // import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import "../AvaloanERC20.sol"; contract AvaloanTestToken is ERC20, ERC20Detailed { constructor() ERC20Detailed("AvaloanTestToken", "ATT", 18) public { _mint(msg.sender, 21000000000000000000000000); } } contract AvaloanERC20RecursiveTest { function testInOneContract() external { IERC20 token = new AvaloanTestToken(); // Interest rate 10% AvaloanERC20 avaloan = new AvaloanERC20(10000); // Token and account setup token.approve(address(avaloan), 50000); AvaloanERC20TestAccount account1 = new AvaloanERC20TestAccount(); token.transfer(address(account1), 10000); account1.approve(token, address(avaloan), 10000); AvaloanERC20TestAccount account2 = new AvaloanERC20TestAccount(); token.transfer(address(account2), 500); account2.approve(token, address(avaloan), 500); // Lender map setup AvaloanERC20TestLenderMap lenderMap = new AvaloanERC20TestLenderMap(); lenderMap.addLender(address(this), 50000, 55000, avaloan, address(account1)); lenderMap.addLender(address(account1), 10000, 11000, avaloan, address(account2)); lenderMap.addLender(address(account2), 500, 550, IAvaloanERC20(0x00), address(0x00)); AvaloanERC20TestRunnerRecursive runner = new AvaloanERC20TestRunnerRecursive(lenderMap); // Send token for interests 5000 + 1000 + 50 to runner token.transfer(address(runner), 6050); avaloan.flashLoan(token, address(this), 50000, runner); } function testInMultipleContracts() external { IERC20 token = new AvaloanTestToken(); // Interest rate 10% AvaloanERC20 avaloan = new AvaloanERC20(10000); // No interest AvaloanERC20 avaloan1 = new AvaloanERC20(0); // Interest rate 50% AvaloanERC20 avaloan2 = new AvaloanERC20(50000); // Token and account setup token.approve(address(avaloan), 50000); AvaloanERC20TestAccount account1 = new AvaloanERC20TestAccount(); token.transfer(address(account1), 10000); account1.approve(token, address(avaloan1), 10000); AvaloanERC20TestAccount account2 = new AvaloanERC20TestAccount(); token.transfer(address(account2), 500); account2.approve(token, address(avaloan2), 500); // Lender map setup AvaloanERC20TestLenderMap lenderMap = new AvaloanERC20TestLenderMap(); // Interest rate 10% lenderMap.addLender(address(this), 50000, 55000, avaloan1, address(account1)); // No interest lenderMap.addLender(address(account1), 10000, 10000, avaloan2, address(account2)); // Interest rate 50% lenderMap.addLender(address(account2), 500, 750, IAvaloanERC20(0x00), address(0x00)); AvaloanERC20TestRunnerRecursive runner = new AvaloanERC20TestRunnerRecursive(lenderMap); // Send token for interests 5000 + 0 + 250 to runner token.transfer(address(runner), 5250); avaloan.flashLoan(token, address(this), 50000, runner); } } contract AvaloanERC20TestLenderMap { struct LenderInfo { uint256 amount; uint256 payback; IAvaloanERC20 nextAvaloan; address nextLender; } mapping (address => LenderInfo) public lenders; function addLender(address lender, uint256 amount, uint256 payback, IAvaloanERC20 nextAvaloan, address nextLender) external { lenders[lender] = LenderInfo(amount, payback, nextAvaloan, nextLender); } } contract AvaloanERC20TestAccount { using SafeERC20 for IERC20; function approve(IERC20 token, address spender, uint256 amount) external { token.safeApprove(spender, amount); } } contract AvaloanERC20TestRunnerRecursive is ILoanRunner { event DoSomething(uint256 totalBalance); using SafeMath for uint256; AvaloanERC20TestLenderMap public lenderMap; constructor(AvaloanERC20TestLenderMap newLenderMap) public { lenderMap = newLenderMap; } function loanRunner(IERC20 token, address lender, uint256 /* amount */) external override { (uint256 amount, uint256 payback, IAvaloanERC20 nextAvaloan, address nextLender) = lenderMap.lenders(lender); if (amount == 0) { // entry not found return; } if (nextLender == address(0x0)) { // No next lender, do something emit DoSomething(token.balanceOf(address(this))); } else { // Has next lender, recursively loan (uint256 nextAmount,,,) = lenderMap.lenders(nextLender); nextAvaloan.flashLoan(token, nextLender, nextAmount, this); } // Pay back token.transfer(lender, payback); } }
Interest rate 10% Token and account setup Lender map setup Send token for interests 5000 + 1000 + 50 to runner
function testInOneContract() external { IERC20 token = new AvaloanTestToken(); AvaloanERC20 avaloan = new AvaloanERC20(10000); token.approve(address(avaloan), 50000); AvaloanERC20TestAccount account1 = new AvaloanERC20TestAccount(); token.transfer(address(account1), 10000); account1.approve(token, address(avaloan), 10000); AvaloanERC20TestAccount account2 = new AvaloanERC20TestAccount(); token.transfer(address(account2), 500); account2.approve(token, address(avaloan), 500); AvaloanERC20TestLenderMap lenderMap = new AvaloanERC20TestLenderMap(); lenderMap.addLender(address(this), 50000, 55000, avaloan, address(account1)); lenderMap.addLender(address(account1), 10000, 11000, avaloan, address(account2)); lenderMap.addLender(address(account2), 500, 550, IAvaloanERC20(0x00), address(0x00)); AvaloanERC20TestRunnerRecursive runner = new AvaloanERC20TestRunnerRecursive(lenderMap); token.transfer(address(runner), 6050); avaloan.flashLoan(token, address(this), 50000, runner); }
12,567,868
[ 1, 4625, 348, 7953, 560, 30, 225, 5294, 395, 4993, 1728, 9, 3155, 471, 2236, 3875, 511, 2345, 852, 3875, 2479, 1147, 364, 16513, 87, 20190, 397, 4336, 397, 6437, 358, 8419, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1842, 382, 3335, 8924, 1435, 3903, 288, 203, 3639, 467, 654, 39, 3462, 1147, 273, 394, 432, 1125, 83, 304, 4709, 1345, 5621, 203, 3639, 432, 1125, 83, 304, 654, 39, 3462, 279, 1125, 83, 304, 273, 394, 432, 1125, 83, 304, 654, 39, 3462, 12, 23899, 1769, 203, 203, 3639, 1147, 18, 12908, 537, 12, 2867, 12, 842, 287, 83, 304, 3631, 1381, 2787, 1769, 203, 203, 3639, 432, 1125, 83, 304, 654, 39, 3462, 4709, 3032, 2236, 21, 273, 394, 432, 1125, 83, 304, 654, 39, 3462, 4709, 3032, 5621, 203, 3639, 1147, 18, 13866, 12, 2867, 12, 4631, 21, 3631, 12619, 1769, 203, 3639, 2236, 21, 18, 12908, 537, 12, 2316, 16, 1758, 12, 842, 287, 83, 304, 3631, 12619, 1769, 203, 203, 3639, 432, 1125, 83, 304, 654, 39, 3462, 4709, 3032, 2236, 22, 273, 394, 432, 1125, 83, 304, 654, 39, 3462, 4709, 3032, 5621, 203, 3639, 1147, 18, 13866, 12, 2867, 12, 4631, 22, 3631, 6604, 1769, 203, 3639, 2236, 22, 18, 12908, 537, 12, 2316, 16, 1758, 12, 842, 287, 83, 304, 3631, 6604, 1769, 203, 203, 3639, 432, 1125, 83, 304, 654, 39, 3462, 4709, 48, 2345, 863, 328, 2345, 863, 273, 394, 432, 1125, 83, 304, 654, 39, 3462, 4709, 48, 2345, 863, 5621, 203, 3639, 328, 2345, 863, 18, 1289, 48, 2345, 12, 2867, 12, 2211, 3631, 1381, 2787, 16, 21483, 3784, 16, 279, 1125, 83, 304, 16, 1758, 12, 4631, 21, 10019, 203, 3639, 328, 2345, 863, 18, 1289, 48, 2345, 12, 2867, 12, 4631, 21, 3631, 12619, 16, 4648, 3784, 16, 279, 1125, 83, 304, 16, 1758, 12, 4631, 22, 10019, 203, 3639, 328, 2345, 863, 18, 1289, 48, 2345, 12, 2867, 12, 4631, 22, 3631, 6604, 16, 1381, 3361, 16, 467, 37, 1125, 83, 304, 654, 39, 3462, 12, 20, 92, 713, 3631, 1758, 12, 20, 92, 713, 10019, 203, 203, 3639, 432, 1125, 83, 304, 654, 39, 3462, 4709, 9709, 10483, 8419, 273, 394, 432, 1125, 83, 304, 654, 39, 3462, 4709, 9709, 10483, 12, 80, 2345, 863, 1769, 203, 3639, 1147, 18, 13866, 12, 2867, 12, 18156, 3631, 4752, 3361, 1769, 203, 203, 3639, 279, 1125, 83, 304, 18, 13440, 1504, 304, 12, 2316, 16, 1758, 12, 2211, 3631, 1381, 2787, 16, 8419, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@bancor/token-governance/contracts/ITokenGovernance.sol"; import "../utility/interfaces/ICheckpointStore.sol"; import "../utility/MathEx.sol"; import "../utility/Types.sol"; import "../utility/Time.sol"; import "../utility/Utils.sol"; import "../utility/Owned.sol"; import "../token/interfaces/IDSToken.sol"; import "../token/ReserveToken.sol"; import "../converter/interfaces/IConverterAnchor.sol"; import "../converter/interfaces/IConverter.sol"; import "../converter/interfaces/IConverterRegistry.sol"; import "./interfaces/ILiquidityProtection.sol"; interface ILiquidityPoolConverter is IConverter { function addLiquidity( IReserveToken[] memory reserveTokens, uint256[] memory reserveAmounts, uint256 _minReturn ) external payable; function removeLiquidity( uint256 amount, IReserveToken[] memory reserveTokens, uint256[] memory _reserveMinReturnAmounts ) external; function recentAverageRate(IReserveToken reserveToken) external view returns (uint256, uint256); } /** * @dev This contract implements the liquidity protection mechanism. */ contract LiquidityProtection is ILiquidityProtection, Utils, Owned, ReentrancyGuard, Time { using SafeMath for uint256; using ReserveToken for IReserveToken; using SafeERC20 for IERC20; using SafeERC20 for IDSToken; using SafeERC20Ex for IERC20; using MathEx for *; struct Position { address provider; // liquidity provider IDSToken poolToken; // pool token address IReserveToken reserveToken; // reserve token address uint256 poolAmount; // pool token amount uint256 reserveAmount; // reserve token amount uint256 reserveRateN; // rate of 1 protected reserve token in units of the other reserve token (numerator) uint256 reserveRateD; // rate of 1 protected reserve token in units of the other reserve token (denominator) uint256 timestamp; // timestamp } // various rates between the two reserve tokens. the rate is of 1 unit of the protected reserve token in units of the other reserve token struct PackedRates { uint128 addSpotRateN; // spot rate of 1 A in units of B when liquidity was added (numerator) uint128 addSpotRateD; // spot rate of 1 A in units of B when liquidity was added (denominator) uint128 removeSpotRateN; // spot rate of 1 A in units of B when liquidity is removed (numerator) uint128 removeSpotRateD; // spot rate of 1 A in units of B when liquidity is removed (denominator) uint128 removeAverageRateN; // average rate of 1 A in units of B when liquidity is removed (numerator) uint128 removeAverageRateD; // average rate of 1 A in units of B when liquidity is removed (denominator) } uint256 internal constant MAX_UINT128 = 2**128 - 1; uint256 internal constant MAX_UINT256 = uint256(-1); ILiquidityProtectionSettings private immutable _settings; ILiquidityProtectionStore private immutable _store; ILiquidityProtectionStats private immutable _stats; ILiquidityProtectionSystemStore private immutable _systemStore; ITokenHolder private immutable _wallet; IERC20 private immutable _networkToken; ITokenGovernance private immutable _networkTokenGovernance; IERC20 private immutable _govToken; ITokenGovernance private immutable _govTokenGovernance; ICheckpointStore private immutable _lastRemoveCheckpointStore; /** * @dev initializes a new LiquidityProtection contract * * @param settings liquidity protection settings * @param store liquidity protection store * @param stats liquidity protection stats * @param systemStore liquidity protection system store * @param wallet liquidity protection wallet * @param networkTokenGovernance network token governance * @param govTokenGovernance governance token governance * @param lastRemoveCheckpointStore last liquidity removal/unprotection checkpoints store */ constructor( ILiquidityProtectionSettings settings, ILiquidityProtectionStore store, ILiquidityProtectionStats stats, ILiquidityProtectionSystemStore systemStore, ITokenHolder wallet, ITokenGovernance networkTokenGovernance, ITokenGovernance govTokenGovernance, ICheckpointStore lastRemoveCheckpointStore ) public validAddress(address(settings)) validAddress(address(store)) validAddress(address(stats)) validAddress(address(systemStore)) validAddress(address(wallet)) validAddress(address(lastRemoveCheckpointStore)) { _settings = settings; _store = store; _stats = stats; _systemStore = systemStore; _wallet = wallet; _networkTokenGovernance = networkTokenGovernance; _govTokenGovernance = govTokenGovernance; _lastRemoveCheckpointStore = lastRemoveCheckpointStore; _networkToken = networkTokenGovernance.token(); _govToken = govTokenGovernance.token(); } // ensures that the pool is supported and whitelisted modifier poolSupportedAndWhitelisted(IConverterAnchor poolAnchor) { _poolSupported(poolAnchor); _poolWhitelisted(poolAnchor); _; } // ensures that add liquidity is enabled modifier addLiquidityEnabled(IConverterAnchor poolAnchor, IReserveToken reserveToken) { _addLiquidityEnabled(poolAnchor, reserveToken); _; } // error message binary size optimization function _poolSupported(IConverterAnchor poolAnchor) internal view { require(_settings.isPoolSupported(poolAnchor), "ERR_POOL_NOT_SUPPORTED"); } // error message binary size optimization function _poolWhitelisted(IConverterAnchor poolAnchor) internal view { require(_settings.isPoolWhitelisted(poolAnchor), "ERR_POOL_NOT_WHITELISTED"); } // error message binary size optimization function _addLiquidityEnabled(IConverterAnchor poolAnchor, IReserveToken reserveToken) internal view { require(!_settings.addLiquidityDisabled(poolAnchor, reserveToken), "ERR_ADD_LIQUIDITY_DISABLED"); } // error message binary size optimization function verifyEthAmount(uint256 value) internal view { require(msg.value == value, "ERR_ETH_AMOUNT_MISMATCH"); } /** * @dev returns the LP store * * @return the LP store */ function store() external view override returns (ILiquidityProtectionStore) { return _store; } /** * @dev returns the LP stats * * @return the LP stats */ function stats() external view override returns (ILiquidityProtectionStats) { return _stats; } /** * @dev returns the LP settings * * @return the LP settings */ function settings() external view override returns (ILiquidityProtectionSettings) { return _settings; } /** * @dev returns the LP system store * * @return the LP system store */ function systemStore() external view override returns (ILiquidityProtectionSystemStore) { return _systemStore; } /** * @dev returns the LP wallet * * @return the LP wallet */ function wallet() external view override returns (ITokenHolder) { return _wallet; } /** * @dev accept ETH */ receive() external payable {} /** * @dev transfers the ownership of the store * can only be called by the contract owner * * @param newOwner the new owner of the store */ function transferStoreOwnership(address newOwner) external ownerOnly { _store.transferOwnership(newOwner); } /** * @dev accepts the ownership of the store * can only be called by the contract owner */ function acceptStoreOwnership() external ownerOnly { _store.acceptOwnership(); } /** * @dev transfers the ownership of the wallet * can only be called by the contract owner * * @param newOwner the new owner of the wallet */ function transferWalletOwnership(address newOwner) external ownerOnly { _wallet.transferOwnership(newOwner); } /** * @dev accepts the ownership of the wallet * can only be called by the contract owner */ function acceptWalletOwnership() external ownerOnly { _wallet.acceptOwnership(); } /** * @dev adds protected liquidity to a pool for a specific recipient * also mints new governance tokens for the caller if the caller adds network tokens * * @param owner position owner * @param poolAnchor anchor of the pool * @param reserveToken reserve token to add to the pool * @param amount amount of tokens to add to the pool * * @return new position id */ function addLiquidityFor( address owner, IConverterAnchor poolAnchor, IReserveToken reserveToken, uint256 amount ) external payable override nonReentrant validAddress(owner) poolSupportedAndWhitelisted(poolAnchor) addLiquidityEnabled(poolAnchor, reserveToken) greaterThanZero(amount) returns (uint256) { return addLiquidity(owner, poolAnchor, reserveToken, amount); } /** * @dev adds protected liquidity to a pool * also mints new governance tokens for the caller if the caller adds network tokens * * @param poolAnchor anchor of the pool * @param reserveToken reserve token to add to the pool * @param amount amount of tokens to add to the pool * * @return new position id */ function addLiquidity( IConverterAnchor poolAnchor, IReserveToken reserveToken, uint256 amount ) external payable override nonReentrant poolSupportedAndWhitelisted(poolAnchor) addLiquidityEnabled(poolAnchor, reserveToken) greaterThanZero(amount) returns (uint256) { return addLiquidity(msg.sender, poolAnchor, reserveToken, amount); } /** * @dev adds protected liquidity to a pool for a specific recipient * also mints new governance tokens for the caller if the caller adds network tokens * * @param owner position owner * @param poolAnchor anchor of the pool * @param reserveToken reserve token to add to the pool * @param amount amount of tokens to add to the pool * * @return new position id */ function addLiquidity( address owner, IConverterAnchor poolAnchor, IReserveToken reserveToken, uint256 amount ) private returns (uint256) { if (isNetworkToken(reserveToken)) { verifyEthAmount(0); return addNetworkTokenLiquidity(owner, poolAnchor, amount); } // verify that ETH was passed with the call if needed verifyEthAmount(reserveToken.isNativeToken() ? amount : 0); return addBaseTokenLiquidity(owner, poolAnchor, reserveToken, amount); } /** * @dev adds network token liquidity to a pool * also mints new governance tokens for the caller * * @param owner position owner * @param poolAnchor anchor of the pool * @param amount amount of tokens to add to the pool * * @return new position id */ function addNetworkTokenLiquidity( address owner, IConverterAnchor poolAnchor, uint256 amount ) internal returns (uint256) { IDSToken poolToken = IDSToken(address(poolAnchor)); IReserveToken networkToken = IReserveToken(address(_networkToken)); // get the rate between the pool token and the reserve Fraction memory poolRate = poolTokenRate(poolToken, networkToken); // calculate the amount of pool tokens based on the amount of reserve tokens uint256 poolTokenAmount = amount.mul(poolRate.d).div(poolRate.n); // remove the pool tokens from the system's ownership (will revert if not enough tokens are available) _systemStore.decSystemBalance(poolToken, poolTokenAmount); // add the position for the recipient uint256 id = addPosition(owner, poolToken, networkToken, poolTokenAmount, amount, time()); // burns the network tokens from the caller. we need to transfer the tokens to the contract itself, since only // token holders can burn their tokens _networkToken.safeTransferFrom(msg.sender, address(this), amount); burnNetworkTokens(poolAnchor, amount); // mint governance tokens to the recipient _govTokenGovernance.mint(owner, amount); return id; } /** * @dev adds base token liquidity to a pool * * @param owner position owner * @param poolAnchor anchor of the pool * @param baseToken the base reserve token of the pool * @param amount amount of tokens to add to the pool * * @return new position id */ function addBaseTokenLiquidity( address owner, IConverterAnchor poolAnchor, IReserveToken baseToken, uint256 amount ) internal returns (uint256) { IDSToken poolToken = IDSToken(address(poolAnchor)); IReserveToken networkToken = IReserveToken(address(_networkToken)); // get the reserve balances ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(ownedBy(poolAnchor))); (uint256 reserveBalanceBase, uint256 reserveBalanceNetwork) = converterReserveBalances(converter, baseToken, networkToken); require(reserveBalanceNetwork >= _settings.minNetworkTokenLiquidityForMinting(), "ERR_NOT_ENOUGH_LIQUIDITY"); // calculate and mint the required amount of network tokens for adding liquidity uint256 newNetworkLiquidityAmount = amount.mul(reserveBalanceNetwork).div(reserveBalanceBase); // verify network token minting limit uint256 mintingLimit = _settings.networkTokenMintingLimits(poolAnchor); if (mintingLimit == 0) { mintingLimit = _settings.defaultNetworkTokenMintingLimit(); } uint256 newNetworkTokensMinted = _systemStore.networkTokensMinted(poolAnchor).add(newNetworkLiquidityAmount); require(newNetworkTokensMinted <= mintingLimit, "ERR_MAX_AMOUNT_REACHED"); // issue new network tokens to the system mintNetworkTokens(address(this), poolAnchor, newNetworkLiquidityAmount); // transfer the base tokens from the caller and approve the converter networkToken.ensureApprove(address(converter), newNetworkLiquidityAmount); if (!baseToken.isNativeToken()) { baseToken.safeTransferFrom(msg.sender, address(this), amount); baseToken.ensureApprove(address(converter), amount); } // add the liquidity to the converter addLiquidity(converter, baseToken, networkToken, amount, newNetworkLiquidityAmount, msg.value); // transfer the new pool tokens to the wallet uint256 poolTokenAmount = poolToken.balanceOf(address(this)); poolToken.safeTransfer(address(_wallet), poolTokenAmount); // the system splits the pool tokens with the caller // increase the system's pool token balance and add the position for the caller _systemStore.incSystemBalance(poolToken, poolTokenAmount - poolTokenAmount / 2); // account for rounding errors return addPosition(owner, poolToken, baseToken, poolTokenAmount / 2, amount, time()); } /** * @dev returns the single-side staking limits of a given pool * * @param poolAnchor anchor of the pool * * @return maximum amount of base tokens that can be single-side staked in the pool * @return maximum amount of network tokens that can be single-side staked in the pool */ function poolAvailableSpace(IConverterAnchor poolAnchor) external view poolSupportedAndWhitelisted(poolAnchor) returns (uint256, uint256) { return (baseTokenAvailableSpace(poolAnchor), networkTokenAvailableSpace(poolAnchor)); } /** * @dev returns the base-token staking limits of a given pool * * @param poolAnchor anchor of the pool * * @return maximum amount of base tokens that can be single-side staked in the pool */ function baseTokenAvailableSpace(IConverterAnchor poolAnchor) internal view returns (uint256) { // get the pool converter ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(ownedBy(poolAnchor))); // get the base token IReserveToken networkToken = IReserveToken(address(_networkToken)); IReserveToken baseToken = converterOtherReserve(converter, networkToken); // get the reserve balances (uint256 reserveBalanceBase, uint256 reserveBalanceNetwork) = converterReserveBalances(converter, baseToken, networkToken); // get the network token minting limit uint256 mintingLimit = _settings.networkTokenMintingLimits(poolAnchor); if (mintingLimit == 0) { mintingLimit = _settings.defaultNetworkTokenMintingLimit(); } // get the amount of network tokens already minted for the pool uint256 networkTokensMinted = _systemStore.networkTokensMinted(poolAnchor); // get the amount of network tokens which can minted for the pool uint256 networkTokensCanBeMinted = MathEx.max(mintingLimit, networkTokensMinted) - networkTokensMinted; // return the maximum amount of base token liquidity that can be single-sided staked in the pool return networkTokensCanBeMinted.mul(reserveBalanceBase).div(reserveBalanceNetwork); } /** * @dev returns the network-token staking limits of a given pool * * @param poolAnchor anchor of the pool * * @return maximum amount of network tokens that can be single-side staked in the pool */ function networkTokenAvailableSpace(IConverterAnchor poolAnchor) internal view returns (uint256) { // get the pool token IDSToken poolToken = IDSToken(address(poolAnchor)); IReserveToken networkToken = IReserveToken(address(_networkToken)); // get the pool token rate Fraction memory poolRate = poolTokenRate(poolToken, networkToken); // return the maximum amount of network token liquidity that can be single-sided staked in the pool return _systemStore.systemBalance(poolToken).mul(poolRate.n).add(poolRate.n).sub(1).div(poolRate.d); } /** * @dev returns the expected/actual amounts the provider will receive for removing liquidity * it's also possible to provide the remove liquidity time to get an estimation * for the return at that given point * * @param id position id * @param portion portion of liquidity to remove, in PPM * @param removeTimestamp time at which the liquidity is removed * * @return expected return amount in the reserve token * @return actual return amount in the reserve token * @return compensation in the network token */ function removeLiquidityReturn( uint256 id, uint32 portion, uint256 removeTimestamp ) external view validPortion(portion) returns ( uint256, uint256, uint256 ) { Position memory pos = position(id); // verify input require(pos.provider != address(0), "ERR_INVALID_ID"); require(removeTimestamp >= pos.timestamp, "ERR_INVALID_TIMESTAMP"); // calculate the portion of the liquidity to remove if (portion != PPM_RESOLUTION) { pos.poolAmount = pos.poolAmount.mul(portion) / PPM_RESOLUTION; pos.reserveAmount = pos.reserveAmount.mul(portion) / PPM_RESOLUTION; } // get the various rates between the reserves upon adding liquidity and now PackedRates memory packedRates = packRates(pos.poolToken, pos.reserveToken, pos.reserveRateN, pos.reserveRateD); uint256 targetAmount = removeLiquidityTargetAmount( pos.poolToken, pos.reserveToken, pos.poolAmount, pos.reserveAmount, packedRates, pos.timestamp, removeTimestamp ); // for network token, the return amount is identical to the target amount if (isNetworkToken(pos.reserveToken)) { return (targetAmount, targetAmount, 0); } // handle base token return // calculate the amount of pool tokens required for liquidation // note that the amount is doubled since it's not possible to liquidate one reserve only Fraction memory poolRate = poolTokenRate(pos.poolToken, pos.reserveToken); uint256 poolAmount = targetAmount.mul(poolRate.d).div(poolRate.n / 2); // limit the amount of pool tokens by the amount the system/caller holds uint256 availableBalance = _systemStore.systemBalance(pos.poolToken).add(pos.poolAmount); poolAmount = poolAmount > availableBalance ? availableBalance : poolAmount; // calculate the base token amount received by liquidating the pool tokens // note that the amount is divided by 2 since the pool amount represents both reserves uint256 baseAmount = poolAmount.mul(poolRate.n / 2).div(poolRate.d); uint256 networkAmount = networkCompensation(targetAmount, baseAmount, packedRates); return (targetAmount, baseAmount, networkAmount); } /** * @dev removes protected liquidity from a pool * also burns governance tokens from the caller if the caller removes network tokens * * @param id position id * @param portion portion of liquidity to remove, in PPM */ function removeLiquidity(uint256 id, uint32 portion) external override nonReentrant validPortion(portion) { removeLiquidity(msg.sender, id, portion); } /** * @dev removes a position from a pool * also burns governance tokens from the caller if the caller removes network tokens * * @param provider liquidity provider * @param id position id * @param portion portion of liquidity to remove, in PPM */ function removeLiquidity( address payable provider, uint256 id, uint32 portion ) internal { // remove the position from the store and update the stats and the last removal checkpoint Position memory removedPos = removePosition(provider, id, portion); // add the pool tokens to the system _systemStore.incSystemBalance(removedPos.poolToken, removedPos.poolAmount); // if removing network token liquidity, burn the governance tokens from the caller. we need to transfer the // tokens to the contract itself, since only token holders can burn their tokens if (isNetworkToken(removedPos.reserveToken)) { _govToken.safeTransferFrom(provider, address(this), removedPos.reserveAmount); _govTokenGovernance.burn(removedPos.reserveAmount); } // get the various rates between the reserves upon adding liquidity and now PackedRates memory packedRates = packRates(removedPos.poolToken, removedPos.reserveToken, removedPos.reserveRateN, removedPos.reserveRateD); // verify rate deviation as early as possible in order to reduce gas-cost for failing transactions verifyRateDeviation( packedRates.removeSpotRateN, packedRates.removeSpotRateD, packedRates.removeAverageRateN, packedRates.removeAverageRateD ); // get the target token amount uint256 targetAmount = removeLiquidityTargetAmount( removedPos.poolToken, removedPos.reserveToken, removedPos.poolAmount, removedPos.reserveAmount, packedRates, removedPos.timestamp, time() ); // remove network token liquidity if (isNetworkToken(removedPos.reserveToken)) { // mint network tokens for the caller and lock them mintNetworkTokens(address(_wallet), removedPos.poolToken, targetAmount); lockTokens(provider, targetAmount); return; } // remove base token liquidity // calculate the amount of pool tokens required for liquidation // note that the amount is doubled since it's not possible to liquidate one reserve only Fraction memory poolRate = poolTokenRate(removedPos.poolToken, removedPos.reserveToken); uint256 poolAmount = targetAmount.mul(poolRate.d).div(poolRate.n / 2); // limit the amount of pool tokens by the amount the system holds uint256 systemBalance = _systemStore.systemBalance(removedPos.poolToken); poolAmount = poolAmount > systemBalance ? systemBalance : poolAmount; // withdraw the pool tokens from the wallet IReserveToken poolToken = IReserveToken(address(removedPos.poolToken)); _systemStore.decSystemBalance(removedPos.poolToken, poolAmount); _wallet.withdrawTokens(poolToken, address(this), poolAmount); // remove liquidity removeLiquidity( removedPos.poolToken, poolAmount, removedPos.reserveToken, IReserveToken(address(_networkToken)) ); // transfer the base tokens to the caller uint256 baseBalance = removedPos.reserveToken.balanceOf(address(this)); removedPos.reserveToken.safeTransfer(provider, baseBalance); // compensate the caller with network tokens if still needed uint256 delta = networkCompensation(targetAmount, baseBalance, packedRates); if (delta > 0) { // check if there's enough network token balance, otherwise mint more uint256 networkBalance = _networkToken.balanceOf(address(this)); if (networkBalance < delta) { _networkTokenGovernance.mint(address(this), delta - networkBalance); } // lock network tokens for the caller _networkToken.safeTransfer(address(_wallet), delta); lockTokens(provider, delta); } // if the contract still holds network tokens, burn them uint256 networkBalance = _networkToken.balanceOf(address(this)); if (networkBalance > 0) { burnNetworkTokens(removedPos.poolToken, networkBalance); } } /** * @dev returns the amount the provider will receive for removing liquidity * it's also possible to provide the remove liquidity rate & time to get an estimation * for the return at that given point * * @param poolToken pool token * @param reserveToken reserve token * @param poolAmount pool token amount when the liquidity was added * @param reserveAmount reserve token amount that was added * @param packedRates see `struct PackedRates` * @param addTimestamp time at which the liquidity was added * @param removeTimestamp time at which the liquidity is removed * * @return amount received for removing liquidity */ function removeLiquidityTargetAmount( IDSToken poolToken, IReserveToken reserveToken, uint256 poolAmount, uint256 reserveAmount, PackedRates memory packedRates, uint256 addTimestamp, uint256 removeTimestamp ) internal view returns (uint256) { // get the rate between the pool token and the reserve token Fraction memory poolRate = poolTokenRate(poolToken, reserveToken); // get the rate between the reserves upon adding liquidity and now Fraction memory addSpotRate = Fraction({ n: packedRates.addSpotRateN, d: packedRates.addSpotRateD }); Fraction memory removeSpotRate = Fraction({ n: packedRates.removeSpotRateN, d: packedRates.removeSpotRateD }); Fraction memory removeAverageRate = Fraction({ n: packedRates.removeAverageRateN, d: packedRates.removeAverageRateD }); // calculate the protected amount of reserve tokens plus accumulated fee before compensation uint256 total = protectedAmountPlusFee(poolAmount, poolRate, addSpotRate, removeSpotRate); // calculate the impermanent loss Fraction memory loss = impLoss(addSpotRate, removeAverageRate); // calculate the protection level Fraction memory level = protectionLevel(addTimestamp, removeTimestamp); // calculate the compensation amount return compensationAmount(reserveAmount, MathEx.max(reserveAmount, total), loss, level); } /** * @dev transfers a position to a new provider * * @param id position id * @param newProvider the new provider * * @return new position id */ function transferPosition(uint256 id, address newProvider) external override nonReentrant validAddress(newProvider) returns (uint256) { return transferPosition(msg.sender, id, newProvider); } /** * @dev transfers a position to a new provider and optionally notifies another contract * * @param id position id * @param newProvider the new provider * @param callback the callback contract to notify * @param data custom data provided to the callback * * @return new position id */ function transferPositionAndNotify( uint256 id, address newProvider, ITransferPositionCallback callback, bytes calldata data ) external override nonReentrant validAddress(newProvider) validAddress(address(callback)) returns (uint256) { uint256 newId = transferPosition(msg.sender, id, newProvider); callback.onTransferPosition(newId, msg.sender, data); return newId; } /** * @dev transfers a position to a new provider * * @param provider the existing provider * @param id position id * @param newProvider the new provider * * @return new position id */ function transferPosition( address provider, uint256 id, address newProvider ) internal returns (uint256) { // remove the position from the store and update the stats and the last removal checkpoint Position memory removedPos = removePosition(provider, id, PPM_RESOLUTION); // add the position to the store, update the stats, and return the new id return addPosition( newProvider, removedPos.poolToken, removedPos.reserveToken, removedPos.poolAmount, removedPos.reserveAmount, removedPos.timestamp ); } /** * @dev allows the caller to claim network token balance that is no longer locked * note that the function can revert if the range is too large * * @param startIndex start index in the caller's list of locked balances * @param endIndex end index in the caller's list of locked balances (exclusive) */ function claimBalance(uint256 startIndex, uint256 endIndex) external nonReentrant { // get the locked balances from the store (uint256[] memory amounts, uint256[] memory expirationTimes) = _store.lockedBalanceRange(msg.sender, startIndex, endIndex); uint256 totalAmount = 0; uint256 length = amounts.length; assert(length == expirationTimes.length); // reverse iteration since we're removing from the list for (uint256 i = length; i > 0; i--) { uint256 index = i - 1; if (expirationTimes[index] > time()) { continue; } // remove the locked balance item _store.removeLockedBalance(msg.sender, startIndex + index); totalAmount = totalAmount.add(amounts[index]); } if (totalAmount > 0) { // transfer the tokens to the caller in a single call _wallet.withdrawTokens(IReserveToken(address(_networkToken)), msg.sender, totalAmount); } } /** * @dev returns the ROI for removing liquidity in the current state after providing liquidity with the given args * the function assumes full protection is in effect * return value is in PPM and can be larger than PPM_RESOLUTION for positive ROI, 1M = 0% ROI * * @param poolToken pool token * @param reserveToken reserve token * @param reserveAmount reserve token amount that was added * @param poolRateN rate of 1 pool token in reserve token units when the liquidity was added (numerator) * @param poolRateD rate of 1 pool token in reserve token units when the liquidity was added (denominator) * @param reserveRateN rate of 1 reserve token in the other reserve token units when the liquidity was added (numerator) * @param reserveRateD rate of 1 reserve token in the other reserve token units when the liquidity was added (denominator) * * @return ROI in PPM */ function poolROI( IDSToken poolToken, IReserveToken reserveToken, uint256 reserveAmount, uint256 poolRateN, uint256 poolRateD, uint256 reserveRateN, uint256 reserveRateD ) external view returns (uint256) { // calculate the amount of pool tokens based on the amount of reserve tokens uint256 poolAmount = reserveAmount.mul(poolRateD).div(poolRateN); // get the various rates between the reserves upon adding liquidity and now PackedRates memory packedRates = packRates(poolToken, reserveToken, reserveRateN, reserveRateD); // get the current return uint256 protectedReturn = removeLiquidityTargetAmount( poolToken, reserveToken, poolAmount, reserveAmount, packedRates, time().sub(_settings.maxProtectionDelay()), time() ); // calculate the ROI as the ratio between the current fully protected return and the initial amount return protectedReturn.mul(PPM_RESOLUTION).div(reserveAmount); } /** * @dev adds the position to the store and updates the stats * * @param provider the provider * @param poolToken pool token * @param reserveToken reserve token * @param poolAmount amount of pool tokens to protect * @param reserveAmount amount of reserve tokens to protect * @param timestamp the timestamp of the position * * @return new position id */ function addPosition( address provider, IDSToken poolToken, IReserveToken reserveToken, uint256 poolAmount, uint256 reserveAmount, uint256 timestamp ) internal returns (uint256) { // verify rate deviation as early as possible in order to reduce gas-cost for failing transactions (Fraction memory spotRate, Fraction memory averageRate) = reserveTokenRates(poolToken, reserveToken); verifyRateDeviation(spotRate.n, spotRate.d, averageRate.n, averageRate.d); notifyEventSubscribersOnAddingLiquidity(provider, poolToken, reserveToken, poolAmount, reserveAmount); _stats.increaseTotalAmounts(provider, poolToken, reserveToken, poolAmount, reserveAmount); _stats.addProviderPool(provider, poolToken); return _store.addProtectedLiquidity( provider, poolToken, reserveToken, poolAmount, reserveAmount, spotRate.n, spotRate.d, timestamp ); } /** * @dev removes the position from the store and updates the stats and the last removal checkpoint * * @param provider the provider * @param id position id * @param portion portion of the position to remove, in PPM * * @return a Position struct representing the removed liquidity */ function removePosition( address provider, uint256 id, uint32 portion ) private returns (Position memory) { Position memory pos = providerPosition(id, provider); // verify that the pool is whitelisted _poolWhitelisted(pos.poolToken); // verify that the position is not removed on the same block in which it was added require(pos.timestamp < time(), "ERR_TOO_EARLY"); if (portion == PPM_RESOLUTION) { notifyEventSubscribersOnRemovingLiquidity( id, pos.provider, pos.poolToken, pos.reserveToken, pos.poolAmount, pos.reserveAmount ); // remove the position from the provider _store.removeProtectedLiquidity(id); } else { // remove a portion of the position from the provider uint256 fullPoolAmount = pos.poolAmount; uint256 fullReserveAmount = pos.reserveAmount; pos.poolAmount = pos.poolAmount.mul(portion) / PPM_RESOLUTION; pos.reserveAmount = pos.reserveAmount.mul(portion) / PPM_RESOLUTION; notifyEventSubscribersOnRemovingLiquidity( id, pos.provider, pos.poolToken, pos.reserveToken, pos.poolAmount, pos.reserveAmount ); _store.updateProtectedLiquidityAmounts( id, fullPoolAmount - pos.poolAmount, fullReserveAmount - pos.reserveAmount ); } // update the statistics _stats.decreaseTotalAmounts(pos.provider, pos.poolToken, pos.reserveToken, pos.poolAmount, pos.reserveAmount); // update last liquidity removal checkpoint _lastRemoveCheckpointStore.addCheckpoint(provider); return pos; } /** * @dev locks network tokens for the provider and emits the tokens locked event * * @param provider tokens provider * @param amount amount of network tokens */ function lockTokens(address provider, uint256 amount) internal { uint256 expirationTime = time().add(_settings.lockDuration()); _store.addLockedBalance(provider, amount, expirationTime); } /** * @dev returns the rate of 1 pool token in reserve token units * * @param poolToken pool token * @param reserveToken reserve token */ function poolTokenRate(IDSToken poolToken, IReserveToken reserveToken) internal view virtual returns (Fraction memory) { // get the pool token supply uint256 poolTokenSupply = poolToken.totalSupply(); // get the reserve balance IConverter converter = IConverter(payable(ownedBy(poolToken))); uint256 reserveBalance = converter.getConnectorBalance(reserveToken); // for standard pools, 50% of the pool supply value equals the value of each reserve return Fraction({ n: reserveBalance.mul(2), d: poolTokenSupply }); } /** * @dev returns the spot rate and average rate of 1 reserve token in the other reserve token units * * @param poolToken pool token * @param reserveToken reserve token * * @return spot rate * @return average rate */ function reserveTokenRates(IDSToken poolToken, IReserveToken reserveToken) internal view returns (Fraction memory, Fraction memory) { ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(ownedBy(poolToken))); IReserveToken otherReserve = converterOtherReserve(converter, reserveToken); (uint256 spotRateN, uint256 spotRateD) = converterReserveBalances(converter, otherReserve, reserveToken); (uint256 averageRateN, uint256 averageRateD) = converter.recentAverageRate(reserveToken); return (Fraction({ n: spotRateN, d: spotRateD }), Fraction({ n: averageRateN, d: averageRateD })); } /** * @dev returns the various rates between the reserves * * @param poolToken pool token * @param reserveToken reserve token * @param addSpotRateN add spot rate numerator * @param addSpotRateD add spot rate denominator * * @return see `struct PackedRates` */ function packRates( IDSToken poolToken, IReserveToken reserveToken, uint256 addSpotRateN, uint256 addSpotRateD ) internal view returns (PackedRates memory) { (Fraction memory removeSpotRate, Fraction memory removeAverageRate) = reserveTokenRates(poolToken, reserveToken); assert( addSpotRateN <= MAX_UINT128 && addSpotRateD <= MAX_UINT128 && removeSpotRate.n <= MAX_UINT128 && removeSpotRate.d <= MAX_UINT128 && removeAverageRate.n <= MAX_UINT128 && removeAverageRate.d <= MAX_UINT128 ); return PackedRates({ addSpotRateN: uint128(addSpotRateN), addSpotRateD: uint128(addSpotRateD), removeSpotRateN: uint128(removeSpotRate.n), removeSpotRateD: uint128(removeSpotRate.d), removeAverageRateN: uint128(removeAverageRate.n), removeAverageRateD: uint128(removeAverageRate.d) }); } /** * @dev verifies that the deviation of the average rate from the spot rate is within the permitted range * for example, if the maximum permitted deviation is 5%, then verify `95/100 <= average/spot <= 100/95` * * @param spotRateN spot rate numerator * @param spotRateD spot rate denominator * @param averageRateN average rate numerator * @param averageRateD average rate denominator */ function verifyRateDeviation( uint256 spotRateN, uint256 spotRateD, uint256 averageRateN, uint256 averageRateD ) internal view { uint256 ppmDelta = PPM_RESOLUTION - _settings.averageRateMaxDeviation(); uint256 min = spotRateN.mul(averageRateD).mul(ppmDelta).mul(ppmDelta); uint256 mid = spotRateD.mul(averageRateN).mul(ppmDelta).mul(PPM_RESOLUTION); uint256 max = spotRateN.mul(averageRateD).mul(PPM_RESOLUTION).mul(PPM_RESOLUTION); require(min <= mid && mid <= max, "ERR_INVALID_RATE"); } /** * @dev utility to add liquidity to a converter * * @param converter converter * @param reserveToken1 reserve token 1 * @param reserveToken2 reserve token 2 * @param reserveAmount1 reserve amount 1 * @param reserveAmount2 reserve amount 2 * @param value ETH amount to add */ function addLiquidity( ILiquidityPoolConverter converter, IReserveToken reserveToken1, IReserveToken reserveToken2, uint256 reserveAmount1, uint256 reserveAmount2, uint256 value ) internal { IReserveToken[] memory reserveTokens = new IReserveToken[](2); uint256[] memory amounts = new uint256[](2); reserveTokens[0] = reserveToken1; reserveTokens[1] = reserveToken2; amounts[0] = reserveAmount1; amounts[1] = reserveAmount2; converter.addLiquidity{ value: value }(reserveTokens, amounts, 1); } /** * @dev utility to remove liquidity from a converter * * @param poolToken pool token of the converter * @param poolAmount amount of pool tokens to remove * @param reserveToken1 reserve token 1 * @param reserveToken2 reserve token 2 */ function removeLiquidity( IDSToken poolToken, uint256 poolAmount, IReserveToken reserveToken1, IReserveToken reserveToken2 ) internal { ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(ownedBy(poolToken))); IReserveToken[] memory reserveTokens = new IReserveToken[](2); uint256[] memory minReturns = new uint256[](2); reserveTokens[0] = reserveToken1; reserveTokens[1] = reserveToken2; minReturns[0] = 1; minReturns[1] = 1; converter.removeLiquidity(poolAmount, reserveTokens, minReturns); } /** * @dev returns a position from the store * * @param id position id * * @return a position */ function position(uint256 id) internal view returns (Position memory) { Position memory pos; ( pos.provider, pos.poolToken, pos.reserveToken, pos.poolAmount, pos.reserveAmount, pos.reserveRateN, pos.reserveRateD, pos.timestamp ) = _store.protectedLiquidity(id); return pos; } /** * @dev returns a position from the store * * @param id position id * @param provider authorized provider * * @return a position */ function providerPosition(uint256 id, address provider) internal view returns (Position memory) { Position memory pos = position(id); require(pos.provider == provider, "ERR_ACCESS_DENIED"); return pos; } /** * @dev returns the protected amount of reserve tokens plus accumulated fee before compensation * * @param poolAmount pool token amount when the liquidity was added * @param poolRate rate of 1 pool token in the related reserve token units * @param addRate rate of 1 reserve token in the other reserve token units when the liquidity was added * @param removeRate rate of 1 reserve token in the other reserve token units when the liquidity is removed * * @return protected amount of reserve tokens plus accumulated fee = sqrt(removeRate / addRate) * poolRate * poolAmount */ function protectedAmountPlusFee( uint256 poolAmount, Fraction memory poolRate, Fraction memory addRate, Fraction memory removeRate ) internal pure returns (uint256) { uint256 n = MathEx.ceilSqrt(addRate.d.mul(removeRate.n)).mul(poolRate.n); uint256 d = MathEx.floorSqrt(addRate.n.mul(removeRate.d)).mul(poolRate.d); uint256 x = n * poolAmount; if (x / n == poolAmount) { return x / d; } (uint256 hi, uint256 lo) = n > poolAmount ? (n, poolAmount) : (poolAmount, n); (uint256 p, uint256 q) = MathEx.reducedRatio(hi, d, MAX_UINT256 / lo); uint256 min = (hi / d).mul(lo); if (q > 0) { return MathEx.max(min, (p * lo) / q); } return min; } /** * @dev returns the impermanent loss incurred due to the change in rates between the reserve tokens * * @param prevRate previous rate between the reserves * @param newRate new rate between the reserves * * @return impermanent loss (as a ratio) */ function impLoss(Fraction memory prevRate, Fraction memory newRate) internal pure returns (Fraction memory) { uint256 ratioN = newRate.n.mul(prevRate.d); uint256 ratioD = newRate.d.mul(prevRate.n); uint256 prod = ratioN * ratioD; uint256 root = prod / ratioN == ratioD ? MathEx.floorSqrt(prod) : MathEx.floorSqrt(ratioN) * MathEx.floorSqrt(ratioD); uint256 sum = ratioN.add(ratioD); // the arithmetic below is safe because `x + y >= sqrt(x * y) * 2` if (sum % 2 == 0) { sum /= 2; return Fraction({ n: sum - root, d: sum }); } return Fraction({ n: sum - root * 2, d: sum }); } /** * @dev returns the protection level based on the timestamp and protection delays * * @param addTimestamp time at which the liquidity was added * @param removeTimestamp time at which the liquidity is removed * * @return protection level (as a ratio) */ function protectionLevel(uint256 addTimestamp, uint256 removeTimestamp) internal view returns (Fraction memory) { uint256 timeElapsed = removeTimestamp.sub(addTimestamp); uint256 minProtectionDelay = _settings.minProtectionDelay(); uint256 maxProtectionDelay = _settings.maxProtectionDelay(); if (timeElapsed < minProtectionDelay) { return Fraction({ n: 0, d: 1 }); } if (timeElapsed >= maxProtectionDelay) { return Fraction({ n: 1, d: 1 }); } return Fraction({ n: timeElapsed, d: maxProtectionDelay }); } /** * @dev returns the compensation amount based on the impermanent loss and the protection level * * @param amount protected amount in units of the reserve token * @param total amount plus fee in units of the reserve token * @param loss protection level (as a ratio between 0 and 1) * @param level impermanent loss (as a ratio between 0 and 1) * * @return compensation amount */ function compensationAmount( uint256 amount, uint256 total, Fraction memory loss, Fraction memory level ) internal pure returns (uint256) { uint256 levelN = level.n.mul(amount); uint256 levelD = level.d; uint256 maxVal = MathEx.max(MathEx.max(levelN, levelD), total); (uint256 lossN, uint256 lossD) = MathEx.reducedRatio(loss.n, loss.d, MAX_UINT256 / maxVal); return total.mul(lossD.sub(lossN)).div(lossD).add(lossN.mul(levelN).div(lossD.mul(levelD))); } function networkCompensation( uint256 targetAmount, uint256 baseAmount, PackedRates memory packedRates ) internal view returns (uint256) { if (targetAmount <= baseAmount) { return 0; } // calculate the delta in network tokens uint256 delta = (targetAmount - baseAmount).mul(packedRates.removeAverageRateN).div(packedRates.removeAverageRateD); // the delta might be very small due to precision loss // in which case no compensation will take place (gas optimization) if (delta >= _settings.minNetworkCompensation()) { return delta; } return 0; } // utility to mint network tokens function mintNetworkTokens( address owner, IConverterAnchor poolAnchor, uint256 amount ) private { _systemStore.incNetworkTokensMinted(poolAnchor, amount); _networkTokenGovernance.mint(owner, amount); } // utility to burn network tokens function burnNetworkTokens(IConverterAnchor poolAnchor, uint256 amount) private { _systemStore.decNetworkTokensMinted(poolAnchor, amount); _networkTokenGovernance.burn(amount); } /** * @dev notify event subscribers on adding liquidity * * @param provider liquidity provider * @param poolToken pool token * @param reserveToken reserve token * @param poolAmount amount of pool tokens to protect * @param reserveAmount amount of reserve tokens to protect */ function notifyEventSubscribersOnAddingLiquidity( address provider, IDSToken poolToken, IReserveToken reserveToken, uint256 poolAmount, uint256 reserveAmount ) private { address[] memory subscribers = _settings.subscribers(); uint256 length = subscribers.length; for (uint256 i = 0; i < length; i++) { ILiquidityProvisionEventsSubscriber(subscribers[i]).onAddingLiquidity( provider, poolToken, reserveToken, poolAmount, reserveAmount ); } } /** * @dev notify event subscribers on removing liquidity * * @param id position id * @param provider liquidity provider * @param poolToken pool token * @param reserveToken reserve token * @param poolAmount amount of pool tokens to protect * @param reserveAmount amount of reserve tokens to protect */ function notifyEventSubscribersOnRemovingLiquidity( uint256 id, address provider, IDSToken poolToken, IReserveToken reserveToken, uint256 poolAmount, uint256 reserveAmount ) private { address[] memory subscribers = _settings.subscribers(); uint256 length = subscribers.length; for (uint256 i = 0; i < length; i++) { ILiquidityProvisionEventsSubscriber(subscribers[i]).onRemovingLiquidity( id, provider, poolToken, reserveToken, poolAmount, reserveAmount ); } } // utility to get the reserve balances function converterReserveBalances( IConverter converter, IReserveToken reserveToken1, IReserveToken reserveToken2 ) private view returns (uint256, uint256) { return (converter.getConnectorBalance(reserveToken1), converter.getConnectorBalance(reserveToken2)); } // utility to get the other reserve function converterOtherReserve(IConverter converter, IReserveToken thisReserve) private view returns (IReserveToken) { IReserveToken otherReserve = converter.connectorTokens(0); return otherReserve != thisReserve ? otherReserve : converter.connectorTokens(1); } // utility to get the owner function ownedBy(IOwned owned) private view returns (address) { return owned.owner(); } /** * @dev returns whether the provided reserve token is the network token * * @return whether the provided reserve token is the network token */ function isNetworkToken(IReserveToken reserveToken) private view returns (bool) { return address(reserveToken) == address(_networkToken); } }
* @dev transfers the ownership of the wallet can only be called by the contract owner @param newOwner the new owner of the wallet/
function transferWalletOwnership(address newOwner) external ownerOnly { _wallet.transferOwnership(newOwner); }
1,086,341
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 29375, 326, 23178, 434, 326, 9230, 848, 1338, 506, 2566, 635, 326, 6835, 3410, 632, 891, 394, 5541, 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, 18, 13866, 5460, 12565, 12, 2704, 5541, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.8.11; import "@rari-capital/solmate/src/auth/Auth.sol"; import "@rari-capital/solmate/src/utils/SafeTransferLib.sol"; contract QuantumSplitter is Auth { /// >>>>>>>>>>>>>>>>>>>>>>> STRUCTS <<<<<<<<<<<<<<<<<<<<<<<<<< /// struct Split { uint256 balance; address[] recipients; uint256[] shares; } /// >>>>>>>>>>>>>>>>>>>>>>> STATE <<<<<<<<<<<<<<<<<<<<<<<<<< /// address payable public treasury = payable(0xe0faf18f33c307Ca812B80c771ad3c9E5f043Fe9); uint256 public treasuryShare = 2000; mapping (uint256 => Split) public splits; /// >>>>>>>>>>>>>>>>>>>>>>> CONSTRUCTOR <<<<<<<<<<<<<<<<<<<<<<<<<< /// constructor(address owner, address authority) Auth(owner, Authority(authority)) { } /// >>>>>>>>>>>>>>>>>>>>>>> RESTRICTED <<<<<<<<<<<<<<<<<<<<<<<<<< /// /// @notice Set a split /// @param dropId dropId corresponding to the split /// @dev Treasury payout is already taken in account /// @param recipients array of recipients /// @dev The fee denominator is 10000 in BPS. /// @param shares array of shares /* Example This would set the fee at 5% ``` setSplit(0, [0xBEEF], [500]) ``` */ function setSplit( uint256 dropId, address[] calldata recipients, uint256[] calldata shares) requiresAuth public { require(recipients.length == shares.length, "UNMATCHED_LENGTH"); /// @dev reads balance in case of split wasn't defined before it received eth splits[dropId] = Split(splits[dropId].balance, recipients, shares); } /// @notice Sets the treasury address /// @param treasury_ address of the treasury function setTreasury(address payable treasury_) requiresAuth public { treasury = treasury_; } /// @notice Sets the treasury's share of all splits /// @param share share of the treasury /// @dev The fee denominator is 10000 in BPS. /* Example This would set the fee at 5% ``` setTreasuryShare(500) ``` */ function setTreasuryShare(uint256 share) requiresAuth public { treasuryShare = share; } /// @notice Withdraws all the funds held by the splitt /// @param to recipient of funds /// @param amount amount to withdraw function withdraw(address payable to, uint256 amount) requiresAuth public { SafeTransferLib.safeTransferETH(to, amount); } /// >>>>>>>>>>>>>>>>>>>>>>> EXTERNAL <<<<<<<<<<<<<<<<<<<<<<<<<< /// /// @notice Deposit funds for a dropId /// @dev split should exist beforehand /// @param dropId dropId corresponding to the split function deposit(uint256 dropId) public payable { require(splits[dropId].recipients.length > 0, "INVALID_SPLIT"); splits[dropId].balance += msg.value; } /// @notice distribute funds of a split function distribute(uint256 dropId) public { Split memory split = splits[dropId]; uint256 balance = split.balance; // initialize with Quantum's share uint256 toSend = balance * treasuryShare / 10000; uint256 length = split.recipients.length; SafeTransferLib.safeTransferETH(treasury, toSend); balance -= toSend; split.balance -= toSend; for(uint i; i < length; i++) { toSend = (split.balance * split.shares[i]) / 10000; balance -= toSend; SafeTransferLib.safeTransferETH(split.recipients[i], toSend); } require(balance == 0, "INSUFFICIENT_FUNDS"); splits[dropId].balance = 0; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnerUpdated(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnerUpdated(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function setOwner(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnerUpdated(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. library SafeTransferLib { /*/////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool callStatus; assembly { // Transfer the ETH and store if it succeeded or not. callStatus := call(gas(), to, amount, 0, 0, 0, 0) } require(callStatus, "ETH_TRANSFER_FAILED"); } /*/////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 100 because the calldata length is 4 + 32 * 3. callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED"); } /*/////////////////////////////////////////////////////////////// INTERNAL HELPER LOGIC //////////////////////////////////////////////////////////////*/ function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) { assembly { // Get how many bytes the call returned. let returnDataSize := returndatasize() // If the call reverted: if iszero(callStatus) { // Copy the revert message into memory. returndatacopy(0, 0, returnDataSize) // Revert with the same message. revert(0, returnDataSize) } switch returnDataSize case 32 { // Copy the return data into memory. returndatacopy(0, 0, returnDataSize) // Set success to whether it returned true. success := iszero(iszero(mload(0))) } case 0 { // There was no return data. success := 1 } default { // It returned some malformed input. success := 0 } } } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*/////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*/////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*/////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*/////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*/////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*/////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
@notice Sets the treasury address @param treasury_ address of the treasury
function setTreasury(address payable treasury_) requiresAuth public { treasury = treasury_; } This would set the fee at 5% ``` setTreasuryShare(500) ```
10,459,935
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 11511, 326, 9787, 345, 22498, 1758, 632, 891, 9787, 345, 22498, 67, 1758, 434, 326, 9787, 345, 22498, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 444, 56, 266, 345, 22498, 12, 2867, 8843, 429, 9787, 345, 22498, 67, 13, 4991, 1730, 1071, 288, 203, 3639, 9787, 345, 22498, 273, 9787, 345, 22498, 67, 31, 203, 565, 289, 203, 203, 203, 3639, 1220, 4102, 444, 326, 14036, 622, 1381, 9, 203, 203, 3639, 31621, 203, 3639, 444, 56, 266, 345, 22498, 9535, 12, 12483, 13, 203, 3639, 31621, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/3/0x353ec5bDa1B02d3E9E7a43535b74265DfcC9Cf41/sources/tokenSales.sol
string public name = "EthSwap Instant Exchange";
contract tokenSales { IERC20 public token; V2 public rgp; address owner; uint public price; uint256 public tokensSold; uint256 public decimals; event sold(address account, uint price, address token); constructor(IERC20 _token, V2 _rgp, uint _price) public payable{ owner == msg.sender; token = _token; rgp = _rgp; price = _price; } function() external payable{ } function add(uint x, uint y) public pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) public pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } function buyTokens(uint _amount1) public payable { require(_amount1 > 0); uint256 tokensToBuy = _amount1 * 10 * decimals / _amount1 / price; require(_amount1 <= token.allowance(msg.sender, address(this))); token.approve(address(this), _amount1); token.transferFrom( msg.sender, address(this), _amount1); require(tokensToBuy <= rgp.allowance(address(this), msg.sender)); rgp.approve(msg.sender, tokensToBuy); rgp.transfer(msg.sender, tokensToBuy); if (_amount1 > 0) rgp.transferFrom( address(this), msg.sender, tokensToBuy); token.balanceOf(address(this)) + _amount1; rgp.balanceOf(msg.sender) + tokensToBuy; tokensSold += _amount1; emit sold(msg.sender, _amount1 * price, address(token)); } }
5,138,462
[ 1, 4625, 348, 7953, 560, 30, 533, 1071, 508, 273, 315, 41, 451, 12521, 11190, 18903, 14432, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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565, 2254, 1071, 6205, 31, 203, 377, 203, 565, 2254, 5034, 1071, 2430, 55, 1673, 31, 203, 565, 2254, 5034, 1071, 15105, 31, 203, 377, 203, 565, 871, 272, 1673, 12, 2867, 2236, 16, 2254, 6205, 16, 1758, 1147, 1769, 203, 377, 203, 565, 3885, 12, 45, 654, 39, 3462, 389, 2316, 16, 776, 22, 389, 86, 6403, 16, 2254, 389, 8694, 13, 1071, 8843, 429, 95, 203, 3639, 3410, 422, 225, 1234, 18, 15330, 31, 203, 3639, 1147, 273, 389, 2316, 31, 203, 3639, 436, 6403, 273, 389, 86, 6403, 31, 203, 3639, 6205, 273, 389, 8694, 31, 203, 540, 203, 565, 289, 203, 377, 203, 565, 445, 1435, 3903, 8843, 429, 95, 203, 565, 289, 203, 377, 203, 565, 445, 527, 12, 11890, 619, 16, 2254, 677, 13, 1071, 16618, 1135, 261, 11890, 998, 13, 288, 203, 3639, 2583, 12443, 94, 273, 619, 397, 677, 13, 1545, 619, 16, 296, 2377, 17, 15949, 17, 1289, 17, 11512, 8284, 203, 565, 289, 203, 203, 565, 445, 720, 12, 11890, 619, 16, 2254, 677, 13, 1071, 16618, 1135, 261, 11890, 998, 13, 288, 203, 3639, 2583, 12443, 94, 273, 619, 300, 677, 13, 1648, 619, 16, 296, 2377, 17, 15949, 17, 1717, 17, 9341, 2426, 8284, 203, 565, 289, 203, 203, 565, 445, 14064, 12, 11890, 619, 16, 2254, 677, 13, 1071, 16618, 1135, 261, 11890, 998, 13, 288, 203, 3639, 2583, 12, 93, 422, 374, 747, 261, 94, 273, 619, 380, 677, 13, 342, 677, 422, 619, 16, 296, 2377, 17, 15949, 17, 16411, 17, 11512, 8284, 203, 565, 289, 203, 377, 203, 3639, 203, 565, 445, 30143, 5157, 12, 11890, 389, 8949, 21, 13, 1071, 8843, 429, 288, 7010, 3639, 2583, 24899, 8949, 21, 405, 374, 1769, 203, 3639, 2254, 5034, 2430, 774, 38, 9835, 273, 389, 8949, 21, 380, 1728, 380, 15105, 342, 389, 8949, 21, 342, 6205, 31, 203, 3639, 2583, 24899, 8949, 21, 1648, 1147, 18, 5965, 1359, 12, 3576, 18, 15330, 16, 1758, 12, 2211, 3719, 1769, 203, 3639, 1147, 18, 12908, 537, 12, 2867, 12, 2211, 3631, 389, 8949, 21, 1769, 203, 3639, 1147, 18, 13866, 1265, 12, 1234, 18, 15330, 16, 1758, 12, 2211, 3631, 389, 8949, 21, 1769, 203, 540, 203, 3639, 2583, 12, 7860, 774, 38, 9835, 1648, 436, 6403, 18, 5965, 1359, 12, 2867, 12, 2211, 3631, 1234, 18, 15330, 10019, 203, 3639, 436, 6403, 18, 12908, 537, 12, 3576, 18, 15330, 16, 2430, 774, 38, 9835, 1769, 203, 3639, 436, 6403, 18, 13866, 12, 3576, 18, 15330, 16, 2430, 774, 38, 9835, 1769, 203, 3639, 309, 261, 67, 8949, 21, 405, 374, 13, 436, 6403, 18, 13866, 1265, 12, 1758, 12, 2211, 3631, 1234, 18, 15330, 16, 2430, 774, 38, 9835, 1769, 203, 540, 203, 3639, 1147, 18, 12296, 951, 12, 2867, 12, 2211, 3719, 397, 389, 8949, 21, 31, 203, 3639, 436, 6403, 18, 12296, 951, 12, 3576, 18, 15330, 13, 397, 2430, 774, 38, 9835, 31, 203, 540, 203, 3639, 2430, 55, 1673, 1011, 389, 8949, 21, 31, 7010, 3639, 3626, 272, 1673, 12, 3576, 18, 15330, 16, 389, 8949, 21, 380, 6205, 16, 1758, 12, 2316, 10019, 203, 2398, 203, 565, 289, 203, 377, 203, 97, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// 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/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: contracts/interfaces/IHuxleyComics.sol pragma solidity 0.8.6; interface IHuxleyComics is IERC721 { struct Issue { uint256 price; uint256 goldSupplyLeft; uint256 firstEditionSupplyLeft; uint256 holographicSupplyLeft; uint256 serialNumberToMintGold; uint256 serialNumberToMintFirstEdition; uint256 serialNumberToMintHolographic; uint256 maxPayableMintBatch; string uri; bool exist; } struct Token { uint256 serialNumber; uint256 issueNumber; TokenType tokenType; } enum TokenType {FirstEdition, Gold, Holographic} function safeMint(address _to) external returns (uint256); function getCurrentIssue() external returns (uint256 _currentIssue); function getCurrentPrice() external returns (uint256 _currentPrice); function getCurrentMaxPayableMintBatch() external returns (uint256 _currentMaxPayableMintBatch); function createNewIssue( uint256 _price, uint256 _goldSupply, uint256 _firstEditionSupply, uint256 _holographicSupply, uint256 _startSerialNumberGold, uint256 _startSerialNumberFirstEdition, uint256 _startSerialNumberHolographic, uint256 _maxPaybleMintBatch, string memory _uri ) external; function getIssue(uint256 _issueNumber) external returns (Issue memory _issue); function getToken(uint256 _tokenId) external returns (Token memory _token); function setTokenDetails(uint256 _tokenId, TokenType _tokenType) external; function setBaseURI(uint256 _issueNumber, string memory _uri) external; function setCanBurn(bool _canBurn) external; } // 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: @openzeppelin/contracts/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/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/access/AccessControl.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @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 Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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]{20}) is missing role (0x[0-9a-f]{32})$/ * * _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]{20}) is missing role (0x[0-9a-f]{32})$/ */ 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 { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = 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()); } } } // File: @openzeppelin/contracts/security/Pausable.sol pragma solidity ^0.8.0; /** * @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()); } } // File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return recover(hash, r, vs); } else { revert("ECDSA: invalid signature length"); } } /** * @dev Overload of {ECDSA-recover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // 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: @openzeppelin/contracts/interfaces/IERC1271.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); } // File: @openzeppelin/contracts/utils/cryptography/SignatureChecker.sol pragma solidity ^0.8.0; /** * @dev Signature verification helper: Provide a single mechanism to verify both private-key (EOA) ECDSA signature and * ERC1271 contract sigantures. Using this instead of ECDSA.recover in your contract will make them compatible with * smart contract wallets such as Argent and Gnosis. * * Note: unlike ECDSA signatures, contract signature's are revocable, and the outcome of this function can thus change * through time. It could return true at block N and false at block N+1 (or the opposite). * * _Available since v4.1._ */ library SignatureChecker { function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { if (Address.isContract(signer)) { try IERC1271(signer).isValidSignature(hash, signature) returns (bytes4 magicValue) { return magicValue == IERC1271(signer).isValidSignature.selector; } catch { return false; } } else { return ECDSA.recover(hash, signature) == signer; } } } // File: contracts/HuxleyComicsOps.sol pragma solidity 0.8.6; /** * @title HuxleyComicsOps * @dev This contract allows minting HuxleyComics tokens. * Users can pay to mint tokens when not paused. * */ contract HuxleyComicsOps is Pausable, AccessControl { using SignatureChecker for address; address public trustedWallet_A; address public trustedWallet_B; // address used to sign whitelisted addresses address public signer; // ER721 Huxley Comics Token IHuxleyComics public huxleyComics; // Mapping from blacklisted addresses mapping(address => bool) public blacklisted; // Mapping from address to amount of tokens purchased per issue number mapping(address => mapping(uint256 => uint256)) public purchased; // Role that can call createIssue(), setBaseURI(), privateMint...Batch() and setBlacklisted() bytes32 public constant OPERATIONS_ROLE = keccak256("OPERATIONS_ROLE"); event FundsTransfered(address _wallet, uint256 _amount); event IssueCreated(address _sender, uint256 _newIssue); event StartedBurn(address _sender); event StoppedBurn(address _sender); event IssueBaseURIUpdated(address _sender, string _uri); event FreeMintExecuted(address _sender); event FirstEditionMintExecuted(address _sender, uint256 _paid); /** * @dev Creates an instance of `HuxleyComicsOps`. * * 'msg.sender' gets the Admin role. '_trustedWallet_A' and '_trustedWallet_B' are wallets that will receive * funds. '_huxLeyComics' is the address of the HuxleyComics Token smart contract. * * Also sets contract to 'paused' state. */ constructor( address _operationAddress, address _trustedWallet_A, address _trustedWallet_B, address _huxLeyComics ) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(OPERATIONS_ROLE, _operationAddress); trustedWallet_A = _trustedWallet_A; trustedWallet_B = _trustedWallet_B; huxleyComics = IHuxleyComics(_huxLeyComics); signer = msg.sender; _pause(); } /** * @dev It creates a new Issue. Checks if contract is 'paused' and pauses it otherwise. * It calls 'createNewIssue' from the HuxleyComics contract. * Only an address with Operations Role can call this function. * * Emits a {IssueCreated} event. * * @param _price Price for each token to be minted in wei * @param _goldSupply Total supply of Gold token * @param _firstEditionSupply Total supply of First Edition token * @param _holographicSupply Total supply of Holographic token * @param _startSerialNumberGold Initial serial number for Gold token * @param _startSerialNumberFirstEdition Initial serial number for First Edition token * @param _startSerialNumberHolographic Initial serial number for Holographic token * @param _maxPayableMintBatch Max amount of tokens that can be minted when calling batch functions (should not be greater than 100 so it won't run out of gas) * @param _uri Uri for the tokens of the issue */ function createIssue( uint256 _price, uint256 _goldSupply, uint256 _firstEditionSupply, uint256 _holographicSupply, uint256 _startSerialNumberGold, uint256 _startSerialNumberFirstEdition, uint256 _startSerialNumberHolographic, uint256 _maxPayableMintBatch, string memory _uri ) external onlyRole(OPERATIONS_ROLE) { if (!paused()) { _pause(); } huxleyComics.createNewIssue( _price, _goldSupply, _firstEditionSupply, _holographicSupply, _startSerialNumberGold, _startSerialNumberFirstEdition, _startSerialNumberHolographic, _maxPayableMintBatch, _uri ); emit IssueCreated(msg.sender, huxleyComics.getCurrentIssue()); } /** * @dev Sets a new uri for an Issue. Only an address with Operations Role can call this function. * Emits a {IssueBaseURIUpdated} event. * @param _issueNumber issueNumber * @param _uri uri */ function setBaseURI(uint256 _issueNumber, string memory _uri) external onlyRole(OPERATIONS_ROLE) { huxleyComics.setBaseURI(_issueNumber, _uri); emit IssueBaseURIUpdated(msg.sender, _uri); } /** * @dev Mint a free token of type First Edition for Issue #1. Whitelisted addresses can free mint one token. * Emits a {FreeMintExecuted} event. * @param signature Message signed by 'signer' adddress to allow a wallet to free mint. */ function freeMint(bytes memory signature) external { require(huxleyComics.getCurrentIssue() == 1, "Huxley: not issue 1"); require(!blacklisted[msg.sender], "Huxley: blacklisted"); require(isWhitelisted(signature), "Huxley: not whtl"); require(isFirstToken(), "Huxley: not first"); _mint(IHuxleyComics.TokenType.FirstEdition, 1); emit FreeMintExecuted(msg.sender); } /// @dev Mint a FirstEdition token for a price /// Emits a {FirstEditionMintExecuted} event. function payableMint() external payable whenNotPaused { uint256 price = huxleyComics.getCurrentPrice(); require(price == msg.value, "Huxley: invalid price"); uint256 maxPayableMintBatch = huxleyComics.getCurrentMaxPayableMintBatch(); _mint(IHuxleyComics.TokenType.FirstEdition, maxPayableMintBatch); payment(); emit FirstEditionMintExecuted(msg.sender, msg.value); } /** * @dev Batch mint tokens for a price. Value should be equal to '_amountToMint1' x 'Issue.price'. * @param _amountToMint Amount of tokens to be minted. It should be greater than 0 and less or equal than 'Issue.maxPayableMintBatch' */ function payableMintBatch(uint256 _amountToMint) external payable whenNotPaused { require(_amountToMint > 0, "Huxley: batch is 0"); uint256 maxPayableMintBatch = huxleyComics.getCurrentMaxPayableMintBatch(); require(_amountToMint <= maxPayableMintBatch, "Huxley: max batch"); uint256 price = huxleyComics.getCurrentPrice(); price = price * _amountToMint; require(price == msg.value, "Huxley: invalid price"); for (uint256 i = 1; i <= _amountToMint; i++) { _mint(IHuxleyComics.TokenType.FirstEdition, maxPayableMintBatch); } payment(); } /// @dev Split value paid for a token /// Emits two {FundsTransfered} events. function payment() internal { uint256 amount = (msg.value * 85) / 100; (bool success, ) = trustedWallet_A.call{value: amount}(""); require(success, "HV: Transfer A failed"); emit FundsTransfered(trustedWallet_A, amount); amount = msg.value - amount; (success, ) = trustedWallet_B.call{value: amount}(""); require(success, "HV: Transfer B failed"); emit FundsTransfered(trustedWallet_B, amount); } /// @dev Allows team to mint FirstEdition token function privateMintFirstEditionBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.FirstEdition); } /// @dev Allows team to mint Gold token function privateMintGoldBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.Gold); } /// @dev Allows team to mint Holographic token function privateMintHolographicBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.Holographic); } /// @dev Batch mint tokens. It should not be greater than 100 to avoid running out of gas function privateMintBatch(uint256 _amountToMint, IHuxleyComics.TokenType _tokenType) internal { require(_amountToMint > 0, "Huxley: amount is 0"); for (uint256 i = 1; i <= _amountToMint; i++) { _privateMint(_tokenType, true, 0); } } /** * @dev Mints a token of an specific 'Token.Type'. It can be 'FirstEdition', 'Gold' or 'Holographic' * @param _tokenType Token Type that will be minted */ function _mint(IHuxleyComics.TokenType _tokenType, uint256 _maxAmount) internal { _privateMint(_tokenType, false, _maxAmount); } /** * @dev Mints a token of a specific 'Token.Type'. It can be 'FirstEdition', 'Gold' or ' 'Holographic' * @param _tokenType Token Type that will be minted */ function _privateMint(IHuxleyComics.TokenType _tokenType, bool _isPrivateMint, uint256 _maxAmount) internal { if(!_isPrivateMint){ uint256 totalTokenspurchased = purchased[msg.sender][huxleyComics.getCurrentIssue()]; require(totalTokenspurchased < _maxAmount, "Huxley: over max amount"); // update total amount of tokens purchased for current issue purchased[msg.sender][huxleyComics.getCurrentIssue()] = totalTokenspurchased + 1; } // mint and get token id uint256 tokenId = huxleyComics.safeMint(msg.sender); huxleyComics.setTokenDetails(tokenId, _tokenType); } // Setup functions /** * @dev Updates address of 'trustedWallet_A' * @param _trustedWallet New address for 'trustedWallet_A' */ function setTrustedWallet_A(address _trustedWallet) external onlyRole(DEFAULT_ADMIN_ROLE) { trustedWallet_A = _trustedWallet; } /** * @dev Updates address of 'trustedWallet_B' * @param _trustedWallet New address for 'trustedWallet_B' */ function setTrustedWallet_B(address _trustedWallet) external onlyRole(DEFAULT_ADMIN_ROLE) { trustedWallet_B = _trustedWallet; } /** * @dev Updates address of 'signer' * @param _signer New address for 'signer' */ function setSigner(address _signer) external onlyRole(DEFAULT_ADMIN_ROLE) { signer = _signer; } /// @dev Returns if user already has a token function isFirstToken() internal view returns (bool) { uint256 balance = huxleyComics.balanceOf(msg.sender); return balance == 0; } /// @dev Returns if user is whitelisted to free mint 1 token. function isWhitelisted(bytes memory signature) internal view returns (bool) { bytes32 result = keccak256(abi.encodePacked(msg.sender)); bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", result)); return signer.isValidSignatureNow(hash, signature); } /** * @dev Sets if an address is blacklist or not * @param _addr Address to update in the blacklist list * @param _value Use 'True' to blacklist '_addr', 'False' otherwise */ function setBlacklisted(address _addr, bool _value) external onlyRole(OPERATIONS_ROLE) { blacklisted[_addr] = _value; } /// @dev Pause payableMint() function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } /// @dev Unpause payableMint() function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /// @dev Start the possibility to burn tokens /// Emits {StartedBurn} event. function startBurn() external onlyRole(DEFAULT_ADMIN_ROLE) { huxleyComics.setCanBurn(true); emit StartedBurn(msg.sender); } /// @dev Stop the possibility to burn tokens /// Emits {StoppedBurn} event. function stopBurn() external onlyRole(DEFAULT_ADMIN_ROLE) { huxleyComics.setCanBurn(false); emit StoppedBurn(msg.sender); } // End Burn Requirement }
* @title HuxleyComicsOps @dev This contract allows minting HuxleyComics tokens. Users can pay to mint tokens when not paused./ address used to sign whitelisted addresses ER721 Huxley Comics Token Mapping from blacklisted addresses Mapping from address to amount of tokens purchased per issue number Role that can call createIssue(), setBaseURI(), privateMint...Batch() and setBlacklisted()
contract HuxleyComicsOps is Pausable, AccessControl { using SignatureChecker for address; address public trustedWallet_A; address public trustedWallet_B; address public signer; IHuxleyComics public huxleyComics; mapping(address => bool) public blacklisted; mapping(address => mapping(uint256 => uint256)) public purchased; bytes32 public constant OPERATIONS_ROLE = keccak256("OPERATIONS_ROLE"); event FundsTransfered(address _wallet, uint256 _amount); event IssueCreated(address _sender, uint256 _newIssue); event StartedBurn(address _sender); event StoppedBurn(address _sender); event IssueBaseURIUpdated(address _sender, string _uri); event FreeMintExecuted(address _sender); event FirstEditionMintExecuted(address _sender, uint256 _paid); constructor( address _operationAddress, address _trustedWallet_A, address _trustedWallet_B, address _huxLeyComics ) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(OPERATIONS_ROLE, _operationAddress); trustedWallet_A = _trustedWallet_A; trustedWallet_B = _trustedWallet_B; huxleyComics = IHuxleyComics(_huxLeyComics); signer = msg.sender; _pause(); } function createIssue( uint256 _price, uint256 _goldSupply, uint256 _firstEditionSupply, uint256 _holographicSupply, uint256 _startSerialNumberGold, uint256 _startSerialNumberFirstEdition, uint256 _startSerialNumberHolographic, uint256 _maxPayableMintBatch, string memory _uri ) external onlyRole(OPERATIONS_ROLE) { if (!paused()) { _pause(); } huxleyComics.createNewIssue( _price, _goldSupply, _firstEditionSupply, _holographicSupply, _startSerialNumberGold, _startSerialNumberFirstEdition, _startSerialNumberHolographic, _maxPayableMintBatch, _uri ); emit IssueCreated(msg.sender, huxleyComics.getCurrentIssue()); } function createIssue( uint256 _price, uint256 _goldSupply, uint256 _firstEditionSupply, uint256 _holographicSupply, uint256 _startSerialNumberGold, uint256 _startSerialNumberFirstEdition, uint256 _startSerialNumberHolographic, uint256 _maxPayableMintBatch, string memory _uri ) external onlyRole(OPERATIONS_ROLE) { if (!paused()) { _pause(); } huxleyComics.createNewIssue( _price, _goldSupply, _firstEditionSupply, _holographicSupply, _startSerialNumberGold, _startSerialNumberFirstEdition, _startSerialNumberHolographic, _maxPayableMintBatch, _uri ); emit IssueCreated(msg.sender, huxleyComics.getCurrentIssue()); } function setBaseURI(uint256 _issueNumber, string memory _uri) external onlyRole(OPERATIONS_ROLE) { huxleyComics.setBaseURI(_issueNumber, _uri); emit IssueBaseURIUpdated(msg.sender, _uri); } function freeMint(bytes memory signature) external { require(huxleyComics.getCurrentIssue() == 1, "Huxley: not issue 1"); require(!blacklisted[msg.sender], "Huxley: blacklisted"); require(isWhitelisted(signature), "Huxley: not whtl"); require(isFirstToken(), "Huxley: not first"); _mint(IHuxleyComics.TokenType.FirstEdition, 1); emit FreeMintExecuted(msg.sender); } function payableMint() external payable whenNotPaused { uint256 price = huxleyComics.getCurrentPrice(); require(price == msg.value, "Huxley: invalid price"); uint256 maxPayableMintBatch = huxleyComics.getCurrentMaxPayableMintBatch(); _mint(IHuxleyComics.TokenType.FirstEdition, maxPayableMintBatch); payment(); emit FirstEditionMintExecuted(msg.sender, msg.value); } It should be greater than 0 and less or equal than 'Issue.maxPayableMintBatch' function payableMintBatch(uint256 _amountToMint) external payable whenNotPaused { require(_amountToMint > 0, "Huxley: batch is 0"); uint256 maxPayableMintBatch = huxleyComics.getCurrentMaxPayableMintBatch(); require(_amountToMint <= maxPayableMintBatch, "Huxley: max batch"); uint256 price = huxleyComics.getCurrentPrice(); price = price * _amountToMint; require(price == msg.value, "Huxley: invalid price"); for (uint256 i = 1; i <= _amountToMint; i++) { _mint(IHuxleyComics.TokenType.FirstEdition, maxPayableMintBatch); } payment(); } function payableMintBatch(uint256 _amountToMint) external payable whenNotPaused { require(_amountToMint > 0, "Huxley: batch is 0"); uint256 maxPayableMintBatch = huxleyComics.getCurrentMaxPayableMintBatch(); require(_amountToMint <= maxPayableMintBatch, "Huxley: max batch"); uint256 price = huxleyComics.getCurrentPrice(); price = price * _amountToMint; require(price == msg.value, "Huxley: invalid price"); for (uint256 i = 1; i <= _amountToMint; i++) { _mint(IHuxleyComics.TokenType.FirstEdition, maxPayableMintBatch); } payment(); } function payment() internal { uint256 amount = (msg.value * 85) / 100; require(success, "HV: Transfer A failed"); emit FundsTransfered(trustedWallet_A, amount); amount = msg.value - amount; require(success, "HV: Transfer B failed"); emit FundsTransfered(trustedWallet_B, amount); } (bool success, ) = trustedWallet_A.call{value: amount}(""); (success, ) = trustedWallet_B.call{value: amount}(""); function privateMintFirstEditionBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.FirstEdition); } function privateMintGoldBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.Gold); } function privateMintHolographicBatch(uint256 _amountToMint) external onlyRole(OPERATIONS_ROLE) { privateMintBatch(_amountToMint, IHuxleyComics.TokenType.Holographic); } function privateMintBatch(uint256 _amountToMint, IHuxleyComics.TokenType _tokenType) internal { require(_amountToMint > 0, "Huxley: amount is 0"); for (uint256 i = 1; i <= _amountToMint; i++) { _privateMint(_tokenType, true, 0); } } function privateMintBatch(uint256 _amountToMint, IHuxleyComics.TokenType _tokenType) internal { require(_amountToMint > 0, "Huxley: amount is 0"); for (uint256 i = 1; i <= _amountToMint; i++) { _privateMint(_tokenType, true, 0); } } function _mint(IHuxleyComics.TokenType _tokenType, uint256 _maxAmount) internal { _privateMint(_tokenType, false, _maxAmount); } function _privateMint(IHuxleyComics.TokenType _tokenType, bool _isPrivateMint, uint256 _maxAmount) internal { if(!_isPrivateMint){ uint256 totalTokenspurchased = purchased[msg.sender][huxleyComics.getCurrentIssue()]; require(totalTokenspurchased < _maxAmount, "Huxley: over max amount"); purchased[msg.sender][huxleyComics.getCurrentIssue()] = totalTokenspurchased + 1; } huxleyComics.setTokenDetails(tokenId, _tokenType); } function _privateMint(IHuxleyComics.TokenType _tokenType, bool _isPrivateMint, uint256 _maxAmount) internal { if(!_isPrivateMint){ uint256 totalTokenspurchased = purchased[msg.sender][huxleyComics.getCurrentIssue()]; require(totalTokenspurchased < _maxAmount, "Huxley: over max amount"); purchased[msg.sender][huxleyComics.getCurrentIssue()] = totalTokenspurchased + 1; } huxleyComics.setTokenDetails(tokenId, _tokenType); } uint256 tokenId = huxleyComics.safeMint(msg.sender); function setTrustedWallet_A(address _trustedWallet) external onlyRole(DEFAULT_ADMIN_ROLE) { trustedWallet_A = _trustedWallet; } function setTrustedWallet_B(address _trustedWallet) external onlyRole(DEFAULT_ADMIN_ROLE) { trustedWallet_B = _trustedWallet; } function setSigner(address _signer) external onlyRole(DEFAULT_ADMIN_ROLE) { signer = _signer; } function isFirstToken() internal view returns (bool) { uint256 balance = huxleyComics.balanceOf(msg.sender); return balance == 0; } function isWhitelisted(bytes memory signature) internal view returns (bool) { bytes32 result = keccak256(abi.encodePacked(msg.sender)); bytes32 hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", result)); return signer.isValidSignatureNow(hash, signature); } function setBlacklisted(address _addr, bool _value) external onlyRole(OPERATIONS_ROLE) { blacklisted[_addr] = _value; } function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } function startBurn() external onlyRole(DEFAULT_ADMIN_ROLE) { huxleyComics.setCanBurn(true); emit StartedBurn(msg.sender); } function stopBurn() external onlyRole(DEFAULT_ADMIN_ROLE) { huxleyComics.setCanBurn(false); emit StoppedBurn(msg.sender); } }
12,610,405
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 670, 2616, 30678, 799, 2102, 8132, 632, 5206, 1220, 6835, 5360, 312, 474, 310, 670, 2616, 30678, 799, 2102, 2430, 18, 12109, 848, 8843, 358, 312, 474, 2430, 1347, 486, 17781, 18, 19, 1758, 1399, 358, 1573, 26944, 6138, 4232, 27, 5340, 670, 2616, 30678, 1286, 2102, 3155, 9408, 628, 25350, 6138, 9408, 628, 1758, 358, 3844, 434, 2430, 5405, 343, 8905, 1534, 5672, 1300, 6204, 716, 848, 745, 752, 12956, 9334, 26435, 3098, 9334, 3238, 49, 474, 2777, 4497, 1435, 471, 444, 13155, 18647, 1435, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 670, 2616, 30678, 799, 2102, 8132, 353, 21800, 16665, 16, 24349, 288, 203, 565, 1450, 9249, 8847, 364, 1758, 31, 203, 203, 565, 1758, 1071, 13179, 16936, 67, 37, 31, 203, 565, 1758, 1071, 13179, 16936, 67, 38, 31, 203, 203, 565, 1758, 1071, 10363, 31, 203, 203, 565, 467, 44, 2616, 30678, 799, 2102, 1071, 366, 2616, 30678, 799, 2102, 31, 203, 203, 565, 2874, 12, 2867, 516, 1426, 13, 1071, 25350, 31, 203, 203, 565, 2874, 12, 2867, 516, 2874, 12, 11890, 5034, 516, 2254, 5034, 3719, 1071, 5405, 343, 8905, 31, 203, 203, 565, 1731, 1578, 1071, 5381, 17205, 15297, 67, 16256, 273, 417, 24410, 581, 5034, 2932, 13950, 15297, 67, 16256, 8863, 203, 203, 565, 871, 478, 19156, 5912, 329, 12, 2867, 389, 19177, 16, 2254, 5034, 389, 8949, 1769, 203, 565, 871, 11820, 6119, 12, 2867, 389, 15330, 16, 2254, 5034, 389, 2704, 12956, 1769, 203, 565, 871, 29386, 38, 321, 12, 2867, 389, 15330, 1769, 203, 565, 871, 5131, 1845, 38, 321, 12, 2867, 389, 15330, 1769, 203, 565, 871, 11820, 2171, 3098, 7381, 12, 2867, 389, 15330, 16, 533, 389, 1650, 1769, 203, 565, 871, 15217, 49, 474, 23839, 12, 2867, 389, 15330, 1769, 203, 565, 871, 5783, 41, 1460, 49, 474, 23839, 12, 2867, 389, 15330, 16, 2254, 5034, 389, 29434, 1769, 203, 203, 565, 3885, 12, 203, 3639, 1758, 389, 7624, 1887, 16, 203, 3639, 1758, 389, 25247, 16936, 67, 37, 16, 203, 3639, 1758, 389, 25247, 16936, 67, 38, 16, 203, 3639, 1758, 389, 76, 2616, 48, 402, 799, 2102, 203, 203, 565, 262, 288, 203, 3639, 389, 8401, 2996, 12, 5280, 67, 15468, 67, 16256, 16, 1234, 18, 15330, 1769, 203, 3639, 389, 8401, 2996, 12, 13950, 15297, 67, 16256, 16, 389, 7624, 1887, 1769, 203, 203, 3639, 13179, 16936, 67, 37, 273, 389, 25247, 16936, 67, 37, 31, 203, 3639, 13179, 16936, 67, 38, 273, 389, 25247, 16936, 67, 38, 31, 203, 203, 3639, 366, 2616, 30678, 799, 2102, 273, 467, 44, 2616, 30678, 799, 2102, 24899, 76, 2616, 48, 402, 799, 2102, 1769, 203, 203, 3639, 10363, 273, 1234, 18, 15330, 31, 203, 203, 3639, 389, 19476, 5621, 203, 565, 289, 203, 203, 565, 445, 752, 12956, 12, 203, 3639, 2254, 5034, 389, 8694, 16, 203, 3639, 2254, 5034, 389, 75, 1673, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 3645, 41, 1460, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 76, 3966, 1483, 335, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 43, 1673, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 3759, 41, 1460, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 44, 3966, 1483, 335, 16, 203, 3639, 2254, 5034, 389, 1896, 9148, 429, 49, 474, 4497, 16, 203, 3639, 533, 3778, 389, 1650, 203, 565, 262, 3903, 1338, 2996, 12, 13950, 15297, 67, 16256, 13, 288, 203, 3639, 309, 16051, 8774, 3668, 10756, 288, 203, 5411, 389, 19476, 5621, 203, 3639, 289, 203, 203, 3639, 366, 2616, 30678, 799, 2102, 18, 2640, 1908, 12956, 12, 203, 5411, 389, 8694, 16, 203, 5411, 389, 75, 1673, 3088, 1283, 16, 203, 5411, 389, 3645, 41, 1460, 3088, 1283, 16, 203, 5411, 389, 76, 3966, 1483, 335, 3088, 1283, 16, 203, 5411, 389, 1937, 6342, 1854, 43, 1673, 16, 203, 5411, 389, 1937, 6342, 1854, 3759, 41, 1460, 16, 203, 5411, 389, 1937, 6342, 1854, 44, 3966, 1483, 335, 16, 203, 5411, 389, 1896, 9148, 429, 49, 474, 4497, 16, 203, 5411, 389, 1650, 203, 3639, 11272, 203, 203, 3639, 3626, 11820, 6119, 12, 3576, 18, 15330, 16, 366, 2616, 30678, 799, 2102, 18, 588, 3935, 12956, 10663, 203, 565, 289, 203, 203, 565, 445, 752, 12956, 12, 203, 3639, 2254, 5034, 389, 8694, 16, 203, 3639, 2254, 5034, 389, 75, 1673, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 3645, 41, 1460, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 76, 3966, 1483, 335, 3088, 1283, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 43, 1673, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 3759, 41, 1460, 16, 203, 3639, 2254, 5034, 389, 1937, 6342, 1854, 44, 3966, 1483, 335, 16, 203, 3639, 2254, 5034, 389, 1896, 9148, 429, 49, 474, 4497, 16, 203, 3639, 533, 3778, 389, 1650, 203, 565, 262, 3903, 1338, 2996, 12, 13950, 15297, 67, 16256, 13, 288, 203, 3639, 309, 16051, 8774, 3668, 10756, 288, 203, 5411, 389, 19476, 5621, 203, 3639, 289, 203, 203, 3639, 366, 2616, 30678, 799, 2102, 18, 2640, 1908, 12956, 12, 203, 5411, 389, 8694, 16, 203, 5411, 389, 75, 1673, 3088, 1283, 16, 203, 5411, 389, 3645, 41, 1460, 3088, 1283, 16, 203, 5411, 389, 76, 3966, 1483, 335, 3088, 1283, 16, 203, 5411, 389, 1937, 6342, 1854, 43, 1673, 16, 203, 5411, 389, 1937, 6342, 1854, 3759, 41, 1460, 16, 203, 5411, 389, 1937, 6342, 1854, 44, 3966, 1483, 335, 16, 203, 5411, 389, 1896, 9148, 429, 49, 474, 4497, 16, 203, 5411, 389, 1650, 203, 3639, 11272, 203, 203, 3639, 3626, 11820, 6119, 12, 3576, 18, 15330, 16, 366, 2616, 30678, 799, 2102, 18, 588, 3935, 12956, 10663, 203, 565, 289, 203, 203, 565, 445, 26435, 3098, 12, 11890, 5034, 389, 13882, 1854, 16, 533, 3778, 389, 1650, 13, 203, 3639, 3903, 203, 3639, 1338, 2996, 12, 13950, 15297, 67, 16256, 13, 203, 565, 288, 203, 3639, 366, 2616, 30678, 799, 2102, 18, 542, 2171, 3098, 24899, 13882, 1854, 16, 389, 1650, 1769, 203, 203, 3639, 3626, 11820, 2171, 3098, 7381, 12, 3576, 18, 15330, 16, 389, 1650, 1769, 203, 565, 289, 203, 203, 565, 445, 4843, 49, 474, 12, 3890, 3778, 3372, 13, 3903, 288, 203, 3639, 2583, 12, 76, 2616, 30678, 799, 2102, 18, 588, 3935, 12956, 1435, 422, 404, 16, 315, 44, 2616, 30678, 30, 486, 5672, 404, 8863, 203, 3639, 2583, 12, 5, 11223, 18647, 63, 3576, 18, 15330, 6487, 315, 44, 2616, 30678, 30, 25350, 8863, 203, 3639, 2583, 12, 291, 18927, 329, 12, 8195, 3631, 315, 44, 2616, 30678, 30, 486, 600, 6172, 8863, 203, 3639, 2583, 12, 291, 3759, 1345, 9334, 315, 44, 2616, 30678, 30, 486, 1122, 8863, 2 ]
pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./interfaces/IOwnable.sol"; import "./interfaces/ISTFactory.sol"; import "./interfaces/IERC20.sol"; import "./interfaces/ISecurityTokenRegistry.sol"; import "./storage/EternalStorage.sol"; import "./libraries/Util.sol"; import "./libraries/Encoder.sol"; import "./libraries/VersionUtils.sol"; /** * @title Registry contract for issuers to register their tickers and security tokens */ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage { /** * @notice state variables address public polyToken; uint256 public stLaunchFee; uint256 public tickerRegFee; uint256 public expiryLimit; uint256 public latestProtocolVersion; bool public paused; address public owner; address public polymathRegistry; address[] public activeUsers; mapping(address => bool) public seenUsers; mapping(address => bytes32[]) userToTickers; mapping(string => address) tickerToSecurityToken; mapping(string => uint) tickerIndex; mapping(string => TickerDetails) registeredTickers; mapping(address => SecurityTokenData) securityTokens; mapping(bytes32 => address) protocolVersionST; mapping(uint256 => ProtocolVersion) versionData; struct ProtocolVersion { uint8 major; uint8 minor; uint8 patch; } struct TickerDetails { address owner; uint256 registrationDate; uint256 expiryDate; string tokenName; bool status; } struct SecurityTokenData { string ticker; string tokenDetails; uint256 deployedAt; } */ using SafeMath for uint256; bytes32 constant INITIALIZE = 0x9ef7257c3339b099aacf96e55122ee78fb65a36bd2a6c19249882be9c98633bf; bytes32 constant POLYTOKEN = 0xacf8fbd51bb4b83ba426cdb12f63be74db97c412515797993d2a385542e311d7; bytes32 constant STLAUNCHFEE = 0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2; bytes32 constant TICKERREGFEE = 0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2; bytes32 constant EXPIRYLIMIT = 0x604268e9a73dfd777dcecb8a614493dd65c638bad2f5e7d709d378bd2fb0baee; bytes32 constant PAUSED = 0xee35723ac350a69d2a92d3703f17439cbaadf2f093a21ba5bf5f1a53eb2a14d9; bytes32 constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d; // Emit when network becomes paused event Pause(uint256 _timestammp); // Emit when network becomes unpaused event Unpause(uint256 _timestamp); // Emit when the ticker is removed from the registry event TickerRemoved(string _ticker, uint256 _removedAt, address _removedBy); // Emit when the token ticker expiry is changed event ChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry); // Emit when changeSecurityLaunchFee is called event ChangeSecurityLaunchFee(uint256 _oldFee, uint256 _newFee); // Emit when changeTickerRegistrationFee is called event ChangeTickerRegistrationFee(uint256 _oldFee, uint256 _newFee); // Emit when ownership gets transferred event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // Emit when ownership of the ticker gets changed event ChangeTickerOwnership(string _ticker, address indexed _oldOwner, address indexed _newOwner); // Emit at the time of launching a new security token event NewSecurityToken( string _ticker, string _name, address indexed _securityTokenAddress, address indexed _owner, uint256 _addedAt, address _registrant, bool _fromAdmin, uint256 _registrationFee ); // Emit after ticker registration event RegisterTicker( address indexed _owner, string _ticker, string _name, uint256 indexed _registrationDate, uint256 indexed _expiryDate, bool _fromAdmin, uint256 _registrationFee ); ///////////////////////////// // Modifiers ///////////////////////////// /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner(),"sender must be owner"); _; } /** * @notice Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPausedOrOwner() { if (msg.sender == owner()) _; else { require(!isPaused(), "Already paused"); _; } } /** * @notice Modifier to make a function callable only when the contract is not paused and ignore is msg.sender is owner. */ modifier whenNotPaused() { require(!isPaused(), "Already paused"); _; } /** * @notice Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(isPaused(), "Should not be paused"); _; } ///////////////////////////// // Initialization ///////////////////////////// /** * @notice Initializes instance of STR * @param _polymathRegistry is the address of the Polymath Registry * @param _STFactory is the address of the Proxy contract for Security Tokens * @param _stLaunchFee is the fee in POLY required to launch a token * @param _tickerRegFee is the fee in POLY required to register a ticker * @param _polyToken is the address of the POLY ERC20 token * @param _owner is the owner of the STR */ function initialize( address _polymathRegistry, address _STFactory, uint256 _stLaunchFee, uint256 _tickerRegFee, address _polyToken, address _owner ) external payable { require(!getBool(INITIALIZE),"already initialized"); require( _STFactory != address(0) && _polyToken != address(0) && _owner != address(0) && _polymathRegistry != address(0), "Invalid address" ); require(_stLaunchFee != 0 && _tickerRegFee != 0, "Fees should not be 0"); set(POLYTOKEN, _polyToken); set(STLAUNCHFEE, _stLaunchFee); set(TICKERREGFEE, _tickerRegFee); set(EXPIRYLIMIT, uint256(60 * 1 days)); set(PAUSED, false); set(OWNER, _owner); set(POLYMATHREGISTRY, _polymathRegistry); _setProtocolVersion(_STFactory, uint8(2), uint8(0), uint8(0)); set(INITIALIZE, true); } ///////////////////////////// // Token Ticker Management ///////////////////////////// /** * @notice Registers the token ticker to the selected owner * @notice Once the token ticker is registered to its owner then no other issuer can claim * @notice its ownership. If the ticker expires and its issuer hasn't used it, then someone else can take it. * @param _owner is address of the owner of the token * @param _ticker is unique token ticker * @param _tokenName is the name of the token */ function registerTicker(address _owner, string _ticker, string _tokenName) external whenNotPausedOrOwner { require(_owner != address(0), "Owner should not be 0x"); require(bytes(_ticker).length > 0 && bytes(_ticker).length <= 10, "Ticker length range (0,10]"); // Attempt to charge the reg fee if it is > 0 POLY uint256 tickerFee = getTickerRegistrationFee(); if (tickerFee > 0) require(IERC20(getAddress(POLYTOKEN)).transferFrom(msg.sender, address(this), tickerFee), "Insufficent allowance"); string memory ticker = Util.upper(_ticker); require(_tickerAvailable(ticker), "Ticker is reserved"); // Check whether ticker was previously registered (and expired) address previousOwner = _tickerOwner(ticker); if (previousOwner != address(0)) { _deleteTickerOwnership(previousOwner, ticker); } /*solium-disable-next-line security/no-block-members*/ _addTicker(_owner, ticker, _tokenName, now, now.add(getExpiryLimit()), false, false, tickerFee); } /** * @notice Internal - Sets the details of the ticker */ function _addTicker( address _owner, string _ticker, string _tokenName, uint256 _registrationDate, uint256 _expiryDate, bool _status, bool _fromAdmin, uint256 _fee ) internal { _setTickerOwnership(_owner, _ticker); _storeTickerDetails(_ticker, _owner, _registrationDate, _expiryDate, _tokenName, _status); emit RegisterTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _fee); } /** * @notice Modifies the ticker details. Only Polymath has the ability to do so. * @notice Only allowed to modify the tickers which are not yet deployed. * @param _owner is the owner of the token * @param _ticker is the token ticker * @param _tokenName is the name of the token * @param _registrationDate is the date at which ticker is registered * @param _expiryDate is the expiry date for the ticker * @param _status is the token deployment status */ function modifyTicker( address _owner, string _ticker, string _tokenName, uint256 _registrationDate, uint256 _expiryDate, bool _status ) external onlyOwner { require(bytes(_ticker).length > 0 && bytes(_ticker).length <= 10, "Ticker length range (0,10]"); require(_expiryDate != 0 && _registrationDate != 0, "Dates should not be 0"); require(_registrationDate <= _expiryDate, "Registration date should < expiry date"); require(_owner != address(0), "Invalid address"); string memory ticker = Util.upper(_ticker); _modifyTicker(_owner, ticker, _tokenName, _registrationDate, _expiryDate, _status); } /** * @notice Internal -- Modifies the ticker details. */ function _modifyTicker( address _owner, string _ticker, string _tokenName, uint256 _registrationDate, uint256 _expiryDate, bool _status ) internal { address currentOwner = _tickerOwner(_ticker); if (currentOwner != address(0)) { _deleteTickerOwnership(currentOwner, _ticker); } if (_tickerStatus(_ticker) && !_status) { set(Encoder.getKey("tickerToSecurityToken", _ticker), address(0)); } // If status is true, there must be a security token linked to the ticker already if (_status) { require(getAddress(Encoder.getKey("tickerToSecurityToken", _ticker)) != address(0), "Token not registered"); } _addTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true, uint256(0)); } function _tickerOwner(string _ticker) internal view returns(address) { return getAddress(Encoder.getKey("registeredTickers_owner", _ticker)); } /** * @notice Removes the ticker details, associated ownership & security token mapping * @param _ticker is the token ticker */ function removeTicker(string _ticker) external onlyOwner { string memory ticker = Util.upper(_ticker); address owner = _tickerOwner(ticker); require(owner != address(0), "Ticker doesn't exist"); _deleteTickerOwnership(owner, ticker); set(Encoder.getKey("tickerToSecurityToken", ticker), address(0)); _storeTickerDetails(ticker, address(0), 0, 0, "", false); /*solium-disable-next-line security/no-block-members*/ emit TickerRemoved(ticker, now, msg.sender); } /** * @notice Internal - Checks if the entered ticker is registered and has not expired * @param _ticker is the token ticker * @return bool */ function _tickerAvailable(string _ticker) internal view returns(bool) { if (_tickerOwner(_ticker) != address(0)) { /*solium-disable-next-line security/no-block-members*/ if ((now > getUint(Encoder.getKey("registeredTickers_expiryDate", _ticker))) && !_tickerStatus(_ticker)) { return true; } else return false; } return true; } function _tickerStatus(string _ticker) internal view returns(bool) { return getBool(Encoder.getKey("registeredTickers_status", _ticker)); } /** * @notice Internal - Sets the ticker owner * @param _owner is the address of the owner of the ticker * @param _ticker is the ticker symbol */ function _setTickerOwnership(address _owner, string _ticker) internal { bytes32 _ownerKey = Encoder.getKey("userToTickers", _owner); uint256 length = uint256(getArrayBytes32(_ownerKey).length); pushArray(_ownerKey, Util.stringToBytes32(_ticker)); set(Encoder.getKey("tickerIndex", _ticker), length); bytes32 seenKey = Encoder.getKey("seenUsers", _owner); if (!getBool(seenKey)) { pushArray(Encoder.getKey("activeUsers"), _owner); set(seenKey, true); } } /** * @notice Internal - Stores the ticker details */ function _storeTickerDetails( string _ticker, address _owner, uint256 _registrationDate, uint256 _expiryDate, string _tokenName, bool _status ) internal { bytes32 key = Encoder.getKey("registeredTickers_owner", _ticker); if (getAddress(key) != _owner) set(key, _owner); key = Encoder.getKey("registeredTickers_registrationDate", _ticker); if (getUint(key) != _registrationDate) set(key, _registrationDate); key = Encoder.getKey("registeredTickers_expiryDate", _ticker); if (getUint(key) != _expiryDate) set(key, _expiryDate); key = Encoder.getKey("registeredTickers_tokenName", _ticker); if (Encoder.getKey(getString(key)) != Encoder.getKey(_tokenName)) set(key, _tokenName); key = Encoder.getKey("registeredTickers_status", _ticker); if (getBool(key) != _status) set(key, _status); } /** * @notice Transfers the ownership of the ticker * @param _newOwner is the address of the new owner of the ticker * @param _ticker is the ticker symbol */ function transferTickerOwnership(address _newOwner, string _ticker) external whenNotPausedOrOwner { string memory ticker = Util.upper(_ticker); require(_newOwner != address(0), "Invalid address"); bytes32 ownerKey = Encoder.getKey("registeredTickers_owner", ticker); require(getAddress(ownerKey) == msg.sender, "Not authorised"); if (_tickerStatus(ticker)) require(IOwnable(getAddress(Encoder.getKey("tickerToSecurityToken", ticker))).owner() == _newOwner, "New owner does not match token owner"); _deleteTickerOwnership(msg.sender, ticker); _setTickerOwnership(_newOwner, ticker); set(ownerKey, _newOwner); emit ChangeTickerOwnership(ticker, msg.sender, _newOwner); } /** * @notice Internal - Removes the owner of a ticker */ function _deleteTickerOwnership(address _owner, string _ticker) internal { uint256 index = uint256(getUint(Encoder.getKey("tickerIndex", _ticker))); bytes32 ownerKey = Encoder.getKey("userToTickers", _owner); bytes32[] memory tickers = getArrayBytes32(ownerKey); assert(index < tickers.length); assert(_tickerOwner(_ticker) == _owner); deleteArrayBytes32(ownerKey, index); if (getArrayBytes32(ownerKey).length > index) { bytes32 switchedTicker = getArrayBytes32(ownerKey)[index]; set(Encoder.getKey("tickerIndex", Util.bytes32ToString(switchedTicker)), index); } } /** * @notice Changes the expiry time for the token ticker. Only available to Polymath. * @param _newExpiry is the new expiry for newly generated tickers */ function changeExpiryLimit(uint256 _newExpiry) external onlyOwner { require(_newExpiry >= 1 days, "Expiry should >= 1 day"); emit ChangeExpiryLimit(getUint(EXPIRYLIMIT), _newExpiry); set(EXPIRYLIMIT, _newExpiry); } /** * @notice Returns the list of tickers owned by the selected address * @param _owner is the address which owns the list of tickers */ function getTickersByOwner(address _owner) external view returns(bytes32[]) { uint counter = 0; // accessing the data structure userTotickers[_owner].length bytes32[] memory tickers = getArrayBytes32(Encoder.getKey("userToTickers", _owner)); for (uint i = 0; i < tickers.length; i++) { string memory ticker = Util.bytes32ToString(tickers[i]); /*solium-disable-next-line security/no-block-members*/ if (getUint(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now || _tickerStatus(ticker)) { counter ++; } } bytes32[] memory tempList = new bytes32[](counter); counter = 0; for (i = 0; i < tickers.length; i++) { ticker = Util.bytes32ToString(tickers[i]); /*solium-disable-next-line security/no-block-members*/ if (getUint(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now || _tickerStatus(ticker)) { tempList[counter] = tickers[i]; counter ++; } } return tempList; } /** * @notice Returns the list of tokens owned by the selected address * @param _owner is the address which owns the list of tickers * @dev Intention is that this is called off-chain so block gas limit is not relevant */ function getTokensByOwner(address _owner) external view returns(address[]) { // Loop over all active users, then all associated tickers of those users // This ensures we find tokens, even if their owner has been modified address[] memory activeUsers = getArrayAddress(Encoder.getKey("activeUsers")); bytes32[] memory tickers; address token; uint256 count = 0; uint256 i = 0; uint256 j = 0; for (i = 0; i < activeUsers.length; i++) { tickers = getArrayBytes32(Encoder.getKey("userToTickers", activeUsers[i])); for (j = 0; j < tickers.length; j++) { token = getAddress(Encoder.getKey("tickerToSecurityToken", Util.bytes32ToString(tickers[j]))); if (token != address(0)) { if (IOwnable(token).owner() == _owner) { count = count + 1; } } } } uint256 index = 0; address[] memory result = new address[](count); for (i = 0; i < activeUsers.length; i++) { tickers = getArrayBytes32(Encoder.getKey("userToTickers", activeUsers[i])); for (j = 0; j < tickers.length; j++) { token = getAddress(Encoder.getKey("tickerToSecurityToken", Util.bytes32ToString(tickers[j]))); if (token != address(0)) { if (IOwnable(token).owner() == _owner) { result[index] = token; index = index + 1; } } } } return result; } /** * @notice Returns the owner and timestamp for a given ticker * @param _ticker is the ticker symbol * @return address * @return uint256 * @return uint256 * @return string * @return bool */ function getTickerDetails(string _ticker) external view returns (address, uint256, uint256, string, bool) { string memory ticker = Util.upper(_ticker); bool tickerStatus = _tickerStatus(ticker); uint256 expiryDate = getUint(Encoder.getKey("registeredTickers_expiryDate", ticker)); /*solium-disable-next-line security/no-block-members*/ if ((tickerStatus == true) || (expiryDate > now)) { return ( _tickerOwner(ticker), getUint(Encoder.getKey("registeredTickers_registrationDate", ticker)), expiryDate, getString(Encoder.getKey("registeredTickers_tokenName", ticker)), tickerStatus ); } else return (address(0), uint256(0), uint256(0), "", false); } ///////////////////////////// // Security Token Management ///////////////////////////// /** * @notice Deploys an instance of a new Security Token and records it to the registry * @param _name is the name of the token * @param _ticker is the ticker symbol of the security token * @param _tokenDetails is the off-chain details of the token * @param _divisible is whether or not the token is divisible */ function generateSecurityToken(string _name, string _ticker, string _tokenDetails, bool _divisible) external whenNotPausedOrOwner { require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "Ticker length > 0"); string memory ticker = Util.upper(_ticker); bytes32 statusKey = Encoder.getKey("registeredTickers_status", ticker); require(!getBool(statusKey), "Already deployed"); set(statusKey, true); require(_tickerOwner(ticker) == msg.sender, "Not authorised"); /*solium-disable-next-line security/no-block-members*/ require(getUint(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now, "Ticker gets expired"); uint256 launchFee = getSecurityTokenLaunchFee(); if (launchFee > 0) require(IERC20(getAddress(POLYTOKEN)).transferFrom(msg.sender, address(this), launchFee), "Insufficient allowance"); address newSecurityTokenAddress = ISTFactory(getSTFactoryAddress()).deployToken( _name, ticker, 18, _tokenDetails, msg.sender, _divisible, getAddress(POLYMATHREGISTRY) ); /*solium-disable-next-line security/no-block-members*/ _storeSecurityTokenData(newSecurityTokenAddress, ticker, _tokenDetails, now); set(Encoder.getKey("tickerToSecurityToken", ticker), newSecurityTokenAddress); /*solium-disable-next-line security/no-block-members*/ emit NewSecurityToken(ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, launchFee); } /** * @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface) * @param _name is the name of the token * @param _ticker is the ticker symbol of the security token * @param _owner is the owner of the token * @param _securityToken is the address of the securityToken * @param _tokenDetails is the off-chain details of the token * @param _deployedAt is the timestamp at which the security token is deployed */ function modifySecurityToken( string _name, string _ticker, address _owner, address _securityToken, string _tokenDetails, uint256 _deployedAt ) external onlyOwner { require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "String length > 0"); require(bytes(_ticker).length <= 10, "Ticker length range (0,10]"); require(_deployedAt != 0 && _owner != address(0), "0 value params not allowed"); string memory ticker = Util.upper(_ticker); require(_securityToken != address(0), "ST address is 0x"); uint256 registrationTime = getUint(Encoder.getKey("registeredTickers_registrationDate", ticker)); uint256 expiryTime = getUint(Encoder.getKey("registeredTickers_expiryDate", ticker)); if (registrationTime == 0) { /*solium-disable-next-line security/no-block-members*/ registrationTime = now; expiryTime = registrationTime.add(getExpiryLimit()); } set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken); _modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true); _storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt); emit NewSecurityToken(ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, getSecurityTokenLaunchFee()); } /** * @notice Internal - Stores the security token details */ function _storeSecurityTokenData(address _securityToken, string _ticker, string _tokenDetails, uint256 _deployedAt) internal { set(Encoder.getKey("securityTokens_ticker", _securityToken), _ticker); set(Encoder.getKey("securityTokens_tokenDetails", _securityToken), _tokenDetails); set(Encoder.getKey("securityTokens_deployedAt", _securityToken), _deployedAt); } /** * @notice Checks that Security Token is registered * @param _securityToken is the address of the security token * @return bool */ function isSecurityToken(address _securityToken) external view returns (bool) { return (keccak256(bytes(getString(Encoder.getKey("securityTokens_ticker", _securityToken)))) != keccak256("")); } /** * @notice Returns the security token address by ticker symbol * @param _ticker is the ticker of the security token * @return address */ function getSecurityTokenAddress(string _ticker) external view returns (address) { string memory ticker = Util.upper(_ticker); return getAddress(Encoder.getKey("tickerToSecurityToken", ticker)); } /** * @notice Returns the security token data by address * @param _securityToken is the address of the security token. * @return string is the ticker of the security Token. * @return address is the issuer of the security Token. * @return string is the details of the security token. * @return uint256 is the timestamp at which security Token was deployed. */ function getSecurityTokenData(address _securityToken) external view returns (string, address, string, uint256) { return ( getString(Encoder.getKey("securityTokens_ticker", _securityToken)), IOwnable(_securityToken).owner(), getString(Encoder.getKey("securityTokens_tokenDetails", _securityToken)), getUint(Encoder.getKey("securityTokens_deployedAt", _securityToken)) ); } ///////////////////////////// // Ownership, lifecycle & Utility ///////////////////////////// /** * @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) external onlyOwner { require(_newOwner != address(0), "Invalid address"); emit OwnershipTransferred(getAddress(OWNER), _newOwner); set(OWNER, _newOwner); } /** * @notice Called by the owner to pause, triggers stopped state */ function pause() external whenNotPaused onlyOwner { set(PAUSED, true); /*solium-disable-next-line security/no-block-members*/ emit Pause(now); } /** * @notice Called by the owner to unpause, returns to normal state */ function unpause() external whenPaused onlyOwner { set(PAUSED, false); /*solium-disable-next-line security/no-block-members*/ emit Unpause(now); } /** * @notice Sets the ticker registration fee in POLY tokens. Only Polymath. * @param _tickerRegFee is the registration fee in POLY tokens (base 18 decimals) */ function changeTickerRegistrationFee(uint256 _tickerRegFee) external onlyOwner { uint256 fee = getUint(TICKERREGFEE); require(fee != _tickerRegFee, "Fee not changed"); emit ChangeTickerRegistrationFee(fee, _tickerRegFee); set(TICKERREGFEE, _tickerRegFee); } /** * @notice Sets the ticker registration fee in POLY tokens. Only Polymath. * @param _stLaunchFee is the registration fee in POLY tokens (base 18 decimals) */ function changeSecurityLaunchFee(uint256 _stLaunchFee) external onlyOwner { uint256 fee = getUint(STLAUNCHFEE); require(fee != _stLaunchFee, "Fee not changed"); emit ChangeSecurityLaunchFee(fee, _stLaunchFee); set(STLAUNCHFEE, _stLaunchFee); } /** * @notice Reclaims all ERC20Basic compatible tokens * @param _tokenContract is the address of the token contract */ function reclaimERC20(address _tokenContract) external onlyOwner { require(_tokenContract != address(0), "Invalid address"); IERC20 token = IERC20(_tokenContract); uint256 balance = token.balanceOf(address(this)); require(token.transfer(owner(), balance), "Transfer failed"); } /** * @notice Changes the protocol version and the SecurityToken contract * @notice Used only by Polymath to upgrade the SecurityToken contract and add more functionalities to future versions * @notice Changing versions does not affect existing tokens. * @param _STFactoryAddress is the address of the proxy. * @param _major Major version of the proxy. * @param _minor Minor version of the proxy. * @param _patch Patch version of the proxy */ function setProtocolVersion(address _STFactoryAddress, uint8 _major, uint8 _minor, uint8 _patch) external onlyOwner { require(_STFactoryAddress != address(0), "0x address is not allowed"); _setProtocolVersion(_STFactoryAddress, _major, _minor, _patch); } /** * @notice Internal - Changes the protocol version and the SecurityToken contract */ function _setProtocolVersion(address _STFactoryAddress, uint8 _major, uint8 _minor, uint8 _patch) internal { uint8[] memory _version = new uint8[](3); _version[0] = _major; _version[1] = _minor; _version[2] = _patch; uint24 _packedVersion = VersionUtils.pack(_major, _minor, _patch); require(VersionUtils.isValidVersion(getProtocolVersion(), _version),"In-valid version"); set(Encoder.getKey("latestVersion"), uint256(_packedVersion)); set(Encoder.getKey("protocolVersionST", getUint(Encoder.getKey("latestVersion"))), _STFactoryAddress); } /** * @notice Returns the current STFactory Address */ function getSTFactoryAddress() public view returns(address) { return getAddress(Encoder.getKey("protocolVersionST", getUint(Encoder.getKey("latestVersion")))); } /** * @notice Gets Protocol version */ function getProtocolVersion() public view returns(uint8[]) { return VersionUtils.unpack(uint24(getUint(Encoder.getKey("latestVersion")))); } /** * @notice Changes the PolyToken address. Only Polymath. * @param _newAddress is the address of the polytoken. */ function updatePolyTokenAddress(address _newAddress) external onlyOwner { require(_newAddress != address(0), "Invalid address"); set(POLYTOKEN, _newAddress); } /** * @notice Gets the security token launch fee * @return Fee amount */ function getSecurityTokenLaunchFee() public view returns(uint256) { return getUint(STLAUNCHFEE); } /** * @notice Gets the ticker registration fee * @return Fee amount */ function getTickerRegistrationFee() public view returns(uint256) { return getUint(TICKERREGFEE); } /** * @notice Gets the expiry limit * @return Expiry limit */ function getExpiryLimit() public view returns(uint256) { return getUint(EXPIRYLIMIT); } /** * @notice Check whether the registry is paused or not * @return bool */ function isPaused() public view returns(bool) { return getBool(PAUSED); } /** * @notice Gets the owner of the contract * @return address owner */ function owner() public view returns(address) { return getAddress(OWNER); } }
* @notice Modifier to make a function callable only when the contract is paused./
modifier whenPaused() { require(isPaused(), "Should not be paused"); _; }
12,831,524
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 12832, 358, 1221, 279, 445, 4140, 1338, 1347, 326, 6835, 353, 17781, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 9606, 1347, 28590, 1435, 288, 203, 3639, 2583, 12, 291, 28590, 9334, 315, 14309, 486, 506, 17781, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: GPL-3.0 pragma solidity =0.8.10; import "./IERC20.sol"; import "./IUniswapV2Router02.sol"; import "./IUniswapV2Factory.sol"; import "./IUniswapV2Pair.sol"; import "./IHyperDeFi.sol"; import "./IHyperDeFiBuffer.sol"; import "./IHyperDeFiIDO.sol"; import "./Ownable.sol"; import "./Math.sol"; import "./HyperDeFiTokenMetadata.sol"; /** * @dev DeFi Token */ contract HyperDeFiToken is Ownable, IHyperDeFi, HyperDeFiTokenMetadata { using Math for uint256; struct Percentage { uint8 farm; uint8 airdrop; uint8 fomo; uint8 liquidity; uint8 fund; uint8 destroy; } struct Snap { uint256 totalSupply; uint256 totalTax; } bool private _swapLock; uint256 internal _totalSupply; uint256 internal _distributed; uint256 internal _totalFarm; uint256 internal _totalUsername; uint256 internal _fomoTimestamp; address[] internal _flats; address[] internal _slots; address[] internal _funds; address[] internal _holders; // Resources IHyperDeFiIDO internal constant IDO = IHyperDeFiIDO(ADDRESS_IDO); IHyperDeFiBuffer internal constant BUFFER = IHyperDeFiBuffer(ADDRESS_BUFFER); IUniswapV2Router02 internal constant DEX = IUniswapV2Router02(ADDRESS_DEX); IUniswapV2Factory internal immutable DEX_FACTORY; IUniswapV2Pair internal immutable DEX_PAIR; IERC20 internal immutable WRAP; // uint256 internal _initPrice; uint256 internal _timestampLiquidityCreated; address internal _fomoNextAccount; // tax Percentage internal TAKER_TAX = Percentage(3, 1, 2, 5, 1, 3); Percentage internal MAKER_TAX = Percentage(3, 1, 1, 4, 1, 0); Percentage internal WHALE_TAX = Percentage(3, 1, 1, 5, 1, 19); Percentage internal ROBBER_TAX = Percentage(3, 1, 1, 5, 1, 74); mapping (address => uint256) internal _balance; mapping (address => uint256) internal _totalHarvest; mapping (address => uint256) internal _totalFarmSnap; mapping (address => string) internal _username; mapping (address => bool) internal _usernamed; mapping (string => address) internal _username2address; mapping (address => uint256) internal _coupon; mapping (uint256 => address) internal _inviter; mapping (address => uint256) internal _couponUsed; mapping (address => uint256) internal _visitors; mapping (address => bool) internal _isFlat; mapping (address => bool) internal _isSlot; mapping (address => bool) internal _isFund; mapping (address => bool) internal _isHolder; mapping (address => mapping (address => uint256)) internal _allowances; // enum enum TX_TYPE {MINT, HARVEST, FLAT, TAKER, MAKER, WHALE, ROBBER} // events event TX(uint8 indexed txType, address indexed sender, address indexed recipient, uint256 amount, uint256 txAmount); event SlotRegistered(address account); event UsernameSet(address indexed account, string username); event CouponVisitor(address inviter, address visitor); event Airdrop(address indexed account, uint256 amount); event Bonus(address indexed account, uint256 amount); event Fund(address indexed account, uint256 amount); // modifier withSwapLock { _swapLock = true; _; _swapLock = false; } // constructor () { WRAP = IERC20(DEX.WETH()); DEX_FACTORY = IUniswapV2Factory(DEX.factory()); DEX_PAIR = IUniswapV2Pair(DEX_FACTORY.createPair(address(WRAP), address(this))); _registerFund(FOMO); _registerFund(BLACK_HOLE); _registerFund(address(BUFFER)); _registerFund(address(IDO)); _registerFund(address(this)); _registerFund(_msgSender()); _mint(BLACK_HOLE, BURN_AMOUNT); _mint(address(IDO), IDO_AMOUNT); _isHolder[owner()] = true; _holders.push(owner()); } function getIDOConfigs() public pure returns ( uint256 IDOAmount, uint256 IDODepositCap, uint256 IDODepositMax, uint32 IDOTimestampFrom, uint32 IDOTimestampTo, address buffer ) { IDOAmount = IDO_AMOUNT; IDODepositCap = IDO_DEPOSIT_CAP; IDODepositMax = IDO_DEPOSIT_MAX; IDOTimestampFrom = IDO_TIMESTAMP_FROM; IDOTimestampTo = IDO_TIMESTAMP_TO; buffer = ADDRESS_BUFFER; } function getBufferConfigs() public pure returns ( address dex, address usd ) { dex = ADDRESS_DEX; usd = ADDRESS_USD; } function isInitialLiquidityCreated() public view returns (bool) { return 0 < _timestampLiquidityCreated; } /** * @dev Set username for `_msgSender()` */ function setUsername(string calldata value) external { require(0 < balanceOf(_msgSender()) || IDO.isFounder(_msgSender()), "HyperDeFi: balance is zero"); require(address(0) == _username2address[value], "HyperDeFi: username is already benn taken"); require(!_usernamed[_msgSender()], "HyperDeFi: username cannot be changed"); _username[_msgSender()] = value; _usernamed[_msgSender()] = true; _username2address[value] = _msgSender(); _totalUsername++; emit UsernameSet(_msgSender(), value); _mayAutoSwapIntoLiquidity(); } /** * @dev Generate coupon for `_msgSender()` */ function genConpon() external { require(0 < balanceOf(_msgSender()) || IDO.isFounder(_msgSender()), "HyperDeFi Conpon: balance is zero"); require(_coupon[_msgSender()] == 0, "HyperDeFi Conpon: already generated"); uint256 coupon = uint256(keccak256(abi.encode(blockhash(block.number - 1), _msgSender()))) % type(uint32).max; require(0 < coupon, "HyperDeFi Conpon: invalid code, please retry"); _coupon[_msgSender()] = coupon; _inviter[coupon] = _msgSender(); _mayAutoSwapIntoLiquidity(); } /** * @dev Set coupon for `_msgSender()` */ function useCoupon(uint256 coupon) external { address inviter = _inviter[coupon]; require(isValidCouponForAccount(coupon, _msgSender()), "HyperDeFi Coupon: invalid"); _couponUsed[_msgSender()] = coupon; _visitors[inviter]++; emit CouponVisitor(inviter, _msgSender()); _mayAutoSwapIntoLiquidity(); } /** * @dev Returns `true` if `coupon` is valid for `account` */ function isValidCouponForAccount(uint256 coupon, address account) public view returns (bool) { address inviter = _inviter[coupon]; if (inviter == address(0)) return false; for (uint8 i = 1; i < BONUS.length; i++) { if (inviter == account) return false; inviter = _inviter[_couponUsed[inviter]]; if (inviter == address(0)) return true; } return true; } /** * @dev Pay TAX */ function payFee(uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy) public returns (bool) { uint256 amount = farm + airdrop + fomo + liquidity + fund + destroy; require(amount > 0, "HyperDeFi: fee amount is zero"); require(amount <= balanceOf(_msgSender()), "HyperDeFi: fee amount exceeds balance"); unchecked { _balance[_msgSender()] -= amount; } if (0 < farm) _payFarm( _msgSender(), farm); if (0 < airdrop) _payAirdrop( _msgSender(), airdrop, _generateRandom(tx.origin)); if (0 < fomo) _payFomo( _msgSender(), fomo); if (0 < liquidity) _payLiquidity(_msgSender(), liquidity); if (0 < fund) _payFund( _msgSender(), fund); if (0 < destroy) _payDestroy( _msgSender(), destroy); _mayAutoSwapIntoLiquidity(); return true; } /** * @dev Pay TAX from `sender` */ function payFeeFrom(address sender, uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy) public returns (bool) { uint256 amount = farm + airdrop + fomo + liquidity + fund + destroy; require(amount > 0, "HyperDeFi: fee amount is zero"); require(amount <= balanceOf(sender), "HyperDeFi: fee amount exceeds balance"); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "HyperDeFi: fee amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); _balance[sender] -= amount; } if (0 < farm) _payFarm( sender, farm); if (0 < airdrop) _payAirdrop( sender, airdrop, _generateRandom(tx.origin)); if (0 < fomo) _payFomo( sender, fomo); if (0 < liquidity) _payLiquidity(sender, liquidity); if (0 < fund) _payFund( sender, fund); if (0 < destroy) _payDestroy( sender, destroy); _mayAutoSwapIntoLiquidity(); return true; } function harvestOf(address account) public view returns (uint256) { if (_totalFarm <= _totalFarmSnap[account]) return 0; // never happens uint256 harvest = _balance[account] * (_totalFarm - _totalFarmSnap[account]) / _totalSupply; return harvest.min(balanceOf(FARM)); } function takeHarvest() public returns (bool) { _takeHarvest(_msgSender()); _mayAutoSwapIntoLiquidity(); return true; } /** * @dev Register a slot for DApp */ function registerSlot(address account) public onlyOwner { require(!_isSlot[account], "The slot is already exist"); require(!_isHolder[account], "The holder is already exist"); _isSlot[account] = true; _isFlat[account] = true; _slots.push(account); _flats.push(account); emit SlotRegistered(account); _mayAutoSwapIntoLiquidity(); } // --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- ERC20 /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balance[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 override returns (bool) { if (BLACK_HOLE == recipient || address(this) == recipient) { _burn(_msgSender(), amount); return true; } _transfer(_msgSender(), recipient, amount); return true; } /** * @dev Create initial liquidity */ function createInitLiquidity() public payable returns (bool) { require(_msgSender() == address(IDO), "HyperDeFi: caller is not the IDO contract"); require(0 == _timestampLiquidityCreated, "HyperDeFi: initial liquidity has been created"); _initPrice = address(this).balance * 10 ** _decimals / INIT_LIQUIDITY; _mint(address(this), INIT_LIQUIDITY); _approve(address(this), ADDRESS_DEX, type(uint256).max); DEX.addLiquidityETH{value: address(this).balance}( address(this), INIT_LIQUIDITY, 0, 0, BLACK_HOLE, block.timestamp ); _timestampLiquidityCreated = block.timestamp; return true; } /** * @dev Burn */ function burn(uint256 amount) public returns (bool) { _burn(_msgSender(), amount); _mayAutoSwapIntoLiquidity(); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view 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 override returns (bool) { _approve(_msgSender(), spender, amount); _mayAutoSwapIntoLiquidity(); 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 override returns (bool) { uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } _transfer(sender, recipient, amount); return true; } /** * @dev Burn from `sender` */ function burnFrom(address sender, uint256 amount) public returns (bool) { uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } _burn(sender, amount); _mayAutoSwapIntoLiquidity(); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); _mayAutoSwapIntoLiquidity(); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } _mayAutoSwapIntoLiquidity(); return true; } /** * @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 { 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 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) private { require(account != address(0), "ERC20: mint to the zero address"); require(TOTAL_SUPPLY_CAP >= _totalSupply + amount, "ERC20: cap exceeded"); _totalSupply += amount; _balance[account] += amount; emit Transfer(address(0), account, amount); emit TX(uint8(TX_TYPE.MINT), address(0), account, amount, amount); } /** * @dev Destroys `amount` tokens from `account` to black-hole. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); require(_totalSupply >= amount, "ERC20: burn amount exceeds total supply"); require(_balance[account] >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balance[account] -= amount; _balance[BLACK_HOLE] += amount; } emit Transfer(account, BLACK_HOLE, amount); } // --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- --------- ERC20 <END> function _priceToken2WRAP() internal view returns (uint256 price) { uint256 pairTokenAmount = balanceOf(address(DEX_PAIR)); if (0 < pairTokenAmount) { return BUFFER.priceToken2WRAP(); } else { return IDO.priceToken2WRAP(); } } function _priceToken2USD() internal view returns (uint256 price) { uint256 pairTokenAmount = balanceOf(address(DEX_PAIR)); if (0 < pairTokenAmount) { return BUFFER.priceToken2USD(); } else { return IDO.priceToken2USD(); } } function _takeHarvest(address account) internal { uint256 amount = harvestOf(account); if (0 == amount) return; _totalFarmSnap[account] = _totalFarm; if (0 == amount) return; if (_balance[FARM] < amount) return; unchecked { _balance[FARM] -= amount; } _balance[account] += amount; _totalHarvest[account] += amount; emit Transfer(FARM, account, amount); emit TX(uint8(TX_TYPE.HARVEST), FARM, account, amount, amount); } /** * @dev Register a fund for this DeFi token */ function _registerFund(address account) internal { require(!_isFund[account], "The fund is already exist"); require(!_isHolder[account], "The holder is already exist"); _isFund[account] = true; _isFlat[account] = true; _funds.push(account); _flats.push(account); } /** * @dev Add Holder */ function _addHolder(address account) internal { if (_isHolder[account] || _isSlot[account] || _isFund[account]) return; if (account == ADDRESS_DEX || account == address(DEX_PAIR)) return; _isHolder[account] = true; _holders.push(account); } /** * @dev Auto-swap amount */ function _getAutoSwapAmountMin() internal view returns (uint256) { uint256 pairBalance = balanceOf(address(DEX_PAIR)); if (0 < pairBalance) return pairBalance * AUTO_SWAP_NUMERATOR_MIN / AUTO_SWAP_DENOMINATOR; return INIT_LIQUIDITY * AUTO_SWAP_NUMERATOR_MIN / AUTO_SWAP_DENOMINATOR; } function _getAutoSwapAmountMax() internal view returns (uint256) { uint256 pairBalance = balanceOf(address(DEX_PAIR)); if (0 < pairBalance) return pairBalance * AUTO_SWAP_NUMERATOR_MAX / AUTO_SWAP_DENOMINATOR; return INIT_LIQUIDITY * AUTO_SWAP_NUMERATOR_MAX / AUTO_SWAP_DENOMINATOR; } /** * @dev Returns whale balance amount */ function _getWhaleThreshold() internal view returns (uint256 amount) { uint256 pairBalance = balanceOf(address(DEX_PAIR)); if (0 < pairBalance) return pairBalance * WHALE_NUMERATOR / WHALE_DENOMINATOR; } /** * @dev Returns robber balance amount */ function _getRobberThreshold() internal view returns (uint256 amount) { uint256 pairBalance = balanceOf(address(DEX_PAIR)); if (0 < pairBalance) return pairBalance * ROBBER_PERCENTAGE / 100; } /** * @dev FOMO amount */ function _getFomoAmount() internal view returns (uint256) { return balanceOf(FOMO) * FOMO_PERCENTAGE / 100; } /** * @dev May auto-swap into liquidity - from the `_BUFFER` contract */ function _mayAutoSwapIntoLiquidity() internal withSwapLock { // may mint to `_BUFFER` _mayMintToBuffer(); // may swap uint256 amount = balanceOf(address(BUFFER)); if (0 == amount) return; if (amount < _getAutoSwapAmountMin()) return; _approve(address(BUFFER), address(DEX), balanceOf(address(BUFFER))); BUFFER.swapIntoLiquidity(amount.min(_getAutoSwapAmountMax())); } /** * @dev Transfer token */ 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"); require(amount > 0, "ERC20: transfer amount is zero"); require(amount <= balanceOf(sender), "ERC20: transfer amount exceeds the balance"); // may transfer fomo _mayMoveFomo(); // get harvest for recipient if (recipient != address(DEX_PAIR)) _takeHarvest(recipient); // may auto-swap into liquidity if (sender != address(DEX_PAIR) && recipient != address(DEX_PAIR) && !_swapLock) _mayAutoSwapIntoLiquidity(); // tx type uint256 coupon = sender == address(DEX_PAIR) ? _couponUsed[recipient] : _couponUsed[sender]; TX_TYPE txType = TX_TYPE.TAKER; if (_isFlat[sender] || _isFlat[recipient]) txType = TX_TYPE.FLAT; else if (sender == address(DEX_PAIR)) txType = TX_TYPE.MAKER; // whale or robber if (txType != TX_TYPE.FLAT) { require(block.timestamp > TIMESTAMP_LAUNCH, "HyperDeFi: transfer before the `LAUNCH_TIMESTAMP`"); uint256 whaleThreshold = _getWhaleThreshold(); uint256 txAmountIfWhale = amount * (100 - WHALE_TAX.farm - WHALE_TAX.airdrop - WHALE_TAX.fomo - WHALE_TAX.liquidity - WHALE_TAX.fund - WHALE_TAX.destroy) / 100; // buy as/to a whale if (sender == address(DEX_PAIR) && whaleThreshold < balanceOf(recipient) + txAmountIfWhale) txType = TX_TYPE.WHALE; // sell as a whale else if (recipient == address(DEX_PAIR) && whaleThreshold < balanceOf(sender)) txType = TX_TYPE.WHALE; // send from a whale else if (sender != address(DEX_PAIR) && recipient != address(DEX_PAIR) && whaleThreshold < balanceOf(sender)) txType = TX_TYPE.WHALE; // // send to a whale // else if (sender != DEX_PAIR && recipient != DEX_PAIR && whaleThreshold < balanceOf(recipient)) txType = TX_TYPE.WHALE; // buy/sell as a robber if ((sender == address(DEX_PAIR) || recipient == address(DEX_PAIR)) && _getRobberThreshold() < amount) txType = TX_TYPE.ROBBER; } // tx uint256 rand = _generateRandom(tx.origin); (uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy, uint256 txAmount) = _txData(amount, txType, coupon); _balance[sender] -= amount; _balance[recipient] += txAmount; emit Transfer(sender, recipient, txAmount); // buy from liquidity, non-slot if (sender == address(DEX_PAIR) && !_isFlat[recipient] && !_isSlot[recipient] && txType != TX_TYPE.ROBBER) { // fomo _fomoNextAccount = recipient; _fomoTimestamp = block.timestamp + FOMO_TIMESTAMP_STEP; } // fee if (0 < farm) _payFarm( sender, farm); if (0 < airdrop) _payAirdrop( sender, airdrop, rand); if (0 < fomo) _payFomo( sender, fomo); if (0 < liquidity) _payLiquidity(sender, liquidity); if (0 < fund) _payFund( sender, fund); if (0 < destroy) _payDestroy( sender, destroy); // Tx event emit TX(uint8(txType), sender, recipient, amount, txAmount); // // may mint to `_BUFFER` // if (!_isFlat[sender] && !_isFlat[recipient]) _mayMintToBuffer(); // add holder _addHolder(sender); _addHolder(recipient); } /** * @dev Generate random from account */ function _generateRandom(address account) private view returns (uint256) { return uint256(keccak256(abi.encode(blockhash(block.number - 1), account))); } /** * @dev TxData */ function _txData(uint256 amount, TX_TYPE txType, uint256 coupon) private view returns ( uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy, uint256 txAmount ) { (farm, airdrop, fomo, liquidity, fund, destroy) = _txDataWithoutTxAmount(amount, txType, coupon); txAmount = amount - farm - airdrop - fomo - liquidity - fund - destroy; return (farm, airdrop, fomo, liquidity, fund, destroy, txAmount); } function _txDataWithoutTxAmount(uint256 amount, TX_TYPE txType, uint256 coupon) private view returns ( uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy ) { if (txType == TX_TYPE.FLAT) return (0, 0, 0, 0, 0, 0); Percentage memory percentage; if (txType == TX_TYPE.MAKER) percentage = MAKER_TAX; else if (txType == TX_TYPE.WHALE) percentage = WHALE_TAX; else if (txType == TX_TYPE.ROBBER) percentage = ROBBER_TAX; else percentage = TAKER_TAX; if (0 < percentage.farm) farm = amount * percentage.farm / 100; if (0 < percentage.airdrop) airdrop = amount * percentage.airdrop / 100; if (0 < percentage.fomo) fomo = amount * percentage.fomo / 100; if (0 < percentage.liquidity) { if (coupon == 0 || txType == TX_TYPE.ROBBER) { liquidity = amount * percentage.liquidity / 100; } else { liquidity = amount * (percentage.liquidity - 1) / 100; } } if (0 < percentage.fund) fund = amount * percentage.fund / 100; if (0 < percentage.destroy) destroy = amount * percentage.destroy / 100; return (farm, airdrop, fomo, liquidity, fund, destroy); } /** * @dev Pay FARM */ function _payFarm(address account, uint256 amount) private { _totalFarm += amount; _balance[FARM] += amount; emit Transfer(account, FARM, amount); } /** * @dev Pay AIRDROP */ function _payAirdrop(address account, uint256 amount, uint256 rand) private { uint256 destroy; uint256 airdrop = amount; address accountAirdrop = _holders[rand % _holders.length]; address accountLoop = accountAirdrop; for (uint8 i; i < BONUS.length; i++) { address inviter = _inviter[_couponUsed[accountLoop]]; if (inviter == address(0)) { break; } uint256 bonus = amount * BONUS[i] / 100; airdrop -= bonus; if (balanceOf(inviter) < AIRDROP_THRESHOLD) { destroy += bonus; } else { _balance[inviter] += bonus; emit Transfer(account, inviter, bonus); emit Bonus(inviter, bonus); } accountLoop = inviter; } if (balanceOf(accountAirdrop) < AIRDROP_THRESHOLD) { destroy += airdrop; airdrop = 0; } if (0 < destroy) { _payDestroy(account, destroy); } if (0 < airdrop) { _balance[accountAirdrop] += airdrop; emit Transfer(account, accountAirdrop, airdrop); emit Airdrop(accountAirdrop, airdrop); } } /** * @dev Pay FOMO to `_fomo` */ function _payFomo(address account, uint256 amount) private { _balance[FOMO] += amount; emit Transfer(account, FOMO, amount); } /** * @dev Pay LIQUIDITY */ function _payLiquidity(address account, uint256 amount) private { _balance[address(BUFFER)] += amount; emit Transfer(account, address(BUFFER), amount); } /** * @dev Pay FUND */ function _payFund(address account, uint256 amount) private { _balance[owner()] += amount; emit Transfer(account, owner(), amount); emit Fund(account, amount); } /** * @dev pay DESTROY */ function _payDestroy(address account, uint256 amount) internal { _balance[BLACK_HOLE] += amount; emit Transfer(account, BLACK_HOLE, amount); } /** * @dev May move FOMO amount */ function _mayMoveFomo() private { if (_fomoNextAccount == address(0) || block.timestamp < _fomoTimestamp) return; uint256 amount = _getFomoAmount(); _balance[FOMO] -= amount; _balance[_fomoNextAccount] += amount; emit Transfer(FOMO, _fomoNextAccount, amount); _fomoNextAccount = address(0); } /** * @dev May mint to `_BUFFER` */ function _mayMintToBuffer() private { if (0 == _initPrice) return; if (0 == balanceOf(address(DEX_PAIR))) return; uint256 amount = DIST_AMOUNT * BUFFER.priceToken2WRAP() / _initPrice / 1024; if (amount >= DIST_AMOUNT) return; if (_distributed >= amount) return; amount -= _distributed; _distributed += amount; _mint(address(BUFFER), amount); } }
* @dev Pay TAX from `sender`/
function payFeeFrom(address sender, uint256 farm, uint256 airdrop, uint256 fomo, uint256 liquidity, uint256 fund, uint256 destroy) public returns (bool) { uint256 amount = farm + airdrop + fomo + liquidity + fund + destroy; require(amount > 0, "HyperDeFi: fee amount is zero"); require(amount <= balanceOf(sender), "HyperDeFi: fee amount exceeds balance"); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "HyperDeFi: fee amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); _balance[sender] -= amount; } if (0 < farm) _payFarm( sender, farm); if (0 < airdrop) _payAirdrop( sender, airdrop, _generateRandom(tx.origin)); if (0 < fomo) _payFomo( sender, fomo); if (0 < liquidity) _payLiquidity(sender, liquidity); if (0 < fund) _payFund( sender, fund); if (0 < destroy) _payDestroy( sender, destroy); _mayAutoSwapIntoLiquidity(); return true; }
5,439,704
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 13838, 399, 2501, 628, 1375, 15330, 68, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 8843, 14667, 1265, 12, 2867, 5793, 16, 2254, 5034, 284, 4610, 16, 2254, 5034, 279, 6909, 1764, 16, 2254, 5034, 284, 362, 83, 16, 2254, 5034, 4501, 372, 24237, 16, 2254, 5034, 284, 1074, 16, 2254, 5034, 5546, 13, 1071, 1135, 261, 6430, 13, 288, 203, 3639, 2254, 5034, 3844, 273, 284, 4610, 397, 279, 6909, 1764, 397, 284, 362, 83, 397, 4501, 372, 24237, 397, 284, 1074, 397, 5546, 31, 203, 3639, 2583, 12, 8949, 405, 374, 16, 315, 15996, 758, 42, 77, 30, 14036, 3844, 353, 3634, 8863, 203, 3639, 2583, 12, 8949, 1648, 11013, 951, 12, 15330, 3631, 315, 15996, 758, 42, 77, 30, 14036, 3844, 14399, 11013, 8863, 203, 203, 3639, 2254, 5034, 783, 7009, 1359, 273, 389, 5965, 6872, 63, 15330, 6362, 67, 3576, 12021, 1435, 15533, 203, 3639, 2583, 12, 2972, 7009, 1359, 1545, 3844, 16, 315, 15996, 758, 42, 77, 30, 14036, 3844, 14399, 1699, 1359, 8863, 203, 3639, 22893, 288, 203, 5411, 389, 12908, 537, 12, 15330, 16, 389, 3576, 12021, 9334, 783, 7009, 1359, 300, 3844, 1769, 203, 5411, 389, 12296, 63, 15330, 65, 3947, 3844, 31, 203, 3639, 289, 203, 203, 3639, 309, 261, 20, 411, 284, 4610, 13, 1377, 389, 10239, 42, 4610, 12, 377, 5793, 16, 284, 4610, 1769, 203, 202, 565, 309, 261, 20, 411, 279, 6909, 1764, 13, 282, 389, 10239, 37, 6909, 1764, 12, 225, 5793, 16, 279, 6909, 1764, 16, 389, 7163, 8529, 12, 978, 18, 10012, 10019, 203, 3639, 309, 261, 20, 411, 284, 362, 83, 13, 1377, 389, 10239, 42, 362, 83, 12, 377, 5793, 16, 284, 362, 83, 1769, 203, 202, 565, 309, 261, 20, 411, 4501, 372, 24237, 13, 389, 10239, 48, 18988, 24237, 12, 15330, 16, 4501, 372, 24237, 1769, 203, 202, 565, 309, 261, 20, 411, 284, 1074, 13, 1377, 389, 10239, 42, 1074, 12, 377, 5793, 16, 284, 1074, 1769, 203, 202, 565, 309, 261, 20, 411, 5546, 13, 282, 389, 10239, 10740, 12, 225, 5793, 16, 5546, 1769, 203, 202, 377, 203, 202, 565, 389, 24877, 4965, 12521, 5952, 48, 18988, 24237, 5621, 203, 3639, 327, 638, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.25; import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./oraclize.sol"; // REQUIREMENT 1 // FlightSuretyData : contracts used for data persistence contract FlightSuretyData is usingOraclize { using SafeMath for uint256; /********************************************************************************************/ /* DATA VARIABLES */ /********************************************************************************************/ // Account used to deploy contract address private contractOwner; // Blocks all state changes throughout the contract if false bool private operational = true; /** REQUIREMENT 2: Airlines - To make it simpler, have the first airline automatically deployed - Only existing airlines may register a new airlane until there are at least 4 airlined registered The second, third and fourth register airlnes are registered by any of the airlines that had been registered to that point. - use multi-party consensus technique to have at least 50% of the currently registered airlines to apporve the registration. - registration : when they get registered and approved - 2 insuerance : each arline has to submit 10 ether As exercise exerciseC6A create struct uint constant M = 2; struct UserProfile { bool isRegistered; bool isAdmin; } mapping(address => UserProfile) userProfiles // Mapping for storing user profiles */ // removed new status cause complex to manage with oracles //uint8 private constant STATUS_ACCEPT_PASSENGERS = 5; uint8 private constant STATUS_CODE_UNKNOWN = 0; uint8 private constant STATUS_CODE_ON_TIME = 10; uint8 private constant STATUS_CODE_LATE_AIRLINE = 20; uint8 private constant STATUS_CODE_LATE_WEATHER = 30; uint8 private constant STATUS_CODE_LATE_TECHNICAL = 40; uint8 private constant STATUS_CODE_LATE_OTHER = 50; uint constant M = 1; address[] multiCalls = new address[](0); uint private constant LIMIT_PASSENGER = 100; //create airline struct Airline { uint numberAirline; address addressAirline; bool isFunded; } uint countAirline = 0; mapping(address => Airline) mapAirline; mapping(uint => address) mapCountToAddressAirline; /* as showed with default method getFlightKey, * It return a key identifier of bytes32 and flight got string name flight */ uint countFlight = 0; struct Flight { address addressAirline; string flight; mapping(address => Passenger) mapPassenger; mapping(uint => address) mapNumberPassengerToAddress; uint countPassengers; uint numberFlight; uint8 status; uint256 timestamp; } // registration : when flights get registered and approved // bytes is abi.encode of airline + flight mapping(bytes32 => Flight) mapFlight; // insurance : each arline has to submit 10 ether uint countInsurance = 0; struct FlightInsurance { uint numberInsurance; Payment payment; bool isPayed; } /** REQUIREMENTS 3: PASSENGERS - passengers may pay to tone ether for insurance - cap for the amount that a passenger may invest - flight numbers and timestamps are fixed for the purpose of the project and can be defined in the Dapp Client - if flight is delayed due to airline fault passenger receives credito fo 1.5X the amount they paid */ struct Payment { uint amountToPay; uint multiplier; } mapping(address => uint) mapPaymentsToDo; /** REQUIREMENTS 4: ORACLES */ /** REQUIREMENTS 5: GENERAL - operational status control - function must fail fast - use require */ struct Passenger { /* The funds are transferred, if airline delay, the passenger does not actually get the funds in their wallet, it accumulates in their account in the smart contract, and they have to initiate a withdrawal at which point they will be able to get the funds */ address passengerAddress; string name; string surname; FlightInsurance insurance; uint numberPassenger; } // AUTHORIZED CONTRACTS - who can register airline, flight or passenger mapping(address => uint256) private mapAuthorized; /********************************************************************************************/ /* EVENT DEFINITIONS */ /********************************************************************************************/ // airlines event RegisterAirlineEvent(address _airlineAddress); event FundedEvent(address _addressAirline); // flight event RegisterFlightEvent(address _airlineAddress, string _flight); event UpdateFlightEvent(address _airlineAddress, string _flight, uint _status, uint _timestamp); event StatusChangedEvent(uint8 _status); // passengers event RegisterPassengerEvent(address _airlineAddress,string _flight, address _passenger); event BoughtInsuranceEvent(address _airlineAddress, string _flight, address _passenger); event PayedInsuranceEvent(address _airlineAddress, string _flight, address _passenger); event AccountWithdrawnEvent(address _passenger); /** * @dev Constructor * The deploying account becomes contractOwner */ constructor( // To make it simpler, have the first airline automatically deployed address _addressAirline ) public { contractOwner = msg.sender; _registerAirline(_addressAirline); // first airline already funded at start mapAirline[_addressAirline].isFunded = true; } function getContractOwner() external view returns (string) { return addressToString(contractOwner); } /********************************************************************************************/ /* FUNCTION MODIFIERS */ /********************************************************************************************/ // Modifiers help avoid duplication of code. They are typically used to validate something // before a function is allowed to be executed. /** * @dev Modifier that requires the "operational" boolean variable to be "true" * This is used on all state changing functions to pause the contract in * the event there is an issue that needs to be fixed */ modifier requireIsOperational() { require(operational, "Contract is currently not operational"); _; // All modifiers require an "_" which indicates where the function body will be added } /** * @dev Modifier that requires the "ContractOwner" account to be the function caller */ modifier requireContractOwner() { require(msg.sender == contractOwner, strConcat("Caller is not contract owner : ", addressToString(msg.sender), addressToString(contractOwner))); _; } modifier requireAuthorized(address _msgSender) { require(mapAuthorized[_msgSender] == 1, strConcat("Caller is not authorized", addressToString(_msgSender))); _; } // removed but could be a good idea to have timer on registering and dont allow double entry /* /********************************************************************************************/ /* UTILITY FUNCTIONS */ /********************************************************************************************/ /** * @dev Get operating status of contract * * @return A bool that is the current operating status */ function isOperational() public view returns(bool) { return operational; } /** * @dev Sets contract operations on/off * * When operational mode is disabled, all write transactions except for this one will fail */ function setOperatingStatus( bool mode ) external requireContractOwner { require(mode != operational, "Mode is different from operational"); bool isDuplicate = false; for(uint i = 0; i < multiCalls.length; i++) { if (multiCalls[i] == msg.sender) { isDuplicate = true; break; } } require(!isDuplicate, "Already Present."); multiCalls.push(msg.sender); if (multiCalls.length >= M) { operational = mode; multiCalls = new address[](0); } } // manage authorization function authorizeCaller(address _addressToAuth) external requireContractOwner { mapAuthorized[_addressToAuth] = 1; } function isAuthorizedCaller(address _addressToAuth) external view returns (bool) { return mapAuthorized[_addressToAuth] == 1; } /********************************************************************************************/ /* SMART CONTRACT FUNCTIONS */ /********************************************************************************************/ //-----------------------------------------------------// // ------------------ PASSENGER ------------------------- // //-----------------------------------------------------// function registerPassenger ( address _addressAirline, string _flight, address _addressPassenger, string _name, string _surname ) requireIsOperational requireAuthorized(_addressAirline) external { require( mapAirline[_addressAirline].isFunded, "Airline is not already funded"); require( mapAirline[_addressAirline].numberAirline > 0, "Airline is not already registered"); bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); require(mapFlight[_flightKey].numberFlight > 0, "Flight doesn't exists"); /*require(mapFlight[_flightKey].status == STATUS_ACCEPT_PASSENGERS, "Flight status doesn't accept anymore passengers");*/ require(mapFlight[_flightKey].mapPassenger[_addressPassenger].numberPassenger == 0, 'Already registered Passenger'); require(mapFlight[_flightKey].countPassengers < LIMIT_PASSENGER, 'All busy'); uint _countPassengers = mapFlight[_flightKey].countPassengers; _countPassengers = _countPassengers.add(1); mapFlight[_flightKey].mapPassenger[_addressPassenger].passengerAddress = _addressPassenger; mapFlight[_flightKey].mapPassenger[_addressPassenger].name = _name; mapFlight[_flightKey].mapPassenger[_addressPassenger].surname = _surname; mapFlight[_flightKey].mapPassenger[_addressPassenger].numberPassenger = _countPassengers; mapFlight[_flightKey].mapNumberPassengerToAddress[_countPassengers] = _addressPassenger; mapFlight[_flightKey].countPassengers = _countPassengers; emit RegisterPassengerEvent(_addressAirline, _flight, _addressPassenger); } function isPassenger( address _addressAirline, string _flight, address _addressPassenger ) external view returns(bool) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].mapPassenger[_addressPassenger].numberPassenger > 0; } function getPassengerCountByFlight( address _addressAirline, string _flight ) external view returns(uint) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].countPassengers; } //-----------------------------------------------------// // ------------------ FLIGHT ------------------------- // //-----------------------------------------------------// function registerFlight( address _addressAirline, string _flight, address _msgSender ) external requireIsOperational requireAuthorized(_msgSender) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); require(! (mapFlight[_flightKey].numberFlight > 0), "Flight has already been registered"); require( mapAirline[_addressAirline].isFunded, "Airline is not already funded"); countFlight = countFlight.add(1); mapFlight[_flightKey].addressAirline = _addressAirline; mapFlight[_flightKey].flight = _flight; mapFlight[_flightKey].numberFlight = countFlight; mapFlight[_flightKey].countPassengers = 0; emit RegisterFlightEvent(_addressAirline, _flight); } // check if is flight registered function isFlight( address _addressAirline, string _flight ) external view returns(bool) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].numberFlight > 0; } function getFlightCount() external view returns(uint) { return countFlight; } //-----------------------------------------------------// // ------------------ AIRLINE ------------------------ // //-----------------------------------------------------// /** * @dev Add an airline to the registration queue * Can only be called from FlightSuretyApp contract * */ function registerAirline ( address _addressAirline, address _msgSender ) requireIsOperational requireAuthorized(_msgSender) external { require(getAirlineNumberByAddress(_addressAirline) == 0, "Airline is already registered"); require(mapAirline[_addressAirline].isFunded, "Airline is not funded"); _registerAirline(_addressAirline); emit RegisterAirlineEvent(_addressAirline); } function _registerAirline ( address _addressAirline ) internal { countAirline = countAirline.add(1); mapAirline[_addressAirline].numberAirline = countAirline; mapAirline[_addressAirline].addressAirline = _addressAirline; mapCountToAddressAirline[countAirline] = _addressAirline; } function getAirlinesCount() external view requireIsOperational returns (uint){ return countAirline; } function isAirline(address _addressAirline) external view returns (bool result) { for (uint idxAirlines = 1 ; idxAirlines <= countAirline; idxAirlines++) { if(_addressAirline == mapCountToAddressAirline[idxAirlines]) { return true; } } return false; } function getAirlineNumberByAddress(address _addressAirline) public view returns (uint _numberAirline) { for (uint idxAirlines = 1 ; idxAirlines <= countAirline; idxAirlines++) { if(_addressAirline == mapCountToAddressAirline[idxAirlines]) { return idxAirlines; } } return 0; } function getAirlineAddressByNumber(uint _numberAirline) public view returns (address _addressAirline) { for (uint idxAirlines = 1 ; idxAirlines <= countAirline; idxAirlines++) { if(idxAirlines == _numberAirline) { return mapCountToAddressAirline[idxAirlines]; } } } function getAirlineAddressStringByNumber(uint _numberAirline) public view returns (string _addressAirline) { for (uint idxAirlines = 1 ; idxAirlines <= countAirline; idxAirlines++) { if(idxAirlines == _numberAirline) { return addressToString(mapCountToAddressAirline[idxAirlines]); } } } function isFund(address _addressAirline) public view returns (bool) { return mapAirline[_addressAirline].isFunded; } // has required form suretyApp, need a method to processFlightStatus function processFlightStatus( address _addressAirline, string _flight, uint8 _status, uint _timestamp, address _oracleAddress) requireIsOperational requireAuthorized(_oracleAddress) external { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); require(mapFlight[_flightKey].numberFlight > 0, "Flight is not registered"); mapFlight[_flightKey].status = _status; mapFlight[_flightKey].timestamp = _timestamp; if(_status == STATUS_CODE_LATE_AIRLINE) { for (uint idxPassenger = 1 ; idxPassenger <= mapFlight[_flightKey].countPassengers; idxPassenger++) { address _addressPassenger = mapFlight[_flightKey].mapNumberPassengerToAddress[idxPassenger]; if(_addressPassenger != address(0)) { creditInsurees( _addressAirline, _flight, _addressPassenger); } } } emit StatusChangedEvent(_status); } function fund( address _addressAirline) external payable requireIsOperational { require(!mapAirline[_addressAirline].isFunded, "Airline already funded"); mapAirline[_addressAirline].isFunded = true; emit FundedEvent(_addressAirline); } /** * @dev Buy insurance for a flight * */ function buy ( address _addressAirline, string _flight, address _passengerAddress, uint _amount, uint _multiplier, address msgSender ) external payable requireIsOperational requireAuthorized(msgSender) returns (uint) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); require(msgSender == tx.origin, "Contracts not allowed"); require(mapFlight[_flightKey].numberFlight > 0, "Flight is not registered"); require(mapFlight[_flightKey].mapPassenger[_passengerAddress].numberPassenger > 0, "Its not a passenger of this flight"); countInsurance = countInsurance.add(1); mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.numberInsurance = countInsurance; mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.isPayed = false; Payment memory _payment = Payment({ amountToPay : _amount, multiplier : _multiplier }); mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.payment = _payment; emit BoughtInsuranceEvent(_addressAirline, _flight, _passengerAddress); return countInsurance; } /** * @dev Credits payouts to insurees */ function creditInsurees ( address _addressAirline, string _flight, address _passengerAddress ) public requireIsOperational { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); require(mapFlight[_flightKey].numberFlight > 0, "Flight is not registered"); require(mapFlight[_flightKey].mapPassenger[_passengerAddress].numberPassenger > 0, "Passenger is not registered"); mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.isPayed = true; uint _amountToPay = mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.payment.amountToPay .mul(mapFlight[_flightKey].mapPassenger[_passengerAddress].insurance.payment.multiplier) .div(100); mapPaymentsToDo[_passengerAddress] = _amountToPay; emit PayedInsuranceEvent(_addressAirline, _flight, _passengerAddress); } /** * @dev Transfers eligible payout funds to insuree * */ function pay ( address _passengerAddress ) external requireIsOperational requireAuthorized(_passengerAddress) { uint _amountToPay = mapPaymentsToDo[_passengerAddress]; mapPaymentsToDo[_passengerAddress] = 0; _passengerAddress.transfer(_amountToPay); emit AccountWithdrawnEvent(_passengerAddress); } function hasInsurance( address _addressAirline, string _flight, address _addressPassenger ) external view requireIsOperational returns (bool) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].mapPassenger[_addressPassenger].insurance.numberInsurance != 0; } function getInsurance( address _addressAirline, string _flight, address _addressPassenger ) external view requireIsOperational returns (uint) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].mapPassenger[_addressPassenger].insurance.numberInsurance; } function isPayed( address _addressAirline, string _flight, address _addressPassenger ) external view requireIsOperational returns (bool) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].mapPassenger[_addressPassenger].insurance.isPayed; } function getCountInsurance() external view requireIsOperational returns (uint) { return countInsurance; } /** * @dev Initial funding for the insurance. Unless there are too many delayed flights * resulting in insurance payouts, the contract should be self-sustaining * */ function fund ( ) public payable { } function getFlightKey ( address airline, string memory flight, uint256 timestamp ) internal pure returns(bytes32) { return keccak256(abi.encodePacked(airline, flight, timestamp)); } function getFlightKeyOfMap ( address airline, string memory flight ) internal pure returns(bytes32) { return keccak256(abi.encodePacked(airline, flight)); } function getFlightStatus ( address _addressAirline, string _flight ) external view returns(uint8) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); return mapFlight[_flightKey].status; } // conversion function tiped by stackoverflow function addressToString(address _address) pure internal returns (string memory _uintAsString) { bytes32 value = bytes32(uint256(_address)); bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(51); str[0] = "0"; str[1] = "x"; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint(uint8(value[i + 12] >> 4))]; str[3+i*2] = alphabet[uint(uint8(value[i + 12] & 0x0f))]; } return string(str); } // conversion function tiped by stackoverflow function uintToString(uint v) pure internal returns (string str) { uint maxlength = 100; bytes memory reversed = new bytes(maxlength); uint i = 0; while (v != 0) { uint remainder = v % 10; v = v / 10; reversed[i++] = byte(48 + remainder); } bytes memory s = new bytes(i + 1); for (uint j = 0; j <= i; j++) { s[j] = reversed[i - j]; } str = string(s); } function getPassengerInfo ( address _addressAirline, string _flight, uint idx ) public view returns(string) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); address _addressPassenger = mapFlight[_flightKey].mapNumberPassengerToAddress[idx]; mapFlight[_flightKey].mapPassenger[_addressPassenger].passengerAddress; mapFlight[_flightKey].mapPassenger[_addressPassenger].name; mapFlight[_flightKey].mapPassenger[_addressPassenger].surname; mapFlight[_flightKey].mapPassenger[_addressPassenger].numberPassenger; string memory addressPassengerString = strConcat("addressPassengerString :", addressToString(mapFlight[_flightKey].mapPassenger[_addressPassenger].passengerAddress)); string memory nameString = strConcat("name :", mapFlight[_flightKey].mapPassenger[_addressPassenger].name); string memory surnameString = strConcat("surname :", mapFlight[_flightKey].mapPassenger[_addressPassenger].surname); string memory numberString = strConcat("numberPassenger :", uintToString(mapFlight[_flightKey].mapPassenger[_addressPassenger].numberPassenger)); string memory part1 = strConcat(addressPassengerString, nameString, surnameString, numberString); return part1; } function getFlightInfo ( address _addressAirline, string _flight ) public view returns(string) { bytes32 _flightKey = getFlightKeyOfMap(_addressAirline, _flight); string memory addressString = strConcat("airline :", addressToString(mapFlight[_flightKey].addressAirline)); string memory flightString = strConcat("flight :", mapFlight[_flightKey].flight); string memory timestampString = strConcat("timestamp :", uintToString(mapFlight[_flightKey].timestamp)); string memory countPassString = strConcat("countPassengers :", uintToString(mapFlight[_flightKey].countPassengers)); string memory numberString = strConcat("numberFlight :", uintToString(mapFlight[_flightKey].numberFlight)); string memory statusString = strConcat("status :", uintToString(mapFlight[_flightKey].status)); string memory part1 = strConcat(addressString, flightString, timestampString); string memory part2 = strConcat(countPassString, numberString, statusString); return strConcat(part1, part2); } /** * @dev Fallback function for funding smart contract. * */ function() external payable { fund(); } }
registration : when flights get registered and approved bytes is abi.encode of airline + flight
mapping(bytes32 => Flight) mapFlight;
12,788,834
[ 1, 4625, 348, 7953, 560, 30, 225, 7914, 294, 1347, 1183, 10730, 336, 4104, 471, 20412, 1731, 353, 24126, 18, 3015, 434, 23350, 1369, 397, 25187, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2874, 12, 3890, 1578, 516, 3857, 750, 13, 852, 24243, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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"; 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; import "../../utils/introspection/IERC165.sol"; /** * @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; } // 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 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); } // 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 "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, type(IERC165).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (bool)); } } // 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; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such 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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; /** * @title Abstract ownable contract that can be inherited by other contracts * @notice 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 is the deployer of the contract. * * The owner account is set through a two steps process. * 1. The current `owner` calls {transferOwnership} to set a `pendingOwner` * 2. The `pendingOwner` calls {acceptOwnership} to accept the ownership transfer * * The manager account needs to be set using {setManager}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable { address private _owner; address private _pendingOwner; /** * @dev Emitted when `_pendingOwner` has been changed. * @param pendingOwner new `_pendingOwner` address. */ event OwnershipOffered(address indexed pendingOwner); /** * @dev Emitted when `_owner` has been changed. * @param previousOwner previous `_owner` address. * @param newOwner new `_owner` address. */ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /* ============ Deploy ============ */ /** * @notice Initializes the contract setting `_initialOwner` as the initial owner. * @param _initialOwner Initial owner of the contract. */ constructor(address _initialOwner) { _setOwner(_initialOwner); } /* ============ External Functions ============ */ /** * @notice Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @notice Gets current `_pendingOwner`. * @return Current `_pendingOwner` address. */ function pendingOwner() external view virtual returns (address) { return _pendingOwner; } /** * @notice Renounce ownership of the contract. * @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() external virtual onlyOwner { _setOwner(address(0)); } /** * @notice Allows current owner to set the `_pendingOwner` address. * @param _newOwner Address to transfer ownership to. */ function transferOwnership(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Ownable/pendingOwner-not-zero-address"); _pendingOwner = _newOwner; emit OwnershipOffered(_newOwner); } /** * @notice Allows the `_pendingOwner` address to finalize the transfer. * @dev This function is only callable by the `_pendingOwner`. */ function claimOwnership() external onlyPendingOwner { _setOwner(_pendingOwner); _pendingOwner = address(0); } /* ============ Internal Functions ============ */ /** * @notice Internal function to set the `_owner` of the contract. * @param _newOwner New `_owner` address. */ function _setOwner(address _newOwner) private { address _oldOwner = _owner; _owner = _newOwner; emit OwnershipTransferred(_oldOwner, _newOwner); } /* ============ Modifier Functions ============ */ /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == msg.sender, "Ownable/caller-not-owner"); _; } /** * @dev Throws if called by any account other than the `pendingOwner`. */ modifier onlyPendingOwner() { require(msg.sender == _pendingOwner, "Ownable/caller-not-pendingOwner"); _; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ICompLike is IERC20 { function getCurrentVotes(address account) external view returns (uint96); function delegate(address delegate) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** @title IControlledToken * @author PoolTogether Inc Team * @notice ERC20 Tokens with a controller for minting & burning. */ interface IControlledToken is IERC20 { /** @notice Interface to the contract responsible for controlling mint/burn */ function controller() external view returns (address); /** * @notice Allows the controller to mint tokens for a user account * @dev May be overridden to provide more granular control over minting * @param user Address of the receiver of the minted tokens * @param amount Amount of tokens to mint */ function controllerMint(address user, uint256 amount) external; /** * @notice Allows the controller to burn tokens from a user account * @dev May be overridden to provide more granular control over burning * @param user Address of the holder account to burn tokens from * @param amount Amount of tokens to burn */ function controllerBurn(address user, uint256 amount) external; /** * @notice Allows an operator via the controller to burn tokens on behalf of a user account * @dev May be overridden to provide more granular control over operator-burning * @param operator Address of the operator performing the burn action via the controller contract * @param user Address of the holder account to burn tokens from * @param amount Amount of tokens to burn */ function controllerBurnFrom( address operator, address user, uint256 amount ) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "../external/compound/ICompLike.sol"; import "../interfaces/ITicket.sol"; interface IPrizePool { /// @dev Event emitted when controlled token is added event ControlledTokenAdded(ITicket indexed token); event AwardCaptured(uint256 amount); /// @dev Event emitted when assets are deposited event Deposited( address indexed operator, address indexed to, ITicket indexed token, uint256 amount ); /// @dev Event emitted when interest is awarded to a winner event Awarded(address indexed winner, ITicket indexed token, uint256 amount); /// @dev Event emitted when external ERC20s are awarded to a winner event AwardedExternalERC20(address indexed winner, address indexed token, uint256 amount); /// @dev Event emitted when external ERC20s are transferred out event TransferredExternalERC20(address indexed to, address indexed token, uint256 amount); /// @dev Event emitted when external ERC721s are awarded to a winner event AwardedExternalERC721(address indexed winner, address indexed token, uint256[] tokenIds); /// @dev Event emitted when assets are withdrawn event Withdrawal( address indexed operator, address indexed from, ITicket indexed token, uint256 amount, uint256 redeemed ); /// @dev Event emitted when the Balance Cap is set event BalanceCapSet(uint256 balanceCap); /// @dev Event emitted when the Liquidity Cap is set event LiquidityCapSet(uint256 liquidityCap); /// @dev Event emitted when the Prize Strategy is set event PrizeStrategySet(address indexed prizeStrategy); /// @dev Event emitted when the Ticket is set event TicketSet(ITicket indexed ticket); /// @dev Emitted when there was an error thrown awarding an External ERC721 event ErrorAwardingExternalERC721(bytes error); /// @notice Deposit assets into the Prize Pool in exchange for tokens /// @param to The address receiving the newly minted tokens /// @param amount The amount of assets to deposit function depositTo(address to, uint256 amount) external; /// @notice Deposit assets into the Prize Pool in exchange for tokens, /// then sets the delegate on behalf of the caller. /// @param to The address receiving the newly minted tokens /// @param amount The amount of assets to deposit /// @param delegate The address to delegate to for the caller function depositToAndDelegate(address to, uint256 amount, address delegate) external; /// @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit. /// @param from The address to redeem tokens from. /// @param amount The amount of tokens to redeem for assets. /// @return The actual amount withdrawn function withdrawFrom(address from, uint256 amount) external returns (uint256); /// @notice Called by the prize strategy to award prizes. /// @dev The amount awarded must be less than the awardBalance() /// @param to The address of the winner that receives the award /// @param amount The amount of assets to be awarded function award(address to, uint256 amount) external; /// @notice Returns the balance that is available to award. /// @dev captureAwardBalance() should be called first /// @return The total amount of assets to be awarded for the current prize function awardBalance() external view returns (uint256); /// @notice Captures any available interest as award balance. /// @dev This function also captures the reserve fees. /// @return The total amount of assets to be awarded for the current prize function captureAwardBalance() external returns (uint256); /// @dev Checks with the Prize Pool if a specific token type may be awarded as an external prize /// @param externalToken The address of the token to check /// @return True if the token may be awarded, false otherwise function canAwardExternal(address externalToken) external view returns (bool); // @dev Returns the total underlying balance of all assets. This includes both principal and interest. /// @return The underlying balance of assets function balance() external returns (uint256); /** * @notice Read internal Ticket accounted balance. * @return uint256 accountBalance */ function getAccountedBalance() external view returns (uint256); /** * @notice Read internal balanceCap variable */ function getBalanceCap() external view returns (uint256); /** * @notice Read internal liquidityCap variable */ function getLiquidityCap() external view returns (uint256); /** * @notice Read ticket variable */ function getTicket() external view returns (ITicket); /** * @notice Read token variable */ function getToken() external view returns (address); /** * @notice Read prizeStrategy variable */ function getPrizeStrategy() external view returns (address); /// @dev Checks if a specific token is controlled by the Prize Pool /// @param controlledToken The address of the token to check /// @return True if the token is a controlled token, false otherwise function isControlled(ITicket controlledToken) external view returns (bool); /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens /// @dev Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything. /// @param to The address of the winner that receives the award /// @param externalToken The address of the external asset token being awarded /// @param amount The amount of external assets to be awarded function transferExternalERC20( address to, address externalToken, uint256 amount ) external; /// @notice Called by the Prize-Strategy to award external ERC20 prizes /// @dev Used to award any arbitrary tokens held by the Prize Pool /// @param to The address of the winner that receives the award /// @param amount The amount of external assets to be awarded /// @param externalToken The address of the external asset token being awarded function awardExternalERC20( address to, address externalToken, uint256 amount ) external; /// @notice Called by the prize strategy to award external ERC721 prizes /// @dev Used to award any arbitrary NFTs held by the Prize Pool /// @param to The address of the winner that receives the award /// @param externalToken The address of the external NFT token being awarded /// @param tokenIds An array of NFT Token IDs to be transferred function awardExternalERC721( address to, address externalToken, uint256[] calldata tokenIds ) external; /// @notice Allows the owner to set a balance cap per `token` for the pool. /// @dev If a user wins, his balance can go over the cap. He will be able to withdraw the excess but not deposit. /// @dev Needs to be called after deploying a prize pool to be able to deposit into it. /// @param balanceCap New balance cap. /// @return True if new balance cap has been successfully set. function setBalanceCap(uint256 balanceCap) external returns (bool); /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold /// @param liquidityCap The new liquidity cap for the prize pool function setLiquidityCap(uint256 liquidityCap) external; /// @notice Sets the prize strategy of the prize pool. Only callable by the owner. /// @param _prizeStrategy The new prize strategy. function setPrizeStrategy(address _prizeStrategy) external; /// @notice Set prize pool ticket. /// @param ticket Address of the ticket to set. /// @return True if ticket has been successfully set. function setTicket(ITicket ticket) external returns (bool); /// @notice Delegate the votes for a Compound COMP-like token held by the prize pool /// @param compLike The COMP-like token held by the prize pool that should be delegated /// @param to The address to delegate to function compLikeDelegate(ICompLike compLike, address to) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "../libraries/TwabLib.sol"; import "./IControlledToken.sol"; interface ITicket is IControlledToken { /** * @notice A struct containing details for an Account. * @param balance The current balance for an Account. * @param nextTwabIndex The next available index to store a new twab. * @param cardinality The number of recorded twabs (plus one!). */ struct AccountDetails { uint224 balance; uint16 nextTwabIndex; uint16 cardinality; } /** * @notice Combines account details with their twab history. * @param details The account details. * @param twabs The history of twabs for this account. */ struct Account { AccountDetails details; ObservationLib.Observation[65535] twabs; } /** * @notice Emitted when TWAB balance has been delegated to another user. * @param delegator Address of the delegator. * @param delegate Address of the delegate. */ event Delegated(address indexed delegator, address indexed delegate); /** * @notice Emitted when ticket is initialized. * @param name Ticket name (eg: PoolTogether Dai Ticket (Compound)). * @param symbol Ticket symbol (eg: PcDAI). * @param decimals Ticket decimals. * @param controller Token controller address. */ event TicketInitialized(string name, string symbol, uint8 decimals, address indexed controller); /** * @notice Emitted when a new TWAB has been recorded. * @param delegate The recipient of the ticket power (may be the same as the user). * @param newTwab Updated TWAB of a ticket holder after a successful TWAB recording. */ event NewUserTwab( address indexed delegate, ObservationLib.Observation newTwab ); /** * @notice Emitted when a new total supply TWAB has been recorded. * @param newTotalSupplyTwab Updated TWAB of tickets total supply after a successful total supply TWAB recording. */ event NewTotalSupplyTwab(ObservationLib.Observation newTotalSupplyTwab); /** * @notice Retrieves the address of the delegate to whom `user` has delegated their tickets. * @dev Address of the delegate will be the zero address if `user` has not delegated their tickets. * @param user Address of the delegator. * @return Address of the delegate. */ function delegateOf(address user) external view returns (address); /** * @notice Delegate time-weighted average balances to an alternative address. * @dev Transfers (including mints) trigger the storage of a TWAB in delegate(s) account, instead of the targetted sender and/or recipient address(s). * @dev To reset the delegate, pass the zero address (0x000.000) as `to` parameter. * @dev Current delegate address should be different from the new delegate address `to`. * @param to Recipient of delegated TWAB. */ function delegate(address to) external; /** * @notice Allows the controller to delegate on a users behalf. * @param user The user for whom to delegate * @param delegate The new delegate */ function controllerDelegateFor(address user, address delegate) external; /** * @notice Allows a user to delegate via signature * @param user The user who is delegating * @param delegate The new delegate * @param deadline The timestamp by which this must be submitted * @param v The v portion of the ECDSA sig * @param r The r portion of the ECDSA sig * @param s The s portion of the ECDSA sig */ function delegateWithSignature( address user, address delegate, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @notice Gets a users twab context. This is a struct with their balance, next twab index, and cardinality. * @param user The user for whom to fetch the TWAB context. * @return The TWAB context, which includes { balance, nextTwabIndex, cardinality } */ function getAccountDetails(address user) external view returns (TwabLib.AccountDetails memory); /** * @notice Gets the TWAB at a specific index for a user. * @param user The user for whom to fetch the TWAB. * @param index The index of the TWAB to fetch. * @return The TWAB, which includes the twab amount and the timestamp. */ function getTwab(address user, uint16 index) external view returns (ObservationLib.Observation memory); /** * @notice Retrieves `user` TWAB balance. * @param user Address of the user whose TWAB is being fetched. * @param timestamp Timestamp at which we want to retrieve the TWAB balance. * @return The TWAB balance at the given timestamp. */ function getBalanceAt(address user, uint64 timestamp) external view returns (uint256); /** * @notice Retrieves `user` TWAB balances. * @param user Address of the user whose TWABs are being fetched. * @param timestamps Timestamps range at which we want to retrieve the TWAB balances. * @return `user` TWAB balances. */ function getBalancesAt(address user, uint64[] calldata timestamps) external view returns (uint256[] memory); /** * @notice Retrieves the average balance held by a user for a given time frame. * @param user The user whose balance is checked. * @param startTime The start time of the time frame. * @param endTime The end time of the time frame. * @return The average balance that the user held during the time frame. */ function getAverageBalanceBetween( address user, uint64 startTime, uint64 endTime ) external view returns (uint256); /** * @notice Retrieves the average balances held by a user for a given time frame. * @param user The user whose balance is checked. * @param startTimes The start time of the time frame. * @param endTimes The end time of the time frame. * @return The average balance that the user held during the time frame. */ function getAverageBalancesBetween( address user, uint64[] calldata startTimes, uint64[] calldata endTimes ) external view returns (uint256[] memory); /** * @notice Retrieves the total supply TWAB balance at the given timestamp. * @param timestamp Timestamp at which we want to retrieve the total supply TWAB balance. * @return The total supply TWAB balance at the given timestamp. */ function getTotalSupplyAt(uint64 timestamp) external view returns (uint256); /** * @notice Retrieves the total supply TWAB balance between the given timestamps range. * @param timestamps Timestamps range at which we want to retrieve the total supply TWAB balance. * @return Total supply TWAB balances. */ function getTotalSuppliesAt(uint64[] calldata timestamps) external view returns (uint256[] memory); /** * @notice Retrieves the average total supply balance for a set of given time frames. * @param startTimes Array of start times. * @param endTimes Array of end times. * @return The average total supplies held during the time frame. */ function getAverageTotalSuppliesBetween( uint64[] calldata startTimes, uint64[] calldata endTimes ) external view returns (uint256[] memory); } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such 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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library ExtendedSafeCastLib { /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 _value) internal pure returns (uint208) { require(_value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(_value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 _value) internal pure returns (uint224) { require(_value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(_value); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "./OverflowSafeComparatorLib.sol"; import "./RingBufferLib.sol"; /** * @title Observation Library * @notice This library allows one to store an array of timestamped values and efficiently binary search them. * @dev Largely pulled from Uniswap V3 Oracle.sol: https://github.com/Uniswap/v3-core/blob/c05a0e2c8c08c460fb4d05cfdda30b3ad8deeaac/contracts/libraries/Oracle.sol * @author PoolTogether Inc. */ library ObservationLib { using OverflowSafeComparatorLib for uint32; using SafeCast for uint256; /// @notice The maximum number of observations uint24 public constant MAX_CARDINALITY = 16777215; // 2**24 /** * @notice Observation, which includes an amount and timestamp. * @param amount `amount` at `timestamp`. * @param timestamp Recorded `timestamp`. */ struct Observation { uint224 amount; uint32 timestamp; } /** * @notice Fetches Observations `beforeOrAt` and `atOrAfter` a `_target`, eg: where [`beforeOrAt`, `atOrAfter`] is satisfied. * The result may be the same Observation, or adjacent Observations. * @dev The answer must be contained in the array used when the target is located within the stored Observation. * boundaries: older than the most recent Observation and younger, or the same age as, the oldest Observation. * @dev If `_newestObservationIndex` is less than `_oldestObservationIndex`, it means that we've wrapped around the circular buffer. * So the most recent observation will be at `_oldestObservationIndex + _cardinality - 1`, at the beginning of the circular buffer. * @param _observations List of Observations to search through. * @param _newestObservationIndex Index of the newest Observation. Right side of the circular buffer. * @param _oldestObservationIndex Index of the oldest Observation. Left side of the circular buffer. * @param _target Timestamp at which we are searching the Observation. * @param _cardinality Cardinality of the circular buffer we are searching through. * @param _time Timestamp at which we perform the binary search. * @return beforeOrAt Observation recorded before, or at, the target. * @return atOrAfter Observation recorded at, or after, the target. */ function binarySearch( Observation[MAX_CARDINALITY] storage _observations, uint24 _newestObservationIndex, uint24 _oldestObservationIndex, uint32 _target, uint24 _cardinality, uint32 _time ) internal view returns (Observation memory beforeOrAt, Observation memory atOrAfter) { uint256 leftSide = _oldestObservationIndex; uint256 rightSide = _newestObservationIndex < leftSide ? leftSide + _cardinality - 1 : _newestObservationIndex; uint256 currentIndex; while (true) { // We start our search in the middle of the `leftSide` and `rightSide`. // After each iteration, we narrow down the search to the left or the right side while still starting our search in the middle. currentIndex = (leftSide + rightSide) / 2; beforeOrAt = _observations[uint24(RingBufferLib.wrap(currentIndex, _cardinality))]; uint32 beforeOrAtTimestamp = beforeOrAt.timestamp; // We've landed on an uninitialized timestamp, keep searching higher (more recently). if (beforeOrAtTimestamp == 0) { leftSide = currentIndex + 1; continue; } atOrAfter = _observations[uint24(RingBufferLib.nextIndex(currentIndex, _cardinality))]; bool targetAtOrAfter = beforeOrAtTimestamp.lte(_target, _time); // Check if we've found the corresponding Observation. if (targetAtOrAfter && _target.lte(atOrAfter.timestamp, _time)) { break; } // If `beforeOrAtTimestamp` is greater than `_target`, then we keep searching lower. To the left of the current index. if (!targetAtOrAfter) { rightSide = currentIndex - 1; } else { // Otherwise, we keep searching higher. To the left of the current index. leftSide = currentIndex + 1; } } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; /// @title OverflowSafeComparatorLib library to share comparator functions between contracts /// @dev Code taken from Uniswap V3 Oracle.sol: https://github.com/Uniswap/v3-core/blob/3e88af408132fc957e3e406f65a0ce2b1ca06c3d/contracts/libraries/Oracle.sol /// @author PoolTogether Inc. library OverflowSafeComparatorLib { /// @notice 32-bit timestamps comparator. /// @dev safe for 0 or 1 overflows, `_a` and `_b` must be chronologically before or equal to time. /// @param _a A comparison timestamp from which to determine the relative position of `_timestamp`. /// @param _b Timestamp to compare against `_a`. /// @param _timestamp A timestamp truncated to 32 bits. /// @return bool Whether `_a` is chronologically < `_b`. function lt( uint32 _a, uint32 _b, uint32 _timestamp ) internal pure returns (bool) { // No need to adjust if there hasn't been an overflow if (_a <= _timestamp && _b <= _timestamp) return _a < _b; uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32; uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32; return aAdjusted < bAdjusted; } /// @notice 32-bit timestamps comparator. /// @dev safe for 0 or 1 overflows, `_a` and `_b` must be chronologically before or equal to time. /// @param _a A comparison timestamp from which to determine the relative position of `_timestamp`. /// @param _b Timestamp to compare against `_a`. /// @param _timestamp A timestamp truncated to 32 bits. /// @return bool Whether `_a` is chronologically <= `_b`. function lte( uint32 _a, uint32 _b, uint32 _timestamp ) internal pure returns (bool) { // No need to adjust if there hasn't been an overflow if (_a <= _timestamp && _b <= _timestamp) return _a <= _b; uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32; uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32; return aAdjusted <= bAdjusted; } /// @notice 32-bit timestamp subtractor /// @dev safe for 0 or 1 overflows, where `_a` and `_b` must be chronologically before or equal to time /// @param _a The subtraction left operand /// @param _b The subtraction right operand /// @param _timestamp The current time. Expected to be chronologically after both. /// @return The difference between a and b, adjusted for overflow function checkedSub( uint32 _a, uint32 _b, uint32 _timestamp ) internal pure returns (uint32) { // No need to adjust if there hasn't been an overflow if (_a <= _timestamp && _b <= _timestamp) return _a - _b; uint256 aAdjusted = _a > _timestamp ? _a : _a + 2**32; uint256 bAdjusted = _b > _timestamp ? _b : _b + 2**32; return uint32(aAdjusted - bAdjusted); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; library RingBufferLib { /** * @notice Returns wrapped TWAB index. * @dev In order to navigate the TWAB circular buffer, we need to use the modulo operator. * @dev For example, if `_index` is equal to 32 and the TWAB circular buffer is of `_cardinality` 32, * it will return 0 and will point to the first element of the array. * @param _index Index used to navigate through the TWAB circular buffer. * @param _cardinality TWAB buffer cardinality. * @return TWAB index. */ function wrap(uint256 _index, uint256 _cardinality) internal pure returns (uint256) { return _index % _cardinality; } /** * @notice Computes the negative offset from the given index, wrapped by the cardinality. * @dev We add `_cardinality` to `_index` to be able to offset even if `_amount` is superior to `_cardinality`. * @param _index The index from which to offset * @param _amount The number of indices to offset. This is subtracted from the given index. * @param _cardinality The number of elements in the ring buffer * @return Offsetted index. */ function offset( uint256 _index, uint256 _amount, uint256 _cardinality ) internal pure returns (uint256) { return wrap(_index + _cardinality - _amount, _cardinality); } /// @notice Returns the index of the last recorded TWAB /// @param _nextIndex The next available twab index. This will be recorded to next. /// @param _cardinality The cardinality of the TWAB history. /// @return The index of the last recorded TWAB function newestIndex(uint256 _nextIndex, uint256 _cardinality) internal pure returns (uint256) { if (_cardinality == 0) { return 0; } return wrap(_nextIndex + _cardinality - 1, _cardinality); } /// @notice Computes the ring buffer index that follows the given one, wrapped by cardinality /// @param _index The index to increment /// @param _cardinality The number of elements in the Ring Buffer /// @return The next index relative to the given index. Will wrap around to 0 if the next index == cardinality function nextIndex(uint256 _index, uint256 _cardinality) internal pure returns (uint256) { return wrap(_index + 1, _cardinality); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "./ExtendedSafeCastLib.sol"; import "./OverflowSafeComparatorLib.sol"; import "./RingBufferLib.sol"; import "./ObservationLib.sol"; /** * @title PoolTogether V4 TwabLib (Library) * @author PoolTogether Inc Team * @dev Time-Weighted Average Balance Library for ERC20 tokens. * @notice This TwabLib adds on-chain historical lookups to a user(s) time-weighted average balance. Each user is mapped to an Account struct containing the TWAB history (ring bufffer) and ring buffer parameters. Every token.transfer() creates a new TWAB checkpoint. The new TWAB checkpoint is stored in the circular ring buffer, as either a new checkpoint or rewriting a previous checkpoint with new parameters. The TwabLib (using existing blocktimes 1block/15sec) guarantees minimum 7.4 years of search history. */ library TwabLib { using OverflowSafeComparatorLib for uint32; using ExtendedSafeCastLib for uint256; /** * @notice Sets max ring buffer length in the Account.twabs Observation list. As users transfer/mint/burn tickets new Observation checkpoints are recorded. The current max cardinality guarantees a six month minimum, of historical accurate lookups with current estimates of 1 new block every 15 seconds - the of course contain a transfer to trigger an observation write to storage. * @dev The user Account.AccountDetails.cardinality parameter can NOT exceed the max cardinality variable. Preventing "corrupted" ring buffer lookup pointers and new observation checkpoints. The MAX_CARDINALITY in fact guarantees at least 7.4 years of records: If 14 = block time in seconds (2**24) * 14 = 234881024 seconds of history 234881024 / (365 * 24 * 60 * 60) ~= 7.44 years */ uint24 public constant MAX_CARDINALITY = 16777215; // 2**24 /** @notice Struct ring buffer parameters for single user Account * @param balance Current balance for an Account * @param nextTwabIndex Next uninitialized or updatable ring buffer checkpoint storage slot * @param cardinality Current total "initialized" ring buffer checkpoints for single user AccountDetails. Used to set initial boundary conditions for an efficient binary search. */ struct AccountDetails { uint208 balance; uint24 nextTwabIndex; uint24 cardinality; } /// @notice Combines account details with their twab history /// @param details The account details /// @param twabs The history of twabs for this account struct Account { AccountDetails details; ObservationLib.Observation[MAX_CARDINALITY] twabs; } /// @notice Increases an account's balance and records a new twab. /// @param _account The account whose balance will be increased /// @param _amount The amount to increase the balance by /// @param _currentTime The current time /// @return accountDetails The new AccountDetails /// @return twab The user's latest TWAB /// @return isNew Whether the TWAB is new function increaseBalance( Account storage _account, uint208 _amount, uint32 _currentTime ) internal returns ( AccountDetails memory accountDetails, ObservationLib.Observation memory twab, bool isNew ) { AccountDetails memory _accountDetails = _account.details; (accountDetails, twab, isNew) = _nextTwab(_account.twabs, _accountDetails, _currentTime); accountDetails.balance = _accountDetails.balance + _amount; } /** @notice Calculates the next TWAB checkpoint for an account with a decreasing balance. * @dev With Account struct and amount decreasing calculates the next TWAB observable checkpoint. * @param _account Account whose balance will be decreased * @param _amount Amount to decrease the balance by * @param _revertMessage Revert message for insufficient balance * @return accountDetails Updated Account.details struct * @return twab TWAB observation (with decreasing average) * @return isNew Whether TWAB is new or calling twice in the same block */ function decreaseBalance( Account storage _account, uint208 _amount, string memory _revertMessage, uint32 _currentTime ) internal returns ( AccountDetails memory accountDetails, ObservationLib.Observation memory twab, bool isNew ) { AccountDetails memory _accountDetails = _account.details; require(_accountDetails.balance >= _amount, _revertMessage); (accountDetails, twab, isNew) = _nextTwab(_account.twabs, _accountDetails, _currentTime); unchecked { accountDetails.balance -= _amount; } } /** @notice Calculates the average balance held by a user for a given time frame. * @dev Finds the average balance between start and end timestamp epochs. Validates the supplied end time is within the range of elapsed time i.e. less then timestamp of now. * @param _twabs Individual user Observation recorded checkpoints passed as storage pointer * @param _accountDetails User AccountDetails struct loaded in memory * @param _startTime Start of timestamp range as an epoch * @param _endTime End of timestamp range as an epoch * @param _currentTime Block.timestamp * @return Average balance of user held between epoch timestamps start and end */ function getAverageBalanceBetween( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, uint32 _startTime, uint32 _endTime, uint32 _currentTime ) internal view returns (uint256) { uint32 endTime = _endTime > _currentTime ? _currentTime : _endTime; return _getAverageBalanceBetween(_twabs, _accountDetails, _startTime, endTime, _currentTime); } /// @notice Retrieves the oldest TWAB /// @param _twabs The storage array of twabs /// @param _accountDetails The TWAB account details /// @return index The index of the oldest TWAB in the twabs array /// @return twab The oldest TWAB function oldestTwab( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails ) internal view returns (uint24 index, ObservationLib.Observation memory twab) { index = _accountDetails.nextTwabIndex; twab = _twabs[index]; // If the TWAB is not initialized we go to the beginning of the TWAB circular buffer at index 0 if (twab.timestamp == 0) { index = 0; twab = _twabs[0]; } } /// @notice Retrieves the newest TWAB /// @param _twabs The storage array of twabs /// @param _accountDetails The TWAB account details /// @return index The index of the newest TWAB in the twabs array /// @return twab The newest TWAB function newestTwab( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails ) internal view returns (uint24 index, ObservationLib.Observation memory twab) { index = uint24(RingBufferLib.newestIndex(_accountDetails.nextTwabIndex, MAX_CARDINALITY)); twab = _twabs[index]; } /// @notice Retrieves amount at `_targetTime` timestamp /// @param _twabs List of TWABs to search through. /// @param _accountDetails Accounts details /// @param _targetTime Timestamp at which the reserved TWAB should be for. /// @return uint256 TWAB amount at `_targetTime`. function getBalanceAt( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, uint32 _targetTime, uint32 _currentTime ) internal view returns (uint256) { uint32 timeToTarget = _targetTime > _currentTime ? _currentTime : _targetTime; return _getBalanceAt(_twabs, _accountDetails, timeToTarget, _currentTime); } /// @notice Calculates the average balance held by a user for a given time frame. /// @param _startTime The start time of the time frame. /// @param _endTime The end time of the time frame. /// @return The average balance that the user held during the time frame. function _getAverageBalanceBetween( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, uint32 _startTime, uint32 _endTime, uint32 _currentTime ) private view returns (uint256) { (uint24 oldestTwabIndex, ObservationLib.Observation memory oldTwab) = oldestTwab( _twabs, _accountDetails ); (uint24 newestTwabIndex, ObservationLib.Observation memory newTwab) = newestTwab( _twabs, _accountDetails ); ObservationLib.Observation memory startTwab = _calculateTwab( _twabs, _accountDetails, newTwab, oldTwab, newestTwabIndex, oldestTwabIndex, _startTime, _currentTime ); ObservationLib.Observation memory endTwab = _calculateTwab( _twabs, _accountDetails, newTwab, oldTwab, newestTwabIndex, oldestTwabIndex, _endTime, _currentTime ); // Difference in amount / time return (endTwab.amount - startTwab.amount) / OverflowSafeComparatorLib.checkedSub(endTwab.timestamp, startTwab.timestamp, _currentTime); } /** @notice Searches TWAB history and calculate the difference between amount(s)/timestamp(s) to return average balance between the Observations closes to the supplied targetTime. * @param _twabs Individual user Observation recorded checkpoints passed as storage pointer * @param _accountDetails User AccountDetails struct loaded in memory * @param _targetTime Target timestamp to filter Observations in the ring buffer binary search * @param _currentTime Block.timestamp * @return uint256 Time-weighted average amount between two closest observations. */ function _getBalanceAt( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, uint32 _targetTime, uint32 _currentTime ) private view returns (uint256) { uint24 newestTwabIndex; ObservationLib.Observation memory afterOrAt; ObservationLib.Observation memory beforeOrAt; (newestTwabIndex, beforeOrAt) = newestTwab(_twabs, _accountDetails); // If `_targetTime` is chronologically after the newest TWAB, we can simply return the current balance if (beforeOrAt.timestamp.lte(_targetTime, _currentTime)) { return _accountDetails.balance; } uint24 oldestTwabIndex; // Now, set before to the oldest TWAB (oldestTwabIndex, beforeOrAt) = oldestTwab(_twabs, _accountDetails); // If `_targetTime` is chronologically before the oldest TWAB, we can early return if (_targetTime.lt(beforeOrAt.timestamp, _currentTime)) { return 0; } // Otherwise, we perform the `binarySearch` (beforeOrAt, afterOrAt) = ObservationLib.binarySearch( _twabs, newestTwabIndex, oldestTwabIndex, _targetTime, _accountDetails.cardinality, _currentTime ); // Sum the difference in amounts and divide by the difference in timestamps. // The time-weighted average balance uses time measured between two epoch timestamps as // a constaint on the measurement when calculating the time weighted average balance. return (afterOrAt.amount - beforeOrAt.amount) / OverflowSafeComparatorLib.checkedSub(afterOrAt.timestamp, beforeOrAt.timestamp, _currentTime); } /** @notice Calculates a user TWAB for a target timestamp using the historical TWAB records. The balance is linearly interpolated: amount differences / timestamp differences using the simple (after.amount - before.amount / end.timestamp - start.timestamp) formula. /** @dev Binary search in _calculateTwab fails when searching out of bounds. Thus, before searching we exclude target timestamps out of range of newest/oldest TWAB(s). IF a search is before or after the range we "extrapolate" a Observation from the expected state. * @param _twabs Individual user Observation recorded checkpoints passed as storage pointer * @param _accountDetails User AccountDetails struct loaded in memory * @param _newestTwab Newest TWAB in history (end of ring buffer) * @param _oldestTwab Olderst TWAB in history (end of ring buffer) * @param _newestTwabIndex Pointer in ring buffer to newest TWAB * @param _oldestTwabIndex Pointer in ring buffer to oldest TWAB * @param _targetTimestamp Epoch timestamp to calculate for time (T) in the TWAB * @param _time Block.timestamp * @return accountDetails Updated Account.details struct */ function _calculateTwab( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, ObservationLib.Observation memory _newestTwab, ObservationLib.Observation memory _oldestTwab, uint24 _newestTwabIndex, uint24 _oldestTwabIndex, uint32 _targetTimestamp, uint32 _time ) private view returns (ObservationLib.Observation memory) { // If `_targetTimestamp` is chronologically after the newest TWAB, we extrapolate a new one if (_newestTwab.timestamp.lt(_targetTimestamp, _time)) { return _computeNextTwab(_newestTwab, _accountDetails.balance, _targetTimestamp); } if (_newestTwab.timestamp == _targetTimestamp) { return _newestTwab; } if (_oldestTwab.timestamp == _targetTimestamp) { return _oldestTwab; } // If `_targetTimestamp` is chronologically before the oldest TWAB, we create a zero twab if (_targetTimestamp.lt(_oldestTwab.timestamp, _time)) { return ObservationLib.Observation({ amount: 0, timestamp: _targetTimestamp }); } // Otherwise, both timestamps must be surrounded by twabs. ( ObservationLib.Observation memory beforeOrAtStart, ObservationLib.Observation memory afterOrAtStart ) = ObservationLib.binarySearch( _twabs, _newestTwabIndex, _oldestTwabIndex, _targetTimestamp, _accountDetails.cardinality, _time ); uint224 heldBalance = (afterOrAtStart.amount - beforeOrAtStart.amount) / OverflowSafeComparatorLib.checkedSub(afterOrAtStart.timestamp, beforeOrAtStart.timestamp, _time); return _computeNextTwab(beforeOrAtStart, heldBalance, _targetTimestamp); } /** * @notice Calculates the next TWAB using the newestTwab and updated balance. * @dev Storage of the TWAB obersation is managed by the calling function and not _computeNextTwab. * @param _currentTwab Newest Observation in the Account.twabs list * @param _currentBalance User balance at time of most recent (newest) checkpoint write * @param _time Current block.timestamp * @return TWAB Observation */ function _computeNextTwab( ObservationLib.Observation memory _currentTwab, uint224 _currentBalance, uint32 _time ) private pure returns (ObservationLib.Observation memory) { // New twab amount = last twab amount (or zero) + (current amount * elapsed seconds) return ObservationLib.Observation({ amount: _currentTwab.amount + _currentBalance * (_time.checkedSub(_currentTwab.timestamp, _time)), timestamp: _time }); } /// @notice Sets a new TWAB Observation at the next available index and returns the new account details. /// @dev Note that if _currentTime is before the last observation timestamp, it appears as an overflow /// @param _twabs The twabs array to insert into /// @param _accountDetails The current account details /// @param _currentTime The current time /// @return accountDetails The new account details /// @return twab The newest twab (may or may not be brand-new) /// @return isNew Whether the newest twab was created by this call function _nextTwab( ObservationLib.Observation[MAX_CARDINALITY] storage _twabs, AccountDetails memory _accountDetails, uint32 _currentTime ) private returns ( AccountDetails memory accountDetails, ObservationLib.Observation memory twab, bool isNew ) { (, ObservationLib.Observation memory _newestTwab) = newestTwab(_twabs, _accountDetails); // if we're in the same block, return if (_newestTwab.timestamp == _currentTime) { return (_accountDetails, _newestTwab, false); } ObservationLib.Observation memory newTwab = _computeNextTwab( _newestTwab, _accountDetails.balance, _currentTime ); _twabs[_accountDetails.nextTwabIndex] = newTwab; AccountDetails memory nextAccountDetails = push(_accountDetails); return (nextAccountDetails, newTwab, true); } /// @notice "Pushes" a new element on the AccountDetails ring buffer, and returns the new AccountDetails /// @param _accountDetails The account details from which to pull the cardinality and next index /// @return The new AccountDetails function push(AccountDetails memory _accountDetails) internal pure returns (AccountDetails memory) { _accountDetails.nextTwabIndex = uint24( RingBufferLib.nextIndex(_accountDetails.nextTwabIndex, MAX_CARDINALITY) ); // Prevent the Account specific cardinality from exceeding the MAX_CARDINALITY. // The ring buffer length is limited by MAX_CARDINALITY. IF the account.cardinality // exceeds the max cardinality, new observations would be incorrectly set or the // observation would be out of "bounds" of the ring buffer. Once reached the // AccountDetails.cardinality will continue to be equal to max cardinality. if (_accountDetails.cardinality < MAX_CARDINALITY) { _accountDetails.cardinality += 1; } return _accountDetails; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@pooltogether/owner-manager-contracts/contracts/Ownable.sol"; import "../external/compound/ICompLike.sol"; import "../interfaces/IPrizePool.sol"; import "../interfaces/ITicket.sol"; /** * @title PoolTogether V4 PrizePool * @author PoolTogether Inc Team * @notice Escrows assets and deposits them into a yield source. Exposes interest to Prize Strategy. Users deposit and withdraw from this contract to participate in Prize Pool. Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract. Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens */ abstract contract PrizePool is IPrizePool, Ownable, ReentrancyGuard, IERC721Receiver { using SafeCast for uint256; using SafeERC20 for IERC20; using ERC165Checker for address; /// @notice Semver Version string public constant VERSION = "4.0.0"; /// @notice Prize Pool ticket. Can only be set once by calling `setTicket()`. ITicket internal ticket; /// @notice The Prize Strategy that this Prize Pool is bound to. address internal prizeStrategy; /// @notice The total amount of tickets a user can hold. uint256 internal balanceCap; /// @notice The total amount of funds that the prize pool can hold. uint256 internal liquidityCap; /// @notice the The awardable balance uint256 internal _currentAwardBalance; /* ============ Modifiers ============ */ /// @dev Function modifier to ensure caller is the prize-strategy modifier onlyPrizeStrategy() { require(msg.sender == prizeStrategy, "PrizePool/only-prizeStrategy"); _; } /// @dev Function modifier to ensure the deposit amount does not exceed the liquidity cap (if set) modifier canAddLiquidity(uint256 _amount) { require(_canAddLiquidity(_amount), "PrizePool/exceeds-liquidity-cap"); _; } /* ============ Constructor ============ */ /// @notice Deploy the Prize Pool /// @param _owner Address of the Prize Pool owner constructor(address _owner) Ownable(_owner) ReentrancyGuard() { _setLiquidityCap(type(uint256).max); } /* ============ External Functions ============ */ /// @inheritdoc IPrizePool function balance() external override returns (uint256) { return _balance(); } /// @inheritdoc IPrizePool function awardBalance() external view override returns (uint256) { return _currentAwardBalance; } /// @inheritdoc IPrizePool function canAwardExternal(address _externalToken) external view override returns (bool) { return _canAwardExternal(_externalToken); } /// @inheritdoc IPrizePool function isControlled(ITicket _controlledToken) external view override returns (bool) { return _isControlled(_controlledToken); } /// @inheritdoc IPrizePool function getAccountedBalance() external view override returns (uint256) { return _ticketTotalSupply(); } /// @inheritdoc IPrizePool function getBalanceCap() external view override returns (uint256) { return balanceCap; } /// @inheritdoc IPrizePool function getLiquidityCap() external view override returns (uint256) { return liquidityCap; } /// @inheritdoc IPrizePool function getTicket() external view override returns (ITicket) { return ticket; } /// @inheritdoc IPrizePool function getPrizeStrategy() external view override returns (address) { return prizeStrategy; } /// @inheritdoc IPrizePool function getToken() external view override returns (address) { return address(_token()); } /// @inheritdoc IPrizePool function captureAwardBalance() external override nonReentrant returns (uint256) { uint256 ticketTotalSupply = _ticketTotalSupply(); uint256 currentAwardBalance = _currentAwardBalance; // it's possible for the balance to be slightly less due to rounding errors in the underlying yield source uint256 currentBalance = _balance(); uint256 totalInterest = (currentBalance > ticketTotalSupply) ? currentBalance - ticketTotalSupply : 0; uint256 unaccountedPrizeBalance = (totalInterest > currentAwardBalance) ? totalInterest - currentAwardBalance : 0; if (unaccountedPrizeBalance > 0) { currentAwardBalance = totalInterest; _currentAwardBalance = currentAwardBalance; emit AwardCaptured(unaccountedPrizeBalance); } return currentAwardBalance; } /// @inheritdoc IPrizePool function depositTo(address _to, uint256 _amount) external override nonReentrant canAddLiquidity(_amount) { _depositTo(msg.sender, _to, _amount); } /// @inheritdoc IPrizePool function depositToAndDelegate(address _to, uint256 _amount, address _delegate) external override nonReentrant canAddLiquidity(_amount) { _depositTo(msg.sender, _to, _amount); ticket.controllerDelegateFor(msg.sender, _delegate); } /// @notice Transfers tokens in from one user and mints tickets to another /// @notice _operator The user to transfer tokens from /// @notice _to The user to mint tickets to /// @notice _amount The amount to transfer and mint function _depositTo(address _operator, address _to, uint256 _amount) internal { require(_canDeposit(_to, _amount), "PrizePool/exceeds-balance-cap"); ITicket _ticket = ticket; _token().safeTransferFrom(_operator, address(this), _amount); _mint(_to, _amount, _ticket); _supply(_amount); emit Deposited(_operator, _to, _ticket, _amount); } /// @inheritdoc IPrizePool function withdrawFrom(address _from, uint256 _amount) external override nonReentrant returns (uint256) { ITicket _ticket = ticket; // burn the tickets _ticket.controllerBurnFrom(msg.sender, _from, _amount); // redeem the tickets uint256 _redeemed = _redeem(_amount); _token().safeTransfer(_from, _redeemed); emit Withdrawal(msg.sender, _from, _ticket, _amount, _redeemed); return _redeemed; } /// @inheritdoc IPrizePool function award(address _to, uint256 _amount) external override onlyPrizeStrategy { if (_amount == 0) { return; } uint256 currentAwardBalance = _currentAwardBalance; require(_amount <= currentAwardBalance, "PrizePool/award-exceeds-avail"); unchecked { _currentAwardBalance = currentAwardBalance - _amount; } ITicket _ticket = ticket; _mint(_to, _amount, _ticket); emit Awarded(_to, _ticket, _amount); } /// @inheritdoc IPrizePool function transferExternalERC20( address _to, address _externalToken, uint256 _amount ) external override onlyPrizeStrategy { if (_transferOut(_to, _externalToken, _amount)) { emit TransferredExternalERC20(_to, _externalToken, _amount); } } /// @inheritdoc IPrizePool function awardExternalERC20( address _to, address _externalToken, uint256 _amount ) external override onlyPrizeStrategy { if (_transferOut(_to, _externalToken, _amount)) { emit AwardedExternalERC20(_to, _externalToken, _amount); } } /// @inheritdoc IPrizePool function awardExternalERC721( address _to, address _externalToken, uint256[] calldata _tokenIds ) external override onlyPrizeStrategy { require(_canAwardExternal(_externalToken), "PrizePool/invalid-external-token"); if (_tokenIds.length == 0) { return; } uint256[] memory _awardedTokenIds = new uint256[](_tokenIds.length); bool hasAwardedTokenIds; for (uint256 i = 0; i < _tokenIds.length; i++) { try IERC721(_externalToken).safeTransferFrom(address(this), _to, _tokenIds[i]) { hasAwardedTokenIds = true; _awardedTokenIds[i] = _tokenIds[i]; } catch ( bytes memory error ) { emit ErrorAwardingExternalERC721(error); } } if (hasAwardedTokenIds) { emit AwardedExternalERC721(_to, _externalToken, _awardedTokenIds); } } /// @inheritdoc IPrizePool function setBalanceCap(uint256 _balanceCap) external override onlyOwner returns (bool) { _setBalanceCap(_balanceCap); return true; } /// @inheritdoc IPrizePool function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner { _setLiquidityCap(_liquidityCap); } /// @inheritdoc IPrizePool function setTicket(ITicket _ticket) external override onlyOwner returns (bool) { require(address(_ticket) != address(0), "PrizePool/ticket-not-zero-address"); require(address(ticket) == address(0), "PrizePool/ticket-already-set"); ticket = _ticket; emit TicketSet(_ticket); _setBalanceCap(type(uint256).max); return true; } /// @inheritdoc IPrizePool function setPrizeStrategy(address _prizeStrategy) external override onlyOwner { _setPrizeStrategy(_prizeStrategy); } /// @inheritdoc IPrizePool function compLikeDelegate(ICompLike _compLike, address _to) external override onlyOwner { if (_compLike.balanceOf(address(this)) > 0) { _compLike.delegate(_to); } } /// @inheritdoc IERC721Receiver function onERC721Received( address, address, uint256, bytes calldata ) external pure override returns (bytes4) { return IERC721Receiver.onERC721Received.selector; } /* ============ Internal Functions ============ */ /// @notice Transfer out `amount` of `externalToken` to recipient `to` /// @dev Only awardable `externalToken` can be transferred out /// @param _to Recipient address /// @param _externalToken Address of the external asset token being transferred /// @param _amount Amount of external assets to be transferred /// @return True if transfer is successful function _transferOut( address _to, address _externalToken, uint256 _amount ) internal returns (bool) { require(_canAwardExternal(_externalToken), "PrizePool/invalid-external-token"); if (_amount == 0) { return false; } IERC20(_externalToken).safeTransfer(_to, _amount); return true; } /// @notice Called to mint controlled tokens. Ensures that token listener callbacks are fired. /// @param _to The user who is receiving the tokens /// @param _amount The amount of tokens they are receiving /// @param _controlledToken The token that is going to be minted function _mint( address _to, uint256 _amount, ITicket _controlledToken ) internal { _controlledToken.controllerMint(_to, _amount); } /// @dev Checks if `user` can deposit in the Prize Pool based on the current balance cap. /// @param _user Address of the user depositing. /// @param _amount The amount of tokens to be deposited into the Prize Pool. /// @return True if the Prize Pool can receive the specified `amount` of tokens. function _canDeposit(address _user, uint256 _amount) internal view returns (bool) { uint256 _balanceCap = balanceCap; if (_balanceCap == type(uint256).max) return true; return (ticket.balanceOf(_user) + _amount <= _balanceCap); } /// @dev Checks if the Prize Pool can receive liquidity based on the current cap /// @param _amount The amount of liquidity to be added to the Prize Pool /// @return True if the Prize Pool can receive the specified amount of liquidity function _canAddLiquidity(uint256 _amount) internal view returns (bool) { uint256 _liquidityCap = liquidityCap; if (_liquidityCap == type(uint256).max) return true; return (_ticketTotalSupply() + _amount <= _liquidityCap); } /// @dev Checks if a specific token is controlled by the Prize Pool /// @param _controlledToken The address of the token to check /// @return True if the token is a controlled token, false otherwise function _isControlled(ITicket _controlledToken) internal view returns (bool) { return (ticket == _controlledToken); } /// @notice Allows the owner to set a balance cap per `token` for the pool. /// @param _balanceCap New balance cap. function _setBalanceCap(uint256 _balanceCap) internal { balanceCap = _balanceCap; emit BalanceCapSet(_balanceCap); } /// @notice Allows the owner to set a liquidity cap for the pool /// @param _liquidityCap New liquidity cap function _setLiquidityCap(uint256 _liquidityCap) internal { liquidityCap = _liquidityCap; emit LiquidityCapSet(_liquidityCap); } /// @notice Sets the prize strategy of the prize pool. Only callable by the owner. /// @param _prizeStrategy The new prize strategy function _setPrizeStrategy(address _prizeStrategy) internal { require(_prizeStrategy != address(0), "PrizePool/prizeStrategy-not-zero"); prizeStrategy = _prizeStrategy; emit PrizeStrategySet(_prizeStrategy); } /// @notice The current total of tickets. /// @return Ticket total supply. function _ticketTotalSupply() internal view returns (uint256) { return ticket.totalSupply(); } /// @dev Gets the current time as represented by the current block /// @return The timestamp of the current block function _currentTime() internal view virtual returns (uint256) { return block.timestamp; } /* ============ Abstract Contract Implementatiton ============ */ /// @notice Determines whether the passed token can be transferred out as an external award. /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The /// prize strategy should not be allowed to move those tokens. /// @param _externalToken The address of the token to check /// @return True if the token may be awarded, false otherwise function _canAwardExternal(address _externalToken) internal view virtual returns (bool); /// @notice Returns the ERC20 asset token used for deposits. /// @return The ERC20 asset token function _token() internal view virtual returns (IERC20); /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest. /// @return The underlying balance of asset tokens function _balance() internal virtual returns (uint256); /// @notice Supplies asset tokens to the yield source. /// @param _mintAmount The amount of asset tokens to be supplied function _supply(uint256 _mintAmount) internal virtual; /// @notice Redeems asset tokens from the yield source. /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed /// @return The actual amount of tokens that were redeemed. function _redeem(uint256 _redeemAmount) internal virtual returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@pooltogether/yield-source-interface/contracts/IYieldSource.sol"; import "./PrizePool.sol"; /** * @title PoolTogether V4 YieldSourcePrizePool * @author PoolTogether Inc Team * @notice The Yield Source Prize Pool uses a yield source contract to generate prizes. * Funds that are deposited into the prize pool are then deposited into a yield source. (i.e. Aave, Compound, etc...) */ contract YieldSourcePrizePool is PrizePool { using SafeERC20 for IERC20; using Address for address; /// @notice Address of the yield source. IYieldSource public immutable yieldSource; /// @dev Emitted when yield source prize pool is deployed. /// @param yieldSource Address of the yield source. event Deployed(address indexed yieldSource); /// @notice Emitted when stray deposit token balance in this contract is swept /// @param amount The amount that was swept event Swept(uint256 amount); /// @notice Deploy the Prize Pool and Yield Service with the required contract connections /// @param _owner Address of the Yield Source Prize Pool owner /// @param _yieldSource Address of the yield source constructor(address _owner, IYieldSource _yieldSource) PrizePool(_owner) { require( address(_yieldSource) != address(0), "YieldSourcePrizePool/yield-source-not-zero-address" ); yieldSource = _yieldSource; // A hack to determine whether it's an actual yield source (bool succeeded, bytes memory data) = address(_yieldSource).staticcall( abi.encodePacked(_yieldSource.depositToken.selector) ); address resultingAddress; if (data.length > 0) { resultingAddress = abi.decode(data, (address)); } require(succeeded && resultingAddress != address(0), "YieldSourcePrizePool/invalid-yield-source"); emit Deployed(address(_yieldSource)); } /// @notice Sweeps any stray balance of deposit tokens into the yield source. /// @dev This becomes prize money function sweep() external nonReentrant onlyOwner { uint256 balance = _token().balanceOf(address(this)); _supply(balance); emit Swept(balance); } /// @notice Determines whether the passed token can be transferred out as an external award. /// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The /// prize strategy should not be allowed to move those tokens. /// @param _externalToken The address of the token to check /// @return True if the token may be awarded, false otherwise function _canAwardExternal(address _externalToken) internal view override returns (bool) { IYieldSource _yieldSource = yieldSource; return ( _externalToken != address(_yieldSource) && _externalToken != _yieldSource.depositToken() ); } /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest. /// @return The underlying balance of asset tokens function _balance() internal override returns (uint256) { return yieldSource.balanceOfToken(address(this)); } /// @notice Returns the address of the ERC20 asset token used for deposits. /// @return Address of the ERC20 asset token. function _token() internal view override returns (IERC20) { return IERC20(yieldSource.depositToken()); } /// @notice Supplies asset tokens to the yield source. /// @param _mintAmount The amount of asset tokens to be supplied function _supply(uint256 _mintAmount) internal override { _token().safeIncreaseAllowance(address(yieldSource), _mintAmount); yieldSource.supplyTokenTo(_mintAmount, address(this)); } /// @notice Redeems asset tokens from the yield source. /// @param _redeemAmount The amount of yield-bearing tokens to be redeemed /// @return The actual amount of tokens that were redeemed. function _redeem(uint256 _redeemAmount) internal override returns (uint256) { return yieldSource.redeemToken(_redeemAmount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0; /// @title Defines the functions used to interact with a yield source. The Prize Pool inherits this contract. /// @notice Prize Pools subclasses need to implement this interface so that yield can be generated. interface IYieldSource { /// @notice Returns the ERC20 asset token used for deposits. /// @return The ERC20 asset token address. function depositToken() external view returns (address); /// @notice Returns the total balance (in asset tokens). This includes the deposits and interest. /// @return The underlying balance of asset tokens. function balanceOfToken(address addr) external returns (uint256); /// @notice Supplies tokens to the yield source. Allows assets to be supplied on other user's behalf using the `to` param. /// @param amount The amount of asset tokens to be supplied. Denominated in `depositToken()` as above. /// @param to The user whose balance will receive the tokens function supplyTokenTo(uint256 amount, address to) external; /// @notice Redeems tokens from the yield source. /// @param amount The amount of asset tokens to withdraw. Denominated in `depositToken()` as above. /// @return The actual amount of interst bearing tokens that were redeemed. function redeemToken(uint256 amount) external returns (uint256); }
@inheritdoc IPrizePool
function depositTo(address _to, uint256 _amount) external override nonReentrant canAddLiquidity(_amount) { _depositTo(msg.sender, _to, _amount); }
2,567,834
[ 1, 4625, 348, 7953, 560, 30, 225,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, 443, 1724, 774, 12, 2867, 389, 869, 16, 2254, 5034, 389, 8949, 13, 203, 3639, 3903, 203, 3639, 3849, 203, 3639, 1661, 426, 8230, 970, 203, 3639, 848, 986, 48, 18988, 24237, 24899, 8949, 13, 203, 565, 288, 203, 3639, 389, 323, 1724, 774, 12, 3576, 18, 15330, 16, 389, 869, 16, 389, 8949, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0x999512dC124371E6B9ff43CE8D1AF83252F0C851/sources/src/BaseVault.sol
* @dev Returns shares and amounts of token X and token Y to be deposited. @param strategy The address of the strategy. @param amountX The amount of token X to be deposited. @param amountY The amount of token Y to be deposited. @return shares The amount of shares to be minted. @return effectiveX The amount of token X to be deposited. @return effectiveY The amount of token Y to be deposited./* @dev Returns amounts of token X and token Y to be withdrawn. @param strategy The address of the strategy. @param shares The amount of shares to be withdrawn. @param totalShares The total amount of shares. @return amountX The amount of token X to be withdrawn. @return amountY The amount of token Y to be withdrawn./ Get the total amount of tokens held in the strategy Calculate the amount of tokens to be withdrawn, pro rata to the amount of shares
function _previewShares(IStrategy strategy, uint256 amountX, uint256 amountY) internal view virtual returns (uint256 shares, uint256, uint256); function _previewAmounts(IStrategy strategy, uint256 shares, uint256 totalShares) internal view virtual returns (uint256 amountX, uint256 amountY) { if (shares == 0) return (0, 0); if (shares > totalShares) revert BaseVault__InvalidShares(); (uint256 totalX, uint256 totalY) = _getBalances(strategy); amountX = totalX.mulDivRoundDown(shares, totalShares); amountY = totalY.mulDivRoundDown(shares, totalShares); }
1,894,079
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 24123, 471, 30980, 434, 1147, 1139, 471, 1147, 1624, 358, 506, 443, 1724, 329, 18, 632, 891, 6252, 1021, 1758, 434, 326, 6252, 18, 632, 891, 3844, 60, 1021, 3844, 434, 1147, 1139, 358, 506, 443, 1724, 329, 18, 632, 891, 3844, 61, 1021, 3844, 434, 1147, 1624, 358, 506, 443, 1724, 329, 18, 632, 2463, 24123, 1021, 3844, 434, 24123, 358, 506, 312, 474, 329, 18, 632, 2463, 11448, 60, 1021, 3844, 434, 1147, 1139, 358, 506, 443, 1724, 329, 18, 632, 2463, 11448, 61, 1021, 3844, 434, 1147, 1624, 358, 506, 443, 1724, 329, 18, 20308, 632, 5206, 2860, 30980, 434, 1147, 1139, 471, 1147, 1624, 358, 506, 598, 9446, 82, 18, 632, 891, 6252, 1021, 1758, 434, 326, 6252, 18, 632, 891, 24123, 1021, 3844, 434, 24123, 358, 506, 598, 9446, 82, 18, 632, 891, 2078, 24051, 1021, 2078, 3844, 434, 24123, 18, 632, 2463, 3844, 60, 1021, 3844, 434, 1147, 1139, 358, 506, 598, 9446, 82, 18, 632, 2463, 3844, 61, 1021, 3844, 434, 1147, 1624, 358, 506, 598, 9446, 82, 18, 19, 968, 326, 2078, 3844, 434, 2430, 15770, 316, 326, 6252, 9029, 326, 3844, 434, 2430, 358, 506, 598, 9446, 82, 16, 450, 436, 396, 358, 326, 3844, 434, 24123, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 12102, 24051, 12, 45, 4525, 6252, 16, 2254, 5034, 3844, 60, 16, 2254, 5034, 3844, 61, 13, 203, 3639, 2713, 203, 3639, 1476, 203, 3639, 5024, 203, 3639, 1135, 261, 11890, 5034, 24123, 16, 2254, 5034, 16, 2254, 5034, 1769, 203, 203, 565, 445, 389, 12102, 6275, 87, 12, 45, 4525, 6252, 16, 2254, 5034, 24123, 16, 2254, 5034, 2078, 24051, 13, 203, 3639, 2713, 203, 3639, 1476, 203, 3639, 5024, 203, 3639, 1135, 261, 11890, 5034, 3844, 60, 16, 2254, 5034, 3844, 61, 13, 203, 565, 288, 203, 3639, 309, 261, 30720, 422, 374, 13, 327, 261, 20, 16, 374, 1769, 203, 203, 3639, 309, 261, 30720, 405, 2078, 24051, 13, 15226, 3360, 12003, 972, 1941, 24051, 5621, 203, 203, 3639, 261, 11890, 5034, 2078, 60, 16, 2254, 5034, 2078, 61, 13, 273, 389, 588, 38, 26488, 12, 14914, 1769, 203, 203, 3639, 3844, 60, 273, 2078, 60, 18, 16411, 7244, 11066, 4164, 12, 30720, 16, 2078, 24051, 1769, 203, 3639, 3844, 61, 273, 2078, 61, 18, 16411, 7244, 11066, 4164, 12, 30720, 16, 2078, 24051, 1769, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/5/0x079BC05ebF765c3678Bec03A598561f0414f6227/sources/project:/contracts/PropertyNFT.sol
* @dev Ensures that the caller has operational privileges./
modifier onlyOperator() { require(msg.sender == operator, "Caller is not an operator"); _; } uint256 tokenId, string propertyName, uint apr, uint totalPropertyRaised, uint propertyParticipation, uint launchpadID, uint redeemFees, uint sellFees, uint totalEarned );
1,864,615
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 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, 1338, 5592, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 3726, 16, 315, 11095, 353, 486, 392, 3726, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 3639, 2254, 5034, 1147, 548, 16, 203, 3639, 533, 5470, 16, 203, 3639, 2254, 513, 86, 16, 203, 3639, 2254, 2078, 1396, 12649, 5918, 16, 203, 3639, 2254, 1272, 1988, 24629, 367, 16, 203, 3639, 2254, 8037, 6982, 734, 16, 203, 3639, 2254, 283, 24903, 2954, 281, 16, 203, 3639, 2254, 357, 80, 2954, 281, 16, 203, 3639, 2254, 2078, 41, 1303, 329, 203, 565, 11272, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/*** * _____ _ _____ * | | |___ _| |___| __ |_ _ ___ ___ ___ ___ ___ * | | | | . | . | -_| -| | | | | -_| _|_ -| * |_|___|___|___|___|__|__|___|_|_|_|_|___|_| |___| * * https://noderunners.io * MIT License * =========== * * Copyright (c) 2020 NodeRunners * * 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 */ 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; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.5.0; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } } pragma solidity ^0.5.5; contract Governance { address public governance; constructor() public { governance = tx.origin; } event GovernanceTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyGovernance { require(msg.sender == governance, "not governance"); _; } function setGovernance(address _governance) public onlyGovernance { require(_governance != address(0), "new governance the zero address"); emit GovernanceTransferred(governance, _governance); governance = _governance; } } pragma solidity ^0.5.5; /// @title NodeRunners Contract contract NodeRunnersToken is Governance, ERC20Detailed{ using SafeMath for uint256; //events event eveSetRate(uint256 burn_rate, uint256 reward_rate); event eveStakingPool(address stakingPool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); //token base data uint256 internal _totalSupply; mapping(address => uint256) public _balances; mapping (address => mapping (address => uint256)) public _allowances; bool public _openTransfer = false; // hardcode limit rate uint256 public constant _maxGovernValueRate = 2000;//2000/10000 uint256 public constant _minGovernValueRate = 0; //0/10000 uint256 public constant _rateBase = 10000; // additional variables for use if transaction fees ever became necessary uint256 public _burnRate = 0; uint256 public _rewardRate = 200; uint256 public _totalBurnToken = 0; uint256 public _totalRewardToken = 0; address public _stakingPool; address public _burnPool = 0x0000000000000000000000000000000000000000; /** * @dev set the token transfer switch */ function enableOpenTransfer() public onlyGovernance { _openTransfer = true; } /** * CONSTRUCTOR * * @dev Initialize the Token */ constructor (address governance) public ERC20Detailed("NodeRunners", "NDR", 18) { _totalSupply = 28000 * (10**18); //28,000 _balances[governance] = _balances[governance].add(_totalSupply); emit Transfer(address(0), governance, _totalSupply); } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param spender The address which will spend the funds. * @param amount The amount of tokens to be spent. */ function approve(address spender, uint256 amount) external returns (bool) { require(msg.sender != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @dev Function to check the amount of tokens than 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) external view returns (uint256) { return _allowances[owner][spender]; } /** * @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) external view returns (uint256) { return _balances[owner]; } /** * @dev return the token total supply */ function totalSupply() external view returns (uint256) { return _totalSupply; } function() external payable { revert(); } /** * @dev for govern value */ function setRate(uint256 burn_rate, uint256 reward_rate) public onlyGovernance { require(_maxGovernValueRate >= burn_rate && burn_rate >= _minGovernValueRate,"invalid burn rate"); require(_maxGovernValueRate >= reward_rate && reward_rate >= _minGovernValueRate,"invalid reward rate"); _burnRate = burn_rate; _rewardRate = reward_rate; emit eveSetRate(burn_rate, reward_rate); } /** * @dev for set reward */ function setStakingPool(address stakingPool) public onlyGovernance { require(stakingPool != address(0x0)); _stakingPool = stakingPool; emit eveStakingPool(_stakingPool); } /** * @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) external returns (bool) { return _transfer(msg.sender,to,value); } /** * @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) external returns (bool) { uint256 allow = _allowances[from][msg.sender]; _allowances[from][msg.sender] = allow.sub(value); return _transfer(from,to,value); } /** * @dev Transfer tokens with fee * @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 uint256s the amount of tokens to be transferred */ function _transfer(address from, address to, uint256 value) internal returns (bool) { // :) require(_openTransfer || from == governance, "transfer closed"); require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); uint256 sendAmount = value; uint256 burnFee = (value.mul(_burnRate)).div(_rateBase); if (burnFee > 0) { //to burn _balances[_burnPool] = _balances[_burnPool].add(burnFee); _totalSupply = _totalSupply.sub(burnFee); sendAmount = sendAmount.sub(burnFee); _totalBurnToken = _totalBurnToken.add(burnFee); emit Transfer(from, _burnPool, burnFee); } uint256 rewardFee = (value.mul(_rewardRate)).div(_rateBase); if (rewardFee > 0) { //to reward _balances[_stakingPool] = _balances[_stakingPool].add(rewardFee); sendAmount = sendAmount.sub(rewardFee); _totalRewardToken = _totalRewardToken.add(rewardFee); emit Transfer(from, _stakingPool, rewardFee); } _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(sendAmount); emit Transfer(from, to, sendAmount); return true; } }
* @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) external returns (bool) { return _transfer(msg.sender,to,value); }
6,588,401
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 7412, 1147, 364, 279, 1269,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, 2254, 5034, 460, 13, 3903, 203, 282, 1135, 261, 6430, 13, 203, 282, 288, 203, 3639, 327, 389, 13866, 12, 3576, 18, 15330, 16, 869, 16, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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; pragma solidity >=0.4.22 <0.6.0; /** * @title IERC165 * @dev https://eips.ethereum.org/EIPS/eip-165 */ interface IERC165 { /** * @notice Query if a contract implements an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /// @title Shared constants used throughout the Cheeze Wizards contracts contract WizardConstants { // Wizards normally have their affinity set when they are first created, // but for example Exclusive Wizards can be created with no set affinity. // In this case the affinity can be set by the owner. uint8 internal constant ELEMENT_NOTSET = 0; //000 // A neutral Wizard has no particular strength or weakness with specific // elements. uint8 internal constant ELEMENT_NEUTRAL = 1; //001 // The fire, water and wind elements are used both to reflect an affinity // of Elemental Wizards for a specific element, and as the moves a // Wizard can make during a duel. // Note thta if these values change then `moveMask` and `moveDelta` in // ThreeAffinityDuelResolver would need to be updated accordingly. uint8 internal constant ELEMENT_FIRE = 2; //010 uint8 internal constant ELEMENT_WATER = 3; //011 uint8 internal constant ELEMENT_WIND = 4; //100 uint8 internal constant MAX_ELEMENT = ELEMENT_WIND; } /** * @title ERC721 Non-Fungible Token Standard basic interface * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function balanceOf(address owner) public view returns (uint256 balance); function ownerOf(uint256 tokenId) public view returns (address owner); function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function transferFrom(address from, address to, uint256 tokenId) public; function safeTransferFrom(address from, address to, uint256 tokenId) public; function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract IERC721Receiver { /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safeTransfer`. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 contract address is always the message sender. * @param operator The address which called `safeTransferFrom` function * @param from The address which previously owned the token * @param tokenId The NFT identifier which is being transferred * @param data Additional data with no specified format * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4); } /** * @title ERC165 * @author Matt Condon (@shrugs) * @dev Implements ERC165 using a lookup table. */ contract ERC165 is IERC165 { bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /* * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) */ /** * @dev a mapping of interface id to whether or not it's supported */ mapping(bytes4 => bool) private _supportedInterfaces; /** * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself */ constructor () internal { _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev implement supportsInterface(bytes4) using a lookup table */ function supportsInterface(bytes4 interfaceId) external view returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev internal method for registering an interface */ function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff); _supportedInterfaces[interfaceId] = true; } } /// Utility library of inline functions on address payables. /// Modified from original by OpenZeppelin. contract Address { /// @notice Returns whether the target address is a contract. /// @dev This function will return false if invoked during the constructor of a contract, /// as the code is not actually created until after the constructor finishes. /// @param account address of the account to check /// @return whether the target address is a contract function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } // solium-disable-line security/no-inline-assembly return size > 0; } } /** * @title WizardPresaleNFT * @notice The basic ERC-721 functionality for storing the presale Wizard NFTs. * Derived from: https://github.com/OpenZeppelin/openzeppelin-solidity/tree/v2.2.0 */ contract WizardPresaleNFT is ERC165, IERC721, Address { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /// @notice Emitted when a wizard token is created. event WizardSummoned(uint256 indexed tokenId, uint8 element, uint256 power); /// @notice Emitted when a wizard change element. Should only happen once and for wizards /// that previously had the element undefined. event WizardAlignmentAssigned(uint256 indexed tokenId, uint8 element); // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 internal constant _ERC721_RECEIVED = 0x150b7a02; /// @dev The presale Wizard structure. /// Fits in one word struct Wizard { // NOTE: Changing the order or meaning of any of these fields requires an update // to the _createWizard() function which assumes a specific order for these fields. uint8 affinity; uint88 power; address owner; } // Mapping from Wizard ID to Wizard struct mapping (uint256 => Wizard) public _wizardsById; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal _ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ constructor () public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); } /** * @dev Gets the balance of the specified address * @param owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _ownedTokensCount[owner]; } /** * @dev Gets the owner of the specified token ID * @param tokenId uint256 ID of the token to query the owner of * @return address currently marked as the owner of the given token ID */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _wizardsById[tokenId].owner; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param to address to be approved for the given token ID * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param to operator address to set the approval * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { require(to != msg.sender, "ERC721: approve to caller"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } /** * @dev Tells whether an operator is approved by a given owner * @param owner owner address which you want to query the approval of * @param operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll(address owner, address operator) public view returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved"); _transferFrom(from, to, tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether the specified token exists * @param tokenId uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists(uint256 tokenId) internal view returns (bool) { address owner = _wizardsById[tokenId].owner; return owner != address(0); } /** * @dev Returns whether the given spender can transfer a given token ID * @param spender address of the spender to query * @param tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own"); _clearApproval(tokenId); _ownedTokensCount[owner]--; // delete the entire object to recover the most gas delete _wizardsById[tokenId]; // required for ERC721 compatibility emit Transfer(owner, address(0), tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param tokenId uint256 ID of the token being burned */ function _burn(uint256 tokenId) internal { _burn(ownerOf(tokenId), tokenId); } /** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to transferFrom, this imposes no restrictions on msg.sender. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); _ownedTokensCount[from]--; _ownedTokensCount[to]++; _wizardsById[tokenId].owner = to; emit Transfer(from, to, tokenId); } /** * @dev Internal function to invoke `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) internal returns (bool) { if (!isContract(to)) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data); return (retval == _ERC721_RECEIVED); } /** * @dev Private function to clear current approval of a given token ID * @param tokenId uint256 ID of the token to be transferred */ function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } } /// @title WizardPresaleInterface /// @notice This interface represents the single method that the final tournament and master Wizard contracts /// will use to import the presale wizards when those contracts have been finalized a released on /// mainnet. Once all presale Wizards have been absorbed, this temporary pre-sale contract can be /// destroyed. contract WizardPresaleInterface { // See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md on how // to calculate this bytes4 public constant _INTERFACE_ID_WIZARDPRESALE = 0x4df71efb; /// @notice This function is used to bring a presale Wizard into the final contracts. It can /// ONLY be called by the official gatekeeper contract (as set by the Owner of the presale /// contract). It does a number of things: /// 1. Check that the presale Wizard exists, and has not already been absorbed /// 2. Transfer the Eth used to create the presale Wizard to the caller /// 3. Mark the Wizard as having been absorbed, reclaiming the storage used by the presale info /// 4. Return the Wizard information (its owner, minting price, and elemental alignment) /// @param id the id of the presale Wizard to be absorbed function absorbWizard(uint256 id) external returns (address owner, uint256 power, uint8 affinity); /// @notice A convenience function that allows multiple Wizards to be moved to the final contracts /// simultaneously, works the same as the previous function, but in a batch. /// @param ids An array of ids indicating which presale Wizards are to be absorbed function absorbWizardMulti(uint256[] calldata ids) external returns (address[] memory owners, uint256[] memory powers, uint8[] memory affinities); function powerToCost(uint256 power) public pure returns (uint256 cost); function costToPower(uint256 cost) public pure returns (uint256 power); } /// @title WizardPresale - Making Cheeze Wizards available for sale! /// @notice Allows for the creation and sale of Cheeze Wizards before the final tournament /// contract has been reviewed and released on mainnet. There are three main types /// of Wizards that are managed by this contract: /// - Neutral Wizards: Available in unlimited quantities and all have the same /// innate power. Don't have a natural affinity for any particular elemental /// spell... or the corresponding weakness! /// - Elemental Wizards: Available in unlimited quantities, but with a steadily increasing /// power; the power of an Elemental Wizard is always _slightly_ higher than the power /// of the previously created Elemental Wizard. Each Elemental Wizard has an Elemental /// Affinity that gives it a power multiplier when using the associated spell, but also /// gives it a weakness for the opposing element. /// - Exclusive Wizards: Only available in VERY limited quantities, with a hard cap set at /// contract creation time. Exclusive Wizards can ONLY be created by the Guild Master /// address (the address that created this contract), and are assigned the first N /// Wizard IDs, starting with 1 (where N is the hard cap on Exclusive Wizards). The first /// non-exclusive Wizard is assigned the ID N+1. Exclusive Wizards have no starting /// affinity, and their owners much choose an affinity before they can be entered into a /// Battle. The affinity CAN NOT CHANGE once it has been selected. The power of Exclusive /// Wizards is not set by the Guild Master and is not required to follow any pattern (although /// it can't be lower than the power of Neutral Wizards). contract WizardPresale is WizardPresaleNFT, WizardPresaleInterface, WizardConstants { /// @dev The ratio between the cost of a Wizard (in wei) and the power of the wizard. /// power = cost / POWER_SCALE /// cost = power * POWER_SCALE uint256 private constant POWER_SCALE = 1000; /// @dev The unit conversion for tenths of basis points uint256 private constant TENTH_BASIS_POINTS = 100000; /// @dev The address used to create this smart contract, has permission to conjure Exclusive Wizards, /// set the gatekeeper address, and destroy this contract once the sale is finished and all Presale /// Wizards have been absorbed into the main contracts. address payable public guildmaster; /// @dev The start block and duration (in blocks) of the sale. /// ACT NOW! For a limited time only! uint256 public saleStartBlock; uint256 public saleDuration; /// @dev The cost of Neutral Wizards (in wei). uint256 public neutralWizardCost; /// @dev The cost of the _next_ Elemental Wizard (in wei); increases with each Elemental Wizard sold uint256 public elementalWizardCost; /// @dev The increment ratio in price between sequential Elemental Wizards, multiplied by 100k for /// greater granularity (0 == 0% increase, 100000 == 100% increase, 100 = 0.1% increase, etc.) /// NOTE: This is NOT percentage points, or basis points. It's tenths of a basis point. uint256 public elementalWizardIncrement; /// @dev The hard cap on how many Exclusive Wizards can be created uint256 public maxExclusives; /// @dev The ID number of the next Wizard to be created (Neutral or Elemental) uint256 public nextWizardId; /// @dev The address of the Gatekeeper for the tournament, initially set to address(0). /// To be set by the Guild Master when the final Tournament Contract is deployed on mainnet address payable public gatekeeper; /// @notice Emitted whenever the start of the sale changes. event StartBlockChanged(uint256 oldStartBlock, uint256 newStartBlock); /// @param startingCost The minimum cost of a Wizard, used as the price for all Neutral Wizards, and the /// cost of the first Elemental Wizard. Also used as a minimum value for Exclusive Wizards. /// @param costIncremement The rate (in tenths of a basis point) at which the price of Elemental Wizards increases /// @param exclusiveCount The hard cap on Exclusive Wizards, also dictates the ID of the first non-Exclusive /// @param startBlock The starting block of the presale. /// @param duration The duration of the presale. Not changeable! constructor(uint128 startingCost, uint16 costIncremement, uint256 exclusiveCount, uint128 startBlock, uint128 duration) public { require(startBlock > block.number, "Start must be greater than current block"); guildmaster = msg.sender; saleStartBlock = startBlock; saleDuration = duration; neutralWizardCost = startingCost; elementalWizardCost = startingCost; elementalWizardIncrement = costIncremement; maxExclusives = exclusiveCount; nextWizardId = exclusiveCount + 1; _registerInterface(_INTERFACE_ID_WIZARDPRESALE); } /// @dev Throws if called by any account other than the gatekeeper. modifier onlyGatekeeper() { require(msg.sender == gatekeeper, "Must be gatekeeper"); _; } /// @dev Throws if called by any account other than the guildmaster. modifier onlyGuildmaster() { require(msg.sender == guildmaster, "Must be guildmaster"); _; } /// @dev Checks to see that the current block number is within the range /// [saleStartBlock, saleStartBlock + saleDuraction) indicating that the sale /// is currently active modifier onlyDuringSale() { // The addtion of start and duration can't overflow since they can only be set from // 128-bit arguments. require(block.number >= saleStartBlock, "Sale not open yet"); require(block.number < saleStartBlock + saleDuration, "Sale closed"); _; } /// @dev Sets the address of the Gatekeeper contract once the final Tournament contract is live. /// Can only be set once. /// @param gc The gatekeeper address to set function setGatekeeper(address payable gc) external onlyGuildmaster { require(gatekeeper == address(0) && gc != address(0), "Can only set once and must not be 0"); gatekeeper = gc; } /// @dev Updates the start block of the sale. The sale can only be postponed; it can't be made earlier. /// @param newStart the new start block. function postponeSale(uint128 newStart) external onlyGuildmaster { require(block.number < saleStartBlock, "Sale start time only adjustable before previous start time"); require(newStart > saleStartBlock, "New start time must be later than previous start time"); emit StartBlockChanged(saleStartBlock, newStart); saleStartBlock = newStart; } /// @dev Returns true iff the sale is currently active function isDuringSale() external view returns (bool) { return (block.number >= saleStartBlock && block.number < saleStartBlock + saleDuration); } /// @dev Convenience method for getting a presale wizard's data /// @param id The wizard id function getWizard(uint256 id) public view returns (address owner, uint88 power, uint8 affinity) { Wizard memory wizard = _wizardsById[id]; (owner, power, affinity) = (wizard.owner, wizard.power, wizard.affinity); require(wizard.owner != address(0), "Wizard does not exist"); } /// @param cost The price of the wizard in wei /// @return The power of the wizard (left as uint256) function costToPower(uint256 cost) public pure returns (uint256 power) { return cost / POWER_SCALE; } /// @param power The power of the wizard /// @return The cost of the wizard in wei function powerToCost(uint256 power) public pure returns (uint256 cost) { return power * POWER_SCALE; } /// @notice This function is used to bring a presale Wizard into the final contracts. It can /// ONLY be called by the official gatekeeper contract (as set by the Owner of the presale /// contract). It does a number of things: /// 1. Check that the presale Wizard exists, and has not already been absorbed /// 2. Transfer the Eth used to create the presale Wizard to the caller /// 3. Mark the Wizard as having been absorbed, reclaiming the storage used by the presale info /// 4. Return the Wizard information (its owner, minting price, and elemental alignment) /// @param id the id of the presale Wizard to be absorbed function absorbWizard(uint256 id) external onlyGatekeeper returns (address owner, uint256 power, uint8 affinity) { (owner, power, affinity) = getWizard(id); // Free up the storage used by this wizard _burn(owner, id); // send the price paid to the gatekeeper to be used in the tournament prize pool msg.sender.transfer(powerToCost(power)); } /// @notice A convenience function that allows multiple Wizards to be moved to the final contracts /// simultaneously, works the same as the previous function, but in a batch. /// @param ids An array of ids indicating which presale Wizards are to be absorbed function absorbWizardMulti(uint256[] calldata ids) external onlyGatekeeper returns (address[] memory owners, uint256[] memory powers, uint8[] memory affinities) { // allocate arrays owners = new address[](ids.length); powers = new uint256[](ids.length); affinities = new uint8[](ids.length); // The total eth to send (sent in a batch to save gas) uint256 totalTransfer; // Put the data for each Wizard into the returned arrays for (uint256 i = 0; i < ids.length; i++) { (owners[i], powers[i], affinities[i]) = getWizard(ids[i]); // Free up the storage used by this wizard _burn(owners[i], ids[i]); // add the amount to transfer totalTransfer += powerToCost(powers[i]); } // Send all the eth together msg.sender.transfer(totalTransfer); } /// @dev Internal function to create a new Wizard; reverts if the Wizard ID is taken. /// NOTE: This function heavily depends on the internal format of the Wizard struct /// and should always be reassessed if anything about that structure changes. /// @param tokenId ID of the new Wizard /// @param owner The address that will own the newly conjured Wizard /// @param power The power level associated with the new Wizard /// @param affinity The elemental affinity of the new Wizard function _createWizard(uint256 tokenId, address owner, uint256 power, uint8 affinity) internal { require(!_exists(tokenId), "Can't reuse Wizard ID"); require(owner != address(0), "Owner address must exist"); require(power > 0, "Wizard power must be non-0"); require(power < (1<<88), "Wizard power must fit in 88 bits of storage"); require(affinity <= MAX_ELEMENT, "Invalid elemental affinity"); // Create the Wizard! _wizardsById[tokenId] = Wizard(affinity, uint88(power), owner); _ownedTokensCount[owner]++; // Tell the world! emit Transfer(address(0), owner, tokenId); emit WizardSummoned(tokenId, affinity, power); } /// @dev A private utility function that refunds any overpayment to the sender; smart /// enough to only send the excess if the amount we are returning is more than the /// cost of sending it! /// @dev Warning! This does not check for underflows (msg.value < actualPrice) - so /// be sure to call this with correct values! /// @param actualPrice the actual price owed function _transferRefund(uint256 actualPrice) private { uint256 refund = msg.value - actualPrice; // Make sure the amount we're trying to refund is less than the actual cost of sending it! // See https://github.com/ethereum/wiki/wiki/Subtleties for magic values costs. We can // safley ignore the 25000 additional gas cost for new accounts, as msg.sender is // guarunteed to exist at this point! if (refund > (tx.gasprice * (9000+700))) { msg.sender.transfer(refund); } } /// @notice Conjures an Exclusive Wizard with a specific element and ID. This can only be done by /// the Guildmaster, who still has to pay for the power imbued in that Wizard! The power level /// is inferred by the amount of Eth sent. MUST ONLY BE USED FOR EXTERNAL OWNER ADDRESSES. /// @param id The ID of the new Wizard; must be in the Exclusive range, and can't already be allocated /// @param owner The address which will own the new Wizard /// @param affinity The elemental affinity of the new Wizard, can be ELEMENT_NOTSET for Exclusives! function conjureExclusiveWizard(uint256 id, address owner, uint8 affinity) public payable onlyGuildmaster { require(id > 0 && id <= maxExclusives, "Invalid exclusive ID"); _createWizard(id, owner, costToPower(msg.value), affinity); } /// @notice Same as conjureExclusiveWizard(), but reverts if the owner address is a smart /// contract that is not ERC-721 aware. /// @param id The ID of the new Wizard; must be in the Exclusive range, and can't already be allocated /// @param owner The address which will own the new Wizard /// @param affinity The elemental affinity of the new Wizard, can be ELEMENT_NOTSET for Exclusives! function safeConjureExclusiveWizard(uint256 id, address owner, uint8 affinity) external payable onlyGuildmaster { conjureExclusiveWizard(id, owner, affinity); require(_checkOnERC721Received(address(0), owner, id, ""), "Must support erc721"); } /// @notice Allows for the batch creation of Exclusive Wizards. Same rules apply as above, but the /// powers are specified instead of being inferred. The message still needs to have enough /// value to pay for all the newly conjured Wizards! MUST ONLY BE USED FOR EXTERNAL OWNER ADDRESSES. /// @param ids An array of IDs of the new Wizards /// @param owners An array of owners /// @param powers An array of power levels /// @param affinities An array of elemental affinities function conjureExclusiveWizardMulti( uint256[] calldata ids, address[] calldata owners, uint256[] calldata powers, uint8[] calldata affinities) external payable onlyGuildmaster { // Ensure the arrays are all of the same length require( ids.length == owners.length && owners.length == powers.length && owners.length == affinities.length, "Must have equal array lengths" ); uint256 totalPower = 0; for (uint256 i = 0; i < ids.length; i++) { require(ids[i] > 0 && ids[i] <= maxExclusives, "Invalid exclusive ID"); require(affinities[i] <= MAX_ELEMENT, "Must choose a valid elemental affinity"); _createWizard(ids[i], owners[i], powers[i], affinities[i]); totalPower += powers[i]; } // Ensure that the message includes enough eth to cover the total power of all Wizards // If this check fails, all the Wizards that we just created will be deleted, and we'll just // have wasted a bunch of gas. Don't be dumb, Guildmaster! // If the guildMaster has managed to overflow totalPower, well done! require(powerToCost(totalPower) <= msg.value, "Must pay for power in all Wizards"); // We don't return "change" if the caller overpays, because the caller is the Guildmaster and // shouldn't be dumb like that. How many times do I have to say it? Don't be dumb, Guildmaster! } /// @notice Sets the affinity for a Wizard that doesn't already have its elemental affinity chosen. /// Only usable for Exclusive Wizards (all non-Exclusives must have their affinity chosen when /// conjured.) Even Exclusives can't change their affinity once it's been chosen. /// @param wizardId The id of the wizard /// @param newAffinity The new affinity of the wizard function setAffinity(uint256 wizardId, uint8 newAffinity) external { require(newAffinity > ELEMENT_NOTSET && newAffinity <= MAX_ELEMENT, "Must choose a valid affinity"); (address owner, , uint8 affinity) = getWizard(wizardId); require(msg.sender == owner, "Affinity can only be set by owner"); require(affinity == ELEMENT_NOTSET, "Affinity can only be chosen once"); _wizardsById[wizardId].affinity = newAffinity; // Tell the world this wizards now has an affinity! emit WizardAlignmentAssigned(wizardId, newAffinity); } /// @dev An internal convenience function used by conjureWizard and conjureWizardMulti that takes care /// of the work that is shared between them. /// The use of tempElementalWizardCost and updatedElementalWizardCost deserves some explanation here. /// Using elementalWizardCost directly would be very expensive in the case where this function is /// called repeatedly by conjureWizardMulti. Buying an elemental wizard would update the elementalWizardCost /// each time through this function _which would cost 5000 gas each time_. Of course, we don't actually /// need to store the new value each time, only once at the very end. So we go through this very annoying /// process of passing the elementalWizardCost in as an argument (tempElementalWizardCost) and returning /// the updated value as a return value (updatedElementalWizardCost). It's enough to make one want /// tear one's hair out. But! What's done is done, and hopefully SOMEONE will realize how much trouble /// we went to to save them _just that little bit_ of gas cost when they decided to buy a schwack of /// Wizards. function _conjureWizard( uint256 wizardId, address owner, uint8 affinity, uint256 tempElementalWizardCost) private returns (uint256 wizardCost, uint256 updatedElementalWizardCost) { // Check for a valid elemental affinity require(affinity > ELEMENT_NOTSET && affinity <= MAX_ELEMENT, "Non-exclusive Wizards need a real affinity"); updatedElementalWizardCost = tempElementalWizardCost; // Determine the price if (affinity == ELEMENT_NEUTRAL) { wizardCost = neutralWizardCost; } else { wizardCost = updatedElementalWizardCost; // Update the elemental Wizard cost // NOTE: This math can't overflow because the total Ether supply in wei is well less than // 2^128. Multiplying a price in wei by some number <100k can't possibly overflow 256 bits. updatedElementalWizardCost += (updatedElementalWizardCost * elementalWizardIncrement) / TENTH_BASIS_POINTS; } // Bring the new Wizard into existence! _createWizard(wizardId, owner, costToPower(wizardCost), affinity); } /// @notice This is it folks, the main event! The way for the world to get new Wizards! Does /// pretty much what it says on the box: Let's you conjure a new Wizard with a specified /// elemental affinity. The call must include enough eth to cover the cost of the new /// Wizard, and any excess is refunded. The power of the Wizard is derived from /// the sale price. YOU CAN NOT PAY EXTRA TO GET MORE POWER. (But you always have the option /// to conjure some more Wizards!) Returns the ID of the newly conjured Wizard. /// @param affinity The elemental affinity you want for your wizard. function conjureWizard(uint8 affinity) external payable onlyDuringSale returns (uint256 wizardId) { wizardId = nextWizardId; nextWizardId++; uint256 wizardCost; (wizardCost, elementalWizardCost) = _conjureWizard(wizardId, msg.sender, affinity, elementalWizardCost); require(msg.value >= wizardCost, "Not enough eth to pay"); // Refund any overpayment _transferRefund(wizardCost); // Ensure the Wizard is being assigned to an ERC-721 aware address (either an external address, // or a smart contract that implements onERC721Reived()) require(_checkOnERC721Received(address(0), msg.sender, wizardId, ""), "Must support erc721"); } /// @notice A convenience function that allows you to get a whole bunch of Wizards at once! You know how /// there's "a pride of lions", "a murder of crows", and "a parliament of owls"? Well, with this /// here function you can conjure yourself "a stench of Cheeze Wizards"! /// @dev This function is careful to bundle all of the external calls (the refund and onERC721Received) /// at the end of the function to limit the risk of reentrancy attacks. /// @param affinities the elements of the wizards function conjureWizardMulti(uint8[] calldata affinities) external payable onlyDuringSale returns (uint256[] memory wizardIds) { // allocate result array wizardIds = new uint256[](affinities.length); uint256 totalCost = 0; // We take these two storage variables, and turn them into local variables for the course // of this loop to save about 10k gas per wizard. It's kind of ugly, but that's a lot of // gas! Won't somebody please think of the children!! uint256 tempWizardId = nextWizardId; uint256 tempElementalWizardCost = elementalWizardCost; for (uint256 i = 0; i < affinities.length; i++) { wizardIds[i] = tempWizardId; tempWizardId++; uint256 wizardCost; (wizardCost, tempElementalWizardCost) = _conjureWizard( wizardIds[i], msg.sender, affinities[i], tempElementalWizardCost); totalCost += wizardCost; } elementalWizardCost = tempElementalWizardCost; nextWizardId = tempWizardId; // check to see if there's enough eth require(msg.value >= totalCost, "Not enough eth to pay"); // Ensure the Wizard is being assigned to an ERC-721 aware address (either an external address, // or a smart contract that implements onERC721Received()). We unwind the logic of _checkOnERC721Received // because called address.isContract() every time through this loop can get reasonably expensive. We do // need to call this function for each token created, however, because it's allowed for an ERC-721 receiving // contract to reject the transfer based on the properties of the token. if (isContract(msg.sender)) { for (uint256 i = 0; i < wizardIds.length; i++) { bytes4 retval = IERC721Receiver(msg.sender).onERC721Received(msg.sender, address(0), wizardIds[i], ""); require(retval == _ERC721_RECEIVED, "Contract owner didn't accept ERC721 transfer"); } } // Refund any excess funds _transferRefund(totalCost); } /// @dev Transfers the current balance to the owner and terminates the contract. function destroy() external onlyGuildmaster { selfdestruct(guildmaster); } }
Refund any excess funds
_transferRefund(totalCost);
2,529,616
[ 1, 4625, 348, 7953, 560, 30, 225, 3941, 1074, 1281, 23183, 284, 19156, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 389, 13866, 21537, 12, 4963, 8018, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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: contracts/ownership/MultiOwnable.sol /** * @title MultiOwnable * @dev The MultiOwnable contract has owners addresses and provides basic authorization control * functions, this simplifies the implementation of "users permissions". */ contract MultiOwnable { address public manager; // address used to set owners address[] public owners; mapping(address => bool) public ownerByAddress; event SetOwners(address[] owners); modifier onlyOwner() { require(ownerByAddress[msg.sender] == true); _; } /** * @dev MultiOwnable constructor sets the manager */ function MultiOwnable() public { manager = msg.sender; } /** * @dev Function to set owners addresses */ function setOwners(address[] _owners) public { require(msg.sender == manager); _setOwners(_owners); } function _setOwners(address[] _owners) internal { for(uint256 i = 0; i < owners.length; i++) { ownerByAddress[owners[i]] = false; } for(uint256 j = 0; j < _owners.length; j++) { ownerByAddress[_owners[j]] = true; } owners = _owners; emit SetOwners(_owners); } function getOwners() public constant returns (address[]) { return owners; } } // File: 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) { 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/token/ERC20/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } // File: 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 { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 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 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) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit 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. 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 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(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); 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 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/ITokenEventListener.sol /** * @title ITokenEventListener * @dev Interface which should be implemented by token listener */ interface ITokenEventListener { /** * @dev Function is called after token transfer/transferFrom * @param _from Sender address * @param _to Receiver address * @param _value Amount of tokens */ function onTokenTransfer(address _from, address _to, uint256 _value) external; } // File: contracts/token/ManagedToken.sol /** * @title ManagedToken * @dev ERC20 compatible token with issue and destroy facilities * @dev All transfers can be monitored by token event listener */ contract ManagedToken is StandardToken, MultiOwnable { bool public allowTransfers = false; bool public issuanceFinished = false; ITokenEventListener public eventListener; event AllowTransfersChanged(bool _newState); event Issue(address indexed _to, uint256 _value); event Destroy(address indexed _from, uint256 _value); event IssuanceFinished(); modifier transfersAllowed() { assert(allowTransfers); _; } modifier canIssue() { assert(!issuanceFinished); _; } /** * @dev ManagedToken constructor * @param _listener Token listener(address can be 0x0) * @param _owners Owners list */ function ManagedToken(address _listener, address[] _owners) public { if(_listener != address(0)) { eventListener = ITokenEventListener(_listener); } _setOwners(_owners); } /** * @dev Enable/disable token transfers. Can be called only by owners * @param _allowTransfers True - allow False - disable */ function setAllowTransfers(bool _allowTransfers) external onlyOwner { allowTransfers = _allowTransfers; emit AllowTransfersChanged(_allowTransfers); } /** * @dev Set/remove token event listener * @param _listener Listener address (Contract must implement ITokenEventListener interface) */ function setListener(address _listener) public onlyOwner { if(_listener != address(0)) { eventListener = ITokenEventListener(_listener); } else { delete eventListener; } } /** * @dev Override transfer function. Add event listener condition */ function transfer(address _to, uint256 _value) public transfersAllowed returns (bool) { bool success = super.transfer(_to, _value); if(hasListener() && success) { eventListener.onTokenTransfer(msg.sender, _to, _value); } return success; } /** * @dev Override transferFrom function. Add event listener condition */ function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool) { bool success = super.transferFrom(_from, _to, _value); if(hasListener() && success) { eventListener.onTokenTransfer(_from, _to, _value); } return success; } function hasListener() internal view returns(bool) { if(eventListener == address(0)) { return false; } return true; } /** * @dev Issue tokens to specified wallet * @param _to Wallet address * @param _value Amount of tokens */ function issue(address _to, uint256 _value) external onlyOwner canIssue { } /** * @dev Destroy tokens on specified address (Called by owner or token holder) * @dev Fund contract address must be in the list of owners to burn token during refund * @param _from Wallet address * @param _value Amount of tokens to destroy */ function destroy(address _from, uint256 _value) external { } /** * @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 OpenZeppelin StandardToken.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] = SafeMath.add(allowed[msg.sender][_spender], _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 OpenZeppelin StandardToken.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] = SafeMath.sub(oldValue, _subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Finish token issuance * @return True if success */ function finishIssuance() public onlyOwner { issuanceFinished = true; emit IssuanceFinished(); } } // File: contracts/token/TransferLimitedToken.sol /** * @title TransferLimitedToken * @dev Token with ability to limit transfers within wallets included in limitedWallets list for certain period of time */ contract TransferLimitedToken is ManagedToken { mapping(address => bool) public limitedWallets; address public limitedWalletsManager; bool public isLimitEnabled; modifier onlyManager() { require(msg.sender == limitedWalletsManager); _; } /** * @dev Check if transfer between addresses is available * @param _from From address * @param _to To address */ modifier canTransfer(address _from, address _to) { require(!isLimitEnabled || (!limitedWallets[_from] && !limitedWallets[_to])); _; } /** * @dev TransferLimitedToken constructor * @param _listener Token listener(address can be 0x0) * @param _owners Owners list * @param _limitedWalletsManager Address used to add/del wallets from limitedWallets */ function TransferLimitedToken(address _listener, address[] _owners, address _limitedWalletsManager) public ManagedToken(_listener, _owners) { isLimitEnabled = true; limitedWalletsManager = _limitedWalletsManager; } /** * @dev Add address to limitedWallets * @dev Can be called only by manager */ function addLimitedWalletAddress(address _wallet) public onlyManager { limitedWallets[_wallet] = true; } /** * @dev Del address from limitedWallets * @dev Can be called only by manager */ function delLimitedWalletAddress(address _wallet) public onlyManager { limitedWallets[_wallet] = false; } function isLimitedWalletAddress(address _wallet) public view returns(bool) { return limitedWallets[_wallet]; } /** * @dev Enable/disable token transfers limited wallet. Can be called only by manager * @param _setLimitEnabled True - enable limit transfer False - disable */ function setLimitEnabled(bool _setLimitEnabled) public onlyManager { isLimitEnabled = _setLimitEnabled; } /** * @dev Override transfer function. Add canTransfer modifier to check possibility of transferring */ function transfer(address _to, uint256 _value) public canTransfer(msg.sender, _to) returns (bool) { return super.transfer(_to, _value); } /** * @dev Override transferFrom function. Add canTransfer modifier to check possibility of transferring */ function transferFrom(address _from, address _to, uint256 _value) public canTransfer(_from, _to) returns (bool) { return super.transferFrom(_from, _to, _value); } /** * @dev Override approve function. Add canTransfer modifier to check possibility of transferring */ function approve(address _spender, uint256 _value) public canTransfer(msg.sender, _spender) returns (bool) { return super.approve(_spender,_value); } } // File: contracts/MCCToken.sol contract MCCToken is TransferLimitedToken { // ================================================================================================================= // Members // ================================================================================================================= string public name = "MyCreditChain"; string public symbol = "MCC"; uint8 public decimals = 18; event Burn(address indexed burner, uint256 value); // ================================================================================================================= // Constructor // ================================================================================================================= /** * @dev MCC Token * To change to a token for DAICO, you must set up an ITokenEvenListener * to change the voting weight setting through the listener for the * transfer of the token. */ function MCCToken(address _listener, address[] _owners, address _manager) public TransferLimitedToken(_listener, _owners, _manager) { totalSupply_ = uint256(1000000000).mul(uint256(10) ** decimals); // token total supply : 1000000000 balances[_owners[0]] = totalSupply_; } /** * @dev Override ManagedToken.issue. MCCToken can not issue but it need to * distribute tokens to contributors while crowding sales. So. we changed this * Issue tokens to specified wallet * @param _to Wallet address * @param _value Amount of tokens */ function issue(address _to, uint256 _value) external onlyOwner canIssue { balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); emit Issue(_to, _value); emit Transfer(msg.sender, _to, _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); } /** * @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) public { require(_value <= allowed[_from][msg.sender]); // 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); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
* @dev Override approve function. Add canTransfer modifier to check possibility of transferring/
function approve(address _spender, uint256 _value) public canTransfer(msg.sender, _spender) returns (bool) { return super.approve(_spender,_value); }
5,468,965
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 1439, 6617, 537, 445, 18, 1436, 848, 5912, 9606, 358, 866, 25547, 434, 906, 74, 20245, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 6617, 537, 12, 2867, 389, 87, 1302, 264, 16, 2254, 5034, 389, 1132, 13, 1071, 848, 5912, 12, 3576, 18, 15330, 16, 389, 87, 1302, 264, 13, 1135, 261, 6430, 13, 288, 203, 3639, 327, 2240, 18, 12908, 537, 24899, 87, 1302, 264, 16, 67, 1132, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.1; interface IPoTypes { //------------------------------------------------------------------------ // Purchase Order //------------------------------------------------------------------------ enum PoItemStatus { Initial, // 0 expect never to see this Created, // 1 PO item has been created in the contract | 0->1 managed by buyer waller contract fn call from buyer UI Accepted, // 2 PO item has been accepted by the seller and a corresponding SO item created | 1->2 managed by seller wallet contract fn call from seller UI Rejected, // 3 PO item has been rejected by the seller | 1->3 managed by seller wallet contract fn call from seller UI ReadyForGoodsIssue, // 4 PO item is ready for goods issue | 2->4 managed by seller wallet contract fn call from seller UI GoodsIssued, // 5 PO item has been posted or issued by the seller | 4->5 managed by seller wallet contract fn call from seller UI GoodsReceived, // 6 PO item has been received by the buyer or escrow time exceeded | 5->6 managed by buyer wallet contract fn call from buyer OR po main contract 30 days or Seller UI Completed, // 7 PO item is complete and escrow funds released to the buyer wallet | 6->7 managed by seller wallet contract fn call from seller UI Cancelled // 8 PO item has been successfully cancelled and funds refunded to buyer wallet | 1->8 or 2->8 managed by seller wallet contract fn call from seller UI, at discretion of seller (poss break out into own field of po item payment status) } enum PoItemCancelStatus { Initial, // 0 default to empty, no request made RequestMade, // 1 PO item has had cancellation requested | 0->1 managed by buyer wallet contract fn call from buyer UI RequestRejected, // 2 PO item has had cancellation rejected | 1->2 managed by seller wallet contract fn call from seller UI RequestAccepted // 3 PO item has had cancellation accepted | 1->3 managed by seller wallet contract fn call from seller UI } enum PoType { Initial, // 0 expect never to see this Cash, // 1 PO is paid up front by the buyer Invoice // 2 PO is paid later after buyer receives an invoice } struct PoItem { uint poNumber; // contract managed, PO header key uint8 poItemNumber; // contract managed, PO item key bytes32 soNumber; // seller system (eg eShop) managed (any numbering allowed, could be same as PO number and PO item) bytes32 soItemNumber; // seller system (eg eShop) managed (any numbering allowed, could be same as PO number and PO item) bytes32 productId; // buyer UI managed, product id from product registry uint quantity; // buyer UI managed, regular quantity, eg 4 bytes32 unit; // buyer UI managed, regular quantity units, eg PC pieces (TODO are there ISO codes for this?) bytes32 quantitySymbol; // buyer UI managed, symbol of the ERC20 that represents this productId (assume token quantity same as quantity above) address quantityAddress; // buyer UI managed, contract address of the ERC20 that represents this productId uint currencyValue; // buyer UI managed, value in the units of the ERC20 that is making the payment eg DAI has token precision 18, so 1120000000000000000 DAI is 1.12 USD uint currencyValueFee; // contract managed at point of po create, currency value to set aside as fee to shop when escrow released PoItemStatus status; // contract managed for create, then seller system managed uint goodsIssuedDate; // contract managed at point of goods issue, unix timestamp uint goodsReceivedDate; // contract managed at point of goods received (or time out), unix timestamp uint plannedEscrowReleaseDate; // contract managed at point of goods issue, it is the planned escrow release date = goods issue + escrow days eg 30 days uint actualEscrowReleaseDate; // contract managed at point of successful escrow release bool isEscrowReleased; // contract managed, defaults to false, true when escrow funds released to seller PoItemCancelStatus cancelStatus; // contract managed from buyer UI and seller UI fn calls } struct Po { uint poNumber; // contract managed, PO header key, leave blank at PO creation time address buyerUserAddress; // buyer UI managed, buyer EoA address represents user identity and "owner" of the PO ("user address"). Not used in events. address buyerReceiverAddress; // buyer UI managed, buyer EoA address will receive product ownership tokens at end ("logistics address") address buyerWalletAddress; // buyer UI managed, buyer wallet contract address, used in events, used to locate wallet contract whose functions are called by buyer UI, handles tokens ("finance address") bytes32 eShopId; // buyer UI managed, uniquely identifies a shop (GLOBAL) uint quoteId; // buyer UI managed, a quote signed by eShop, eShopId+quoteId uniquely identifies a single poNumber uint quoteExpiryDate; // buyer UI managed, a quote signed by eShop expires on this date address quoteSignerAddress; // contract managed, signer of quote is looked up from eShop master data during PO creation bytes32 sellerId; // buyer UI managed, uniquely identifies a seller (GLOBAL) bytes32 currencySymbol; // buyer UI managed, symbol of the ERC20 that is making payment, eg DAI address currencyAddress; // buyer UI managed, contract address of the ERC20 that is making payment PoType poType; // buyer UI managed, specifies what workflow PO will use uint poCreateDate; // buyer UI managed, po creation unix timestamp uint8 poItemCount; // contract managed, count of line items written to storage PoItem[] poItems; // dynamic array of po items, TODO impose configurable max of eg 16, low enough that contract can iterate all uint8 rulesCount; // contract managed, count of rules written to storage bytes32[] rules; // buyer UI managed, list of rules that were run on PO by seller system before quote was made } //------------------------------------------------------------------------ // eShop //------------------------------------------------------------------------ struct Eshop { bytes32 eShopId; // uniquely identifies a shop bytes32 eShopDescription; // optional free text short description address purchasingContractAddress; // contract address of the shops Purchasing.sol contract that handles purchase orders bool isActive; // flag true if shop is active address createdByAddress; // decentralised admin - only creator can make changes uint8 quoteSignerCount; // count of quote signers address[] quoteSigners; // list of addresses that can sign a quotation tx to prove shop approves it } //------------------------------------------------------------------------ // Seller //------------------------------------------------------------------------ struct Seller { bytes32 sellerId; // uniquely identifies a seller bytes32 sellerDescription; // optional free text short description address adminContractAddress; // contract address of seller wallet, used to manage listings, also where money sent after a sale bool isActive; // flag true if seller is active address createdByAddress; // decentralised admin - only creator can make changes } }
contract managed at point of po create, currency value to set aside as fee to shop when escrow released
uint currencyValueFee;
6,460,503
[ 1, 4625, 348, 7953, 560, 30, 225, 6835, 7016, 622, 1634, 434, 8275, 752, 16, 5462, 460, 358, 444, 487, 831, 487, 14036, 358, 12122, 1347, 2904, 492, 15976, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 2254, 5462, 620, 14667, 31, 2868, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IController.sol"; import "./interfaces/IHarvester.sol"; import "./interfaces/ILegacyController.sol"; import "./interfaces/IManager.sol"; import "./interfaces/IStrategy.sol"; import "./interfaces/ISwap.sol"; /** * @title Harvester * @notice This contract is to be used as a central point to call * harvest on all strategies for any given vault. It has its own * permissions for harvesters (set by the strategist or governance). */ contract Harvester is IHarvester { using SafeMath for uint256; uint256 public constant ONE_HUNDRED_PERCENT = 10000; IManager public immutable override manager; IController public immutable controller; ILegacyController public immutable legacyController; uint256 public slippage; struct Strategy { uint256 timeout; uint256 lastCalled; address[] addresses; } mapping(address => Strategy) public strategies; mapping(address => bool) public isHarvester; /** * @notice Logged when a controller is set */ event ControllerSet(address indexed controller); /** * @notice Logged when harvest is called for a strategy */ event Harvest( address indexed controller, address indexed strategy ); /** * @notice Logged when a harvester is set */ event HarvesterSet(address indexed harvester, bool status); /** * @notice Logged when a strategy is added for a vault */ event StrategyAdded(address indexed vault, address indexed strategy, uint256 timeout); /** * @notice Logged when a strategy is removed for a vault */ event StrategyRemoved(address indexed vault, address indexed strategy, uint256 timeout); /** * @notice Logged when a vault manger is set */ event VaultManagerSet(address indexed manager); /** * @param _manager The address of the yAxisMetaVaultManager contract * @param _controller The address of the controller */ constructor( address _manager, address _controller, address _legacyController ) public { manager = IManager(_manager); controller = IController(_controller); legacyController = ILegacyController(_legacyController); } /** * (GOVERNANCE|STRATEGIST)-ONLY FUNCTIONS */ /** * @notice Adds a strategy to the rotation for a given vault and sets a timeout * @param _vault The address of the vault * @param _strategy The address of the strategy * @param _timeout The timeout between harvests */ function addStrategy( address _vault, address _strategy, uint256 _timeout ) external override onlyController { strategies[_vault].addresses.push(_strategy); strategies[_vault].timeout = _timeout; emit StrategyAdded(_vault, _strategy, _timeout); } /** * @notice Removes a strategy from the rotation for a given vault and sets a timeout * @param _vault The address of the vault * @param _strategy The address of the strategy * @param _timeout The timeout between harvests */ function removeStrategy( address _vault, address _strategy, uint256 _timeout ) external override onlyController { uint256 tail = strategies[_vault].addresses.length; uint256 index; bool found; for (uint i; i < tail; i++) { if (strategies[_vault].addresses[i] == _strategy) { index = i; found = true; break; } } if (found) { strategies[_vault].addresses[index] = strategies[_vault].addresses[tail.sub(1)]; strategies[_vault].addresses.pop(); strategies[_vault].timeout = _timeout; emit StrategyRemoved(_vault, _strategy, _timeout); } } /** * @notice Sets the status of a harvester address to be able to call harvest functions * @param _harvester The address of the harvester * @param _status The status to allow the harvester to harvest */ function setHarvester( address _harvester, bool _status ) external onlyStrategist { isHarvester[_harvester] = _status; emit HarvesterSet(_harvester, _status); } function setSlippage( uint256 _slippage ) external onlyStrategist { require(_slippage < ONE_HUNDRED_PERCENT, "!_slippage"); slippage = _slippage; } /** * HARVESTER-ONLY FUNCTIONS */ function earn( address _strategy, IVault _vault, address _token ) external onlyHarvester { _vault.earn(_token, _strategy); } /** * @notice Harvests a given strategy on the provided controller * @dev This function ignores the timeout * @param _controller The address of the controller * @param _strategy The address of the strategy */ function harvest( IController _controller, address _strategy, uint256 _estimatedWETH, uint256 _estimatedYAXIS ) public onlyHarvester { _controller.harvestStrategy(_strategy, _estimatedWETH, _estimatedYAXIS); emit Harvest(address(_controller), _strategy); } /** * @notice Harvests the next available strategy for a given vault and * rotates the strategies * @param _vault The address of the vault */ function harvestNextStrategy( address _vault, uint256 _estimatedWETH, uint256 _estimatedYAXIS ) external { require(canHarvest(_vault), "!canHarvest"); address strategy = strategies[_vault].addresses[0]; harvest(controller, strategy, _estimatedWETH, _estimatedYAXIS); uint256 k = strategies[_vault].addresses.length; if (k > 1) { address[] memory _strategies = new address[](k); for (uint i; i < k-1; i++) { _strategies[i] = strategies[_vault].addresses[i+1]; } _strategies[k-1] = strategy; strategies[_vault].addresses = _strategies; } // solhint-disable-next-line not-rely-on-time strategies[_vault].lastCalled = block.timestamp; } /** * @notice Earns tokens in the LegacyController to the v3 vault * @param _token The address of the token * @param _expected The expected amount to deposit after conversion */ function legacyEarn( address _token, uint256 _expected ) external onlyHarvester { legacyController.legacyDeposit(_token, _expected); } /** * EXTERNAL VIEW FUNCTIONS */ /** * @notice Returns the addresses of the strategies for a given vault * @param _vault The address of the vault */ function strategyAddresses( address _vault ) external view returns (address[] memory) { return strategies[_vault].addresses; } /** * PUBLIC VIEW FUNCTIONS */ /** * @notice Returns the availability of a vault's strategy to be harvested * @param _vault The address of the vault */ function canHarvest( address _vault ) public view returns (bool) { Strategy storage strategy = strategies[_vault]; if (strategy.addresses.length == 0 || // solhint-disable-next-line not-rely-on-time strategy.lastCalled > block.timestamp.sub(strategy.timeout)) { return false; } return true; } /** * @notice Returns the estimated amount of WETH and YAXIS for the given strategy * @param _strategy The address of the strategy */ function getEstimates( address _strategy ) public view returns (uint256 _estimatedWETH, uint256 _estimatedYAXIS) { ISwap _router = IStrategy(_strategy).router(); address[] memory _path; _path[0] = IStrategy(_strategy).want(); _path[1] = IStrategy(_strategy).weth(); uint256[] memory _amounts = _router.getAmountsOut( IStrategy(_strategy).balanceOfPool(), _path ); _estimatedWETH = _amounts[1]; uint256 _slippage = slippage; if (_slippage > 0) { _estimatedWETH = _estimatedWETH.mul(_slippage).div(ONE_HUNDRED_PERCENT); } _path[0] = manager.yaxis(); uint256 _fee = _estimatedWETH.mul(manager.treasuryFee()).div(ONE_HUNDRED_PERCENT); _amounts = _router.getAmountsOut(_fee, _path); _estimatedYAXIS = _amounts[1]; if (_slippage > 0) { _estimatedYAXIS = _estimatedYAXIS.mul(_slippage).div(ONE_HUNDRED_PERCENT); } } /** * MODIFIERS */ modifier onlyController() { require(manager.allowedControllers(msg.sender), "!controller"); _; } modifier onlyHarvester() { require(isHarvester[msg.sender], "!harvester"); _; } modifier onlyStrategist() { require(msg.sender == manager.strategist(), "!strategist"); _; } }
* @notice Harvests the next available strategy for a given vault and rotates the strategies @param _vault The address of the vault/
function harvestNextStrategy( address _vault, uint256 _estimatedWETH, uint256 _estimatedYAXIS ) external { require(canHarvest(_vault), "!canHarvest"); address strategy = strategies[_vault].addresses[0]; harvest(controller, strategy, _estimatedWETH, _estimatedYAXIS); uint256 k = strategies[_vault].addresses.length; if (k > 1) { address[] memory _strategies = new address[](k); for (uint i; i < k-1; i++) { _strategies[i] = strategies[_vault].addresses[i+1]; } _strategies[k-1] = strategy; strategies[_vault].addresses = _strategies; } }
12,730,784
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 670, 297, 90, 25563, 326, 1024, 2319, 6252, 364, 279, 864, 9229, 471, 4168, 815, 326, 20417, 632, 891, 389, 26983, 1021, 1758, 434, 326, 9229, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 17895, 26923, 2134, 4525, 12, 203, 3639, 1758, 389, 26983, 16, 203, 3639, 2254, 5034, 389, 395, 17275, 59, 1584, 44, 16, 203, 3639, 2254, 5034, 389, 395, 17275, 61, 25614, 203, 565, 262, 203, 3639, 3903, 203, 565, 288, 203, 3639, 2583, 12, 4169, 44, 297, 26923, 24899, 26983, 3631, 17528, 4169, 44, 297, 26923, 8863, 203, 3639, 1758, 6252, 273, 20417, 63, 67, 26983, 8009, 13277, 63, 20, 15533, 203, 3639, 17895, 26923, 12, 5723, 16, 6252, 16, 389, 395, 17275, 59, 1584, 44, 16, 389, 395, 17275, 61, 25614, 1769, 203, 3639, 2254, 5034, 417, 273, 20417, 63, 67, 26983, 8009, 13277, 18, 2469, 31, 203, 3639, 309, 261, 79, 405, 404, 13, 288, 203, 5411, 1758, 8526, 3778, 389, 701, 15127, 273, 394, 1758, 8526, 12, 79, 1769, 203, 5411, 364, 261, 11890, 277, 31, 277, 411, 417, 17, 21, 31, 277, 27245, 288, 203, 7734, 389, 701, 15127, 63, 77, 65, 273, 20417, 63, 67, 26983, 8009, 13277, 63, 77, 15, 21, 15533, 203, 5411, 289, 203, 5411, 389, 701, 15127, 63, 79, 17, 21, 65, 273, 6252, 31, 203, 5411, 20417, 63, 67, 26983, 8009, 13277, 273, 389, 701, 15127, 31, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x10754abf634d39D132Be59117C8297Ca4C5084e5/sources/ElPepe.sol
Pre-flight checksBuy TokenSell Token
function _transfer(address sender, address recipient, uint256 amount) internal virtual override { require(amount > 0, "Transfer amount must be greater than zero"); uint256 contractBalance = balanceOf(address(this)); bool canSwap = contractBalance >= swapTokensAtAmount; if( tradeOpen == true && canSwap && !automatedMarketMakerPairs[sender] && sender != owner() && !swapping ) { swapping = true; if (totalFeeAmount > 0) { swapAndSendToFee(totalFeeAmount, marketingFeeWallet); } totalFeeAmount = 0; swapping = false; } if (sender == owner() || recipient == owner() || _isExcludedFromFees[sender] || _isExcludedFromFees[recipient]) { super._transfer(sender, recipient, amount); require(tradeOpen == true, "Trading is not yet open."); uint256 sendAmount = amount; uint256 feeAmount; if(automatedMarketMakerPairs[sender] && totalFees > 0) { feeAmount = amount.mul(totalFees).div(100); if(feeAmount > balanceOf(address(this))) { totalFeeAmount += feeAmount; totalFeeAmount += feeAmount; feeAmount = 0; } sendAmount = amount.sub(feeAmount); } if(automatedMarketMakerPairs[recipient] && totalFees > 0) { feeAmount = amount.mul(totalFees).div(100); sendAmount = amount.sub(feeAmount); } if(feeAmount > 0) { totalFeeAmount += feeAmount; super._transfer(sender, address(this), feeAmount); } super._transfer(sender, recipient, sendAmount); } }
2,877,070
[ 1, 4625, 348, 7953, 560, 30, 225, 2962, 17, 19131, 4271, 38, 9835, 3155, 55, 1165, 3155, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 377, 445, 389, 13866, 12, 2867, 5793, 16, 1758, 8027, 16, 2254, 5034, 3844, 13, 2713, 5024, 3849, 288, 203, 3639, 2583, 12, 8949, 405, 374, 16, 315, 5912, 3844, 1297, 506, 6802, 2353, 3634, 8863, 203, 203, 3639, 2254, 5034, 6835, 13937, 273, 11013, 951, 12, 2867, 12, 2211, 10019, 203, 3639, 1426, 848, 12521, 225, 273, 6835, 13937, 1545, 7720, 5157, 861, 6275, 31, 203, 3639, 309, 12, 7010, 5411, 18542, 3678, 422, 638, 203, 5411, 597, 848, 12521, 203, 5411, 597, 401, 5854, 362, 690, 3882, 278, 12373, 10409, 63, 15330, 65, 203, 5411, 597, 5793, 480, 3410, 1435, 203, 5411, 597, 401, 22270, 1382, 203, 3639, 262, 288, 203, 5411, 7720, 1382, 273, 638, 31, 203, 203, 5411, 309, 261, 4963, 14667, 6275, 405, 374, 13, 288, 203, 7734, 7720, 1876, 3826, 774, 14667, 12, 4963, 14667, 6275, 16, 13667, 310, 14667, 16936, 1769, 203, 5411, 289, 203, 5411, 2078, 14667, 6275, 273, 374, 31, 203, 5411, 7720, 1382, 273, 629, 31, 203, 3639, 289, 203, 3639, 309, 261, 15330, 422, 3410, 1435, 747, 8027, 422, 3410, 1435, 747, 389, 291, 16461, 1265, 2954, 281, 63, 15330, 65, 747, 389, 291, 16461, 1265, 2954, 281, 63, 20367, 5717, 288, 203, 5411, 2240, 6315, 13866, 12, 15330, 16, 8027, 16, 3844, 1769, 203, 5411, 2583, 12, 20077, 3678, 422, 638, 16, 315, 1609, 7459, 353, 486, 4671, 1696, 1199, 1769, 203, 203, 5411, 2254, 5034, 1366, 6275, 273, 3844, 31, 203, 5411, 2254, 5034, 14036, 6275, 31, 203, 5411, 309, 12, 5854, 362, 690, 3882, 278, 12373, 10409, 63, 15330, 65, 597, 2078, 2954, 281, 405, 374, 13, 288, 203, 7734, 14036, 6275, 273, 3844, 18, 16411, 12, 4963, 2954, 281, 2934, 2892, 12, 6625, 1769, 203, 7734, 309, 12, 21386, 6275, 405, 11013, 951, 12, 2867, 12, 2211, 20349, 203, 7734, 288, 203, 10792, 2078, 14667, 6275, 1011, 14036, 6275, 31, 203, 10792, 2078, 14667, 6275, 1011, 14036, 6275, 31, 203, 10792, 14036, 6275, 273, 374, 31, 203, 7734, 289, 203, 7734, 1366, 6275, 273, 3844, 18, 1717, 12, 21386, 6275, 1769, 203, 5411, 289, 203, 5411, 309, 12, 5854, 362, 690, 3882, 278, 12373, 10409, 63, 20367, 65, 597, 2078, 2954, 281, 405, 374, 13, 288, 203, 7734, 14036, 6275, 273, 3844, 18, 16411, 12, 4963, 2954, 281, 2934, 2892, 12, 6625, 1769, 203, 7734, 1366, 6275, 273, 3844, 18, 1717, 12, 21386, 6275, 1769, 203, 5411, 289, 203, 5411, 309, 12, 21386, 6275, 405, 374, 13, 288, 203, 7734, 2078, 14667, 6275, 1011, 14036, 6275, 31, 203, 7734, 2240, 6315, 13866, 12, 15330, 16, 1758, 12, 2211, 3631, 14036, 6275, 1769, 203, 5411, 289, 203, 5411, 2240, 6315, 13866, 12, 15330, 16, 8027, 16, 1366, 6275, 1769, 203, 3639, 289, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// Dark Lord Inu is here to takeover and rule all other Inus on the blockchain! He is keeping a close eye on the work of Elon Musk // https://t.me/DarkLordInu // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; 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; } } 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); } 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; } } 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 Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; 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; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // Contract implementation contract DarkLordInu is Context, IERC20, Ownable { using SafeMath for uint256; 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; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Dark Lord Inu'; string private _symbol = 'DARKLORDINU'; uint8 private _decimals = 9; uint256 private _taxFee = 1; uint256 private _developmentFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousDevelopmentFee = _developmentFee; address payable public _developmentWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; // We will set a minimum amount of tokens to be swaped => 5M uint256 private _numOfTokensToExchangeForDevelopment = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable developmentWalletAddress, address payable marketingWalletAddress) public { _developmentWalletAddress = developmentWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentWalletAddress] = true; _isExcludedFromFee[_marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } 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 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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _developmentFee == 0) return; _previousTaxFee = _taxFee; _previousDevelopmentFee = _developmentFee; _taxFee = 0; _developmentFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _developmentFee = _previousDevelopmentFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToDevelopment(uint256 amount) private { _developmentWalletAddress.transfer(amount.mul(2).div(6)); _marketingWalletAddress.transfer(amount.mul(2).div(6)); } function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToDevelopment(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeDevelopment(uint256 tDevelopment) private { uint256 currentRate = _getRate(); uint256 rDevelopment = tDevelopment.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rDevelopment); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tDevelopment); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getTValues(tAmount, _taxFee, _developmentFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tDevelopment); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 developmentFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tDevelopment = tAmount.mul(developmentFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tDevelopment); return (tTransferAmount, tFee, tDevelopment); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(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 = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 0 && taxFee <= 25, 'taxFee should be in 0 - 25'); _taxFee = taxFee; } function _setDevelopmentFee(uint256 developmentFee) external onlyOwner() { require(developmentFee >= 1 && developmentFee <= 25, 'developmentFee should be in 1 - 25'); _developmentFee = developmentFee; } function _setDevelopmentWallet(address payable developmentWalletAddress) external onlyOwner() { _developmentWalletAddress = developmentWalletAddress; } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
Contract implementation We will set a minimum amount of tokens to be swaped => 5M
contract DarkLordInu is Context, IERC20, Ownable { using SafeMath for uint256; 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; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Dark Lord Inu'; string private _symbol = 'DARKLORDINU'; uint8 private _decimals = 9; uint256 private _taxFee = 1; uint256 private _developmentFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousDevelopmentFee = _developmentFee; address payable public _developmentWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 100000000000000e9; uint256 private _numOfTokensToExchangeForDevelopment = 5 * 10**3 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable developmentWalletAddress, address payable marketingWalletAddress) public { _developmentWalletAddress = developmentWalletAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentWalletAddress] = true; _isExcludedFromFee[_marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } 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 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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public 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) public 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.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function removeAllFee() private { if(_taxFee == 0 && _developmentFee == 0) return; _previousTaxFee = _taxFee; _previousDevelopmentFee = _developmentFee; _taxFee = 0; _developmentFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _developmentFee = _previousDevelopmentFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForDevelopment; if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); } } bool takeFee = true; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender,recipient,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{ address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToDevelopment(uint256 amount) private { _developmentWalletAddress.transfer(amount.mul(2).div(6)); _marketingWalletAddress.transfer(amount.mul(2).div(6)); } function manualSwap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualSend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToDevelopment(contractETHBalance); } function setSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } 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 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeDevelopment(tDevelopment); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeDevelopment(uint256 tDevelopment) private { uint256 currentRate = _getRate(); uint256 rDevelopment = tDevelopment.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rDevelopment); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tDevelopment); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tDevelopment) = _getTValues(tAmount, _taxFee, _developmentFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tDevelopment); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 developmentFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tDevelopment = tAmount.mul(developmentFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tDevelopment); return (tTransferAmount, tFee, tDevelopment); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(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 = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_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 = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _getTaxFee() private view returns(uint256) { return _taxFee; } function _getMaxTxAmount() private view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { require(taxFee >= 0 && taxFee <= 25, 'taxFee should be in 0 - 25'); _taxFee = taxFee; } function _setDevelopmentFee(uint256 developmentFee) external onlyOwner() { require(developmentFee >= 1 && developmentFee <= 25, 'developmentFee should be in 1 - 25'); _developmentFee = developmentFee; } function _setDevelopmentWallet(address payable developmentWalletAddress) external onlyOwner() { _developmentWalletAddress = developmentWalletAddress; } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
14,748,544
[ 1, 4625, 348, 7953, 560, 30, 225, 13456, 4471, 1660, 903, 444, 279, 5224, 3844, 434, 2430, 358, 506, 1352, 5994, 516, 1381, 49, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 6835, 463, 1313, 48, 517, 382, 89, 353, 1772, 16, 467, 654, 39, 3462, 16, 14223, 6914, 288, 203, 3639, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 3639, 1450, 5267, 364, 1758, 31, 203, 203, 3639, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 86, 5460, 329, 31, 203, 3639, 2874, 261, 2867, 516, 2254, 5034, 13, 3238, 389, 88, 5460, 329, 31, 203, 3639, 2874, 261, 2867, 516, 2874, 261, 2867, 516, 2254, 5034, 3719, 3238, 389, 5965, 6872, 31, 203, 203, 3639, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 291, 16461, 1265, 14667, 31, 203, 203, 3639, 2874, 261, 2867, 516, 1426, 13, 3238, 389, 291, 16461, 31, 203, 3639, 1758, 8526, 3238, 389, 24602, 31, 203, 377, 203, 3639, 2254, 5034, 3238, 5381, 4552, 273, 4871, 11890, 5034, 12, 20, 1769, 203, 3639, 2254, 5034, 3238, 389, 88, 5269, 273, 15088, 9449, 380, 1728, 636, 29, 31, 203, 3639, 2254, 5034, 3238, 389, 86, 5269, 273, 261, 6694, 300, 261, 6694, 738, 389, 88, 5269, 10019, 203, 3639, 2254, 5034, 3238, 389, 88, 14667, 5269, 31, 203, 203, 3639, 533, 3238, 389, 529, 273, 296, 40, 1313, 511, 517, 657, 89, 13506, 203, 3639, 533, 3238, 389, 7175, 273, 296, 40, 9584, 48, 916, 21329, 57, 13506, 203, 3639, 2254, 28, 3238, 389, 31734, 273, 2468, 31, 203, 540, 203, 3639, 2254, 5034, 3238, 389, 8066, 14667, 273, 404, 31, 7010, 3639, 2254, 5034, 3238, 389, 26630, 14667, 273, 1728, 31, 203, 3639, 2254, 5034, 3238, 389, 11515, 7731, 14667, 273, 389, 8066, 14667, 31, 203, 3639, 2254, 5034, 3238, 389, 11515, 26438, 14667, 273, 389, 26630, 14667, 31, 203, 203, 3639, 1758, 8843, 429, 1071, 389, 26630, 16936, 1887, 31, 203, 3639, 1758, 8843, 429, 1071, 389, 3355, 21747, 16936, 1887, 31, 203, 540, 203, 540, 203, 3639, 467, 984, 291, 91, 438, 58, 22, 8259, 3103, 1071, 11732, 640, 291, 91, 438, 58, 22, 8259, 31, 203, 3639, 1758, 1071, 11732, 640, 291, 91, 438, 58, 22, 4154, 31, 203, 203, 3639, 1426, 316, 12521, 273, 629, 31, 203, 3639, 1426, 1071, 7720, 1526, 273, 638, 31, 203, 203, 3639, 2254, 5034, 3238, 389, 1896, 4188, 6275, 273, 2130, 12648, 2787, 73, 29, 31, 203, 3639, 2254, 5034, 3238, 389, 2107, 951, 5157, 774, 11688, 1290, 26438, 273, 1381, 380, 1728, 636, 23, 380, 1728, 636, 29, 31, 203, 203, 3639, 871, 5444, 5157, 4649, 12521, 7381, 12, 11890, 5034, 1131, 5157, 4649, 12521, 1769, 203, 3639, 871, 12738, 1526, 7381, 12, 6430, 3696, 1769, 203, 203, 3639, 9606, 2176, 1986, 12521, 288, 203, 5411, 316, 12521, 273, 638, 31, 203, 5411, 389, 31, 203, 5411, 316, 12521, 273, 629, 31, 203, 3639, 289, 203, 203, 3639, 3885, 261, 2867, 8843, 429, 17772, 16936, 1887, 16, 1758, 8843, 429, 13667, 310, 16936, 1887, 13, 1071, 288, 203, 5411, 389, 26630, 16936, 1887, 273, 17772, 16936, 1887, 31, 203, 5411, 389, 3355, 21747, 16936, 1887, 273, 13667, 310, 16936, 1887, 31, 203, 5411, 389, 86, 5460, 329, 63, 67, 3576, 12021, 1435, 65, 273, 389, 86, 5269, 31, 203, 203, 5411, 467, 984, 291, 91, 438, 58, 22, 8259, 3103, 389, 318, 291, 91, 438, 58, 22, 8259, 273, 467, 984, 291, 91, 438, 58, 22, 8259, 3103, 12, 20, 92, 27, 69, 26520, 72, 4313, 5082, 38, 24, 71, 42, 25, 5520, 27, 5520, 72, 42, 22, 39, 25, 72, 37, 7358, 24, 71, 26, 6162, 42, 3247, 5482, 40, 1769, 7010, 5411, 640, 291, 91, 438, 58, 22, 4154, 273, 467, 984, 291, 91, 438, 58, 22, 1733, 24899, 318, 291, 91, 438, 58, 22, 8259, 18, 6848, 10756, 203, 7734, 263, 2640, 4154, 12, 2867, 12, 2211, 3631, 389, 318, 291, 91, 438, 58, 22, 8259, 18, 59, 1584, 44, 10663, 203, 203, 2398, 203, 5411, 640, 291, 91, 438, 58, 22, 8259, 273, 389, 318, 291, 91, 438, 58, 22, 8259, 31, 203, 203, 2398, 203, 5411, 389, 291, 16461, 1265, 14667, 63, 8443, 1435, 65, 273, 638, 31, 203, 5411, 389, 291, 16461, 1265, 14667, 63, 2867, 12, 2211, 25887, 273, 638, 31, 203, 5411, 389, 291, 16461, 1265, 14667, 63, 67, 26630, 16936, 1887, 65, 273, 638, 31, 203, 5411, 389, 291, 16461, 1265, 14667, 63, 67, 3355, 21747, 16936, 1887, 65, 273, 638, 31, 203, 203, 5411, 3626, 12279, 12, 2867, 12, 20, 3631, 389, 3576, 12021, 9334, 389, 88, 5269, 1769, 203, 3639, 289, 203, 203, 3639, 445, 508, 1435, 1071, 1476, 1135, 261, 1080, 3778, 13, 288, 203, 5411, 327, 389, 529, 31, 203, 3639, 289, 203, 203, 3639, 445, 3273, 1435, 1071, 1476, 1135, 261, 1080, 3778, 13, 288, 203, 5411, 327, 389, 7175, 31, 203, 3639, 289, 203, 203, 3639, 445, 15105, 1435, 1071, 1476, 1135, 261, 11890, 28, 13, 288, 203, 5411, 327, 389, 31734, 31, 203, 3639, 289, 203, 203, 3639, 445, 2078, 3088, 1283, 1435, 1071, 1476, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 5411, 327, 389, 88, 5269, 31, 203, 3639, 289, 203, 203, 3639, 445, 11013, 951, 12, 2867, 2236, 13, 1071, 1476, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 5411, 309, 261, 67, 291, 16461, 63, 4631, 5717, 327, 389, 88, 5460, 329, 63, 4631, 15533, 203, 5411, 327, 1147, 1265, 9801, 24899, 86, 5460, 329, 63, 4631, 19226, 203, 3639, 289, 203, 203, 3639, 445, 7412, 12, 2867, 8027, 16, 2254, 5034, 3844, 13, 1071, 3849, 1135, 261, 6430, 13, 288, 203, 5411, 389, 13866, 24899, 3576, 12021, 9334, 8027, 16, 3844, 1769, 203, 5411, 327, 638, 31, 203, 3639, 289, 203, 203, 3639, 445, 1699, 1359, 12, 2867, 3410, 16, 1758, 17571, 264, 13, 1071, 1476, 3849, 1135, 261, 11890, 5034, 13, 288, 203, 5411, 327, 389, 5965, 6872, 63, 8443, 6362, 87, 1302, 264, 15533, 203, 3639, 289, 203, 203, 3639, 445, 6617, 537, 12, 2867, 17571, 264, 16, 2254, 5034, 3844, 13, 1071, 3849, 1135, 261, 6430, 13, 288, 203, 5411, 389, 12908, 537, 24899, 3576, 12021, 9334, 17571, 264, 16, 3844, 1769, 203, 5411, 327, 638, 31, 203, 3639, 289, 203, 203, 3639, 445, 7412, 1265, 12, 2867, 5793, 16, 2 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma abicoder v2; import "base64-sol/base64.sol"; import "./constants/Colors.sol"; /// @title Hair SVG generator library HairDetail { /// @dev Hair N°1 => Classic Brown function item_1() public pure returns (string memory) { return base(classicHairs(Colors.BROWN)); } /// @dev Hair N°2 => Classic Black function item_2() public pure returns (string memory) { return base(classicHairs(Colors.BLACK)); } /// @dev Hair N°3 => Classic Gray function item_3() public pure returns (string memory) { return base(classicHairs(Colors.GRAY)); } /// @dev Hair N°4 => Classic White function item_4() public pure returns (string memory) { return base(classicHairs(Colors.WHITE)); } /// @dev Hair N°5 => Classic Blue function item_5() public pure returns (string memory) { return base(classicHairs(Colors.BLUE)); } /// @dev Hair N°6 => Classic Yellow function item_6() public pure returns (string memory) { return base(classicHairs(Colors.YELLOW)); } /// @dev Hair N°7 => Classic Pink function item_7() public pure returns (string memory) { return base(classicHairs(Colors.PINK)); } /// @dev Hair N°8 => Classic Red function item_8() public pure returns (string memory) { return base(classicHairs(Colors.RED)); } /// @dev Hair N°9 => Classic Purple function item_9() public pure returns (string memory) { return base(classicHairs(Colors.PURPLE)); } /// @dev Hair N°10 => Classic Green function item_10() public pure returns (string memory) { return base(classicHairs(Colors.GREEN)); } /// @dev Hair N°11 => Classic Saiki function item_11() public pure returns (string memory) { return base(classicHairs(Colors.SAIKI)); } /// @dev Hair N°12 => Classic 2 Brown function item_12() public pure returns (string memory) { return base(classicTwoHairs(Colors.BROWN)); } /// @dev Hair N°13 => Classic 2 Black function item_13() public pure returns (string memory) { return base(classicTwoHairs(Colors.BLACK)); } /// @dev Hair N°14 => Classic 2 Gray function item_14() public pure returns (string memory) { return base(classicTwoHairs(Colors.GRAY)); } /// @dev Hair N°15 => Classic 2 White function item_15() public pure returns (string memory) { return base(classicTwoHairs(Colors.WHITE)); } /// @dev Hair N°16 => Classic 2 Blue function item_16() public pure returns (string memory) { return base(classicTwoHairs(Colors.BLUE)); } /// @dev Hair N°17 => Classic 2 Yellow function item_17() public pure returns (string memory) { return base(classicTwoHairs(Colors.YELLOW)); } /// @dev Hair N°18 => Classic 2 Pink function item_18() public pure returns (string memory) { return base(classicTwoHairs(Colors.PINK)); } /// @dev Hair N°19 => Classic 2 Red function item_19() public pure returns (string memory) { return base(classicTwoHairs(Colors.RED)); } /// @dev Hair N°20 => Classic 2 Purple function item_20() public pure returns (string memory) { return base(classicTwoHairs(Colors.PURPLE)); } /// @dev Hair N°21 => Classic 2 Green function item_21() public pure returns (string memory) { return base(classicTwoHairs(Colors.GREEN)); } /// @dev Hair N°22 => Classic 2 Saiki function item_22() public pure returns (string memory) { return base(classicTwoHairs(Colors.SAIKI)); } /// @dev Hair N°23 => Short Black function item_23() public pure returns (string memory) { return base(shortHairs(Colors.BLACK)); } /// @dev Hair N°24 => Short Blue function item_24() public pure returns (string memory) { return base(shortHairs(Colors.BLUE)); } /// @dev Hair N°25 => Short Pink function item_25() public pure returns (string memory) { return base(shortHairs(Colors.PINK)); } /// @dev Hair N°26 => Short White function item_26() public pure returns (string memory) { return base(shortHairs(Colors.WHITE)); } /// @dev Hair N°27 => Spike Black function item_27() public pure returns (string memory) { return base(spike(Colors.BLACK)); } /// @dev Hair N°28 => Spike Blue function item_28() public pure returns (string memory) { return base(spike(Colors.BLUE)); } /// @dev Hair N°29 => Spike Pink function item_29() public pure returns (string memory) { return base(spike(Colors.PINK)); } /// @dev Hair N°30 => Spike White function item_30() public pure returns (string memory) { return base(spike(Colors.WHITE)); } /// @dev Hair N°31 => Monk function item_31() public pure returns (string memory) { return base(monk()); } /// @dev Hair N°32 => Nihon function item_32() public pure returns (string memory) { return base( string( abi.encodePacked( monk(), '<path opacity="0.36" fill="#6E5454" stroke="#8A8A8A" stroke-width="0.5" stroke-miterlimit="10" d=" M287.5,206.8c0,0,0.1-17.4-2.9-20.3c-3.1-2.9-7.3-8.7-7.3-8.7s0.6-24.8-2.9-31.8c-3.6-7-3.9-24.3-35-23.6 c-30.3,0.7-42.5,5.4-42.5,5.4s-14.2-8.2-43-3.8c-19.3,4.9-17.2,50.1-17.2,50.1s-5.6,9.5-6.2,14.8c-0.6,5.3-0.3,8.3-0.3,8.3 S111,72.1,216.8,70.4c108.4-1.7,87.1,121.7,85.1,122.4C295.4,190.1,293.9,197.7,287.5,206.8z"/>', '<g opacity="0.33">', '<ellipse transform="matrix(0.7071 -0.7071 0.7071 0.7071 0.367 227.089)" fill="#FFFFFF" cx="274.3" cy="113.1" rx="1.4" ry="5.3"/>', '<ellipse transform="matrix(0.5535 -0.8328 0.8328 0.5535 32.4151 255.0608)" fill="#FFFFFF" cx="254.1" cy="97.3" rx="4.2" ry="16.3"/>', "</g>", '<path fill="#FFFFFF" stroke="#2B232B" stroke-miterlimit="10" d="M136.2,125.1c0,0,72,9.9,162.2,0c0,0,4.4,14.9,4.8,26.6 c0,0-125.4,20.9-172.6-0.3C129.5,151.3,132.9,130.3,136.2,125.1z"/>', '<polygon fill="#FFFFFF" stroke="#2B232B" stroke-miterlimit="10" points="306.2,138 324.2,168.1 330,160"/>', '<path fill="#FFFFFF" stroke="#2B232B" stroke-miterlimit="10" d="M298.4,125.1l34.2,54.6l-18,15.5l-10.7-43.5 C302.3,142.2,299.9,128.8,298.4,125.1z"/>', '<ellipse opacity="0.87" fill="#FF0039" cx="198.2" cy="144.1" rx="9.9" ry="10.8"/>' ) ) ); } /// @dev Hair N°33 => Bald function item_33() public pure returns (string memory) { return base( string( abi.encodePacked( '<ellipse transform="matrix(0.7071 -0.7071 0.7071 0.7071 0.1733 226.5807)" fill="#FFFFFF" cx="273.6" cy="113.1" rx="1.4" ry="5.3"/>', '<ellipse transform="matrix(0.5535 -0.8328 0.8328 0.5535 32.1174 254.4671)" fill="#FFFFFF" cx="253.4" cy="97.3" rx="4.2" ry="16.3"/>' ) ) ); } /// @dev Generate classic hairs with the given color function classicHairs(string memory hairsColor) private pure returns (string memory) { return string( abi.encodePacked( "<path fill='#", hairsColor, "' stroke='#000000' stroke-width='0.5' stroke-miterlimit='10' d='M252.4,71.8c0,0-15.1-13.6-42.6-12.3l15.6,8.8c0,0-12.9-0.9-28.4-1.3c-6.1-0.2-21.8,3.3-38.3-1.4c0,0,7.3,7.2,9.4,7.7c0,0-30.6,13.8-47.3,34.2c0,0,10.7-8.9,16.7-10.9c0,0-26,25.2-31.5,70c0,0,9.2-28.6,15.5-34.2c0,0-10.7,27.4-5.3,48.2c0,0,2.4-14.5,4.9-19.2c-1,14.1,2.4,33.9,13.8,47.8c0,0-3.3-15.8-2.2-21.9l8.8-17.9c0.1,4.1,1.3,8.1,3.1,12.3c0,0,13-36.1,19.7-43.9c0,0-2.9,15.4-1.1,29.6c0,0,6.8-23.5,16.9-36.8c0,0-4.6,15.6-2.7,31.9c0,0,9.4-26.2,10.4-28.2l-2.7,9.2c0,0,4.1,21.6,3.8,25.3c0,0,8.4-10.3,21.2-52l-2.9,12c0,0,9.8,20.3,10.3,22.2s-1.3-13.9-1.3-13.9s12.4,21.7,13.5,26c0,0,5.5-20.8,3.4-35.7l1.1,9.6c0,0,15,20.3,16.4,30.1s-0.1-23.4-0.1-23.4s13.8,30.6,17,39.4c0,0,1.9-17,1.4-19.4s8.5,34.6,4.4,46c0,0,11.7-16.4,11.5-21.4c1.4,0.8-1.3,22.6-4,26.3c0,0,3.2-0.3,8.4-9.3c0,0,11.1-13.4,11.8-11.7c0.7,1.7,1.8-2.9,5.5,10.2l2.6-7.6c0,0-0.4,15.4-3.3,21.4c0,0,14.3-32.5,10.4-58.7c0,0,3.7,9.3,4.4,16.9s3.1-32.8-7.7-51.4c0,0,6.9,3.9,10.8,4.8c0,0-12.6-12.5-13.6-15.9c0,0-14.1-25.7-39.1-34.6c0,0,9.3-3.2,15.6,0.2C286.5,78.8,271.5,66.7,252.4,71.8z'/>", '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-miterlimit="10" d="M286,210c0,0,8.5-10.8,8.6-18.7"/>', '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-linecap="round" stroke-miterlimit="10" d="M132.5,190.4c0,0-1.3-11.3,0.3-16.9"/>', '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-linecap="round" stroke-miterlimit="10" d="M141.5,170c0,0-1-6.5,1.6-20.4"/>', '<path opacity="0.2" d="M267.7,151.7l-0.3,30.9c0,0,1.9-18.8,1.8-19.3s8.6,43.5,3.9,47.2c0,0,11.9-18.8,12.1-21.5s0,22-3.9,25c0,0,6-4.4,8.6-10.1c0,0,6.1-7,9.9-10.7c0,0,3.9-1,6.8,8.2l2.8-6.9c0,0,0.1,13.4-1.3,16.1c0,0,10.5-28.2,7.9-52.9c0,0,4.7,8.3,4.9,17.1c0.1,8.8,1.7-8.6,0.2-17.8c0,0-6.5-13.9-8.2-15.4c0,0,2.2,14.9,1.3,18.4c0,0-8.2-15.1-11.4-17.3c0,0,1.2,41-1.6,46.1c0,0-6.8-22.7-11.4-26.5c0,0,0.7,17.4-3.6,23.2C284.5,183.3,280.8,169.9,267.7,151.7z"/>', '<path opacity="0.2" d="M234.3,137.1c0,0,17.1,23.2,16.7,30.2s-0.2-13.3-0.2-13.3s-11.7-22-17.6-26.2L234.3,137.1z"/>', '<polygon opacity="0.2" points="250.7,143.3 267.5,162.9 267.3,181.9"/>', '<path opacity="0.2" d="M207.4,129.2l9.7,20.7l-1-13.7c0,0,11.6,21,13.5,25.4l1.4-5l-17.6-27.4l1,7.5l-6-12.6L207.4,129.2z"/>', '<path opacity="0.2" d="M209.2,118c0,0-13.7,36.6-18.5,40.9c-1.7-7.2-1.9-7.9-4.2-20.3c0,0-0.1,2.7-1.4,5.3c0.7,8.2,4.1,24.4,4,24.5S206.4,136.6,209.2,118z"/>', '<path opacity="0.2" d="M187.6,134.7c0,0-9.6,25.5-10,26.9l-0.4-3.6C177.1,158.1,186.8,135.8,187.6,134.7z"/>', '<path opacity="0.2" fill-rule="evenodd" clip-rule="evenodd" d="M180.7,129.6c0,0-16.7,22.3-17.7,24.2s0,12.4,0.3,12.8S165.9,153,180.7,129.6z"/>', '<path opacity="0.2" fill-rule="evenodd" clip-rule="evenodd" d="M180.4,130.6c0,0-0.2,20.5-0.6,21.5c-0.4,0.9-2.6,5.8-2.6,5.8S176.1,147.1,180.4,130.6z"/>', abi.encodePacked( '<path opacity="0.2" d="M163.9,138c0,0-16.3,25.3-17.9,26.3c0,0-3.8-12.8-3-14.7s-9.6,10.3-9.9,17c0,0-8.4-0.6-11-7.4c-1-2.5,1.4-9.1,2.1-12.2c0,0-6.5,7.9-9.4,22.5c0,0,0.6,8.8,1.1,10c0,0,3.5-14.8,4.9-17.7c0,0-0.3,33.3,13.6,46.7c0,0-3.7-18.6-2.6-21l9.4-18.6c0,0,2.1,10.5,3.1,12.3l13.9-33.1L163.9,138z"/>', '<path fill="#FFFFFF" d="M204,82.3c0,0-10.3,24.4-11.5,30.4c0,0,11.1-20.6,12.6-20.8c0,0,11.4,20.4,12,22.2C217.2,114.1,208.2,88.2,204,82.3z"/>', '<path fill="#FFFFFF" d="M185.6,83.5c0,0-1,29.2,0,39.2c0,0-4-21.4-3.6-25.5c0.4-4-13.5,19.6-16,23.9c0,0,7.5-20.6,10.5-25.8c0,0-14.4,9.4-22,21.3C154.6,116.7,170.1,93.4,185.6,83.5z"/>', '<path fill="#FFFFFF" d="M158.6,96.2c0,0-12,15.3-14.7,23.2"/>', '<path fill="#FFFFFF" d="M125.8,125.9c0,0,9.5-20.6,23.5-27.7"/>', '<path fill="#FFFFFF" d="M296.5,121.6c0,0-9.5-20.6-23.5-27.7"/>', '<path fill="#FFFFFF" d="M216.1,88.5c0,0,10.9,19.9,11.6,23.6s3.7-5.5-10.6-23.6"/>', '<path fill="#FFFFFF" d="M227,92c0,0,21.1,25.4,22,27.4s-4.9-23.8-12.9-29.5c0,0,9.5,20.7,9.9,21.9C246.3,113,233.1,94.1,227,92z"/>', '<path fill="#FFFFFF" d="M263.1,119.5c0,0-9.5-26.8-10.6-28.3s15.5,14.1,16.2,22.5c0,0-11.1-16.1-11.8-16.9C256.1,96,264.3,114.1,263.1,119.5z"/>' ) ) ); } /// @dev Generate classic 2 hairs with the given color function classicTwoHairs(string memory hairsColor) private pure returns (string memory) { return string( abi.encodePacked( "<polygon fill='#", hairsColor, "' points='188.2,124.6 198.3,128.1 211.2,124.3 197.8,113.2'/>", '<polygon opacity="0.5" points="188.4,124.7 198.3,128.1 211.7,124.2 197.7,113.6"/>', "<path fill='#", hairsColor, "' stroke='#000000' stroke-width='0.5' stroke-miterlimit='10' d='M274,209.6c1,0.9,10.1-12.8,10.5-18.3 c1.1,3.2-0.2,16.8-2.9,20.5c0,0,3.7-0.7,8.3-6.5c0,0,11.1-13.4,11.8-11.7c0.7,1.7,1.8-2.9,5.5,10.2l2.6-7.6 c0,0-0.4,15.4-3.3,21.4c0,0,14.3-32.5,10.4-58.7c0,0,3.7,9.3,4.4,16.9s3.1-32.8-7.7-51.4c0,0,6.9,3.9,10.8,4.8 c0,0-12.6-12.5-13.6-15.9c0,0-14.1-25.7-39.1-34.6c0,0,9.3-3.2,15.6,0.2c-0.1-0.1-15.1-12.2-34.2-7.1c0,0-15.1-13.6-42.6-12.3 l15.6,8.8c0,0-12.9-0.9-28.4-1.3c-6.1-0.2-21.8,3.3-38.3-1.4c0,0,7.3,7.2,9.4,7.7c0,0-30.6,13.8-47.3,34.2 c0,0,10.7-8.9,16.7-10.9c0,0-26,25.2-31.5,70c0,0,9.2-28.6,15.5-34.2c0,0-10.7,27.4-5.3,48.2c0,0,2.4-14.5,4.9-19.2 c-1,14.1,2.4,33.9,13.8,47.8c0,0-3.3-15.8-2.2-21.9l8.8-17.9c0.1,4.1,1.3,8.1,3.1,12.3c0,0,13-36.1,19.7-43.9 c0,0-2.9,15.4-1.1,29.6c0,0,7.2-26.8,17.3-40.1c0,0,0.8,0.1,17.6-7.6c6.3,3.1,8,1.4,17.9,7.7c4.1,5.3,13.8,31.9,15.6,41.5 c3.4-7.3,5.6-19,5.2-29.5c2.7,3.7,8.9,19.9,9.6,34.3c0,0,7.9-15.9,5.9-29c0-0.2,0.2,14.5,0.3,14.3c0,0,12.1,19.9,14.9,19.7 c0-0.8-1.7-12.9-1.7-12.8c1.3,5.8,2.8,23.3,3.1,27.1l5-9.5C276.2,184,276.8,204.9,274,209.6z'/>", '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-miterlimit="10" d="M286.7,210c0,0,8.5-10.8,8.6-18.7"/>', '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-linecap="round" stroke-miterlimit="10" d="M133.2,190.4 c0,0-1.3-11.3,0.3-16.9"/>', abi.encodePacked( '<path fill="none" stroke="#000000" stroke-width="0.5" stroke-linecap="round" stroke-miterlimit="10" d="M142.2,170 c0,0-1-6.5,1.6-20.4"/>', '<path opacity="0.2" fill-rule="evenodd" clip-rule="evenodd" d="M180.6,128.2 c0,0-15.9,23.7-16.9,25.6s0,12.4,0.3,12.8S165.8,151.6,180.6,128.2z"/>', '<path opacity="0.2" d="M164.6,138c0,0-16.3,25.3-17.9,26.3c0,0-3.8-12.8-3-14.7s-9.6,10.3-9.9,17 c0,0-8.4-0.6-11-7.4c-1-2.5,1.4-9.1,2.1-12.2c0,0-6.5,7.9-9.4,22.5c0,0,0.6,8.8,1.1,10c0,0,3.5-14.8,4.9-17.7 c0,0-0.3,33.3,13.6,46.7c0,0-3.7-18.6-2.6-21l9.4-18.6c0,0,2.1,10.5,3.1,12.3l13.9-33.1L164.6,138z"/>', '<path opacity="0.16" d="M253.3,155.9c0.8,4.4,8.1,12.1,13.1,11.7l1.6,11c0,0-5.2-3.9-14.7-19.9 V155.9z"/>', '<path opacity="0.16" d="M237.6,139.4c0,0,4.4,3,13.9,21.7c0,0-4.3,12-4.6,12.4 C246.6,173.9,248.5,162.8,237.6,139.4z"/>', '<path opacity="0.17" d="M221,136.7c0,0,5.2,4,14.4,23c0,0-1.2,4.6-3.1,8.9 C227.7,152.4,227.1,149.9,221,136.7z"/>', '<path opacity="0.2" d="M272.1,152.6c-2.4,8.1-3.6,13.8-4.9,17.9c0,0,1.3,12.8,2.1,22.2 c4.7-8.4,5.4-8.8,5.4-9c-0.1-0.5,3.6,11.2-0.7,25.9c1.6,1,13.3-16.9,11.9-20.6c-1-2.5-0.4,19.8-4.3,22.8c0,0,6.4-2.2,9-7.9 c0,0,6.1-7,9.9-10.7c0,0,3.9-1,6.8,8.2l2.8-6.9c0,0,0.1,13.4-1.3,16.1c0,0,10.5-28.2,7.9-52.9c0,0,4.7,8.3,4.9,17.1 c0.1,8.8,1.7-8.6,0.2-17.8c0,0-6.5-13.9-8.2-15.4c0,0,2.2,14.9,1.3,18.4c0,0-8.2-15.1-11.4-17.3c0,0,1.2,41-1.6,46.1 c0,0-6.8-22.7-11.4-26.5c0,0-1.8,15.7-5,22.9C283.7,183,280.5,166.7,272.1,152.6z"/>' ), abi.encodePacked( '<path opacity="0.14" d="M198.2,115.2c-0.9-3.9,3.2-35.1,34.7-36C227.6,78.5,198.9,99.8,198.2,115.2z"/>', '<g opacity="0.76">', '<path fill="#FFFFFF" d="M153,105.9c0,0-12,15.3-14.7,23.2"/>', '<path fill="#FFFFFF" d="M126.5,125.9c0,0,9.5-20.6,23.5-27.7"/>', '<path fill="#FFFFFF" d="M297.2,121.6c0,0-9.5-20.6-23.5-27.7"/>', '<path fill="#FFFFFF" d="M241.9,109.4c0,0,10.9,19.9,11.6,23.6s3.7-5.5-10.6-23.6"/>', '<path fill="#FFFFFF" d="M155.1,117.3c0,0-10.9,19.9-11.6,23.6s-3.7-5.5,10.6-23.6"/>', '<path fill="#FFFFFF" d="M256.1,101.5c0,0,21.1,25.4,22,27.4c0.9,2-4.9-23.8-12.9-29.5c0,0,9.5,20.7,9.9,21.9 C275.4,122.5,262.2,103.6,256.1,101.5z"/>', '<path fill="#FFFFFF" d="M230,138.5c0,0-12.9-24.9-14.1-26.4c-1.2-1.4,18.2,11.9,19.3,20.2c0,0-11.9-13-12.7-13.7 C221.8,117.9,230.9,133,230,138.5z"/>', '<path fill="#FFFFFF" d="M167,136.6c0,0,15.5-24.5,17-25.8c1.5-1.2-19.1,10.6-21.6,18.8c0,0,15-13.5,15.8-14.2 C179.2,114.8,166.8,130.9,167,136.6z"/>', "</g>" ) ) ); } /// @dev Generate mohawk with the given color function spike(string memory hairsColor) private pure returns (string memory) { return string( abi.encodePacked( "<path fill='#", hairsColor, "' d='M287.3,207.1c0,0-0.4-17.7-3.4-20.6c-3.1-2.9-7.3-8.7-7.3-8.7s0.6-24.8-2.9-31.8c-3.6-7-3.9-24.3-35-23.6c-30.3,0.7-42.5,5.4-42.5,5.4s-14.2-8.2-43-3.8c-19.3,4.9-17.2,50.1-17.2,50.1s-5.6,9.5-6.2,14.8c-0.6,5.3-0.3,8.3-0.3,8.3c0.9-0.2-19.1-126.3,86.7-126.8c108.4-0.3,87.1,121.7,85.1,122.4C294.5,191.6,293.7,198,287.3,207.1z'/>", '<path fill-rule="evenodd" clip-rule="evenodd" fill="#212121" stroke="#000000" stroke-miterlimit="10" d="M196,124.6c0,0-30.3-37.5-20.6-77.7c0,0,0.7,18,12,25.1c0,0-8.6-13.4-0.3-33.4c0,0,2.7,15.8,10.7,23.4c0,0-2.7-18.4,2.2-29.6c0,0,9.7,23.2,13.9,26.3c0,0-6.5-17.2,5.4-27.7c0,0-0.8,18.6,9.8,25.4c0,0-2.7-11,4-18.9c0,0,1.2,25.1,6.6,29.4c0,0-2.7-12,2.1-20c0,0,6,24,8.6,28.5c-9.1-2.6-17.9-3.2-26.6-3C223.7,72.3,198,80.8,196,124.6z"/>', crop() ) ); } function shortHairs(string memory hairsColor) private pure returns (string memory) { return string( abi.encodePacked( "<path fill='#", hairsColor, "' d='M287.3,207.1c0,0-0.4-17.7-3.4-20.6c-3.1-2.9-7.3-8.7-7.3-8.7s0.6-24.8-2.9-31.8c-3.6-7-3.9-24.3-35-23.6c-30.3,0.7-42.5,5.4-42.5,5.4s-14.2-8.2-43-3.8c-19.3,4.9-17.2,50.1-17.2,50.1s-5.6,9.5-6.2,14.8c-0.6,5.3-0.3,8.3-0.3,8.3c0.9-0.2-19.1-126.3,86.7-126.8c108.4-0.3,87.1,121.7,85.1,122.4C294.5,191.6,293.7,198,287.3,207.1z'/>", '<path fill="#212121" stroke="#000000" stroke-miterlimit="10" d="M134.9,129.3c1-8.7,2.8-19.9,2.6-24.1 c1.1,2,4.4,6.1,4.7,6.9c2-15.1,3.9-18.6,6.6-28.2c0.1,5.2,0.4,6.1,4.6,11.9c0.1-7,4.5-17.6,8.8-24.3c0.6,3,4,8.2,5.8,10.7 c2.4-7,8.6-13.4,14.5-17.9c-0.3,3.4-0.1,6.8,0.7,10.1c4.9-5.1,7.1-8.7,15.6-15.4c-0.2,4.5,1.8,9,5.1,12c4.1-3.7,7.7-8,10.6-12.7 c0.6,3.7,1.4,7.3,2.5,10.8c2.6-4.6,7.9-8.4,12.4-11.3c1.5,3.5,1.3,11,5.9,11.7c7.1,1.1,10-3.3,11.4-10.1 c2.2,6.6,4.8,12.5,9.4,17.7c4.2,0.5,5.7-5.6,4.2-9c4.2,5.8,8.4,11.6,12.5,17.4c0.7-2.9,0.9-5.9,0.6-8.8 c3.4,7.6,9.1,16.7,13.6,23.6c0-1.9,1.8-8.5,1.8-10.4c2.6,7.3,7.7,17.9,10.3,36.6c0.2,1.1-23.8,7.5-28.8,10.1 c-1.2-2.3-2.2-4.3-6.2-8c-12.1-5.7-35.6-7.9-54.5-2.2c-16.3,4.8-21.5-2.3-31.3-3.1c-11.8-1.8-31.1-1.7-36.2,10.7 C139.6,133.6,137.9,132.2,134.9,129.3z"/>', '<polygon fill="#212121" points="270.7,138.4 300.2,129 300.7,131.1 271.3,139.9"/>', '<polygon fill="#212121" points="141.1,137 134,131.7 133.8,132.9 140.8,137.7 "/>', crop() ) ); } /// @dev Generate crop SVG function crop() private pure returns (string memory) { return string( abi.encodePacked( '<g id="Light" opacity="0.14">', '<ellipse transform="matrix(0.7071 -0.7071 0.7071 0.7071 0.1603 226.5965)" fill="#FFFFFF" cx="273.6" cy="113.1" rx="1.4" ry="5.3"/>', '<ellipse transform="matrix(0.5535 -0.8328 0.8328 0.5535 32.0969 254.4865)" fill="#FFFFFF" cx="253.4" cy="97.3" rx="4.2" ry="16.3"/>', "</g>", '<path opacity="0.05" fill-rule="evenodd" clip-rule="evenodd" d="M276.4,163.7c0,0,0.2-1.9,0.2,14.1c0,0,6.5,7.5,8.5,11s2.6,17.8,2.6,17.8l7-11.2c0,0,1.8-3.2,6.6-2.6c0,0,5.6-13.1,2.2-42.2C303.5,150.6,294.2,162.1,276.4,163.7z"/>', '<path opacity="0.1" fill-rule="evenodd" clip-rule="evenodd" d="M129.2,194.4c0,0-0.7-8.9,6.8-20.3c0,0-0.2-21.2,1.3-22.9c-3.7,0-6.7-0.5-7.7-2.4C129.6,148.8,125.8,181.5,129.2,194.4z"/>' ) ); } /// @dev Generate monk SVG function monk() private pure returns (string memory) { return string( abi.encodePacked( '<path opacity="0.36" fill="#6E5454" stroke="#8A8A8A" stroke-width="0.5" stroke-miterlimit="10" d="M286.8,206.8c0,0,0.1-17.4-2.9-20.3c-3.1-2.9-7.3-8.7-7.3-8.7s0.6-24.8-2.9-31.8c-3.6-7-3.9-24.3-35-23.6c-30.3,0.7-42.5,5.4-42.5,5.4s-14.2-8.2-43-3.8c-19.3,4.9-17.2,50.1-17.2,50.1s-5.6,9.5-6.2,14.8c-0.6,5.3-0.3,8.3-0.3,8.3S110.3,72.1,216.1,70.4c108.4-1.7,87.1,121.7,85.1,122.4C294.7,190.1,293.2,197.7,286.8,206.8z"/>', '<g id="Bald" opacity="0.33">', '<ellipse transform="matrix(0.7071 -0.7071 0.7071 0.7071 0.1603 226.5965)" fill="#FFFFFF" cx="273.6" cy="113.1" rx="1.4" ry="5.3"/>', '<ellipse transform="matrix(0.5535 -0.8328 0.8328 0.5535 32.0969 254.4865)" fill="#FFFFFF" cx="253.4" cy="97.3" rx="4.2" ry="16.3"/>', "</g>" ) ); } /// @notice Return the hair cut name of the given id /// @param id The hair Id function getItemNameById(uint8 id) public pure returns (string memory name) { name = ""; if (id == 1) { name = "Classic Brown"; } else if (id == 2) { name = "Classic Black"; } else if (id == 3) { name = "Classic Gray"; } else if (id == 4) { name = "Classic White"; } else if (id == 5) { name = "Classic Blue"; } else if (id == 6) { name = "Classic Yellow"; } else if (id == 7) { name = "Classic Pink"; } else if (id == 8) { name = "Classic Red"; } else if (id == 9) { name = "Classic Purple"; } else if (id == 10) { name = "Classic Green"; } else if (id == 11) { name = "Classic Saiki"; } else if (id == 12) { name = "Classic Brown"; } else if (id == 13) { name = "Classic 2 Black"; } else if (id == 14) { name = "Classic 2 Gray"; } else if (id == 15) { name = "Classic 2 White"; } else if (id == 16) { name = "Classic 2 Blue"; } else if (id == 17) { name = "Classic 2 Yellow"; } else if (id == 18) { name = "Classic 2 Pink"; } else if (id == 19) { name = "Classic 2 Red"; } else if (id == 20) { name = "Classic 2 Purple"; } else if (id == 21) { name = "Classic 2 Green"; } else if (id == 22) { name = "Classic 2 Saiki"; } else if (id == 23) { name = "Short Black"; } else if (id == 24) { name = "Short Blue"; } else if (id == 25) { name = "Short Pink"; } else if (id == 26) { name = "Short White"; } else if (id == 27) { name = "Spike Black"; } else if (id == 28) { name = "Spike Blue"; } else if (id == 29) { name = "Spike Pink"; } else if (id == 30) { name = "Spike White"; } else if (id == 31) { name = "Monk"; } else if (id == 32) { name = "Nihon"; } else if (id == 33) { name = "Bald"; } } /// @dev The base SVG for the hair function base(string memory children) private pure returns (string memory) { return string(abi.encodePacked('<g id="Hair">', children, "</g>")); } }
@dev Hair N°20 => Classic 2 Purple
function item_20() public pure returns (string memory) { return base(classicTwoHairs(Colors.PURPLE)); }
1,028,764
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 670, 1826, 423, 131, 113, 3462, 516, 26902, 576, 14466, 1802, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 761, 67, 3462, 1435, 1071, 16618, 1135, 261, 1080, 3778, 13, 288, 203, 3639, 327, 1026, 12, 1106, 335, 11710, 44, 1826, 87, 12, 12570, 18, 52, 1099, 30099, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.8.10; pragma abicoder v2; import "../DjinnBottleUSDC.sol"; import "../interfaces/CTokenInterfaces.sol"; import "../interfaces/ComptrollerInterface.sol"; import "../interfaces/IStdReference.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import "../interfaces/IMasterChef.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract DeltaNeutralFtmTomb is ERC20 { //Contract Specifics address public creator; uint private constant CREATOR_FEE = 100; //1% address public treasuryWallet; DjinnBottleUSDC public VAULT; //Balances For Withdraw mapping(address => uint) public tokenBorrowBalance; //18 decimals mapping(address => uint) public mintedETH; mapping(address => uint) public mintedUSDC; //Cream Finance Contracts (also just the Iron Bank Contracts) address public constant crUSDC = 0x328A7b4d538A2b3942653a9983fdA3C12c571141; address public constant crETH = 0xcc3E89fBc10e155F1164f8c9Cf0703aCDe53f6Fd; //Public Tokens address public constant USDC = 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75; address public constant WETH = 0x74b23882a30290451A17c44f4F05243b6b58C76d; address public constant WFTM = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83; address public constant TOMB = 0x6c021Ae822BEa943b2E66552bDe1D2696a53fbB7; address public constant TSHARE = 0x4cdF39285D7Ca8eB3f090fDA0C069ba5F4145B37; //SpookySwap Router, LP, TSHAREPool address public constant spookyAddress = 0xF491e7B69E4244ad4002BC14e878a34207E38c29; address public constant spookyFtmTombLP = 0x2A651563C9d3Af67aE0388a5c8F89b867038089e; address public constant tShareRewardPool = 0xcc0a87F7e7c693042a9Cc703661F5060c80ACb43; //Contract Interfaces IUniswapV2Router02 public immutable spookyRouter; ComptrollerInterface public immutable comptroller; IStdReference public immutable priceOracle; constructor(DjinnBottleUSDC _djBottle, IUniswapV2Router02 _spookyRouter, ComptrollerInterface _comptroller, IStdReference _priceOracle, address wallet) ERC20("Djinn FTM Short Farm", "dFTMShort") { creator = msg.sender; VAULT = _djBottle; spookyRouter = _spookyRouter; comptroller = _comptroller; priceOracle = _priceOracle; treasuryWallet = wallet; } //designed for single user ie. user opens via vault contract function open(address user, uint amount) external { require(msg.sender == address(VAULT), "!vault"); split(user, amount); } //automate the harvest function harvest() external { require(msg.sender == address(VAULT), "!vault"); IMasterChef(tShareRewardPool).deposit(0, 0); //0 is poolId and we call a deposit of 0 to allocate the shares to this contract compoundLPTokens(); } //automate the closing of the position //designed for single use ie. user closes via vault contract //so we need to vault contract to determine how many tokens belong to the user from this contract function close(address user, uint amountShares) external { require(msg.sender == address(VAULT), "!vault"); withdrawLP(user, amountShares); } ////////////////// BEGIN DEPOSIT LOGIC ////////////////// function split(address user, uint amount) internal { uint swapAmount = (amount * 70) / 100; swap(USDC, WETH, swapAmount); uint usdcAmount = getTokenBalance(USDC); uint wethAmount = getTokenBalance(WETH); //next step borrow(user, usdcAmount, wethAmount); } //we are borrowing the same amount of deposited ETH to achieve a vault that does not get liquidated function borrow(address user, uint amountUSDC, uint amountWETH) internal { //first check for any leftovers in the contract uint cTokenETHBefore = getCrTokenBalance(crETH); uint cTokenUSDCBefore = getCrTokenBalance(crUSDC); //supply USDC && WETH IERC20(USDC).approve(crUSDC, amountUSDC); CERC20(crUSDC).mint(amountUSDC); IERC20(WETH).approve(crETH, amountWETH); CERC20(crETH).mint(amountWETH); uint cTokenETHAfter = getCrTokenBalance(crETH); uint cTokenUSDCAfter = getCrTokenBalance(crUSDC); uint cTokenUSDCAmount = cTokenUSDCAfter - cTokenUSDCBefore; uint cTokenETHAmount = cTokenETHAfter - cTokenETHBefore; //store cTokens user amounts separate due to different interest rates VAULT.storeCrTokens(user, cTokenUSDCAmount, cTokenETHAmount); mintedUSDC[user] += cTokenUSDCAmount; mintedETH[user] += cTokenETHAmount; //we enter the markets to use usdc && wftm as collateral address[] memory cTokenSupplied = new address[](2); cTokenSupplied[0] = crUSDC; //cToken address cTokenSupplied[1] = crETH; comptroller.enterMarkets(cTokenSupplied); uint borrowBalanceBefore = borrowBalance(); //get max borrow && borrow ( ,uint borrowAmount, ) = getBorrowAmount(); CERC20(crETH).borrow(borrowAmount); uint borrowBalanceAfter = borrowBalance(); tokenBorrowBalance[user] += (borrowBalanceAfter - borrowBalanceBefore); //next step swapForTokens(); } function swapForTokens() internal { uint half = (getTokenBalance(WETH) * 50) / 100; IERC20(WETH).approve(spookyAddress, getTokenBalance(WETH)); //execute the swap here swap(WETH, WFTM, half); uint rest = getTokenBalance(WETH); swap(WETH, TOMB, rest); //next step getLPTokens(); } function getLPTokens() internal { //we need to approve the router to spend our TOMB uint wftmAmount = getTokenBalance(WFTM); uint tombAmount = getTokenBalance(TOMB); //now we add liquidity //@params token, tokenAmount, minToken, minETH, to, deadline IERC20(TOMB).approve(spookyAddress, tombAmount); IERC20(WFTM).approve(spookyAddress, wftmAmount); uint lpTokenBalanceBefore = getTokenBalance(spookyFtmTombLP); spookyRouter.addLiquidity(TOMB, WFTM, tombAmount, wftmAmount, 1, 1, address(this), block.timestamp + 30); uint lpTokenBalanceAfter = getTokenBalance(spookyFtmTombLP); uint lpTokenToMint = lpTokenBalanceAfter - lpTokenBalanceBefore; //keep track of LP token amount in this contract using a 1:1 mint _mint(address(this), lpTokenToMint); depositLPGetTShare(lpTokenToMint); } function depositLPGetTShare(uint lpTokenAmount) internal { //after this deposit the contract should be earning tshares as a reward IERC20(spookyFtmTombLP).approve(tShareRewardPool, lpTokenAmount); IMasterChef(tShareRewardPool).deposit(0, lpTokenAmount); //FTM-TOMB pool ID is 0 on Tomb.finance } ////////////////// DEPOSIT LOGIC ENDS ////////////////// ////////////////// BEGIN WITHDRAW LOGIC ////////////////// //the shares are based on the dUSDC in the users wallet function withdrawLP(address user, uint amountShares) internal { uint strategyBalance = getTokenBalance(address(this)); //18 decimals uint totalShares = IERC20(address(VAULT)).totalSupply(); //8 decimals uint withdrawAmount = (strategyBalance / totalShares) * amountShares; //handle rounding error case on full vault withdraw if (withdrawAmount > strategyBalance) { withdrawAmount = strategyBalance; } //we first withdraw the LP tokens from TOMB ///we have to check the balances before and after the withdraw in case there are leftovers uint amountBefore = getTokenBalance(spookyFtmTombLP); IMasterChef(tShareRewardPool).withdraw(0, withdrawAmount); uint amountAfter = getTokenBalance(spookyFtmTombLP); uint lpTokenAmount = amountAfter - amountBefore; removeLiq(user, lpTokenAmount, amountShares); } function removeLiq(address user, uint lpTokenAmount, uint amountShares) internal { //we remove liquidity belonging to the user(amount) back for tomb + wftm uint wftmBefore = getTokenBalance(WFTM); uint tombBefore = getTokenBalance(TOMB); IERC20(spookyFtmTombLP).approve(spookyAddress, lpTokenAmount); spookyRouter.removeLiquidity( WFTM, TOMB, lpTokenAmount, 1, 1, address(this), block.timestamp + 30 ); _burn(address(this), lpTokenAmount); uint wftmAfter = getTokenBalance(WFTM); uint tombAfter = getTokenBalance(TOMB); uint wftmToSwap = wftmAfter - wftmBefore; uint tombToSwap = tombAfter - tombBefore; IERC20(WFTM).approve(spookyAddress, wftmToSwap); IERC20(TOMB).approve(spookyAddress, tombToSwap); uint ethBefore = getTokenBalance(WETH); //execute the swaps swap(WFTM, WETH, wftmToSwap); swap(TOMB, WETH, tombToSwap); uint ethAfter = getTokenBalance(WETH); uint ethAfterSwap = ethAfter - ethBefore; //next step repay(user, amountShares, ethAfterSwap); } function repay(address user, uint amountShares, uint ethAfterSwap) internal { //crToken shares (uint ethShares, uint usdcShares) = splitShares(amountShares); uint ethRedeem; uint usdcRedeem; //main logic uint profits; uint amountToRepay; if (ethAfterSwap > tokenBorrowBalance[user]) { profits = ethAfterSwap - tokenBorrowBalance[user]; amountToRepay = tokenBorrowBalance[user]; tokenBorrowBalance[user] = 0; //min fee ethRedeem = ethShares - (chargeFees(ethShares)); usdcRedeem = usdcShares - (chargeFees(usdcShares)); payCreator(chargeFees(ethShares), chargeFees(usdcShares)); } else { profits = 0; amountToRepay = ethAfterSwap; tokenBorrowBalance[user] -= ethAfterSwap; //max fee on insta withdraw to prevent rounding error profits //2% fee instead of 1% ethRedeem = ethShares - (chargeFees(ethShares) * 2); usdcRedeem = usdcShares - (chargeFees(usdcShares) * 2); payCreator(chargeFees(ethShares) * 2, chargeFees(usdcShares) * 2); } if (ethRedeem > mintedETH[user]) { ethRedeem = mintedETH[user]; } if (usdcRedeem > mintedUSDC[user]) { usdcRedeem = mintedUSDC[user]; } ass = ethRedeem; balls = usdcRedeem; cocks = CERC20(crETH).balanceOf(address(this)); tits = CERC20(crUSDC).balanceOf(address(this)); //account for rounding errors if last person in vault wants to withdraw if (amountToRepay > borrowBalance()) { amountToRepay = borrowBalance(); } //now we can repay our users borrow IERC20(WETH).approve(crETH, amountToRepay); CERC20(crETH).repayBorrow(amountToRepay); uint ethBefore = getTokenBalance(WETH); uint usdcBefore = getTokenBalance(USDC); //redeem initial deposit amount + interest CERC20(crETH).redeem(ethRedeem); CERC20(crUSDC).redeem(usdcRedeem); //one final check for dust if (profits > getTokenBalance(WETH)) { profits = getTokenBalance(WETH); } //recheck uint ethAfter = getTokenBalance(WETH); uint usdcAfter = getTokenBalance(USDC); uint ethAmount = (ethAfter - ethBefore) + profits; uint usdcAmount = usdcAfter - usdcBefore; //final step swapProfits(ethAmount, usdcAmount); } //swap eth for usdc and send back to vault function swapProfits(uint ethAmount, uint usdcAmount) internal { uint usdcBefore = getTokenBalance(USDC); swap(WETH, USDC, ethAmount); uint usdcAfter = getTokenBalance(USDC); uint totalToSend = (usdcAfter - usdcBefore) + usdcAmount; IERC20(USDC).transfer(address(VAULT), totalToSend); } ////////////////// END WITHDRAW LOGIC ////////////////// ////////////////// BEGIN HARVEST LOGIC ////////////////// //sells tshares for tomb and wftm tokens function compoundLPTokens() internal { uint tsharesInitial = getTokenBalance(TSHARE); uint harvestFee = chargeFees(tsharesInitial); IERC20(TSHARE).transfer(treasuryWallet, harvestFee); //goes to treasury and will be swapped for FTM to use for gas fees uint tshares = getTokenBalance(TSHARE); //update amount uint half = (tshares * 50) / 100; IERC20(TSHARE).approve(spookyAddress, tshares); //true for 3 route swap swap(TSHARE, TOMB, half); //swap rest to WFTM //call again to avoid rounding errors uint rest = getTokenBalance(TSHARE); swap(TSHARE, WFTM, rest); //reinvest getLPTokens(); } ////////////////// END HARVEST LOGIC ////////////////// ////////////////// BEGIN HELPER LOGIC ////////////////// function swap(address tokenIn, address tokenOut, uint amount) internal { IERC20(tokenIn).approve(spookyAddress, amount); address[] memory path; if (tokenIn == WFTM || tokenOut == WFTM) { path = new address[](2); path[0] = tokenIn; path[1] = tokenOut; } else { path = new address[](3); path[0] = tokenIn; path[1] = WFTM; path[2] = tokenOut; } IUniswapV2Router02(spookyAddress).swapExactTokensForTokens( amount, 0, //min amount out path, address(this), block.timestamp + 30 ); } //returuns USD value of deposited assets, how much can be borrowed, and the price of the borrowed asset function getBorrowAmount() internal returns(uint liquidity, uint borrowAmount, uint price) { (, liquidity,) = comptroller.getAccountLiquidity(address(this)); IStdReference.ReferenceData memory data = priceOracle.getReferenceData("ETH", "USDC"); price = data.rate; uint maxTokenBorrow = (liquidity * 1e18) / price; //ETH has 18 decimals borrowAmount = (maxTokenBorrow * 94) / 100; //this is token amount //rebalance check to keep vault delta neutral uint borrowCheck = borrowAmount + borrowBalance(); (uint underlying, ) = getUnderlying(); //might have to add current deposit to this? uint diff; if (borrowCheck < underlying) { diff = underlying - borrowCheck; borrowAmount += diff; } else if (borrowCheck > underlying) { diff = borrowCheck - underlying; borrowAmount -= diff; } return (liquidity, borrowAmount, price); } //returns the share per underlying crToken price function splitShares (uint amountShares) internal view returns(uint, uint) { uint cTokenEth = getCrTokenBalance(crETH) * 1e18; uint cTokenUsdc = getCrTokenBalance(crUSDC) * 1e18; uint pool = VAULT.totalSupply() * 1e18; uint ethShares = ((pool * 1e6) / cTokenEth) * amountShares; uint usdcShares = (pool / cTokenUsdc) * amountShares; return (ethShares / 1e6, usdcShares); } function payCreator(uint amountEth, uint amountUSDC) internal { CERC20(crETH).transfer(creator, amountEth); CERC20(crUSDC).transfer(creator, amountUSDC); } function chargeFees(uint amount) internal pure returns(uint feeAmount) { return feeAmount = (amount * CREATOR_FEE) / 1e4; //0.1 or 1% } function getTokenBalance(address token) internal view returns(uint amount) { return amount = IERC20(token).balanceOf(address(this)); } function getCrTokenBalance(address crToken) internal view returns(uint amount) { return amount = CERC20(crToken).balanceOf(address(this)); } function setTreasury(address wallet) external { require(msg.sender == address(VAULT), "!vault"); treasuryWallet = wallet; } //public for querying from frontend function getUnderlying() public returns(uint, uint) { uint underlyingETH = CERC20(crETH).balanceOfUnderlying(address(this)); uint underlyingUSDC = CERC20(crUSDC).balanceOfUnderlying(address(this)); return (underlyingETH, underlyingUSDC); } function borrowBalance() public returns(uint) { return CERC20(crETH).borrowBalanceCurrent(address(this)); } }
we remove liquidity belonging to the user(amount) back for tomb + wftmexecute the swapsnext step
function removeLiq(address user, uint lpTokenAmount, uint amountShares) internal { uint wftmBefore = getTokenBalance(WFTM); uint tombBefore = getTokenBalance(TOMB); IERC20(spookyFtmTombLP).approve(spookyAddress, lpTokenAmount); spookyRouter.removeLiquidity( WFTM, TOMB, lpTokenAmount, 1, 1, address(this), block.timestamp + 30 ); _burn(address(this), lpTokenAmount); uint wftmAfter = getTokenBalance(WFTM); uint tombAfter = getTokenBalance(TOMB); uint wftmToSwap = wftmAfter - wftmBefore; uint tombToSwap = tombAfter - tombBefore; IERC20(WFTM).approve(spookyAddress, wftmToSwap); IERC20(TOMB).approve(spookyAddress, tombToSwap); uint ethBefore = getTokenBalance(WETH); swap(WFTM, WETH, wftmToSwap); swap(TOMB, WETH, tombToSwap); uint ethAfter = getTokenBalance(WETH); uint ethAfterSwap = ethAfter - ethBefore; repay(user, amountShares, ethAfterSwap); }
12,639,497
[ 1, 4625, 348, 7953, 560, 30, 732, 1206, 4501, 372, 24237, 17622, 358, 326, 729, 12, 8949, 13, 1473, 364, 21031, 397, 341, 1222, 81, 8837, 326, 1352, 6679, 4285, 2235, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 1206, 48, 18638, 12, 2867, 729, 16, 2254, 12423, 1345, 6275, 16, 2254, 3844, 24051, 13, 2713, 288, 1082, 7010, 202, 202, 11890, 341, 1222, 81, 4649, 273, 9162, 13937, 12, 59, 4464, 49, 1769, 7010, 202, 202, 11890, 21031, 4649, 273, 9162, 13937, 12, 56, 1872, 38, 1769, 7010, 203, 202, 202, 45, 654, 39, 3462, 12, 1752, 1184, 93, 42, 16925, 56, 16659, 14461, 2934, 12908, 537, 12, 1752, 1184, 93, 1887, 16, 12423, 1345, 6275, 1769, 7010, 202, 202, 1752, 1184, 93, 8259, 18, 4479, 48, 18988, 24237, 12, 203, 1082, 202, 59, 4464, 49, 16, 203, 1082, 202, 56, 1872, 38, 16, 7010, 1082, 202, 9953, 1345, 6275, 16, 203, 1082, 565, 202, 21, 16, 203, 1082, 565, 202, 21, 16, 203, 1082, 565, 202, 2867, 12, 2211, 3631, 203, 1082, 565, 202, 2629, 18, 5508, 397, 5196, 203, 202, 202, 1769, 7010, 203, 202, 202, 67, 70, 321, 12, 2867, 12, 2211, 3631, 12423, 1345, 6275, 1769, 7010, 203, 202, 202, 11890, 341, 1222, 81, 4436, 273, 9162, 13937, 12, 59, 4464, 49, 1769, 7010, 202, 202, 11890, 21031, 4436, 273, 9162, 13937, 12, 56, 1872, 38, 1769, 7010, 203, 202, 202, 11890, 341, 1222, 81, 774, 12521, 273, 341, 1222, 81, 4436, 300, 341, 1222, 81, 4649, 31, 7010, 202, 202, 11890, 21031, 774, 12521, 273, 21031, 4436, 300, 21031, 4649, 31, 7010, 202, 202, 45, 654, 39, 3462, 12, 59, 4464, 49, 2934, 12908, 537, 12, 1752, 1184, 93, 1887, 16, 341, 1222, 81, 774, 12521, 1769, 7010, 202, 202, 45, 654, 39, 3462, 12, 56, 1872, 38, 2934, 12908, 537, 12, 1752, 1184, 93, 1887, 16, 21031, 774, 12521, 1769, 7010, 203, 202, 202, 11890, 13750, 4649, 273, 9162, 13937, 12, 59, 1584, 44, 1769, 7010, 202, 202, 22270, 12, 59, 4464, 49, 16, 678, 1584, 44, 16, 341, 1222, 81, 774, 12521, 1769, 7010, 202, 202, 22270, 12, 56, 1872, 38, 16, 678, 1584, 44, 16, 21031, 774, 12521, 1769, 7010, 202, 202, 11890, 13750, 4436, 273, 9162, 13937, 12, 59, 1584, 44, 1769, 7010, 202, 202, 11890, 13750, 4436, 12521, 273, 13750, 4436, 300, 13750, 4649, 31, 7010, 203, 202, 202, 266, 10239, 12, 1355, 16, 3844, 24051, 16, 13750, 4436, 12521, 1769, 7010, 202, 97, 203, 202, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.11; contract DoNotDeployThisGetTheRightOneCosParityPutsThisOnTop { uint256 nothing; function DoNotDeployThisGetTheRightOneCosParityPutsThisOnTop() { nothing = 27; } } //*************** Ownable contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } //***********Pausible contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { require (!paused); _; } /** * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused { require (paused) ; _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } //*************ERC20 contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function allowance(address owner, address spender) constant returns (uint); function transfer(address to, uint value) returns (bool ok); function transferFrom(address from, address to, uint value) returns (bool ok); function approve(address spender, uint value) returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } //*************** SafeMath contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } } //**************** StandardToken contract StandardToken is ERC20, SafeMath { /** * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) returns (bool success){ balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) returns (bool success) { var _allowance = allowed[_from][msg.sender]; // Check is not needed because safeSub(_allowance, _value) will already throw if this condition is not met // if (_value > _allowance) throw; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract GBT { function parentChange(address,uint); function parentFees(address); function setHGT(address _hgt); } //************ HELLOGOLDTOKEN contract HelloGoldToken is ERC20, SafeMath, Pausable, StandardToken { string public name; string public symbol; uint8 public decimals; GBT goldtoken; function setGBT(address gbt_) onlyOwner { goldtoken = GBT(gbt_); } function GBTAddress() constant returns (address) { return address(goldtoken); } function HelloGoldToken(address _reserve) { name = "HelloGold Token"; symbol = "HGT"; decimals = 8; totalSupply = 1 * 10 ** 9 * 10 ** uint256(decimals); balances[_reserve] = totalSupply; } function parentChange(address _to) internal { require(address(goldtoken) != 0x0); goldtoken.parentChange(_to,balances[_to]); } function parentFees(address _to) internal { require(address(goldtoken) != 0x0); goldtoken.parentFees(_to); } function transferFrom(address _from, address _to, uint256 _value) returns (bool success){ parentFees(_from); parentFees(_to); success = super.transferFrom(_from,_to,_value); parentChange(_from); parentChange(_to); return; } function transfer(address _to, uint _value) whenNotPaused returns (bool success) { parentFees(msg.sender); parentFees(_to); success = super.transfer(_to,_value); parentChange(msg.sender); parentChange(_to); return; } function approve(address _spender, uint _value) whenNotPaused returns (bool success) { return super.approve(_spender,_value); } } //********* GOLDFEES ************************ contract GoldFees is SafeMath,Ownable { // e.g. if rate = 0.0054 //uint rateN = 9999452055; uint rateN = 9999452054794520548; uint rateD = 19; uint public maxDays; uint public maxRate; function GoldFees() { calcMax(); } function calcMax() { maxDays = 1; maxRate = rateN; uint pow = 2; do { uint newN = rateN ** pow; if (newN / maxRate != maxRate) { maxDays = pow / 2; break; } maxRate = newN; pow *= 2; } while (pow < 2000); } function updateRate(uint256 _n, uint256 _d) onlyOwner{ rateN = _n; rateD = _d; calcMax(); } function rateForDays(uint256 numDays) constant returns (uint256 rate) { if (numDays <= maxDays) { uint r = rateN ** numDays; uint d = rateD * numDays; if (d > 18) { uint div = 10 ** (d-18); rate = r / div; } else { div = 10 ** (18 - d); rate = r * div; } } else { uint256 md1 = numDays / 2; uint256 md2 = numDays - md1; uint256 r2; uint256 r1 = rateForDays(md1); if (md1 == md2) { r2 = r1; } else { r2 = rateForDays(md2); } //uint256 r1 = rateForDays(maxDays); //uint256 r2 = rateForDays(numDays-maxDays); rate = safeMul( r1 , r2) / 10 ** 18; } return; } uint256 constant public UTC2MYT = 1483200000; function wotDay(uint256 time) returns (uint256) { return (time - UTC2MYT) / (1 days); } // minimum fee is 1 unless same day function calcFees(uint256 start, uint256 end, uint256 startAmount) constant returns (uint256 amount, uint256 fee) { if (startAmount == 0) return; uint256 numberOfDays = wotDay(end) - wotDay(start); if (numberOfDays == 0) { amount = startAmount; return; } amount = (rateForDays(numberOfDays) * startAmount) / (1 ether); if ((fee == 0) && (amount != 0)) amount--; fee = safeSub(startAmount,amount); } } //******************** GoldBackedToken contract GoldBackedToken is Ownable, SafeMath, ERC20, Pausable { event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); event DeductFees(address indexed owner,uint256 amount); event TokenMinted(address destination, uint256 amount); event TokenBurned(address source, uint256 amount); string public name = "HelloGold Gold Backed Token"; string public symbol = "GBT"; uint256 constant public decimals = 18; // same as ETH uint256 constant public hgtDecimals = 8; uint256 constant public allocationPool = 1 * 10**9 * 10**hgtDecimals; // total HGT holdings uint256 constant public maxAllocation = 38 * 10**5 * 10**decimals; // max GBT that can ever ever be given out uint256 public totAllocation; // amount of GBT so far address public feeCalculator; address public HGT; // HGT contract address function setFeeCalculator(address newFC) onlyOwner { feeCalculator = newFC; } function calcFees(uint256 from, uint256 to, uint256 amount) returns (uint256 val, uint256 fee) { return GoldFees(feeCalculator).calcFees(from,to,amount); } function GoldBackedToken(address feeCalc) { feeCalculator = feeCalc; } struct allocation { uint256 amount; uint256 date; } allocation[] public allocationsOverTime; allocation[] public currentAllocations; function currentAllocationLength() constant returns (uint256) { return currentAllocations.length; } function aotLength() constant returns (uint256) { return allocationsOverTime.length; } struct Balance { uint256 amount; // amount through update or transfer uint256 lastUpdated; // DATE last updated uint256 nextAllocationIndex; // which allocationsOverTime record contains next update uint256 allocationShare; // the share of allocationPool that this holder gets (means they hold HGT) } /*Creates an array with all balances*/ mapping (address => Balance) public balances; mapping (address => mapping (address => uint)) allowed; function update(address where) internal { uint256 pos; uint256 fees; uint256 val; (val,fees,pos) = updatedBalance(where); balances[where].nextAllocationIndex = pos; balances[where].amount = val; balances[where].lastUpdated = now; } function updatedBalance(address where) constant public returns (uint val, uint fees, uint pos) { uint256 c_val; uint256 c_fees; uint256 c_amount; (val, fees) = calcFees(balances[where].lastUpdated,now,balances[where].amount); pos = balances[where].nextAllocationIndex; if ((pos < currentAllocations.length) && (balances[where].allocationShare != 0)) { c_amount = currentAllocations[balances[where].nextAllocationIndex].amount * balances[where].allocationShare / allocationPool; (c_val,c_fees) = calcFees(currentAllocations[balances[where].nextAllocationIndex].date,now,c_amount); } val += c_val; fees += c_fees; pos = currentAllocations.length; } function balanceOf(address where) constant returns (uint256 val) { uint256 fees; uint256 pos; (val,fees,pos) = updatedBalance(where); return ; } event Allocation(uint256 amount, uint256 date); event FeeOnAllocation(uint256 fees, uint256 date); event PartComplete(); event StillToGo(uint numLeft); uint256 public partPos; uint256 public partFees; uint256 partL; allocation[] public partAllocations; function partAllocationLength() constant returns (uint) { return partAllocations.length; } function addAllocationPartOne(uint newAllocation,uint numSteps) onlyOwner{ uint256 thisAllocation = newAllocation; require(totAllocation < maxAllocation); // cannot allocate more than this; if (currentAllocations.length > partAllocations.length) { partAllocations = currentAllocations; } if (totAllocation + thisAllocation > maxAllocation) { thisAllocation = maxAllocation - totAllocation; log0("max alloc reached"); } totAllocation += thisAllocation; Allocation(thisAllocation,now); allocation memory newDiv; newDiv.amount = thisAllocation; newDiv.date = now; // store into history allocationsOverTime.push(newDiv); // add this record to the end of currentAllocations partL = partAllocations.push(newDiv); // update all other records with calcs from last record if (partAllocations.length < 2) { // no fees to consider PartComplete(); currentAllocations = partAllocations; FeeOnAllocation(0,now); return; } // // The only fees that need to be collected are the fees on location zero. // Since they are the last calculated = they come out with the break // for (partPos = partAllocations.length - 2; partPos >= 0; partPos-- ){ (partAllocations[partPos].amount,partFees) = calcFees(partAllocations[partPos].date,now,partAllocations[partPos].amount); partAllocations[partPos].amount += partAllocations[partL - 1].amount; partAllocations[partPos].date = now; if ((partPos == 0) || (partPos == partAllocations.length-numSteps)){ break; } } if (partPos != 0) { StillToGo(partPos); return; // not done yet } PartComplete(); FeeOnAllocation(partFees,now); currentAllocations = partAllocations; } function addAllocationPartTwo(uint numSteps) onlyOwner { require(numSteps > 0); require(partPos > 0); for (uint i = 0; i < numSteps; i++ ){ partPos--; (partAllocations[partPos].amount,partFees) = calcFees(partAllocations[partPos].date,now,partAllocations[partPos].amount); partAllocations[partPos].amount += partAllocations[partL - 1].amount; partAllocations[partPos].date = now; if (partPos == 0) { break; } } if (partPos != 0) { StillToGo(partPos); return; // not done yet } PartComplete(); FeeOnAllocation(partFees,now); currentAllocations = partAllocations; } function setHGT(address _hgt) onlyOwner { HGT = _hgt; } function parentFees(address where) whenNotPaused { require(msg.sender == HGT); update(where); } function parentChange(address where, uint newValue) whenNotPaused { // called when HGT balance changes require(msg.sender == HGT); balances[where].allocationShare = newValue; } /* send GBT */ function transfer(address _to, uint256 _value) whenNotPaused returns (bool ok) { update(msg.sender); // Do this to ensure sender has enough funds. update(_to); balances[msg.sender].amount = safeSub(balances[msg.sender].amount, _value); balances[_to].amount = safeAdd(balances[_to].amount, _value); Transfer(msg.sender, _to, _value); //Notify anyone listening that this transfer took place return true; } function transferFrom(address _from, address _to, uint _value) whenNotPaused returns (bool success) { var _allowance = allowed[_from][msg.sender]; update(_from); // Do this to ensure sender has enough funds. update(_to); balances[_to].amount = safeAdd(balances[_to].amount, _value); balances[_from].amount = safeSub(balances[_from].amount, _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) whenNotPaused returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } // Minting Functions address public authorisedMinter; function setMinter(address minter) onlyOwner { authorisedMinter = minter; } function mintTokens(address destination, uint256 amount) { require(msg.sender == authorisedMinter); update(destination); balances[destination].amount = safeAdd(balances[destination].amount, amount); balances[destination].lastUpdated = now; balances[destination].nextAllocationIndex = currentAllocations.length; TokenMinted(destination,amount); } function burnTokens(address source, uint256 amount) { require(msg.sender == authorisedMinter); update(source); balances[source].amount = safeSub(balances[source].amount,amount); balances[source].lastUpdated = now; balances[source].nextAllocationIndex = currentAllocations.length; TokenBurned(source,amount); } } //**************** HelloGoldSale contract HelloGoldSale is Pausable, SafeMath { uint256 public decimals = 8; uint256 public startDate = 1503892800; // Monday, August 28, 2017 12:00:00 PM GMT+08:00 uint256 public endDate = 1504497600; // Monday, September 4, 2017 12:00:00 PM GMT+08:00 uint256 tranchePeriod = 1 weeks; // address of HGT Token. HGT must Approve this contract to disburse 300M tokens HelloGoldToken token; uint256 constant MaxCoinsR1 = 180 * 10**6 * 10**8; // 180M HGT uint256 public coinsRemaining = 180 * 10**6 * 10**8; uint256 coinsPerTier = 20 * 10**6 * 10**8; // 20M HGT uint256 public coinsLeftInTier = 20 * 10**6 * 10**8; uint256 public minimumCap = 0; // 40M HGT uint256 numTiers = 5; uint16 public tierNo; uint256 public preallocCoins; // used for testing against cap (inc placement) uint256 public purchasedCoins; // used for testing against tier pricing uint256 public ethRaised; uint256 public personalMax = 10 * 1 ether; // max ether per person during public sale uint256 public contributors; address public cs; address public multiSig; address public HGT_Reserve; struct csAction { bool passedKYC; bool blocked; } /* This creates an array with all balances */ mapping (address => csAction) public permissions; mapping (address => uint256) public deposits; modifier MustBeEnabled(address x) { require (!permissions[x].blocked) ; require (permissions[x].passedKYC) ; _; } function HelloGoldSale(address _cs, address _hgt, address _multiSig, address _reserve) { cs = _cs; token = HelloGoldToken(_hgt); multiSig = _multiSig; HGT_Reserve = _reserve; } // We only expect to use this to set/reset the start of the contract under exceptional circumstances function setStart(uint256 when_) onlyOwner { startDate = when_; endDate = when_ + tranchePeriod; } modifier MustBeCs() { require (msg.sender == cs) ; _; } // 1 ether = N HGT tokens uint256[5] public hgtRates = [1248900000000,1196900000000,1144800000000,1092800000000,1040700000000]; /* Approve the account for operation */ function approve(address user) MustBeCs { permissions[user].passedKYC = true; } function block(address user) MustBeCs { permissions[user].blocked = true; } function unblock(address user) MustBeCs { permissions[user].blocked = false; } function newCs(address newCs) onlyOwner { cs = newCs; } function setPeriod(uint256 period_) onlyOwner { require (!funding()) ; tranchePeriod = period_; endDate = startDate + tranchePeriod; if (endDate < now + tranchePeriod) { endDate = now + tranchePeriod; } } function when() constant returns (uint256) { return now; } function funding() constant returns (bool) { if (paused) return false; // frozen if (now < startDate) return false; // too early if (now > endDate) return false; // too late if (coinsRemaining == 0) return false; // no more coins if (tierNo >= numTiers ) return false; // passed end of top tier. Tiers start at zero return true; } function success() constant returns (bool succeeded) { if (coinsRemaining == 0) return true; bool complete = (now > endDate) ; bool didOK = (coinsRemaining <= (MaxCoinsR1 - minimumCap)); // not even 40M Gone?? Aargh. succeeded = (complete && didOK) ; // (out of steam but enough sold) return ; } function failed() constant returns (bool didNotSucceed) { bool complete = (now > endDate ); bool didBad = (coinsRemaining > (MaxCoinsR1 - minimumCap)); didNotSucceed = (complete && didBad); return; } function () payable MustBeEnabled(msg.sender) whenNotPaused { createTokens(msg.sender,msg.value); } function linkCoin(address coin) onlyOwner { token = HelloGoldToken(coin); } function coinAddress() constant returns (address) { return address(token); } // hgtRates in whole tokens per ETH // max individual contribution in whole ETH function setHgtRates(uint256 p0,uint256 p1,uint256 p2,uint256 p3,uint256 p4, uint256 _max ) onlyOwner { require (now < startDate) ; hgtRates[0] = p0 * 10**8; hgtRates[1] = p1 * 10**8; hgtRates[2] = p2 * 10**8; hgtRates[3] = p3 * 10**8; hgtRates[4] = p4 * 10**8; personalMax = _max * 1 ether; // max ETH per person } event Purchase(address indexed buyer, uint256 level,uint256 value, uint256 tokens); event Reduction(string msg, address indexed buyer, uint256 wanted, uint256 allocated); function createTokens(address recipient, uint256 value) private { uint256 totalTokens; uint256 hgtRate; require (funding()) ; require (value > 1 finney) ; require (deposits[recipient] < personalMax); uint256 maxRefund = 0; if ((deposits[msg.sender] + value) > personalMax) { maxRefund = deposits[msg.sender] + value - personalMax; value -= maxRefund; log0("maximum funds exceeded"); } uint256 val = value; ethRaised = safeAdd(ethRaised,value); if (deposits[recipient] == 0) contributors++; do { hgtRate = hgtRates[tierNo]; // hgtRate must include the 10^8 uint tokens = safeMul(val, hgtRate); // (val in eth * 10^18) * #tokens per eth tokens = safeDiv(tokens, 1 ether); // val is in ether, msg.value is in wei if (tokens <= coinsLeftInTier) { uint256 actualTokens = tokens; uint refund = 0; if (tokens > coinsRemaining) { //can't sell desired # tokens Reduction("in tier",recipient,tokens,coinsRemaining); actualTokens = coinsRemaining; refund = safeSub(tokens, coinsRemaining ); // refund amount in tokens refund = safeDiv(refund*1 ether,hgtRate ); // refund amount in ETH // need a refund mechanism here too coinsRemaining = 0; val = safeSub( val,refund); } else { coinsRemaining = safeSub(coinsRemaining, actualTokens); } purchasedCoins = safeAdd(purchasedCoins, actualTokens); totalTokens = safeAdd(totalTokens,actualTokens); require (token.transferFrom(HGT_Reserve, recipient,totalTokens)) ; Purchase(recipient,tierNo,val,actualTokens); // event deposits[recipient] = safeAdd(deposits[recipient],val); // in case of refund - could pull off etherscan refund += maxRefund; if (refund > 0) { ethRaised = safeSub(ethRaised,refund); recipient.transfer(refund); } if (coinsRemaining <= (MaxCoinsR1 - minimumCap)){ // has passed success criteria if (!multiSig.send(this.balance)) { // send funds to HGF log0("cannot forward funds to owner"); } } coinsLeftInTier = safeSub(coinsLeftInTier,actualTokens); if ((coinsLeftInTier == 0) && (coinsRemaining != 0)) { // exact sell out of non final tier coinsLeftInTier = coinsPerTier; tierNo++; endDate = now + tranchePeriod; } return; } // check that coinsLeftInTier >= coinsRemaining uint256 coins2buy = min256(coinsLeftInTier , coinsRemaining); endDate = safeAdd( now, tranchePeriod); // Have bumped levels - need to modify end date here purchasedCoins = safeAdd(purchasedCoins, coins2buy); // give all coins remaining in this tier totalTokens = safeAdd(totalTokens,coins2buy); coinsRemaining = safeSub(coinsRemaining,coins2buy); uint weiCoinsLeftInThisTier = safeMul(coins2buy,1 ether); uint costOfTheseCoins = safeDiv(weiCoinsLeftInThisTier, hgtRate); // how much did that cost? Purchase(recipient, tierNo,costOfTheseCoins,coins2buy); // event deposits[recipient] = safeAdd(deposits[recipient],costOfTheseCoins); val = safeSub(val,costOfTheseCoins); tierNo = tierNo + 1; coinsLeftInTier = coinsPerTier; } while ((val > 0) && funding()); // escaped because we passed the end of the universe..... // so give them their tokens require (token.transferFrom(HGT_Reserve, recipient,totalTokens)) ; if ((val > 0) || (maxRefund > 0)){ Reduction("finished crowdsale, returning ",recipient,value,totalTokens); // return the remainder ! recipient.transfer(val+maxRefund); // if you can't return the balance, abort whole process } if (!multiSig.send(this.balance)) { ethRaised = safeSub(ethRaised,this.balance); log0("cannot send at tier jump"); } } function allocatedTokens(address grantee, uint256 numTokens) onlyOwner { require (now < startDate) ; if (numTokens < coinsRemaining) { coinsRemaining = safeSub(coinsRemaining, numTokens); } else { numTokens = coinsRemaining; coinsRemaining = 0; } preallocCoins = safeAdd(preallocCoins,numTokens); require (token.transferFrom(HGT_Reserve,grantee,numTokens)); } function withdraw() { // it failed. Come and get your ether. if (failed()) { if (deposits[msg.sender] > 0) { uint256 val = deposits[msg.sender]; deposits[msg.sender] = 0; msg.sender.transfer(val); } } } function complete() onlyOwner { // this should not have to be called. Extreme measures. if (success()) { uint256 val = this.balance; if (val > 0) { if (!multiSig.send(val)) { log0("cannot withdraw"); } else { log0("funds withdrawn"); } } else { log0("nothing to withdraw"); } } } }
Monday, August 28, 2017 12:00:00 PM GMT+08:00
uint256 public startDate = 1503892800;
1,011,374
[ 1, 4625, 348, 7953, 560, 30, 225, 490, 28612, 16, 432, 637, 641, 9131, 16, 11015, 2593, 30, 713, 30, 713, 23544, 21706, 15, 6840, 30, 713, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 2254, 5034, 1071, 12572, 273, 18478, 23, 6675, 6030, 713, 31, 4202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]