file_name
stringlengths
71
779k
comments
stringlengths
20
182k
code_string
stringlengths
20
36.9M
__index_level_0__
int64
0
17.2M
input_ids
sequence
attention_mask
sequence
labels
sequence
./full_match/7700/0x6efd43c49dA92f77d890FD8c27F1f23f7Aa0970A/sources/src/CidNFT.sol
@notice Data that is associated with a subprotocol name -> subprotocol NFT ID combination (for reverse lookups)
struct CIDNFTSubprotocolData { uint256 cidNFTID; uint256 position;
4,650,703
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 1910, 716, 353, 3627, 598, 279, 720, 8373, 508, 317, 720, 8373, 423, 4464, 1599, 10702, 261, 1884, 4219, 20286, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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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 ]
[ 1, 565, 1958, 385, 734, 50, 4464, 1676, 8373, 751, 288, 203, 3639, 2254, 5034, 7504, 50, 4464, 734, 31, 203, 3639, 2254, 5034, 1754, 31, 203, 203, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x8ffE0eE5aBAc631e41C38c0Cbc9A6a35A3912eCa/sources/ecycontract.sol
for 18 decimal 6 000 000 + 18 x 0
uint256 TokeninitialSupply = 6000000000000000000000000;
8,194,873
[ 1, 4625, 348, 7953, 560, 30, 225, 364, 6549, 6970, 1666, 20546, 20546, 397, 6549, 619, 374, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ 1, 565, 2254, 5034, 3155, 6769, 3088, 1283, 273, 1666, 12648, 12648, 12648, 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 ]
// contracts/BadgeTokenFactory.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../node_modules/@openzeppelin/contracts/utils/Counters.sol"; import "./BadgeDefinitionFactory.sol"; import "./BadgeQueryOracle.sol"; /** * @title BadgeTokenFactory * @author Geoffrey Garcia * @notice Contract to use to mint and to transfer (if applicable based on associated BadgeDefinition) BadgeToken that are ERC721 tokens. * @dev The BadgeTokenFactory contract provides basic structures, functions & modifiers that allows to manage BadgeToken as ERC721 token. */ contract BadgeTokenFactory is BadgeFactory { using Counters for Counters.Counter; /** * @notice Event emitted to request for a query to be run. * @dev Event emitted to request for a query to be run for BadgeToken minting. * @param _requestID The ID of the query. * @param _indexer The service indexing the data (possible values: "thegraph, "covalent"). * @param _protocol The set/subgraph on the indexer to use (possible values: "uniswap", "compound" ,"aave" ,"ethereum"). * @param _query The query to run. */ event QueryRequest(bytes32 _requestID, string _indexer, string _protocol, string _query); /** * @notice Event emitted after the query and its result have been record into the blockchain. * @dev Event emitted fter the query and its result have been record into the blockchain for BadgeToken minting. * @param _requestID The ID of the query. * @param _queryResult The result of the query. */ event QueryResultReceived(bytes32 _requestID, string _queryResult); /** * @notice Event emitted when a BadgeToken is ready to be minted. * @dev Event emitted when a BadgeToken is ready to be minted. * @param _caller The Ethereum address which has requested for the right to mint the token. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. */ event BadgeTokenReady(address _caller, uint _badgeDefinitionId); /** * @notice Event emitted after a BadgeToken minting. * @dev Event emitted after a BadgeToken minting. * @param _badgeTokenId The ID of the BadgeToken. * @param _originalOwner The Ethereum address of the user that has minted the token. */ event NewBadgeToken(uint _badgeTokenId, address _originalOwner); // Badge token structure struct BadgeToken { uint badgeDefinitionId; // the ID of BadgeDefinition associated to this BadgeToken address originalOwner; // the Ethereum address of the user that has minted the token string[maxNumberOfAttributionConditions] specialValues; // the special value associated with this badge (optional) } // Pending minting structure struct PendingMinting { address caller; // the Ethereum address which has requested for the query result uint badgeDefinitionId; // the ID of BadgeDefinition associated to the BadgeToken the user want to mint uint numberOfConditions; // the number of conditions that have to be evaluated through as many queries mapping (uint => bytes32) _queryIndex; // the IDs of the queries mapping (bytes32 => bool) _pendingQueryStatus; // the current status of the queries (true if pending) mapping (bytes32 => string) _queryResult; // the results of the queries (usable only if associated _pendingQueryStatus value is false) mapping (bytes32 => string) _evaluationOperator; // the operator allowing to compare the query return mapping (bytes32 => string) _evaluationCondition; // the value to compare with the query result } // Storage of the badge tokens BadgeToken[] private _badgeTokens; // BadgeToken storage mapping(address => mapping(uint => uint)) private _ownedBadges; // List of BadgeToken IDs per owner per BadgeDefinition string badgeTokenSymbol = "BTO"; // Symbol of the ERC721 tokens of the BadgeToken // Storage of the badge minting Counters.Counter private _mintingNonce; // a nonce injected to build the ID of the condition group to mint the badge mapping(bytes32 => PendingMinting) private _pendingMintings; // the list of pending badge mintings mapping(address => mapping(uint => bytes32)) private _pendingMintingBadges; // List of pending badge mintings per owner per BadgeDefinition mapping(bytes32 => bytes32) private _pendingQueries; // the list of pending queriesn // Reference to the BadgeDefinitionFactory contract allowing to manage BadgeDefinition BadgeDefinitionFactory badgeDefinitionFactory; // Reference to the BadgeQueryOracle contract allowing to run query on off-chain ressources BadgeQueryOracle badgeQueryOracle; /** * @dev See {ERC721-constructor}. * @param _badgeDefinitionFactoryAddress The Ethereum address of the BadgeDefinitionFactory contract allowing to manage BadgeDefinition. */ constructor(address _badgeDefinitionFactoryAddress) BadgeFactory("BadgeToken", badgeTokenSymbol) { // Linking this contract with the already deployed one BadgeDefinitionFactory badgeDefinitionFactory = BadgeDefinitionFactory(_badgeDefinitionFactoryAddress); // Linking this contract with a freshly instantiated BadgeQueryOracle badgeQueryOracle = new BadgeQueryOracle(); } /** * @dev Throws if the badge is already owned. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. */ modifier notOwned(uint _badgeDefinitionId) { require(_ownedBadges[_msgSender()][_badgeDefinitionId] == 0, string(abi.encodePacked(badgeTokenSymbol, ": badge already owned"))); //TODO: check orignalOwner instead? _; } /** * @dev Throws if the badge minting process is already in progress. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. */ modifier isNotPendingMinting(uint _badgeDefinitionId) { require(_pendingMintingBadges[_msgSender()][_badgeDefinitionId] == 0, string(abi.encodePacked(badgeTokenSymbol, ": badge already in minting process"))); _; } /** * @dev Throws if the badge minting process is not in progress. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. */ modifier isPendingMinting(uint _badgeDefinitionId) { require(_pendingMintingBadges[_msgSender()][_badgeDefinitionId] != 0, string(abi.encodePacked(badgeTokenSymbol, ": badge not in minting process"))); _; } /** * @notice Function to mint a BadgeToken as ERC721 tokens. * @dev Creates & store a BadgeToken. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. */ function requestBadgeTokenMinting(uint _badgeDefinitionId) notOwned(_badgeDefinitionId) isNotPendingMinting(_badgeDefinitionId) public { // Creating for the penting minting _mintingNonce.increment(); bytes32 badgeConditionGroupID = keccak256(abi.encodePacked(block.timestamp, _msgSender(), _mintingNonce.current())); // Add the badge minting to the ones asked by the user _pendingMintingBadges[_msgSender()][_badgeDefinitionId] = badgeConditionGroupID; // Storing for the penting minting PendingMinting storage pendingMinting = _pendingMintings[badgeConditionGroupID]; pendingMinting.caller = _msgSender(); // Get the BadgeAttributionCondition list associated to this BadgeDefinition BadgeAttributionCondition[maxNumberOfAttributionConditions] memory badgeAttributionCondition; uint numberOfConditions = 0; (numberOfConditions, badgeAttributionCondition) = badgeDefinitionFactory.getBadgeDefinitionAttributionCondition(_badgeDefinitionId); pendingMinting.numberOfConditions = numberOfConditions; // Check for every condition in the list for(uint i=0; i < numberOfConditions; i++){ // Ask the Oracle to obtain the result of the query bytes32 requestID = badgeQueryOracle.runQuery(_msgSender(), badgeConditionGroupID, badgeAttributionCondition[i].indexer, badgeAttributionCondition[i].protocol, badgeAttributionCondition[i].query); // Asking for the query to be run emit QueryRequest(requestID, badgeAttributionCondition[i].indexer, badgeAttributionCondition[i].protocol, badgeAttributionCondition[i].query); // Store the references & status of the query _pendingQueries[requestID] = badgeConditionGroupID; pendingMinting._queryIndex[i] = requestID; pendingMinting._pendingQueryStatus[requestID] = true; pendingMinting._evaluationOperator[requestID] = badgeAttributionCondition[i].operator; pendingMinting._evaluationCondition[requestID] = badgeAttributionCondition[i].condition; } } /** * @notice Function to get the result of a query. * @dev Store the result of the query then ask for the Oracle to write it into the blockchain. * @param _requestID The ID of the query. * @param _queryResult The result of the query. */ function updateBadgeTokenMinting(bytes32 _requestID, string memory _queryResult) public { bytes32 badgeConditionGroupID = _pendingQueries[_requestID]; // string memory requestIDString = _bytes32ToString(_requestID); // require(badgeConditionGroupID != 0, string(abi.encodePacked(badgeTokenSymbol, ": wrong request ID(", requestIDString, ") badgeConditionGroupID:", badgeConditionGroupID))); require(badgeConditionGroupID != 0, string(abi.encodePacked(badgeTokenSymbol, ": wrong request ID(", _requestID, ")"))); // Storing the result PendingMinting storage pendingMinting = _pendingMintings[badgeConditionGroupID]; pendingMinting._pendingQueryStatus[_requestID] = false; pendingMinting._queryResult[_requestID] = _queryResult; // Sending the result to the Oracle badgeQueryOracle.recordQueryResult(pendingMinting.caller, badgeConditionGroupID, _requestID, _queryResult); // Telling the query has been recorded emit QueryResultReceived(_requestID, _queryResult); // Evaluating overall minting process status bool evaluationResult = false; for(uint i=0; (i < pendingMinting.numberOfConditions) && (evaluationResult == false); i++){ // Retrieving another query ID bytes32 requestID = pendingMinting._queryIndex[i]; // Evaluate if the condition is met evaluationResult = pendingMinting._pendingQueryStatus[requestID]; } // Emetting a signal if all the queries have been run if(evaluationResult == false){ emit BadgeTokenReady(pendingMinting.caller, pendingMinting.badgeDefinitionId); } } /** * @notice Function to mint a BadgeToken as ERC721 tokens. * @dev Creates & store a BadgeToken. * @param _badgeDefinitionId The ID of BadgeDefinition associated to this BadgeToken. * @return _badgeTokenId The ID of the new BadgeToken. */ function mintBadgeToken(uint _badgeDefinitionId) notOwned(_badgeDefinitionId) isPendingMinting(_badgeDefinitionId) public returns (uint _badgeTokenId) { // Identifying the badge the user want to mint bytes32 badgeConditionGroupID = _pendingMintingBadges[_msgSender()][_badgeDefinitionId]; PendingMinting storage pendingMinting = _pendingMintings[badgeConditionGroupID]; require(_msgSender() == pendingMinting.caller, string(abi.encodePacked(badgeTokenSymbol, ": not the user who has requested the token"))); string[maxNumberOfAttributionConditions] memory _specialValues; require(_assessAttributionCondition(pendingMinting, _specialValues), string(abi.encodePacked(badgeTokenSymbol, ": attempt to mint a token without fullfilling the attribution conditions to get it"))); // Storing the BadgeToken _badgeTokens.push(BadgeToken({ badgeDefinitionId: _badgeDefinitionId, originalOwner: _msgSender(), specialValues: _specialValues})); // Getting the ID of the new BadgeToken // uint badgeTokenId = _badgeTokens.length - 1; uint badgeTokenId = _badgeTokens.length; // Add the badge to the ones owned by the user _ownedBadges[_msgSender()][_badgeDefinitionId] = badgeTokenId; // Minting the BadgeToken _safeMint(_msgSender(), badgeTokenId); // Removing the stored pending badge minting for(uint i=0; i < pendingMinting.numberOfConditions; i++){ bytes32 requestID = pendingMinting._queryIndex[i]; delete _pendingQueries[requestID]; delete pendingMinting._pendingQueryStatus[requestID]; delete pendingMinting._queryResult[requestID]; delete pendingMinting._evaluationOperator[requestID]; delete pendingMinting._evaluationCondition[requestID]; delete pendingMinting._queryIndex[i]; } delete _pendingMintingBadges[_msgSender()][_badgeDefinitionId]; delete _pendingMintings[badgeConditionGroupID]; // Emit the appropriate event emit NewBadgeToken(badgeTokenId, _msgSender()); return badgeTokenId; } /** * @notice Function to test if the badge produced using a BadgeDefinition can be mint. * @dev Check if the conditions to mint the badge are met. * @param _pendingMinting The pending badge minting structure. * @param _specialValues The special values to be stored (optional). * @return _evaluationResult The result of the test. */ function _assessAttributionCondition(PendingMinting storage _pendingMinting, string[maxNumberOfAttributionConditions] memory _specialValues) private view returns (bool _evaluationResult) { _evaluationResult = true; // Check for every condition in the list for(uint i=0; (i < _pendingMinting.numberOfConditions) && (_evaluationResult == true); i++){ // Retrieving the query ID bytes32 requestID = _pendingMinting._queryIndex[i]; // Evaluate if the condition is met _evaluationResult = _evaluateCondition(_pendingMinting._queryResult[requestID], _pendingMinting._evaluationOperator[requestID], _pendingMinting._evaluationCondition[requestID], _specialValues[i]); } return _evaluationResult; } /** * @notice Function to evaluate a condition. * @dev Check if a condition to mint a badge is met. * @param _queryResult The result of the query. * @param _operator The operator allowing to compare the query return. * @param _condition The value to compare with the query result. * @param _specialValue The special value to be stored (optional). * @return _evaluationResult The result of the test. */ function _evaluateCondition(string memory _queryResult, string memory _operator, string memory _condition, string memory _specialValue) private pure returns (bool _evaluationResult) { _evaluationResult = false; bytes32 operatorHash = keccak256(bytes(_operator)); // Evaluate the query return if(operatorHash == keccak256(bytes("<"))){ _evaluationResult = _stringToUint(_queryResult) < _stringToUint(_condition); } else{ if(operatorHash == keccak256(bytes("<="))){ _evaluationResult = _stringToUint(_queryResult) <= _stringToUint(_condition); } else{ if(operatorHash == keccak256(bytes(">"))){ _evaluationResult = _stringToUint(_queryResult) > _stringToUint(_condition); } else{ if(operatorHash == keccak256(bytes(">="))){ _evaluationResult = _stringToUint(_queryResult) >= _stringToUint(_condition); // _evaluationResult = false; } else{ if(operatorHash == keccak256(bytes("=="))){ _evaluationResult = _stringToUint(_queryResult) == _stringToUint(_condition); } else{ if(operatorHash == keccak256(bytes("!="))){ _evaluationResult = _stringToUint(_queryResult) != _stringToUint(_condition); } else{ if(operatorHash == keccak256(bytes("special"))){ _evaluationResult = true; _specialValue = _queryResult; } else{ } } } } } } } return _evaluationResult; } /** * @notice Function to test if the badge produced using a BadgeDefinition can be mint. * @dev Check if the conditions to mint the badge are met. * @param _owner The Ethereum address of the user. * @param _badgeDefinitionId The ID of BadgeDefinition. * @return _evaluationResult The result of the test. */ function doesOwnBadgeFromGivenDefinition(address _owner, uint _badgeDefinitionId) public view returns (bool _evaluationResult) { _evaluationResult = true; // Check for a BadgeToken potentially owned by this user associated to the BadgeDefinition if(_ownedBadges[_owner][_badgeDefinitionId] == 0){ _evaluationResult = false; } return _evaluationResult; } /** * @notice Function to transfer a token (if applicable). * @dev Transfers `tokenId` from `from` to `to`. * @param from The Ethereum address of the user that own the token. * @param to The Ethereum address of the user that could receive the token. * @param tokenId The ID of the BadgeToken. */ function _transfer(address from, address to, uint256 tokenId) internal override { uint tokenIdex = tokenId - 1; // Check if the token can be transfered require(badgeDefinitionFactory.isBadgeTransferable(_badgeTokens[tokenIdex].badgeDefinitionId), string(abi.encodePacked(badgeTokenSymbol, ": this token is bind to its original owner", _badgeTokens[tokenIdex].originalOwner))); // Transfer the token (if applicable) super._transfer(from, to, tokenId); } /** * @notice Function to get the URI associated to a token. * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. * @param tokenId The ID of the BadgeToken. * @return The result URI associated to the token. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); uint tokenIdex = tokenId - 1; string memory URI = badgeDefinitionFactory.tokenURI(_badgeTokens[tokenIdex].badgeDefinitionId); return bytes(URI).length > 0 ? string(URI) : ''; } }
the number of conditions that have to be evaluated through as many queries
uint numberOfCondit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, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 3639, 2254, 7922, 8545, 31, 13491, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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 // 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); } } // 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/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/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/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 (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 (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/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // 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/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @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 { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. 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] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // 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 tryRecover(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 tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @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. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} 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.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // 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 (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @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) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @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 Message, created from `s`. 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(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @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)); } } // 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/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 pragma solidity ^0.8.4; import "hardhat/console.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract FuDaoVerseDAN is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; using ECDSA for bytes32; //NFT params string public baseURI; bool public revealed; string public notRevealedUri; IERC721 public OG; //sale stages: //stage 0: init(no minting) //stage 1: free-mint //stage 2: pre-sale, OGs are included in here //stage 2.5: whitelisted can mint an extra 2, increase presaleMintMax to 4 //stage 3: public sale Counters.Counter public tokenSupply; uint8 public stage = 0; mapping(uint256 => bool) public isOGMinted; mapping(uint256 => uint8) public OGWhitelistMintCount; uint256 public VIP_PASSES = 888; uint256 public presaleSalePrice = 0.077 ether; uint256 public presaleSupply = 6666; uint256 public presaleMintMax = 2; mapping(address => uint8) public presaleMintCount; mapping(address => uint8) public vipMintCount; // For Whitelist Sale mapping(address => uint256) public publicMintCount; //public sale (stage=3) uint256 public publicSalePrice = 0.088 ether; uint256 public publicMintMax = 2; uint256 public totalSaleSupply = 8888; //others bool public paused = false; //sale holders address[2] public fundRecipients = [ 0xaDDfdc72494E29A131B1d4d6668184840f1Fc30C, 0xcD7BCAc7Ee5c18d8cC1374B62F09cf67e6432a08 ]; uint256[] public receivePercentagePt = [7000]; //distribution in basis points // Off-chain whitelist address private signerAddress; mapping(bytes => bool) private _nonceUsed; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, address _newOwner, address _signerAddress, address ogCollection ) ERC721(_name, _symbol) { setNotRevealedURI(_initBaseURI); signerAddress = _signerAddress; transferOwnership(_newOwner); OG = IERC721(ogCollection); } event VIPMint(address indexed to, uint256 tokenId); event WhitelistMint(address indexed to, uint256 tokenId); event PublicMint(address indexed to, uint256 mintAmount); event DevMint(uint256 count); event Airdrop(address indexed to, uint256 tokenId); /** * @notice Performs respective minting condition checks depending on stage of minting * @param tokenIds tokenIds of VIP Pass * @dev Stage 1: OG Mints, Free Claim for OG Pass Holders * @dev Each Pass can only be used once to claim * @dev Minter must be owner of OG pass to claim */ function vipMint(uint256[] memory tokenIds) public { require(!paused, "FuDaoVerseDAN: Contract is paused"); require(stage > 0, "FuDaoVerseDAN: Minting has not started"); for (uint256 i; i < tokenIds.length; i++) { require( OG.ownerOf(tokenIds[i]) == msg.sender, "FuDaoVerseDAN: Claimant is not the owner!" ); require( !isOGMinted[tokenIds[i]], "FuDaoVerseDAN: OG Token has already been used!" ); _vipMint(tokenIds[i]); } } function _vipMint(uint256 tokenId) internal { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); isOGMinted[tokenId] = true; VIP_PASSES--; emit VIPMint(msg.sender, tokenSupply.current()); } /** * @notice VIP Whitelist Mint. VIPs are automatically whitelisted and can use their Mint pass to mint * @param _mintAmount Amount minted for vipWhitelistMint * @dev Stage 2: Presale Mints, VIP Automatically whitelisted * @dev 2 VIP Whitelist Mints at stage 2, another 2 VIP Whitelist Mints at stage 2.5 * @dev Minter must hold an OG pass to VIP Whitelist Mint */ function vipWhitelistMint(uint8 _mintAmount) public payable { require(!paused, "FuDaoVerseDAN: Contract is paused"); require(stage == 2, "FuDaoVerseDAN: Private Sale Closed!"); require( msg.value == _mintAmount * presaleSalePrice, "FuDaoVerseDAN: Insufficient ETH!" ); require( tokenSupply.current() + _mintAmount <= presaleSupply, "FuDaoVerseDAN: Max Supply for Presale Mint Reached!" ); require( OG.balanceOf(msg.sender) > 0, "FuDaoVerseDAN: Claimant does not own a mint pass" ); require( presaleMintCount[msg.sender] + _mintAmount <= presaleMintMax, "FuDaoVerseDAN: Claimant has exceeded VIP Whitelist Mint Max!" ); presaleMintCount[msg.sender] += _mintAmount; for (uint8 i; i < _mintAmount; i++) { _vipWhitelistMint(); } } function _vipWhitelistMint() internal { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); emit VIPMint(msg.sender, tokenSupply.current()); } /** * @notice Performs respective minting condition checks depending on stage of minting * @param _mintAmount Amount that is minted * @param nonce Random bytes32 nonce * @param signature Signature generated off-chain * @dev Stage 1: OG Mints, Free Claim for OG Pass Holders * @dev Each Pass can only be used once to claim */ function whitelistMint( uint8 _mintAmount, bytes memory signature, bytes memory nonce ) public payable { require(!paused, "FuDaoVerseDAN: Contract is paused"); require(stage == 2, "FuDaoVerseDAN: Private Sale Closed!"); require(!_nonceUsed[nonce], "FuDaoVerseDAN: Nonce already used"); _nonceUsed[nonce] = true; require( whitelistSigned(msg.sender, nonce, signature), "FuDaoVerseDAN: Invalid signature!" ); require( tokenSupply.current() + _mintAmount <= presaleSupply, "FuDaoVerseDAN: Max Supply for Presale Mint Reached!" ); require( msg.value == _mintAmount * presaleSalePrice, "FuDaoVerseDAN: Insufficient ETH!" ); require( presaleMintCount[msg.sender] + _mintAmount <= presaleMintMax, "FuDaoVerseDAN: Wallet has already minted Max Amount for Presale!" ); presaleMintCount[msg.sender] += _mintAmount; for (uint256 i; i < _mintAmount; i++) { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); emit WhitelistMint(msg.sender, tokenSupply.current()); } } /** * @notice Public Mint * @param _mintAmount Amount that is minted * @dev Stage 3: Public Mint */ function publicMint(uint8 _mintAmount) public payable { require(!paused, "FuDaoVerseDAN: Contract is paused"); require(stage == 3, "FuDaoVerseDAN: Public Sale Closed!"); require( msg.value == _mintAmount * publicSalePrice, "FuDaoVerseDAN: Insufficient ETH!" ); require( tokenSupply.current() + _mintAmount <= totalSaleSupply - VIP_PASSES, "FuDaoVerseDAN: Max Supply for Public Mint Reached!" ); require( publicMintCount[msg.sender] + _mintAmount <= publicMintMax, "FuDaoVerseDAN: Wallet has already minted Max Amount for Public!" ); publicMintCount[msg.sender] += _mintAmount; // FIX: Gas Optimization for (uint256 i; i < _mintAmount; i++) { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); emit PublicMint(msg.sender, tokenSupply.current()); } } /** * @dev Mints NFTS to the owner's wallet * @param _mintAmount Amount to mint */ function devMint(uint8 _mintAmount) public onlyOwner { require( tokenSupply.current() + _mintAmount <= totalSaleSupply, "FuDaoVerseDAN: Max Supply Reached!" ); for (uint256 i; i < _mintAmount; i++) { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); } emit DevMint(_mintAmount); } /** * @dev Airdrops NFTs to the list of addresses provided * @param addresses List of airdrop recepients */ function airdrop(address[] memory addresses) public onlyOwner { require( tokenSupply.current() + addresses.length <= totalSaleSupply, "FuDaoVerseDAN: Max Supply Reached!" ); for (uint256 i; i < addresses.length; i++) { tokenSupply.increment(); _safeMint(addresses[i], tokenSupply.current()); emit Airdrop(addresses[i], tokenSupply.current()); } } /** * @dev Checks if the the signature is signed by a valid signer for whitelists * @param sender Address of minter * @param nonce Random bytes32 nonce * @param signature Signature generated off-chain */ function whitelistSigned( address sender, bytes memory nonce, bytes memory signature ) private view returns (bool) { bytes32 hash = keccak256(abi.encodePacked(sender, nonce)); return signerAddress == hash.recover(signature); } // ------------------------- VIEW FUNCTIONS ----------------------------- /** * @notice Returns metadata URI for sepecified token id * @param tokenId Token Id to retrieve metadata * @return Metadata URI */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, tokenId.toString(), ".json" ) ) : ""; } /** * @notice Total NFTs Minted */ function totalSupply() public view returns (uint256) { return tokenSupply.current(); } // ------------------------- ADMIN FUNCTIONS ----------------------------- /** * @dev Set Mint Stage */ function setStage(uint8 _stage) public onlyOwner { require(stage < 4, "FuDaoVerseDAN: Exceeded maximum number of stages"); stage = _stage; } /** * @dev Set Revealed Metadata URI */ function setBaseURI(string memory _newBaseURI) public onlyOwner { require(!revealed); baseURI = _newBaseURI; } /** * @dev Set Presale maximum amount of mints */ function setPresaleMintMax(uint256 amount) public onlyOwner { presaleMintMax = amount; } /** * @dev Set the unrevealed URI * @param _notRevealedURI unrevealed URI for metadata */ function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } /** * @dev Set Revealed state of NFT metadata */ function reveal() public onlyOwner { revealed = true; } /** * @dev Switches pause state to `_state` * @param _state Pause State */ function pause(bool _state) public onlyOwner { paused = _state; } /** * @dev Emergency Function to withdraw any ETH deposited to this contract */ function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{ value: address(this).balance }(""); require(success); } /** * @dev requires currentBalance of contract to have some amount * @dev withdraws with the fixed define distribution */ function withdrawFund() public onlyOwner { uint256 currentBal = address(this).balance; require(currentBal > 0); for (uint256 i = 0; i < fundRecipients.length - 1; i++) { _withdraw( fundRecipients[i], (currentBal * receivePercentagePt[i]) / 10000 ); } //final address receives remainder to prevent ether dust _withdraw( fundRecipients[fundRecipients.length - 1], address(this).balance ); } /** * @dev private function utilized by withdrawFund * @param _addr Address of receiver * @param _amt Amount to withdraw */ function _withdraw(address _addr, uint256 _amt) private { (bool success, ) = _addr.call{value: _amt}(""); require(success, "Transfer failed"); } /** * @dev retrieve base URI internally */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } }
* @notice Public Mint @param _mintAmount Amount that is minted @dev Stage 3: Public Mint/
function publicMint(uint8 _mintAmount) public payable { require(!paused, "FuDaoVerseDAN: Contract is paused"); require(stage == 3, "FuDaoVerseDAN: Public Sale Closed!"); require( msg.value == _mintAmount * publicSalePrice, "FuDaoVerseDAN: Insufficient ETH!" ); require( tokenSupply.current() + _mintAmount <= totalSaleSupply - VIP_PASSES, "FuDaoVerseDAN: Max Supply for Public Mint Reached!" ); require( publicMintCount[msg.sender] + _mintAmount <= publicMintMax, "FuDaoVerseDAN: Wallet has already minted Max Amount for Public!" ); for (uint256 i; i < _mintAmount; i++) { tokenSupply.increment(); _safeMint(msg.sender, tokenSupply.current()); emit PublicMint(msg.sender, tokenSupply.current()); } }
13,707,990
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 7224, 490, 474, 632, 891, 389, 81, 474, 6275, 16811, 716, 353, 312, 474, 329, 632, 5206, 16531, 890, 30, 7224, 490, 474, 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,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 307, 40, 1258, 30, 7224, 348, 5349, 25582, 4442, 1769, 203, 203, 3639, 2583, 12, 203, 5411, 1234, 18, 1132, 422, 389, 81, 474, 6275, 380, 1071, 30746, 5147, 16, 203, 5411, 315, 42, 89, 11412, 3945, 307, 40, 1258, 30, 22085, 11339, 512, 2455, 4442, 203, 3639, 11272, 203, 203, 3639, 2583, 12, 203, 5411, 1147, 3088, 1283, 18, 2972, 1435, 397, 389, 81, 474, 6275, 1648, 2078, 30746, 3088, 1283, 300, 776, 2579, 67, 52, 3033, 1090, 55, 16, 203, 5411, 315, 42, 89, 11412, 3945, 307, 40, 1258, 30, 4238, 3425, 1283, 364, 7224, 490, 474, 868, 2004, 4442, 203, 3639, 11272, 203, 203, 3639, 2583, 12, 203, 5411, 1071, 49, 474, 1380, 63, 3576, 18, 15330, 65, 397, 389, 81, 474, 6275, 1648, 1071, 49, 474, 2747, 16, 203, 5411, 315, 42, 89, 11412, 3945, 307, 40, 1258, 30, 20126, 711, 1818, 312, 474, 329, 4238, 16811, 364, 7224, 4442, 203, 3639, 11272, 203, 203, 203, 3639, 364, 261, 11890, 5034, 277, 31, 277, 411, 389, 81, 474, 6275, 31, 277, 27245, 288, 203, 5411, 1147, 3088, 1283, 18, 15016, 5621, 203, 5411, 389, 4626, 49, 474, 12, 3576, 18, 15330, 16, 1147, 3088, 1283, 18, 2972, 10663, 203, 5411, 3626, 7224, 49, 474, 12, 3576, 18, 15330, 16, 1147, 3088, 1283, 18, 2972, 10663, 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 ]
/** *Submitted for verification at Etherscan.io on 2020-10-22 */ // SPDX-License-Identifier: MIT pragma solidity 0.6.8; // /** * @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); } // /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // /** * @title 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"); } } } // /** * @notice Interface for Curve.fi's REN pool. * Note that we are using array of 2 as Curve's REN pool contains only WBTC and renBTC. */ interface ICurveFi { function get_virtual_price() external view returns (uint256); function add_liquidity( // renBTC pool uint256[2] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_imbalance(uint256[2] calldata amounts, uint256 max_burn_amount) external; function remove_liquidity(uint256 _amount, uint256[2] calldata amounts) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; } // /** * @notice Interface for the migrator. */ interface IMigrator { /** * @dev What token is migrated from. */ function want() external view returns (address); /** * @dev What token is migrated to. */ function get() external view returns (address); /** * @dev Performs the token migration. */ function migrate() external; } // /** * @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]. */ 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 () internal { _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; } } // /** * @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. * * Credit: https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/master/packages/core/contracts/Initializable.sol */ 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; } // /** * @notice Interface for ERC20 token which supports minting new tokens. */ interface IERC20Mintable is IERC20 { function mint(address _user, uint256 _amount) external; } // /** * @notice Interface for ERC20 token which supports mint and burn. */ interface IERC20MintableBurnable is IERC20Mintable { function burn(uint256 _amount) external; function burnFrom(address _user, uint256 _amount) external; } // /** * @notice ACoconut swap. */ contract ACoconutSwap is Initializable, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; /** * @dev Token swapped between two underlying tokens. */ event TokenSwapped(address indexed buyer, address indexed tokenSold, address indexed tokenBought, uint256 amountSold, uint256 amountBought); /** * @dev New pool token is minted. */ event Minted(address indexed provider, uint256 mintAmount, uint256[] amounts, uint256 feeAmount); /** * @dev Pool token is redeemed. */ event Redeemed(address indexed provider, uint256 redeemAmount, uint256[] amounts, uint256 feeAmount); /** * @dev Fee is collected. */ event FeeCollected(address indexed feeRecipient, uint256 feeAmount); uint256 public constant feeDenominator = 10 ** 10; address[] public tokens; uint256[] public precisions; // 10 ** (18 - token decimals) uint256[] public balances; // Converted to 10 ** 18 uint256 public mintFee; // Mint fee * 10**10 uint256 public swapFee; // Swap fee * 10**10 uint256 public redeemFee; // Redeem fee * 10**10 address public feeRecipient; address public poolToken; uint256 public totalSupply; // The total amount of pool token minted by the swap. // It might be different from the pool token supply as the pool token can have multiple minters. address public governance; mapping(address => bool) public admins; bool public paused; uint256 public initialA; /** * @dev Initialize the ACoconut Swap. */ function initialize(address[] memory _tokens, uint256[] memory _precisions, uint256[] memory _fees, address _poolToken, uint256 _A) public initializer { require(_tokens.length == _precisions.length, "input mismatch"); require(_fees.length == 3, "no fees"); for (uint256 i = 0; i < _tokens.length; i++) { require(_tokens[i] != address(0x0), "token not set"); require(_precisions[i] != 0, "precision not set"); balances.push(0); } require(_poolToken != address(0x0), "pool token not set"); governance = msg.sender; feeRecipient = msg.sender; tokens = _tokens; precisions = _precisions; mintFee = _fees[0]; swapFee = _fees[1]; redeemFee = _fees[2]; poolToken = _poolToken; initialA = _A; // The swap must start with paused state! paused = true; } /** * @dev Returns the current value of A. This method might be updated in the future. */ function getA() public view returns (uint256) { return initialA; } /** * @dev Computes D given token balances. * @param _balances Normalized balance of each token. * @param _A Amplification coefficient from getA() */ function _getD(uint256[] memory _balances, uint256 _A) internal pure returns (uint256) { uint256 sum = 0; uint256 i = 0; uint256 Ann = _A; for (i = 0; i < _balances.length; i++) { sum = sum.add(_balances[i]); Ann = Ann.mul(_balances.length); } if (sum == 0) return 0; uint256 prevD = 0; uint256 D = sum; for (i = 0; i < 255; i++) { uint256 pD = D; for (uint256 j = 0; j < _balances.length; j++) { // pD = pD * D / (_x * balance.length) pD = pD.mul(D).div(_balances[j].mul(_balances.length)); } prevD = D; // D = (Ann * sum + pD * balance.length) * D / ((Ann - 1) * D + (balance.length + 1) * pD) D = Ann.mul(sum).add(pD.mul(_balances.length)).mul(D).div(Ann.sub(1).mul(D).add(_balances.length.add(1).mul(pD))); if (D > prevD) { if (D - prevD <= 1) break; } else { if (prevD - D <= 1) break; } } return D; } /** * @dev Computes token balance given D. * @param _balances Converted balance of each token except token with index _j. * @param _j Index of the token to calculate balance. * @param _D The target D value. * @param _A Amplification coeffient. * @return Converted balance of the token with index _j. */ function _getY(uint256[] memory _balances, uint256 _j, uint256 _D, uint256 _A) internal pure returns (uint256) { uint256 c = _D; uint256 S_ = 0; uint256 Ann = _A; uint256 i = 0; for (i = 0; i < _balances.length; i++) { Ann = Ann.mul(_balances.length); if (i == _j) continue; S_ = S_.add(_balances[i]); // c = c * D / (_x * N) c = c.mul(_D).div(_balances[i].mul(_balances.length)); } // c = c * D / (Ann * N) c = c.mul(_D).div(Ann.mul(_balances.length)); // b = S_ + D / Ann uint256 b = S_.add(_D.div(Ann)); uint256 prevY = 0; uint256 y = _D; // 255 since the result is 256 digits for (i = 0; i < 255; i++) { prevY = y; // y = (y * y + c) / (2 * y + b - D) y = y.mul(y).add(c).div(y.mul(2).add(b).sub(_D)); if (y > prevY) { if (y - prevY <= 1) break; } else { if (prevY - y <= 1) break; } } return y; } /** * @dev Compute the amount of pool token that can be minted. * @param _amounts Unconverted token balances. * @return The amount of pool token minted. */ function getMintAmount(uint256[] calldata _amounts) external view returns (uint256, uint256) { uint256[] memory _balances = balances; require(_amounts.length == _balances.length, "invalid amount"); uint256 A = getA(); uint256 oldD = totalSupply; uint256 i = 0; for (i = 0; i < _balances.length; i++) { if (address(this).balance == 0) continue; //inject PRESENT ETHER // balance = balance + amount * precision _balances[i] = _balances[i].add(_amounts[i].mul(precisions[i])); } uint256 newD = _getD(_balances, A); // newD should be bigger than or equal to oldD uint256 mintAmount = newD.sub(oldD); uint256 feeAmount = 0; if (mintFee > 0) { feeAmount = mintAmount.mul(mintFee).div(feeDenominator); mintAmount = mintAmount.sub(feeAmount); } return (mintAmount, feeAmount); } /** * @dev Mints new pool token. * @param _amounts Unconverted token balances used to mint pool token. * @param _minMintAmount Minimum amount of pool token to mint. */ function mint(uint256[] calldata _amounts, uint256 _minMintAmount) external nonReentrant { uint256[] memory _balances = balances; // If swap is paused, only admins can mint. require(!paused || admins[msg.sender], "paused"); require(_balances.length == _amounts.length, "invalid amounts"); uint256 A = getA(); uint256 oldD = totalSupply; uint256 i = 0; for (i = 0; i < _balances.length; i++) { if (address(this).balance == 0) { //inject PRESENT ETHER // Initial deposit requires all tokens provided! require(oldD > 0, "zero amount"); continue; } _balances[i] = _balances[i].add(_amounts[i].mul(precisions[i])); } uint256 newD = _getD(_balances, A); // newD should be bigger than or equal to oldD uint256 mintAmount = newD.sub(oldD); uint256 fee = mintFee; uint256 feeAmount; if (fee > 0) { feeAmount = mintAmount.mul(fee).div(feeDenominator); mintAmount = mintAmount.sub(feeAmount); } require(mintAmount >= _minMintAmount, "fewer than expected"); // Transfer tokens into the swap for (i = 0; i < _amounts.length; i++) { if (address(this).balance == 0) continue; //inject PRESENT ETHER // Update the balance in storage balances[i] = _balances[i]; IERC20(tokens[i]).safeTransferFrom(msg.sender, address(this), _amounts[i]); } totalSupply = newD; IERC20MintableBurnable(poolToken).mint(feeRecipient, feeAmount); IERC20MintableBurnable(poolToken).mint(msg.sender, mintAmount); emit Minted(msg.sender, mintAmount, _amounts, feeAmount); } /** * @dev Computes the output amount after the swap. * @param _i Token index to swap in. * @param _j Token index to swap out. * @param _dx Unconverted amount of token _i to swap in. * @return Unconverted amount of token _j to swap out. */ function getSwapAmount(uint256 _i, uint256 _j, uint256 _dx) external view returns (uint256) { uint256[] memory _balances = balances; require(_i != _j, "same token"); require(_i < _balances.length, "invalid in"); require(_j < _balances.length, "invalid out"); require(_dx > 0, "invalid amount"); uint256 A = getA(); uint256 D = totalSupply; // balance[i] = balance[i] + dx * precisions[i] _balances[_i] = _balances[_i].add(_dx.mul(precisions[_i])); uint256 y = _getY(_balances, _j, D, A); // dy = (balance[j] - y - 1) / precisions[j] in case there was rounding errors uint256 dy = _balances[_j].sub(y).sub(1).div(precisions[_j]); if (swapFee > 0) { dy = dy.sub(dy.mul(swapFee).div(feeDenominator)); } return dy; } /** * @dev Exchange between two underlying tokens. * @param _i Token index to swap in. * @param _j Token index to swap out. * @param _dx Unconverted amount of token _i to swap in. * @param _minDy Minimum token _j to swap out in converted balance. */ function swap(uint256 _i, uint256 _j, uint256 _dx, uint256 _minDy) external nonReentrant { uint256[] memory _balances = balances; // If swap is paused, only admins can swap. require(!paused || admins[msg.sender], "paused"); require(_i != _j, "same token"); require(_i < _balances.length, "invalid in"); require(_j < _balances.length, "invalid out"); require(_dx > 0, "invalid amount"); uint256 A = getA(); uint256 D = totalSupply; // balance[i] = balance[i] + dx * precisions[i] _balances[_i] = _balances[_i].add(_dx.mul(precisions[_i])); uint256 y = _getY(_balances, _j, D, A); // dy = (balance[j] - y - 1) / precisions[j] in case there was rounding errors uint256 dy = _balances[_j].sub(y).sub(1).div(precisions[_j]); // Update token balance in storage balances[_j] = y; balances[_i] = _balances[_i]; uint256 fee = swapFee; if (fee > 0) { dy = dy.sub(dy.mul(fee).div(feeDenominator)); } require(dy >= _minDy, "fewer than expected"); IERC20(tokens[_i]).safeTransferFrom(msg.sender, address(this), _dx); // Important: When swap fee > 0, the swap fee is charged on the output token. // Therefore, balances[j] < tokens[j].balanceOf(this) // Since balances[j] is used to compute D, D is unchanged. // collectFees() is used to convert the difference between balances[j] and tokens[j].balanceOf(this) // into pool token as fees! IERC20(tokens[_j]).safeTransfer(msg.sender, dy); emit TokenSwapped(msg.sender, tokens[_i], tokens[_j], _dx, dy); } /** * @dev Computes the amounts of underlying tokens when redeeming pool token. * @param _amount Amount of pool tokens to redeem. * @return Amounts of underlying tokens redeemed. */ function getRedeemProportionAmount(uint256 _amount) external view returns (uint256[] memory, uint256) { uint256[] memory _balances = balances; require(_amount > 0, "zero amount"); uint256 D = totalSupply; uint256[] memory amounts = new uint256[](_balances.length); uint256 feeAmount = 0; if (redeemFee > 0) { feeAmount = _amount.mul(redeemFee).div(feeDenominator); // Redemption fee is charged with pool token before redemption. _amount = _amount.sub(feeAmount); } for (uint256 i = 0; i < _balances.length; i++) { // We might choose to use poolToken.totalSupply to compute the amount, but decide to use // D in case we have multiple minters on the pool token. amounts[i] = _balances[i].mul(_amount).div(D).div(precisions[i]); } return (amounts, feeAmount); } /** * @dev Redeems pool token to underlying tokens proportionally. * @param _amount Amount of pool token to redeem. * @param _minRedeemAmounts Minimum amount of underlying tokens to get. */ function redeemProportion(uint256 _amount, uint256[] calldata _minRedeemAmounts) external nonReentrant { uint256[] memory _balances = balances; // If swap is paused, only admins can redeem. require(!paused || admins[msg.sender], "paused"); require(_amount > 0, "zero amount"); require(_balances.length == _minRedeemAmounts.length, "invalid mins"); uint256 D = totalSupply; uint256[] memory amounts = new uint256[](_balances.length); uint256 fee = redeemFee; uint256 feeAmount; if (fee > 0) { feeAmount = _amount.mul(fee).div(feeDenominator); // Redemption fee is paid with pool token // No conversion is needed as the pool token has 18 decimals IERC20(poolToken).safeTransferFrom(msg.sender, feeRecipient, feeAmount); _amount = _amount.sub(feeAmount); } for (uint256 i = 0; i < _balances.length; i++) { // We might choose to use poolToken.totalSupply to compute the amount, but decide to use // D in case we have multiple minters on the pool token. uint256 tokenAmount = _balances[i].mul(_amount).div(D); // Important: Underlying tokens must convert back to original decimals! amounts[i] = tokenAmount.div(precisions[i]); require(amounts[i] >= _minRedeemAmounts[i], "fewer than expected"); // Updates the balance in storage balances[i] = _balances[i].sub(tokenAmount); IERC20(tokens[i]).safeTransfer(msg.sender, amounts[i]); } totalSupply = D.sub(_amount); // After reducing the redeem fee, the remaining pool tokens are burned! IERC20MintableBurnable(poolToken).burnFrom(msg.sender, _amount); emit Redeemed(msg.sender, _amount.add(feeAmount), amounts, feeAmount); } /** * @dev Computes the amount when redeeming pool token to one specific underlying token. * @param _amount Amount of pool token to redeem. * @param _i Index of the underlying token to redeem to. * @return Amount of underlying token that can be redeem to. */ function getRedeemSingleAmount(uint256 _amount, uint256 _i) external view returns (uint256, uint256) { uint256[] memory _balances = balances; require(_amount > 0, "zero amount"); require(_i < _balances.length, "invalid token"); uint256 A = getA(); uint256 D = totalSupply; uint256 feeAmount = 0; if (redeemFee > 0) { feeAmount = _amount.mul(redeemFee).div(feeDenominator); // Redemption fee is charged with pool token before redemption. _amount = _amount.sub(feeAmount); } // The pool token amount becomes D - _amount uint256 y = _getY(_balances, _i, D.sub(_amount), A); // dy = (balance[i] - y - 1) / precisions[i] in case there was rounding errors uint256 dy = _balances[_i].sub(y).sub(1).div(precisions[_i]); return (dy, feeAmount); } /** * @dev Redeem pool token to one specific underlying token. * @param _amount Amount of pool token to redeem. * @param _i Index of the token to redeem to. * @param _minRedeemAmount Minimum amount of the underlying token to redeem to. */ function redeemSingle(uint256 _amount, uint256 _i, uint256 _minRedeemAmount) external nonReentrant { uint256[] memory _balances = balances; // If swap is paused, only admins can redeem. require(!paused || admins[msg.sender], "paused"); require(_amount > 0, "zero amount"); require(_i < _balances.length, "invalid token"); uint256 A = getA(); uint256 D = totalSupply; uint256 fee = redeemFee; uint256 feeAmount = 0; if (fee > 0) { // Redemption fee is charged with pool token before redemption. feeAmount = _amount.mul(fee).div(feeDenominator); // No conversion is needed as the pool token has 18 decimals IERC20(poolToken).safeTransferFrom(msg.sender, feeRecipient, feeAmount); _amount = _amount.sub(feeAmount); } // y is converted(18 decimals) uint256 y = _getY(_balances, _i, D.sub(_amount), A); // dy is not converted // dy = (balance[i] - y - 1) / precisions[i] in case there was rounding errors uint256 dy = _balances[_i].sub(y).sub(1).div(precisions[_i]); require(dy >= _minRedeemAmount, "fewer than expected"); // Updates token balance in storage balances[_i] = y; uint256[] memory amounts = new uint256[](_balances.length); amounts[_i] = dy; IERC20(tokens[_i]).safeTransfer(msg.sender, dy); totalSupply = D.sub(_amount); IERC20MintableBurnable(poolToken).burnFrom(msg.sender, _amount); emit Redeemed(msg.sender, _amount.add(feeAmount), amounts, feeAmount); } /** * @dev Compute the amount of pool token that needs to be redeemed. * @param _amounts Unconverted token balances. * @return The amount of pool token that needs to be redeemed. */ function getRedeemMultiAmount(uint256[] calldata _amounts) external view returns (uint256, uint256) { uint256[] memory _balances = balances; require(_amounts.length == balances.length, "length not match"); uint256 A = getA(); uint256 oldD = totalSupply; for (uint256 i = 0; i < _balances.length; i++) { if (address(this).balance == 0) continue; //inject PRESENT ETHER // balance = balance + amount * precision _balances[i] = _balances[i].sub(_amounts[i].mul(precisions[i])); } uint256 newD = _getD(_balances, A); // newD should be smaller than or equal to oldD uint256 redeemAmount = oldD.sub(newD); uint256 feeAmount = 0; if (redeemFee > 0) { redeemAmount = redeemAmount.mul(feeDenominator).div(feeDenominator.sub(redeemFee)); feeAmount = redeemAmount.sub(oldD.sub(newD)); } return (redeemAmount, feeAmount); } /** * @dev Redeems underlying tokens. * @param _amounts Amounts of underlying tokens to redeem to. * @param _maxRedeemAmount Maximum of pool token to redeem. */ function redeemMulti(uint256[] calldata _amounts, uint256 _maxRedeemAmount) external nonReentrant { uint256[] memory _balances = balances; require(_amounts.length == balances.length, "length not match"); // If swap is paused, only admins can redeem. require(!paused || admins[msg.sender], "paused"); uint256 A = getA(); uint256 oldD = totalSupply; uint256 i = 0; for (i = 0; i < _balances.length; i++) { if (address(this).balance == 0) continue; //inject PRESENT ETHER // balance = balance + amount * precision _balances[i] = _balances[i].sub(_amounts[i].mul(precisions[i])); } uint256 newD = _getD(_balances, A); // newD should be smaller than or equal to oldD uint256 redeemAmount = oldD.sub(newD); uint256 fee = redeemFee; uint256 feeAmount = 0; if (fee > 0) { redeemAmount = redeemAmount.mul(feeDenominator).div(feeDenominator.sub(fee)); feeAmount = redeemAmount.sub(oldD.sub(newD)); // No conversion is needed as the pool token has 18 decimals IERC20(poolToken).safeTransferFrom(msg.sender, feeRecipient, feeAmount); } require(redeemAmount <= _maxRedeemAmount, "more than expected"); // Updates token balances in storage. balances = _balances; uint256 burnAmount = redeemAmount.sub(feeAmount); totalSupply = oldD.sub(burnAmount); IERC20MintableBurnable(poolToken).burnFrom(msg.sender, burnAmount); for (i = 0; i < _balances.length; i++) { if (address(this).balance == 0) continue; //inject PRESENT ETHER IERC20(tokens[i]).safeTransfer(msg.sender, _amounts[i]); } emit Redeemed(msg.sender, redeemAmount, _amounts, feeAmount); } /** * @dev Return the amount of fee that's not collected. */ function getPendingFeeAmount() external view returns (uint256) { uint256[] memory _balances = balances; uint256 A = getA(); uint256 oldD = totalSupply; for (uint256 i = 0; i < _balances.length; i++) { _balances[i] = IERC20(tokens[i]).balanceOf(address(this)).mul(precisions[i]); } uint256 newD = _getD(_balances, A); return newD.sub(oldD); } /** * @dev Collect fee based on the token balance difference. */ function collectFee() external returns (uint256) { require(admins[msg.sender], "not admin"); uint256[] memory _balances = balances; uint256 A = getA(); uint256 oldD = totalSupply; for (uint256 i = 0; i < _balances.length; i++) { _balances[i] = IERC20(tokens[i]).balanceOf(address(this)).mul(precisions[i]); } uint256 newD = _getD(_balances, A); uint256 feeAmount = newD.sub(oldD); if (address(this).balance == 0) return 0; //inject PRESENT ETHER balances = _balances; totalSupply = newD; address _feeRecipient = feeRecipient; IERC20MintableBurnable(poolToken).mint(_feeRecipient, feeAmount); emit FeeCollected(_feeRecipient, feeAmount); return feeAmount; } /** * @dev Updates the govenance address. */ function setGovernance(address _governance) external { require(msg.sender == governance, "not governance"); governance = _governance; } /** * @dev Updates the mint fee. */ function setMintFee(uint256 _mintFee) external { require(msg.sender == governance, "not governance"); mintFee = _mintFee; } /** * @dev Updates the swap fee. */ function setSwapFee(uint256 _swapFee) external { require(msg.sender == governance, "not governance"); swapFee = _swapFee; } /** * @dev Updates the redeem fee. */ function setRedeemFee(uint256 _redeemFee) external { require(msg.sender == governance, "not governance"); redeemFee = _redeemFee; } /** * @dev Updates the recipient of mint/swap/redeem fees. */ function setFeeRecipient(address _feeRecipient) external { require(msg.sender == governance, "not governance"); require(_feeRecipient != address(0x0), "fee recipient not set"); feeRecipient = _feeRecipient; } /** * @dev Updates the pool token. */ function setPoolToken(address _poolToken) external { require(msg.sender == governance, "not governance"); require(_poolToken != address(0x0), "pool token not set"); poolToken = _poolToken; } /** * @dev Pause mint/swap/redeem actions. Can unpause later. */ function pause() external { require(msg.sender == governance, "not governance"); require(!paused, "paused"); paused = true; } /** * @dev Unpause mint/swap/redeem actions. */ function unpause() external { require(msg.sender == governance, "not governance"); require(paused, "not paused"); paused = false; } /** * @dev Updates the admin role for the address. * @param _account Address to update admin role. * @param _allowed Whether the address is granted the admin role. */ function setAdmin(address _account, bool _allowed) external { require(msg.sender == governance, "not governance"); require(_account != address(0x0), "account not set"); admins[_account] = _allowed; } } // contract CurveRenCrvMigrator is IMigrator { using SafeERC20 for IERC20; address public constant override want = address(0x49849C98ae39Fff122806C06791Fa73784FB3675); // renCrv token address public constant override get = address(0xeF6e45af9a422c5469928F927ca04ed332322e2e); // acBTC address public constant wbtc = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); // WBTC token address public constant renbtc = address(0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D); // renBTC token address public constant acSwap = address(0x73FddFb941c11d16C827169Bb94aCC227841C396); // ACoconutSwap (proxy) address public constant acVault = address(0x1eB47C01cfAb26D2346B449975b7BF20a34e0d45); // acBTC vault address public constant curve = address(0x93054188d876f558f4a66B2EF1d97d16eDf0895B); // REN swap /** * @dev Performs the token migration. Only acBTC vault can trigger the migration. */ function migrate() public override { require(msg.sender == acVault, "not vault"); uint256 _want = IERC20(want).balanceOf(address(this)); // renCrv balance IERC20(want).safeApprove(curve, _want); if (_want > 0) { ICurveFi(curve).remove_liquidity(_want, [uint256(0), 0]); } uint256 _wbtc = IERC20(wbtc).balanceOf(address(this)); uint256 _renbtc = IERC20(renbtc).balanceOf(address(this)); // The initial deposit requires both WBTC and RenBTC. if (_wbtc > 0 && _renbtc > 0) { IERC20(wbtc).safeApprove(acSwap, _wbtc); IERC20(renbtc).safeApprove(acSwap, _renbtc); // WBTC is the first token and renBTC is the second! uint256[] memory amounts = new uint256[](2); amounts[0] = _wbtc; amounts[1] = _renbtc; ACoconutSwap(acSwap).mint(amounts, 0); } uint256 _get = IERC20(get).balanceOf(address(this)); // acBTC balance if (_get > 0) { IERC20(get).safeTransfer(acVault, _get); } } }
* @dev Updates the swap fee./
function setSwapFee(uint256 _swapFee) external { require(msg.sender == governance, "not governance"); swapFee = _swapFee; }
12,730,987
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 15419, 326, 7720, 14036, 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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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 ]
[ 1, 565, 445, 444, 12521, 14667, 12, 11890, 5034, 389, 22270, 14667, 13, 3903, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 314, 1643, 82, 1359, 16, 315, 902, 314, 1643, 82, 1359, 8863, 203, 3639, 7720, 14667, 273, 389, 22270, 14667, 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 ]
pragma solidity ^0.5.3; import "contracts/AnchorRepository.sol"; /** * @title MockAnchorRepository * This mock is for easy testing purposes of an anchor Repository * that goes hand in hand with a mintable ERC721 contract */ contract MockAnchorRepository { // A simplistic representation of a document anchor struct Anchor { bytes32 documentRoot; uint32 anchoredBlock; } mapping(uint256 => Anchor) private _anchors; /** * @dev Sets the anchor details for a document. * @param anchorId bytes32 The document anchor identifier * @param documentRoot bytes32 The root hash of document */ function setAnchorById(uint256 anchorId, bytes32 documentRoot) external { // not allowing empty vals require(anchorId != 0x0); require(documentRoot != 0x0); _anchors[anchorId] = Anchor(documentRoot, uint32(block.number)); } /** * @dev Gets the anchor details for a document. * @param id bytes32 The document anchor identifier * @return identifier bytes32 The document anchor identifier as found * @return merkleRoot bytes32 The document's root hash value */ function getAnchorById (uint256 id) public view returns ( uint256 identifier, bytes32 merkleRoot, uint32 anchoredBlock ) { return ( id, _anchors[id].documentRoot, _anchors[id].anchoredBlock ); } }
* @dev Gets the anchor details for a document. @param id bytes32 The document anchor identifier @return identifier bytes32 The document anchor identifier as found @return merkleRoot bytes32 The document's root hash value/
function getAnchorById (uint256 id) public view returns ( uint256 identifier, bytes32 merkleRoot, uint32 anchoredBlock ) { return ( id, _anchors[id].documentRoot, _anchors[id].anchoredBlock ); }
12,749,747
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 11881, 326, 6984, 3189, 364, 279, 1668, 18, 632, 891, 612, 1731, 1578, 1021, 1668, 6984, 2756, 632, 2463, 2756, 1731, 1578, 1021, 1668, 6984, 2756, 487, 1392, 632, 2463, 30235, 2375, 1731, 1578, 1021, 1668, 1807, 1365, 1651, 460, 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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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 ]
[ 1, 225, 445, 336, 11605, 5132, 261, 11890, 5034, 612, 13, 203, 225, 1071, 203, 225, 1476, 203, 225, 1135, 261, 203, 565, 2254, 5034, 2756, 16, 203, 565, 1731, 1578, 30235, 2375, 16, 203, 565, 2254, 1578, 392, 343, 7653, 1768, 203, 565, 262, 203, 225, 288, 203, 565, 327, 261, 203, 1377, 612, 16, 203, 1377, 389, 304, 15482, 63, 350, 8009, 5457, 2375, 16, 203, 1377, 389, 304, 15482, 63, 350, 8009, 304, 343, 7653, 1768, 203, 565, 11272, 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 ]
// SPDX-License-Identifier: CC-BY-4.0 pragma solidity >=0.4.22 <0.9.0; import "../../common/Version.sol"; import "../../common/Owned.sol"; contract ExemptDebtOffering is Version, Owned { bytes32 constant private ZERO_BYTES = bytes32(0); address constant private ZERO_ADDRESS = address(0); address[] internal stakeholders; mapping(address => bytes32) private verified; mapping(address => address) private cancellations; mapping(address => uint256) private holderIndices; mapping(address => mapping(uint256 => mapping(uint256 => uint256))) public balances; address private owner; string[] public _Symbol; mapping (uint256 => uint256) public _Fibonacci_number; mapping (uint256 => uint256) public _Fibonacci_epoch; mapping (uint256 => uint256) public _genesis_nonce_time; mapping (uint256 => mapping(uint256 => uint256)) private _totalSupply; mapping (uint256 => mapping(uint256 => uint256)) private _activeSupply; mapping (uint256 => mapping(uint256 => uint256)) private _burnedSupply; mapping (uint256 => mapping(uint256 => uint256)) private _redeemedSupply; mapping (uint256 => mapping(uint256 => mapping(uint256 => uint256))) private _info; address[] private _bankAddress; mapping (uint256 => uint256[]) private _nonceCreated; mapping (uint256 => uint256) private last_bond_nonce; address public dev_address=msg.sender; event eventIssueBond(address sender,address _to,uint256 class,uint256 nonce,uint256 _amount); event eventRedeemBond(address sender,address _from,uint256 class,uint256 nonce,uint256 _amount); event eventTransferBond(address sender,address _from,address _to,uint256 class,uint256 nonce,uint256 _amount); event eventBurnBond(address sender,address _from,uint256 class,uint256 nonce,uint256 _amount); constructor() { _Symbol[0] = "SASH-USD Bond"; _Fibonacci_number[0] = 8; _Fibonacci_epoch[0] = 1; _genesis_nonce_time[0] = 0; } function setBond(uint256 class, address bank_contract, bytes32 encrypted, bytes memory signature) public payable onlyOwner(encrypted,signature) returns (bool) { _bankAddress[class] = bank_contract; return true; } function getNonceCreated(uint256 class) public view returns (uint256[] memory) { return _nonceCreated[class]; } function createBondClass( uint256 class, address bank_contract, string memory bond_symbol, uint256 Fibonacci_number, uint256 Fibonacci_epoch, bytes32 encrypted, bytes memory signature) public onlyOwner(encrypted,signature) returns (bool) { _Symbol[class] = bond_symbol; _bankAddress[class] = bank_contract; _Fibonacci_number[class] = Fibonacci_number; _Fibonacci_epoch[class] = Fibonacci_epoch; _genesis_nonce_time[class] = 0; return true; } function totalSupply( uint256 class, uint256 nonce) public view returns (uint256) { return _activeSupply[class][nonce]+_burnedSupply[class][nonce]+_redeemedSupply[class][nonce]; } function activeSupply( uint256 class, uint256 nonce) public view returns (uint256) { return _activeSupply[class][nonce]; } function burnedSupply( uint256 class, uint256 nonce) public view returns (uint256) { return _burnedSupply[class][nonce]; } function redeemedSupply( uint256 class, uint256 nonce) public view returns (uint256) { return _redeemedSupply[class][nonce]; } function balanceOf(address account, uint256 class, uint256 nonce) public view returns (uint256) { require(account != address(0), "balance query for the zero address"); return balances[account][class][nonce]; } function getBondSymbol(uint256 class) public view returns (string memory) { return _Symbol[class]; } function getBondInfo(uint256 class,uint256 nonce) public view returns ( string memory BondSymbol, uint256 timestamp, uint256 info2, uint256 info3, uint256 info4, uint256 info5, uint256 info6) { BondSymbol = _Symbol[class]; timestamp = _info[class][nonce][1]; info2 = _info[class][nonce][2]; info3 = _info[class][nonce][3]; info4 = _info[class][nonce][4]; info5 = _info[class][nonce][5]; info6 = _info[class][nonce][6]; } function bondIsRedeemable(uint256 class, uint256 nonce, uint256 epoch) public view returns (bool) { if(uint(_info[class][nonce][1]) < epoch) { uint256 total_liquidity; uint256 needed_liquidity; //uint256 available_liquidity; for (uint i = 0; i <= last_bond_nonce[class]; i++) { total_liquidity += _activeSupply[class][i]+_redeemedSupply[class][i]; } for (uint i = 0; i <= nonce; i++) { needed_liquidity += (_activeSupply[class][i]+_redeemedSupply[class][i])*2; } if (total_liquidity >= needed_liquidity) { return(true); } else{ return(false); } } else { return(false); } } function _createBond(address _to, uint256 class, uint256 nonce, uint256 _amount) private returns(bool) { if(last_bond_nonce[class]<nonce) { last_bond_nonce[class] = nonce; } _nonceCreated[class].push(nonce); _info[class][nonce][1] = _genesis_nonce_time[class] + (nonce) * _Fibonacci_epoch[class]; balances[_to][class][nonce] += _amount; _activeSupply[class][nonce] += _amount; emit eventIssueBond(msg.sender, _to, class,nonce, _amount); return(true); } function _issueBond(address _to, uint256 class, uint256 nonce, uint256 _amount) private returns(bool) { if (totalSupply(class,nonce)==0){ _createBond(_to,class,nonce,_amount); return(true); } else { balances[_to][class][nonce] += _amount; _activeSupply[class][nonce] += _amount; emit eventIssueBond(msg.sender, _to, class,last_bond_nonce[class], _amount); return(true); } } function _redeemBond(address _from, uint256 class, uint256 nonce, uint256 _amount) private returns(bool) { balances[_from][class][nonce] -= _amount; _activeSupply[class][nonce] -= _amount; _redeemedSupply[class][nonce] += _amount; emit eventRedeemBond(msg.sender,_from, class, nonce, _amount); return(true); } function _transferBond(address _from, address _to, uint256 class, uint256 nonce, uint256 _amount) private returns(bool) { balances[_from][class][nonce] -= _amount; balances[_to][class][nonce] += _amount; emit eventTransferBond(msg.sender,_from,_to, class, nonce, _amount); return(true); } function _burnBond(address _from, uint256 class, uint256 nonce, uint256 _amount) private returns(bool) { balances[_from][class][nonce] -= _amount; emit eventBurnBond(msg.sender,_from, class, nonce, _amount); return(true); } function issueBond(address _to, uint256 class, uint256 _amount, uint256 epoch) external returns(bool) { require(msg.sender==_bankAddress[class], "operator unauthorized"); require(_to != address(0), "issue bond to the zero address"); require(_amount >= 100, "invalid amount"); if (_genesis_nonce_time[class] == 0) { _genesis_nonce_time[class] = epoch % _Fibonacci_epoch[class]; } uint256 now_nonce = (epoch - _genesis_nonce_time[class]) / _Fibonacci_epoch[class]; uint256 FibonacciTimeEponge0 = 1; uint256 FibonacciTimeEponge1 = 2; uint256 FibonacciTimeEponge; uint256 amount_out_eponge; for (uint i = 0; i < _Fibonacci_number[class]; i++) { if(i == 0) { FibonacciTimeEponge = 1; } else { if (i==1) { FibonacciTimeEponge = 2; } else{ FibonacciTimeEponge = (FibonacciTimeEponge0+FibonacciTimeEponge1); FibonacciTimeEponge0 = FibonacciTimeEponge1; FibonacciTimeEponge1 = FibonacciTimeEponge; } } amount_out_eponge += FibonacciTimeEponge; } amount_out_eponge = _amount*1e3/amount_out_eponge; FibonacciTimeEponge = 0; FibonacciTimeEponge0 = 1; FibonacciTimeEponge1 = 2; for (uint i = 0; i < _Fibonacci_number[class]; i++) { if (i == 0) { FibonacciTimeEponge = 1; } else { if (i==1) { FibonacciTimeEponge = 2; } else { FibonacciTimeEponge = (FibonacciTimeEponge0 + FibonacciTimeEponge1); FibonacciTimeEponge0 = FibonacciTimeEponge1; FibonacciTimeEponge1 = FibonacciTimeEponge; } } require(_issueBond(_to, class, now_nonce + FibonacciTimeEponge, amount_out_eponge * FibonacciTimeEponge/1e3) == true,""); } return(true); } function redeemBond(address _from, uint256 class, uint256[] calldata nonce, uint256[] calldata _amount, uint256 epoch) external returns(bool) { require(msg.sender==_bankAddress[class] || msg.sender==_from, "ERC659: operator unauthorized"); for (uint i = 0; i < nonce.length; i++) { require(balances[_from][class][nonce[i]] >= _amount[i], "ERC659: not enough bond for redemption"); require(bondIsRedeemable(class,nonce[i],epoch)==true, "ERC659: can't redeem bond before it's redemption day"); require(_redeemBond(_from,class,nonce[i],_amount[i]),""); } return(true); } function transferBond(address _from, address _to, uint256[] calldata class, uint256[] calldata nonce, uint256[] calldata _amount) external returns(bool) { for (uint n = 0; n < nonce.length; n++) { require(msg.sender==_bankAddress[class[n]] || msg.sender==_from, "operator unauthorized"); require(balances[_from][class[n]][nonce[n]] >= _amount[n], "not enough bond to transfer"); require(_to!=address(0), "cant't transfer to zero bond, use 'burnBond()' instead"); require(_transferBond(_from, _to, class[n], nonce[n], _amount[n]),""); } return(true); } function burnBond(address _from, uint256[] calldata class, uint256[] calldata nonce, uint256[] calldata _amount) external returns(bool) { for (uint n = 0; n < nonce.length; n++) { require(msg.sender==_bankAddress[class[n]] || msg.sender==_from, "operator unauthorized"); require(balances[_from][class[n]][nonce[n]] >= _amount[n], "not enough bond to burn"); require(_burnBond(_from, class[n], nonce[n], _amount[n]),""); } return(true); } }
uint256 available_liquidity;
function bondIsRedeemable(uint256 class, uint256 nonce, uint256 epoch) public view returns (bool) { if(uint(_info[class][nonce][1]) < epoch) { uint256 total_liquidity; uint256 needed_liquidity; for (uint i = 0; i <= last_bond_nonce[class]; i++) { total_liquidity += _activeSupply[class][i]+_redeemedSupply[class][i]; } for (uint i = 0; i <= nonce; i++) { needed_liquidity += (_activeSupply[class][i]+_redeemedSupply[class][i])*2; } if (total_liquidity >= needed_liquidity) { return(true); return(false); } return(false); } }
12,957,906
[ 1, 4625, 348, 7953, 560, 30, 2254, 5034, 2319, 67, 549, 372, 24237, 31, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 8427, 2520, 426, 24903, 429, 12, 11890, 5034, 667, 16, 2254, 5034, 7448, 16, 2254, 5034, 7632, 13, 203, 565, 1071, 203, 565, 1476, 203, 565, 1135, 261, 6430, 13, 203, 225, 288, 203, 565, 309, 12, 11890, 24899, 1376, 63, 1106, 6362, 12824, 6362, 21, 5717, 411, 7632, 13, 288, 203, 1377, 2254, 5034, 2078, 67, 549, 372, 24237, 31, 203, 1377, 2254, 5034, 3577, 67, 549, 372, 24237, 31, 203, 1377, 364, 261, 11890, 277, 273, 374, 31, 277, 1648, 1142, 67, 26425, 67, 12824, 63, 1106, 15533, 277, 27245, 288, 203, 3639, 2078, 67, 549, 372, 24237, 1011, 389, 3535, 3088, 1283, 63, 1106, 6362, 77, 3737, 67, 266, 24903, 329, 3088, 1283, 63, 1106, 6362, 77, 15533, 203, 1377, 289, 203, 1377, 364, 261, 11890, 277, 273, 374, 31, 277, 1648, 7448, 31, 277, 27245, 288, 203, 1850, 3577, 67, 549, 372, 24237, 1011, 261, 67, 3535, 3088, 1283, 63, 1106, 6362, 77, 3737, 67, 266, 24903, 329, 3088, 1283, 63, 1106, 6362, 77, 5717, 14, 22, 31, 203, 1850, 289, 203, 1377, 309, 261, 4963, 67, 549, 372, 24237, 1545, 3577, 67, 549, 372, 24237, 13, 288, 203, 1850, 327, 12, 3767, 1769, 203, 1850, 327, 12, 5743, 1769, 203, 1377, 289, 203, 1377, 327, 12, 5743, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/84531/0x3CC6ba057f394B00aC1fF48707d5C04DE29504C6/sources/src/token/types/TokenTypesV1.sol
@notice The founder type @param wallet The address where tokens are sent @param ownershipPct The percentage of token ownership @param vestExpiry The timestamp when vesting ends
struct Founder { address wallet; uint8 ownershipPct; uint32 vestExpiry; }
14,322,927
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 1021, 284, 465, 765, 618, 632, 891, 9230, 1021, 1758, 1625, 2430, 854, 3271, 632, 891, 23178, 52, 299, 1021, 11622, 434, 1147, 23178, 632, 891, 331, 395, 14633, 1021, 2858, 1347, 331, 10100, 3930, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 1958, 478, 465, 765, 288, 203, 3639, 1758, 9230, 31, 203, 3639, 2254, 28, 23178, 52, 299, 31, 203, 3639, 2254, 1578, 331, 395, 14633, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
<!DOCTYPE html> <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" integrity="sha512-E9wnWjoxQmh5A1jiWVYDPKOvA8VPf0iKQYoc+9ycMJvtAi9gOSlaUci+W2smxFIlWkV8hkX+O27S8NIB59iIDw==" rel="stylesheet" href="https://github.githubassets.com/assets/light-13dc275a3a314268790358e25956033c.css" /><link crossorigin="anonymous" media="all" integrity="sha512-nYSv3KrFhMlGUpjkFQBLMEN6HvHhijcoubQLjV3DWlcABEi2yDYf6KGUjRubJ5R+dJnKXR7jA4wu5Dg200SApA==" rel="stylesheet" href="https://github.githubassets.com/assets/dark-9d84afdcaac584c9465298e415004b30.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" integrity="sha512-73MN8RaWLT6hOrTrxNJOEI8Pb0ArN01fXatO0tqm/qXy73XBb0FG3f8jd0NfztcQGoLTDF6Pl6AxpbnDvgwAiA==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-ef730df116962d3ea13ab4ebc4d24e10.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" integrity="sha512-bOhGZNmild3wSbSBnXK4FdlotedKfGpLBrn2ws0dSVZZaZmQcYoGvkvl1M6L82kHTBkHjonl5pIpbQ9Q066xCw==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-6ce84664d9a295ddf049b4819d72b815.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" integrity="sha512-AwOAfDuSE0kUy1kcP+UA/Gj0G3V2UahdhGF/3XKhrgH+rX5j33z3/p8INmxmpC1TF1XDDPjwJAmvCECOdgDCNw==" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-0303807c3b92134914cb591c3fe500fc.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" integrity="sha512-MTr0RUpwD911150L11H/RfSf+jCC9M4JQt6f3rFBXTMZZop9I/2FqEUXDYYBLnTqXTel4Ost6mblHDW5IK7Q5Q==" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-313af4454a700fdd75d79d0bd751ff45.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" integrity="sha512-YtCQQI4gi5fOKm9+JR5jGw5IqvUk4NlWG6r0YRx3SGXtNYMNuVXlTT3X1HZczk1u9vhCYsMevrnz5FfY2lZyWg==" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-62d090408e208b97ce2a6f7e251e631b.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-zw7LEKJYRly65tkoCHN9EKkBSW87oNvS/W1iwFRH5uw6orvEHdej1Pom9Hx20gdv+RhaXzHW/3h0QjuAlkhynQ==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-cf0ecb10a258465cbae6d92808737d10.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-3UPEO6tpXvbFw23ugE4YF8phTQsG9oq8uDCXLoSq+OurPsH67A8KDMQjHdrbq7C+afONNyrU+Pl71+ATEOlqUQ==" rel="stylesheet" href="https://github.githubassets.com/assets/behaviors-dd43c43bab695ef6c5c36dee804e1817.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-MCJFYfbQoT4EXC6aWx5Wghs8FC/jslHEeN2iWXphliccmede2dQlhIBTAUCBq9Yu5poltu4askungzvyCsycGg==" rel="stylesheet" href="https://github.githubassets.com/assets/tab-size-fix-30224561f6d0a13e045c2e9a5b1e5682.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-ZDCoa3tPoCSCkjoc2jvnpZcDgMVmty5RSsIUN3C/8VP4dXUQD7GDWY54Jzk0ne3p1Tl/8joE0rzQIWY3r26bvQ==" rel="stylesheet" href="https://github.githubassets.com/assets/github-6430a86b7b4fa02482923a1cda3be7a5.css" /> <script crossorigin="anonymous" defer="defer" integrity="sha512-K/kjAAGVhlckApEbskyYOB+ASq3m0GKyJk3y0JoEafwknEbUpmilodEuQQJG09c0v1eCRlX7mSQp+GLGtXmWQg==" type="application/javascript" src="https://github.githubassets.com/assets/environment-2bf92300.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-1QzqMFpBSwRfpLwNjvy7HzWppDH5803c5jyN6K064fvAC/TiKaQF+MiwGcGeEhujqfLnL3lX15BKt2RqSzwlSg==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-frameworks-d50cea30.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-VCprQIl55Uv72iPpYaNMju6N2rRE1xqFzT84jOqw0wBSN37ACO/9V0zgV6w6GwbQkAU/XF+n82OWwtjEQ5fV6Q==" type="application/javascript" src="https://github.githubassets.com/assets/chunk-vendor-542a6b40.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Cob7ptaSJgnqGhNsK0iTvxZ88ZZNj1c7DNulCfmD6PoQSQ+pbDHzCn4v2ts7xmLCdi2ogqom36nXZDgyNSiPZQ==" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-0a86fba6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ODZJzCJpaOfusrIka5QVZQcPiO9LBGyrrMYjhhJWSLuCN5WbZ5xiEiiOPOKVu71dqygyRdB2TY7AKPA1J5hqdg==" type="application/javascript" data-module-id="./chunk-unveil.js" data-src="https://github.githubassets.com/assets/chunk-unveil-383649cc.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-emPgUbSwW9ezLCgRnTE7n4fbbfc/MqEEDHmnkmG61dTyjWKHTYKN4wN3OPS7SY0fwmSJ8mB5+gng2nZw4/HsUg==" type="application/javascript" data-module-id="./chunk-animate-on-scroll.js" data-src="https://github.githubassets.com/assets/chunk-animate-on-scroll-7a63e051.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ocfEAp6AJvGh4otXKow+AVJ14ysircwHagMkRQ3hoQvuy/U9agyT1cYKYiSYph1VLNaI/aAXwVd2go1pb3DD8A==" type="application/javascript" data-module-id="./chunk-input-demux.js" data-src="https://github.githubassets.com/assets/chunk-input-demux-a1c7c402.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-tM2UlPYv6Z04ZoFXp/P+9sanpA9adLc2Y8CIfnVE7OvO0Z41BNLEyIIuxIE87D5su+5Q7HREnk5ZBKWPL8IOQg==" type="application/javascript" data-module-id="./chunk-ref-selector.js" data-src="https://github.githubassets.com/assets/chunk-ref-selector-b4cd9494.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-LsL0Q+kokbEkffjiD0xUiR97zM17wZBt8WBuQwLaLuWpKV3x9rkcZv+A295R8RXTbZuYWZ+OGIEhjSklQjK0vg==" type="application/javascript" data-module-id="./chunk-filter-input.js" data-src="https://github.githubassets.com/assets/chunk-filter-input-2ec2f443.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ynV5nM8UuCr4KZ/msFeRxRL6LnG+XUKzIfh6LNIzQ21ecjLVPvm53ghTE54aIuSUaHJWHnsYg8FRzycZIcRHiA==" type="application/javascript" data-module-id="./chunk-edit.js" data-src="https://github.githubassets.com/assets/chunk-edit-ca75799c.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-zFw83Br81EgtomfNYoZM5UzXZKrlobhEEuoVA0qrNwlcvMCD5X3q5pOtXVL16Uw0l/RRThOPPvBInoS+Gks8tQ==" type="application/javascript" data-module-id="./chunk-responsive-underlinenav.js" data-src="https://github.githubassets.com/assets/chunk-responsive-underlinenav-cc5c3cdc.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-gmw7obKL/JEHWPp6zWFh+ynbXUFOidj1DN2aPiTDwP8Gair0moVuDmA340LD84A29I3ZPak19CEiumG+oIiseg==" type="application/javascript" data-module-id="./chunk-tag-input.js" data-src="https://github.githubassets.com/assets/chunk-tag-input-826c3ba1.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Ao9llFIlj54ApuKf2QLboXukbu2h7MHfMmtYHrrsVe1lprKNLiA0usVcRpvruKhfT5STDuWm/GGmyx8ox27hWQ==" type="application/javascript" data-module-id="./chunk-notification-list-focus.js" data-src="https://github.githubassets.com/assets/chunk-notification-list-focus-028f6594.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-SPWd3rzrxmU6xW6vy1JPWCd+3uWFWmnd0MVGpmw/TpHWUAdLWDqL8kWyC/sBIZJmda4mTtUO1DHJQzAXRSrC+g==" type="application/javascript" data-module-id="./chunk-cookies.js" data-src="https://github.githubassets.com/assets/chunk-cookies-48f59dde.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4vVRplWFI7P4m3RHQ0QAhkq6eZUdtIE8PBhsKYJRwDkhQw9iK/U1st1/fM1tQZFuBFwGMyqaZblbWtQ+2ejcqQ==" type="application/javascript" data-module-id="./chunk-slug.js" data-src="https://github.githubassets.com/assets/chunk-slug-e2f551a6.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-MK53GXbb2BPV+ADlEbJbkrvg34WPcAd5RC2nBJhUH1tR/Mjr9xrsf56ptBajfWcIWKRKbqqRtLktgr0wAbB3zw==" type="application/javascript" data-module-id="./chunk-async-export.js" data-src="https://github.githubassets.com/assets/chunk-async-export-30ae7719.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-tw9SApiMkftVBYeb6/VGhEwGNw8tlyBhXc9RVXH4UbCD6u+48uuCMvXf3bxvBdOld0OoYg83SnD2mgJWhdaTiQ==" type="application/javascript" data-module-id="./chunk-premium-runners.js" data-src="https://github.githubassets.com/assets/chunk-premium-runners-b70f5202.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Lrm8u2MdzXjItcf94UC8RyxQRLxI99xOHX4lSm2/BeP3Qp/fY31KJsB/PK6jPRgAcV6MeGYFepWP8y1q2R4WUg==" type="application/javascript" data-module-id="./chunk-get-repo-element.js" data-src="https://github.githubassets.com/assets/chunk-get-repo-element-2eb9bcbb.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4rRDg68sT8HA9RRbb+k0JJtMxhKVklKcYNdpNPeLnVtuHlZQZQQcmUnm9SvJ9+F0+iJsBoMnhoQ9NQqcOy1yGg==" type="application/javascript" data-module-id="./chunk-prefetched-provider.js" data-src="https://github.githubassets.com/assets/chunk-prefetched-provider-e2b44383.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xhSAO0KtnFAlRqAK+mg8BPj/J334ccvnCmmjmBQBCgZcsoO9teHJSS6oAn3XOWYFsWPU2JehwG7S3OVEbLwdUg==" type="application/javascript" data-module-id="./chunk-color-modes.js" data-src="https://github.githubassets.com/assets/chunk-color-modes-c614803b.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-jitxouuFY6SUcDZV5W3jhadVEIfFBfCQZxfPV3kxNnsWEBzbxMJFp0ccLb7+OlBjSs1zU/MNtuOV6T9Ay7lx4w==" type="application/javascript" data-module-id="./chunk-copy.js" data-src="https://github.githubassets.com/assets/chunk-copy-8e2b71a2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-gwuBCPcczyGD5IyVEn/uqJXvT07GaVMryQC+ZfDhViO9r2JaqeAc4ooM3cVSjqo4m3IK6Y+boPI8MSf4mLlAgQ==" type="application/javascript" data-module-id="./chunk-voting.js" data-src="https://github.githubassets.com/assets/chunk-voting-830b8108.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-HDsLJf6gAN+WDFaJneJwmIY82XkZKWqeX7tStBLRh1XM53K8vMV6JZvjq/UQXszaNVWxWcuYtgYTG6ZWo8+QSw==" type="application/javascript" data-module-id="./chunk-confetti.js" data-src="https://github.githubassets.com/assets/chunk-confetti-1c3b0b25.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-vAs99bZfAF+pQjzGYSEM/dzYwm4SIxUxrcjdLuatAV6WJu/kfw8+s/SO7In/gHFhCR08sl7a38vA+dDmYAYHyQ==" type="application/javascript" data-module-id="./chunk-codemirror.js" data-src="https://github.githubassets.com/assets/chunk-codemirror-bc0b3df5.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Gr3ZcJt5t73JeBM3NwOEziKyDZ3HpHwzqZL/c1pgTUfo+6QC5f88XXRw/RT6X2diwqvaa3OVFh0oWsZ9ZxhtdQ==" type="application/javascript" data-module-id="./chunk-tip.js" data-src="https://github.githubassets.com/assets/chunk-tip-1abdd970.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EdQvlnI4Pu5Q6K0HCvp+mi0Vw9ZuwaEuhbnCbmFKX+c0xwiUWY0L3n9P0F6doLhaHhfpvW3718+miL11WG4BeA==" type="application/javascript" data-module-id="./chunk-line.js" data-src="https://github.githubassets.com/assets/chunk-line-11d42f96.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4zSHP2sQXPKoN9jFy8q2ThHsQNej8s4qhubSR4g0/2dTexAEnoTG+RbaffdIhmjfghGjpS/DlE0cdSTFEOcipQ==" type="application/javascript" data-module-id="./chunk-array.js" data-src="https://github.githubassets.com/assets/chunk-array-e334873f.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-g8fb6U7h9SkWgiK69nfNMn4aN5D2YBYPZUbCIuLpemWoOw8NOaZY8Z0hPq4RUVs4+bYdCFR6K719k8lwFeUijg==" type="application/javascript" data-module-id="./chunk-band.js" data-src="https://github.githubassets.com/assets/chunk-band-83c7dbe9.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-4GJz2wyWwjq7P4hyx3qSkjvnTO7RG5cWvnePVXPB+Oji6MBVugAdl7kCTKbpX8+Ae2ONvGJwFzSc9A7m1pqzXw==" type="application/javascript" data-module-id="./chunk-toast.js" data-src="https://github.githubassets.com/assets/chunk-toast-e06273db.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-miaiZ1xkDsWBUsURHOmeYtbgVKQGnm1octCo/lDXUmPzDyjtubnHULRVw1AK+sttwdwyB0+LOyhIVAWCNSGx+A==" type="application/javascript" data-module-id="./chunk-delayed-loading-element.js" data-src="https://github.githubassets.com/assets/chunk-delayed-loading-element-9a26a267.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-GD25CNhMGDMzEmeFhUT0FILBupAkx5/CHohnYXOP1togy40O0iu/lASaSp3gV8ue0nwscalJVQqR5gKDRHHDVg==" type="application/javascript" data-module-id="./chunk-three.module.js" data-src="https://github.githubassets.com/assets/chunk-three.module-183db908.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xmwKlhTMNVRU8mZLQQVMRsISs88kvYD44890vqs2UgtRESeLhm81nd88P6SoLiGMjyUDMTR0IzBCauoacaqSkA==" type="application/javascript" data-module-id="./chunk-invitations.js" data-src="https://github.githubassets.com/assets/chunk-invitations-c66c0a96.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-vFR+IqThljOLrAWmjhOL/kiQrjgZZg95uPovX0J7kRH5p7Y049LDRZaXLMDijfeqqk71d3MMn9XP5bUcH+lB9w==" type="application/javascript" data-module-id="./chunk-profile.js" data-src="https://github.githubassets.com/assets/chunk-profile-bc547e22.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-W3TFrSn3Iqu38aVxxYxFiNGzaVmLXtGfwRDVRH1RwRvqPVerX1fjQPEYag+HqAoWaGy5ssVFp42oyOIV93afBw==" type="application/javascript" data-module-id="./chunk-overview.js" data-src="https://github.githubassets.com/assets/chunk-overview-5b74c5ad.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-xqw233932eUGcGURAPuwUWZpC5Km/9Btq7/2Jnkt1rSWnPSVfMl+JKpr9eLtCoQmrpgP8vaghEuX8bWAS8fzTg==" type="application/javascript" data-module-id="./chunk-advanced.js" data-src="https://github.githubassets.com/assets/chunk-advanced-c6ac36df.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6Rmd0BBAsJ9ouvb/pgrkToMPs5ogcqi8rcQ7R3GDPPHIjlu0NZ0Bx6HUn/aOruMCECETHm4Exfs5gjYdHs66RQ==" type="application/javascript" data-module-id="./chunk-runner-groups.js" data-src="https://github.githubassets.com/assets/chunk-runner-groups-e9199dd0.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-5H5N/3G/20nmVKntphXb9z0H9q3URFDmHSccLhFkMSA8ILAA9mYlRKCWAWoDcl/W437jtGw1tIxjWStfInvidw==" type="application/javascript" data-module-id="./chunk-profile-pins-element.js" data-src="https://github.githubassets.com/assets/chunk-profile-pins-element-e47e4dff.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6WJL+zyYirKxwD8MNBenuxbMKvCeskXBrXISNlqhV3kltmI8kiSjUX0nDQM3fXeSakcll12sYS8Pli1GFPtG9Q==" type="application/javascript" data-module-id="./chunk-emoji-picker-element.js" data-src="https://github.githubassets.com/assets/chunk-emoji-picker-element-e9624bfb.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-EvJ2Fip59DXgARNuwTWgjdVqoCjhXQL73SP9yexijlWStKq92sfbKeGK5R4wIP0QOr39WsnW/Kaw3Wpl1QPfog==" type="application/javascript" data-module-id="./chunk-edit-hook-secret-element.js" data-src="https://github.githubassets.com/assets/chunk-edit-hook-secret-element-12f27616.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-91JzWtpBUoC7Z4dQpeXRegjwCMooGPFtg/vXxaIGVTxguoOcI/hEdyM7otQGRNQmMencK71thI0oGt11Wgfrww==" type="application/javascript" data-module-id="./chunk-insights-query.js" data-src="https://github.githubassets.com/assets/chunk-insights-query-f752735a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ySdUENYEBMcTMRqhu0hVPVoUQfqjCkRuNy9wtKP3bEcYkMVYCSfEK4HJUTbuu3r4R7b9i6cGRHh8O3fA2/Jqyw==" type="application/javascript" data-module-id="./chunk-remote-clipboard-copy.js" data-src="https://github.githubassets.com/assets/chunk-remote-clipboard-copy-c9275410.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-eO/r0W5ywI2kxVkcH8yquw3n5Gh+cA8lVOgxd+ecgJYU81FB4Q5FqFxgHhx1omigPwexB4ltwXBMDhSeW6qNeQ==" type="application/javascript" data-module-id="./chunk-series-table.js" data-src="https://github.githubassets.com/assets/chunk-series-table-78efebd1.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-eCSMVL1aAfhWSme4/3seObqN3HNdkxWVKaAX5bmZmxIXZdv0ixnuFJeESYdLeMED/wQETtQ971A03mLF3ZX8eQ==" type="application/javascript" data-module-id="./chunk-line-chart.js" data-src="https://github.githubassets.com/assets/chunk-line-chart-78248c54.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-rZhcZvsxbGBxibYeNv4aHYZkgZzW6xnRcAqmuOCbq/ehJgr75pxgiV7HrGrYrX9HNmyH8T+90HC9WSBZNM4L3g==" type="application/javascript" data-module-id="./chunk-bar-chart.js" data-src="https://github.githubassets.com/assets/chunk-bar-chart-ad985c66.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-/QP5yDdYoor56F2+SyPr/8a9FtvCZnnGP0d+lSAHQR5n+xYjaiY6LjJGB/x1cevAH8r4XY/axNN9fRWIfbwAcA==" type="application/javascript" data-module-id="./chunk-stacked-area-chart.js" data-src="https://github.githubassets.com/assets/chunk-stacked-area-chart-fd03f9c8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-TKUxqL6IByP8qqlx+WNc34g/slipjnnKi57B1EBicEWDMUMcBLFsrRiHY535WKJOrkjsqmpJXT5cSE4q6wEyAw==" type="application/javascript" data-module-id="./chunk-presence-avatars.js" data-src="https://github.githubassets.com/assets/chunk-presence-avatars-4ca531a8.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-lkC6s2VaqqzXt1XyrCWmJ1ZolmjIVBcadmxjfUansOJlqeIRYTTqjnMzHvnjnqt6ve2mdLTt5s6iaK9eC8JQrw==" type="application/javascript" data-module-id="./chunk-pulse-authors-graph-element.js" data-src="https://github.githubassets.com/assets/chunk-pulse-authors-graph-element-9640bab3.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-aNAcFMlIdG1ocY5LnZylnN/6KXiJxyPvKg7y1Jnai732wdnrjXazcvNiQkRnj5FY8WP6JRa3K4doCReA4nhj7w==" type="application/javascript" data-module-id="./chunk-stacks-input-config-view.js" data-src="https://github.githubassets.com/assets/chunk-stacks-input-config-view-68d01c14.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-48cie2yevP3AX9vgMj7W25fOv4YujgRxBC3jJ/YnpUEitvyeu6sauZYg1/HBwIYPIvu+JKsCDRGD/9nLq8ZovA==" type="application/javascript" data-module-id="./chunk-community-contributions.js" data-src="https://github.githubassets.com/assets/chunk-community-contributions-e3c7227b.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-fx3qkTaNOwACIrHcd0c9dUe0gtyWr88gcBbdpn5gXvZtBD4Mn3IhF/Ys5CoffBA9pzx7KFRNxjJkIN+Jhf1vnw==" type="application/javascript" data-module-id="./chunk-discussion-page-views.js" data-src="https://github.githubassets.com/assets/chunk-discussion-page-views-7f1dea91.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-qEHZhSvfA+6V31W4k6upvHeMIZI48wt8LNsbFrBFx2qJ4YAdTIxJx0kjryhKOJUaJk1FqK7FehDzoX3MrgWoHg==" type="application/javascript" data-module-id="./chunk-discussions-daily-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-daily-contributors-a841d985.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-RZFMDTXA6+c7lX5QmHt2C4cEbES9a3V7FCFUNn7V44xzj9vih7iv1yAciPJvZUvRbEi53dNXeKLc2c/1CogcXw==" type="application/javascript" data-module-id="./chunk-discussions-new-contributors.js" data-src="https://github.githubassets.com/assets/chunk-discussions-new-contributors-45914c0d.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-TLQillrC8dagau7Smjy8GmWx3jhSvBCnkTPMStBL7tvLAaowBuGx38ICPFBdM+3ammiRlfXAaEe5OdpimWnnmQ==" type="application/javascript" data-module-id="./chunk-tweetsodium.js" data-src="https://github.githubassets.com/assets/chunk-tweetsodium-4cb42296.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-eHSwjhwcxnPBWzrxiC7rQ53wHZETtJQTXUqb6WPdetPBeznP2kqRbmlyCcMXCIrqxGXpzY34wFs8/rWHYjNLFw==" type="application/javascript" data-module-id="./chunk-jump-to.js" data-src="https://github.githubassets.com/assets/chunk-jump-to-7874b08e.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-T3CuYDHAivvjENXpjyng7klVa3JwFrS4vJ+Ac6QdsKcDLIC9CT61uwVeNnHVhcEHsp4jk9idR56Qv5VZ7tXBkg==" type="application/javascript" data-module-id="./chunk-user-status-submit.js" data-src="https://github.githubassets.com/assets/chunk-user-status-submit-4f70ae60.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-L2jxBDS9QAN9O1qn7LqMcs0YJn/gF6xW73zSbWPRlVCEnG05dexaoJWkAG6RqALTnXLsj2GTUKnba6DATR828g==" type="application/javascript" data-module-id="./chunk-launch-code-element.js" data-src="https://github.githubassets.com/assets/chunk-launch-code-element-2f68f104.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-cvjyIYhR2ZkuFAXHYZSjPTc5wXYOdISgqbXw69CXpDXdxffXmXuzjCcGJNVk3mDNYsVH4Q9sb2UMNPFrNxxRUQ==" type="application/javascript" data-module-id="./chunk-metric-selection-element.js" data-src="https://github.githubassets.com/assets/chunk-metric-selection-element-72f8f221.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-/2Oeznu4Qh8QuYb4OvlxCrx/tIfHWnJrhjNFW7MOl0nRMSVUPowbUJ4F+HpdkepXw/OZkF22CN7CN1dRv8bJmQ==" type="application/javascript" data-module-id="./chunk-severity-calculator-element.js" data-src="https://github.githubassets.com/assets/chunk-severity-calculator-element-ff639ece.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-VjkMdcEtlHEJjard7MoGBDuAJ4N4vQlJpvGXIJo9d/i/HGnwF3gLFyYqzjHE7UxyP3pturpOv8BQ29Vnr/Atwg==" type="application/javascript" data-module-id="./chunk-command-palette-page-element.js" data-src="https://github.githubassets.com/assets/chunk-command-palette-page-element-56390c75.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-Z6+ifrBeboG0rRu5KFwsFPLjlDI7CDTCmmLk4UiiUtDyrFoG5/iYC591qjpC9YaZt1ZJBkGP5KbN/ijCbZUGCw==" type="application/javascript" data-module-id="./chunk-command-palette-page-stack-element.js" data-src="https://github.githubassets.com/assets/chunk-command-palette-page-stack-element-67afa27e.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-yXHkwiNZgB6O0iSDKE8jrZzTtTyF8YdFFXHcemhWEPuN3sWs1PQrSwEh0Gw4/B9TIzUfvogbqlJ71yLLuqyM+Q==" type="application/javascript" data-module-id="./chunk-readme-toc-element.js" data-src="https://github.githubassets.com/assets/chunk-readme-toc-element-c971e4c2.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-aGaoVKNIqNkSpelOnfn0UCDbQLW2XBUVVkOOgVZXFNDfgJgFQNMXALc0964DwIi9kYrkYQIShePOSMFo20hHkw==" type="application/javascript" data-module-id="./chunk-feature-callout-element.js" data-src="https://github.githubassets.com/assets/chunk-feature-callout-element-6866a854.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-UPU+AoAUE6KHEpUgAiTtiIcSfgpjC2CMLgSwufa4HHT3Vp5xC+2XCBPh/uS9JQLm6s1jJsQEGyYWY4OKHtVbjQ==" type="application/javascript" data-module-id="./chunk-codespaces-policy-form-element.js" data-src="https://github.githubassets.com/assets/chunk-codespaces-policy-form-element-50f53e02.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-tjhrAsOwOkMKShPCR1t5kJuCZDh0qkv391TPnBsrNJ5wyvwVAUqVQW2bsVNvcyft0Cu2ECsH/R+7Pr91r52Ktg==" type="application/javascript" data-module-id="./chunk-action-list-element.js" data-src="https://github.githubassets.com/assets/chunk-action-list-element-b6386b02.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-3+zUhNS4KGmiMIFiQ6EUBvHTwy6xs4XRC61A+/oJegTh0OCubEosQqG7OnvUuAUd8i6PwhYaZbRm2HXZAW5kgA==" type="application/javascript" data-module-id="./chunk-memex-project-picker-element.js" data-src="https://github.githubassets.com/assets/chunk-memex-project-picker-element-dfecd484.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ooYcnNLBDnMePhMvdQEQiItFZowYg4gwklGZGCrAWPW1LCxePPkzB1kr8U3Bay0NPKYEDmICeXBqqDPd8EDmqA==" type="application/javascript" data-module-id="./chunk-project-picker-element.js" data-src="https://github.githubassets.com/assets/chunk-project-picker-element-a2861c9c.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-YYzSijUU1oA10iMuvfzSHMK7vrQzu8aiLpIfD13kpcq2KVMqdOrIASINY5sBUNPNFZbSLKmBfTcEXEKVcQZHfQ==" type="application/javascript" data-module-id="./chunk-sortable-behavior.js" data-src="https://github.githubassets.com/assets/chunk-sortable-behavior-618cd28a.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-6JUQHgkTqBaCCdDugMcO4fQ8YxUHk+m6rwVp2Wxa4FMVz6BbBMPOzGluT4wBq8NTUcFv6DnXSOnt5e85jNgpGg==" type="application/javascript" data-module-id="./chunk-drag-drop.js" data-src="https://github.githubassets.com/assets/chunk-drag-drop-e895101e.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-28pipPJZvizfcYYETJWBBeDHsrDEz7A06d7Y5swgY/OWmsX0ZJW6mkZVFRO7Z/xZh1D1qFbPHGNixfCd1YpBnA==" type="application/javascript" data-module-id="./chunk-contributions-spider-graph.js" data-src="https://github.githubassets.com/assets/chunk-contributions-spider-graph-dbca62a4.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-VQRofBwNZhBa4vBuw0P5bjjlVtO2R+l1M0TOfMZHX1bB7xy//CFwqmyaL24rLfgLx8sahKZ7eEw1o+nkFoUzNA==" type="application/javascript" data-module-id="./chunk-webgl-warp.js" data-src="https://github.githubassets.com/assets/chunk-webgl-warp-5504687c.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-qb0VNYEOQchz8PqWuYrIqNtb9eGvMmT2WN43rHOug+XWYaUbOkE+mpDBDFWKS7kXjDWK/Glk35qm34JHOEnAQw==" type="application/javascript" src="https://github.githubassets.com/assets/repositories-a9bd1535.js"></script> <script crossorigin="anonymous" defer="defer" integrity="sha512-ICUv50Qz2AAC2/u3xVLvTYSyGd1drvd4+eUWMEc+vx4TXYjgLos3MAqKzYVXrcbPr0cyknutSEbBG519piaiGQ==" type="application/javascript" src="https://github.githubassets.com/assets/diffs-20252fe7.js"></script> <meta name="viewport" content="width=device-width"> <title>openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts · GitHub</title> <meta name="description" content="OpenZeppelin Contracts is a library for secure smart contract development. - openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/9dc230e79f3db4d6077eeb7dda55e745f10154d6bb986aacaaf17c8ce2055d96/OpenZeppelin/openzeppelin-contracts" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts" /><meta name="twitter:description" content="OpenZeppelin Contracts is a library for secure smart contract development. - openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts" /> <meta property="og:image" content="https://opengraph.githubassets.com/9dc230e79f3db4d6077eeb7dda55e745f10154d6bb986aacaaf17c8ce2055d96/OpenZeppelin/openzeppelin-contracts" /><meta property="og:image:alt" content="OpenZeppelin Contracts is a library for secure smart contract development. - openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts" /><meta property="og:url" content="https://github.com/OpenZeppelin/openzeppelin-contracts" /><meta property="og:description" content="OpenZeppelin Contracts is a library for secure smart contract development. - openzeppelin-contracts/Ownable.sol at master · OpenZeppelin/openzeppelin-contracts" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="request-id" content="82FD:448A:2D2373:359A1B:61D19399" data-pjax-transient="true"/><meta name="html-safe-nonce" content="c34bcf9ea6121a3ee91e588e47fa8629167db918f8ee383336679bef73517f4b" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkZEOjQ0OEE6MkQyMzczOjM1OUExQjo2MUQxOTM5OSIsInZpc2l0b3JfaWQiOiIyNzM1MTcwMTQwNzg2MjM0MjY2IiwicmVnaW9uX2VkZ2UiOiJzb3V0aGVhc3Rhc2lhIiwicmVnaW9uX3JlbmRlciI6InNvdXRoZWFzdGFzaWEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="04b588b47785a0230eabb7f49880289b20f5e680d01c802e9f5656d0334219c1" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:64700934" data-pjax-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code" data-pjax-transient="true" /> <meta name="selected-link" value="repo_source" data-pjax-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="octolytics-url" content="https://collector.githubapp.com/github/collect" /> <meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" /> <meta name="optimizely-datafile" content="{&quot;version&quot;: &quot;4&quot;, &quot;rollouts&quot;: [], &quot;typedAudiences&quot;: [], &quot;anonymizeIP&quot;: true, &quot;projectId&quot;: &quot;16737760170&quot;, &quot;variables&quot;: [], &quot;featureFlags&quot;: [], &quot;experiments&quot;: [{&quot;status&quot;: &quot;Running&quot;, &quot;audienceIds&quot;: [], &quot;variations&quot;: [{&quot;variables&quot;: [], &quot;id&quot;: &quot;20438636352&quot;, &quot;key&quot;: &quot;control&quot;}, {&quot;variables&quot;: [], &quot;id&quot;: &quot;20484957397&quot;, &quot;key&quot;: &quot;treatment&quot;}], &quot;id&quot;: &quot;20479227424&quot;, &quot;key&quot;: &quot;growth_ghec_onboarding_experience&quot;, &quot;layerId&quot;: &quot;20467848595&quot;, &quot;trafficAllocation&quot;: [{&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 1000}, {&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 3000}, {&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 5000}, {&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 6000}, {&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 8000}, {&quot;entityId&quot;: &quot;20484957397&quot;, &quot;endOfRange&quot;: 10000}], &quot;forcedVariations&quot;: {&quot;85e2238ce2b9074907d7a3d91d6feeae&quot;: &quot;control&quot;}}, {&quot;status&quot;: &quot;Running&quot;, &quot;audienceIds&quot;: [], &quot;variations&quot;: [{&quot;variables&quot;: [], &quot;id&quot;: &quot;20667381018&quot;, &quot;key&quot;: &quot;control&quot;}, {&quot;variables&quot;: [], &quot;id&quot;: &quot;20680930759&quot;, &quot;key&quot;: &quot;treatment&quot;}], &quot;id&quot;: &quot;20652570897&quot;, &quot;key&quot;: &quot;project_genesis&quot;, &quot;layerId&quot;: &quot;20672300363&quot;, &quot;trafficAllocation&quot;: [{&quot;entityId&quot;: &quot;20667381018&quot;, &quot;endOfRange&quot;: 5000}, {&quot;entityId&quot;: &quot;20680930759&quot;, &quot;endOfRange&quot;: 10000}], &quot;forcedVariations&quot;: {&quot;83356e17066d336d1803024138ecb683&quot;: &quot;treatment&quot;, &quot;18e31c8a9b2271332466133162a4aa0d&quot;: &quot;treatment&quot;, &quot;10f8ab3fbc5ebe989a36a05f79d48f32&quot;: &quot;treatment&quot;, &quot;1686089f6d540cd2deeaec60ee43ecf7&quot;: &quot;treatment&quot;}}], &quot;audiences&quot;: [{&quot;conditions&quot;: &quot;[\&quot;or\&quot;, {\&quot;match\&quot;: \&quot;exact\&quot;, \&quot;name\&quot;: \&quot;$opt_dummy_attribute\&quot;, \&quot;type\&quot;: \&quot;custom_attribute\&quot;, \&quot;value\&quot;: \&quot;$opt_dummy_value\&quot;}]&quot;, &quot;id&quot;: &quot;$opt_dummy_audience&quot;, &quot;name&quot;: &quot;Optimizely-Generated Audience for Backwards Compatibility&quot;}], &quot;groups&quot;: [], &quot;sdkKey&quot;: &quot;WTc6awnGuYDdG98CYRban&quot;, &quot;environmentKey&quot;: &quot;production&quot;, &quot;attributes&quot;: [{&quot;id&quot;: &quot;16822470375&quot;, &quot;key&quot;: &quot;user_id&quot;}, {&quot;id&quot;: &quot;17143601254&quot;, &quot;key&quot;: &quot;spammy&quot;}, {&quot;id&quot;: &quot;18175660309&quot;, &quot;key&quot;: &quot;organization_plan&quot;}, {&quot;id&quot;: &quot;18813001570&quot;, &quot;key&quot;: &quot;is_logged_in&quot;}, {&quot;id&quot;: &quot;19073851829&quot;, &quot;key&quot;: &quot;geo&quot;}, {&quot;id&quot;: &quot;20175462351&quot;, &quot;key&quot;: &quot;requestedCurrency&quot;}, {&quot;id&quot;: &quot;20785470195&quot;, &quot;key&quot;: &quot;country_code&quot;}], &quot;botFiltering&quot;: false, &quot;accountId&quot;: &quot;16737760170&quot;, &quot;events&quot;: [{&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;17911811441&quot;, &quot;key&quot;: &quot;hydro_click.dashboard.teacher_toolbox_cta&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18124116703&quot;, &quot;key&quot;: &quot;submit.organizations.complete_sign_up&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18145892387&quot;, &quot;key&quot;: &quot;no_metric.tracked_outside_of_optimizely&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18178755568&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.add_repo&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18180553241&quot;, &quot;key&quot;: &quot;submit.repository_imports.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18186103728&quot;, &quot;key&quot;: &quot;click.help.learn_more_about_repository_creation&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18188530140&quot;, &quot;key&quot;: &quot;test_event.do_not_use_in_production&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18191963644&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.transfer_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18195612788&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.import_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18210945499&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.invite_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18211063248&quot;, &quot;key&quot;: &quot;click.empty_org_repo_cta.create_repository&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18215721889&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.update_profile&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18224360785&quot;, &quot;key&quot;: &quot;click.org_onboarding_checklist.dismiss&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18234832286&quot;, &quot;key&quot;: &quot;submit.organization_activation.complete&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18252392383&quot;, &quot;key&quot;: &quot;submit.org_repository.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18257551537&quot;, &quot;key&quot;: &quot;submit.org_member_invitation.create&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18259522260&quot;, &quot;key&quot;: &quot;submit.organization_profile.update&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18564603625&quot;, &quot;key&quot;: &quot;view.classroom_select_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18568612016&quot;, &quot;key&quot;: &quot;click.classroom_sign_in_click&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18572592540&quot;, &quot;key&quot;: &quot;view.classroom_name&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18574203855&quot;, &quot;key&quot;: &quot;click.classroom_create_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18582053415&quot;, &quot;key&quot;: &quot;click.classroom_select_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18589463420&quot;, &quot;key&quot;: &quot;click.classroom_create_classroom&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18591323364&quot;, &quot;key&quot;: &quot;click.classroom_create_first_classroom&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18591652321&quot;, &quot;key&quot;: &quot;click.classroom_grant_access&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;18607131425&quot;, &quot;key&quot;: &quot;view.classroom_creation&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;18831680583&quot;, &quot;key&quot;: &quot;upgrade_account_plan&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19064064515&quot;, &quot;key&quot;: &quot;click.signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19075373687&quot;, &quot;key&quot;: &quot;click.view_account_billing_page&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19077355841&quot;, &quot;key&quot;: &quot;click.dismiss_signup_prompt&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19079713938&quot;, &quot;key&quot;: &quot;click.contact_sales&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19120963070&quot;, &quot;key&quot;: &quot;click.compare_account_plans&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19151690317&quot;, &quot;key&quot;: &quot;click.upgrade_account_cta&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19424193129&quot;, &quot;key&quot;: &quot;click.open_account_switcher&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19520330825&quot;, &quot;key&quot;: &quot;click.visit_account_profile&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19540970635&quot;, &quot;key&quot;: &quot;click.switch_account_context&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19730198868&quot;, &quot;key&quot;: &quot;submit.homepage_signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19820830627&quot;, &quot;key&quot;: &quot;click.homepage_signup&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;19988571001&quot;, &quot;key&quot;: &quot;click.create_enterprise_trial&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20036538294&quot;, &quot;key&quot;: &quot;click.create_organization_team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20040653299&quot;, &quot;key&quot;: &quot;click.input_enterprise_trial_form&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20062030003&quot;, &quot;key&quot;: &quot;click.continue_with_team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20068947153&quot;, &quot;key&quot;: &quot;click.create_organization_free&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20086636658&quot;, &quot;key&quot;: &quot;click.signup_continue.username&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20091648988&quot;, &quot;key&quot;: &quot;click.signup_continue.create_account&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20103637615&quot;, &quot;key&quot;: &quot;click.signup_continue.email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20111574253&quot;, &quot;key&quot;: &quot;click.signup_continue.password&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20120044111&quot;, &quot;key&quot;: &quot;view.pricing_page&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20152062109&quot;, &quot;key&quot;: &quot;submit.create_account&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20165800992&quot;, &quot;key&quot;: &quot;submit.upgrade_payment_form&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20171520319&quot;, &quot;key&quot;: &quot;submit.create_organization&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20222645674&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.discuss_your_needs&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20227443657&quot;, &quot;key&quot;: &quot;submit.verify_primary_user_email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20234607160&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.try_enterprise&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20238175784&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.team&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20239847212&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.continue_free&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20251097193&quot;, &quot;key&quot;: &quot;recommended_plan&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20438619534&quot;, &quot;key&quot;: &quot;click.pricing_calculator.1_member&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20456699683&quot;, &quot;key&quot;: &quot;click.pricing_calculator.15_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20467868331&quot;, &quot;key&quot;: &quot;click.pricing_calculator.10_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20476267432&quot;, &quot;key&quot;: &quot;click.trial_days_remaining&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20476357660&quot;, &quot;key&quot;: &quot;click.discover_feature&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20479287901&quot;, &quot;key&quot;: &quot;click.pricing_calculator.custom_members&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20481107083&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.apply_teacher_benefits&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20483089392&quot;, &quot;key&quot;: &quot;click.pricing_calculator.5_members&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;, &quot;20652570897&quot;], &quot;id&quot;: &quot;20484283944&quot;, &quot;key&quot;: &quot;click.onboarding_task&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20484996281&quot;, &quot;key&quot;: &quot;click.recommended_plan_in_signup.apply_student_benefits&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20486713726&quot;, &quot;key&quot;: &quot;click.onboarding_task_breadcrumb&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20490791319&quot;, &quot;key&quot;: &quot;click.upgrade_to_enterprise&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20491786766&quot;, &quot;key&quot;: &quot;click.talk_to_us&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20494144087&quot;, &quot;key&quot;: &quot;click.dismiss_enterprise_trial&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;, &quot;20652570897&quot;], &quot;id&quot;: &quot;20499722759&quot;, &quot;key&quot;: &quot;completed_all_tasks&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;, &quot;20652570897&quot;], &quot;id&quot;: &quot;20500710104&quot;, &quot;key&quot;: &quot;completed_onboarding_tasks&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20513160672&quot;, &quot;key&quot;: &quot;click.read_doc&quot;}, {&quot;experimentIds&quot;: [&quot;20652570897&quot;], &quot;id&quot;: &quot;20516196762&quot;, &quot;key&quot;: &quot;actions_enabled&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20518980986&quot;, &quot;key&quot;: &quot;click.dismiss_trial_banner&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20535446721&quot;, &quot;key&quot;: &quot;click.issue_actions_prompt.dismiss_prompt&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20557002247&quot;, &quot;key&quot;: &quot;click.issue_actions_prompt.setup_workflow&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20595070227&quot;, &quot;key&quot;: &quot;click.pull_request_setup_workflow&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20626600314&quot;, &quot;key&quot;: &quot;click.seats_input&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20642310305&quot;, &quot;key&quot;: &quot;click.decrease_seats_number&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20662990045&quot;, &quot;key&quot;: &quot;click.increase_seats_number&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20679620969&quot;, &quot;key&quot;: &quot;click.public_product_roadmap&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20761240940&quot;, &quot;key&quot;: &quot;click.dismiss_survey_banner&quot;}, {&quot;experimentIds&quot;: [&quot;20479227424&quot;], &quot;id&quot;: &quot;20767210721&quot;, &quot;key&quot;: &quot;click.take_survey&quot;}, {&quot;experimentIds&quot;: [&quot;20652570897&quot;], &quot;id&quot;: &quot;20795281201&quot;, &quot;key&quot;: &quot;click.archive_list&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20966790249&quot;, &quot;key&quot;: &quot;contact_sales.submit&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20996500333&quot;, &quot;key&quot;: &quot;contact_sales.existing_customer&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;20996890162&quot;, &quot;key&quot;: &quot;contact_sales.blank_message_field&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21000470317&quot;, &quot;key&quot;: &quot;contact_sales.personal_email&quot;}, {&quot;experimentIds&quot;: [], &quot;id&quot;: &quot;21002790172&quot;, &quot;key&quot;: &quot;contact_sales.blank_phone_field&quot;}], &quot;revision&quot;: &quot;1020&quot;}" /> <!-- To prevent page flashing, the optimizely JS needs to be loaded in the <head> tag before the DOM renders --> <script crossorigin="anonymous" defer="defer" integrity="sha512-stPGyO+GUOomTBqs1Y5EJnkYCf8cb/wFveUz/ncDr9XaP9olIwZerGQr4wFA3nBNqhbaqHsYbf0NfWJZ6XHjrg==" type="application/javascript" src="https://github.githubassets.com/assets/optimizely-b2d3c6c8.js"></script> <meta name="hostname" content="github.com"> <meta name="user-login" content=""> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="MARKETPLACE_PENDING_INSTALLATIONS"> <meta http-equiv="x-pjax-version" content="2a0ed398d891434ebc5cd37a121dd8663578609e0ecf0d1b542fb263bb3ef861"> <meta http-equiv="x-pjax-csp-version" content="9ea82e8060ac9d44365bfa193918b70ed58abd9413362ba412abb161b3a8d1b6"> <meta http-equiv="x-pjax-css-version" content="8c06702a824b73d05c6dcbe160dc26951e0c3af9f2b6bd2c34681db7ef946a74"> <meta http-equiv="x-pjax-js-version" content="996e21374117f01b7df2c1f75047cbdb09449e0572a60b7722454a61ba4735f6"> <meta name="go-import" content="github.com/OpenZeppelin/openzeppelin-contracts git https://github.com/OpenZeppelin/openzeppelin-contracts.git"> <meta name="octolytics-dimension-user_id" content="20820676" /><meta name="octolytics-dimension-user_login" content="OpenZeppelin" /><meta name="octolytics-dimension-repository_id" content="64700934" /><meta name="octolytics-dimension-repository_nwo" content="OpenZeppelin/openzeppelin-contracts" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="64700934" /><meta name="octolytics-dimension-repository_network_root_nwo" content="OpenZeppelin/openzeppelin-contracts" /> <link rel="canonical" href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol" data-pjax-transient> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"> <meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive page-blob" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> <a href="#start-of-content" class="px-2 py-4 color-bg-accent-emphasis color-fg-on-emphasis show-on-focus js-skip-to-content">Skip to content</a> <span data-view-component="true" class="progress-pjax-loader js-pjax-loader-bar Progress position-fixed width-full"> <span style="width: 0%;" data-view-component="true" class="Progress-item progress-pjax-loader-bar left-0 top-0 color-bg-accent-emphasis"></span> </span> <header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner"> <div class="container-xl d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <a class="mr-4 color-fg-inherit" href="https://github.com/" aria-label="Homepage" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path> </svg> </a> <div class="d-lg-none css-truncate css-truncate-target width-fit p-2"> </div> <div class="d-flex flex-items-center"> <a href="/signup?ref_cta=Sign+up&amp;ref_loc=header+logged+out&amp;ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fblob%2Fshow&amp;source=header-repo" class="d-inline-block d-lg-none f5 no-underline border color-border-default rounded-2 px-2 py-1 mr-3 mr-sm-5 color-fg-inherit" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e00d028a408a1e01c8808e08c18ce42962db3dd55d2dd5257e4d6c69b8bebcb5" > Sign&nbsp;up </a> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link d-lg-none mt-1 color-fg-inherit"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-three-bars"> <path fill-rule="evenodd" d="M1 2.75A.75.75 0 011.75 2h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 2.75zm0 5A.75.75 0 011.75 7h12.5a.75.75 0 110 1.5H1.75A.75.75 0 011 7.75zM1.75 12a.75.75 0 100 1.5h12.5a.75.75 0 100-1.5H1.75z"></path> </svg> </button> </div> </div> <div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto"> <div class="d-flex d-lg-none flex-justify-end border-bottom color-bg-subtle p-3"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-x color-fg-muted"> <path fill-rule="evenodd" d="M5.72 5.72a.75.75 0 011.06 0L12 10.94l5.22-5.22a.75.75 0 111.06 1.06L13.06 12l5.22 5.22a.75.75 0 11-1.06 1.06L12 13.06l-5.22 5.22a.75.75 0 01-1.06-1.06L10.94 12 5.72 6.78a.75.75 0 010-1.06z"></path> </svg> </button> </div> <nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global"> <ul class="d-lg-flex list-style-none"> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Why GitHub? <svg x="0" y="0" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"><path d="M1,1l6.2,6L13,1"></path></svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> <ul class="list-style-none f5 pb-1"> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Features&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Features;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="5c2b0e38f70815fdf7ee961f66d82a3a090177d137f5b1bdfde122d9d0a0d2a0" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Features&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Features;&quot;}" href="/features"> Features </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Mobile&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Mobile;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="10a8ac5133892ba2c1ab9ffd391086b42e8adce176143c8b9b7dc843b4d86e3c" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Mobile&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Mobile;&quot;}" href="/mobile"> Mobile </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Actions&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Actions;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="4192478082d9e63595cc260d66e69c5f2bb4e26f5bfc02dfd792dc584c9a653b" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Actions&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Actions;&quot;}" href="/features/actions"> Actions </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Codespaces&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Codespaces;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e3911716f095056b663ddef9a57b5e1489f6214c2bb5abfd06903fdfccae0e2b" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Codespaces&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Codespaces;&quot;}" href="/features/codespaces"> Codespaces </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Packages&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Packages;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b6c394b7f9e291a8d146a54a92b93f541c55112bb5cec4d0f266850664470f63" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Packages&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Packages;&quot;}" href="/features/packages"> Packages </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Security&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Security;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e0f73d8e5ae17040306ed2cdad3afb017421832b5c77038447a97d4c0dac0810" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Security&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Security;&quot;}" href="/features/security"> Security </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Code review&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Code review;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b466d855ebe03c6cc79f25c142454ec5e45dc4bf3dd821d845a68043a0ffad82" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Code review&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Code review;&quot;}" href="/features/code-review"> Code review </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Issues&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Issues;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="30070e2749118f4864b7d78e3f52a418e2b1c0644bc49acaf9e8db41664de66d" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Issues&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Issues;&quot;}" href="/features/issues"> Issues </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Integrations&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Integrations;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="c0da08318545e30ff664e483471cd46cf58a80b43f9a2d25b77139a34213cb00" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Integrations&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Integrations;&quot;}" href="/features/integrations"> Integrations </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold border-top pt-4 pb-2 mt-3" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to GitHub Sponsors&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Sponsors;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="324f1121c7562af242b8821bf97e73f5b419326072801a5ae68bda29137ad4d7" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to GitHub Sponsors&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Sponsors;&quot;}" href="/sponsors"> GitHub Sponsors </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Customer stories&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Customer stories;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="516a3bfb9953d54904e9fbe54cacbc295d082f66f0f7d34570114be6a6f1b6de" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Customer stories&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Customer stories;&quot;}" href="/customer-stories"> Customer stories </a> </li> </ul> </div> </details> </li> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <a class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Team&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Team;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="565410f46779efbee73ce1be27da6476bed0391d97f57ba41886958eb04ea3cb" data-analytics-event="{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Team&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Team;&quot;}" href="/team">Team</a> </li> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <a class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Enterprise&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Enterprise;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="dfe1ad99bed3cdb47fc0488a16247cd3c31a775547b0a5ac5bdb2cdf6eaed2ab" data-analytics-event="{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Enterprise&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Enterprise;&quot;}" href="/enterprise">Enterprise</a> </li> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Explore <svg x="0" y="0" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"><path d="M1,1l6.2,6L13,1"></path></svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> <ul class="list-style-none f5 pb-1"> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Explore GitHub&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Explore GitHub;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="9b5d376f3a58bcfb8ce17a51aa0a024d9213f40ce0820fbc361b35140e799b7d" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Explore GitHub&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Explore GitHub;&quot;}" href="/explore"> Explore GitHub </a> </li> <li class="color-fg-muted text-normal f6 text-mono mb-1 border-top pt-3 mt-3 mb-1">Learn and contribute</li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Topics&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Topics;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="23afe7b31dc6584d71a1ebc8f4bf3878f47484a1399153ad84282ee5b78767de" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Topics&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Topics;&quot;}" href="/topics"> Topics </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Collections&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Collections;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b71d214b2940526c6cf4f81f78f9af42d46bace8bcd4f0c081c758667167481e" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Collections&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Collections;&quot;}" href="/collections"> Collections </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Trending&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Trending;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="1b8ccb800c3b6f084b3047e0a11e5d9177f9bfbd81636afa4661ef037eb9f3ef" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Trending&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Trending;&quot;}" href="/trending"> Trending </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Learning Lab&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Learning Lab;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="0ed9640ee133710994779cd026f1aae0408baa10dc746ae039177aa6c2e66232" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Learning Lab&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Learning Lab;&quot;}" href="https://lab.github.com/"> Learning Lab </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Open source guides&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Open source guides;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="00815305aaac250b42d9bd5ed03931198f676f57a84a3aa664aad6302d396124" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Open source guides&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Open source guides;&quot;}" href="https://opensource.guide"> Open source guides </a> </li> <li class="color-fg-muted text-normal f6 text-mono mb-1 border-top pt-3 mt-3 mb-1">Connect with others</li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to The ReadME Project&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:The ReadME Project;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="334bc5466f9a652670221720ca623bdcb9b3e12da46ec82cc054782f2938ee8f" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to The ReadME Project&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:The ReadME Project;&quot;}" href="/readme"> The ReadME Project </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Events&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Events;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="fd2893962c9d151b2b890a757ff96f7884d2496b11c9f0c127eae01d8172fa1d" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Events&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Events;&quot;}" href="/events"> Events </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Community forum&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Community forum;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="1285cc5de315f9f370d1df2b241ff9f10aff80bd6a0c5268d7b555d5a61d85b4" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to Community forum&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Community forum;&quot;}" href="https://github.community"> Community forum </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to GitHub Education&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Education;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="7c39536801d15be62686f5cde186dd5b2916d4a7165739d4958a8e428611dbe7" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to GitHub Education&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Education;&quot;}" href="https://education.github.com"> GitHub Education </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to GitHub Stars program&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Stars program;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="d5ae43cb9231bb47432bd35589c358a0327ab14c772295de6ef2768af06974bd" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Explore&quot;,&quot;action&quot;:&quot;click to go to GitHub Stars program&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:GitHub Stars program;&quot;}" href="https://stars.github.com"> GitHub Stars program </a> </li> </ul> </div> </details> </li> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <a class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Marketplace&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Marketplace;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="0e6bc87e938c1a087227dec56465f533c93ce1954664d7f7634d256ad7e2f3dc" data-analytics-event="{&quot;category&quot;:&quot;Header menu top item (logged out)&quot;,&quot;action&quot;:&quot;click to go to Marketplace&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Marketplace;&quot;}" href="/marketplace">Marketplace</a> </li> <li class="mr-0 mr-lg-3 position-relative flex-wrap flex-justify-between flex-items-center border-bottom border-lg-bottom-0 d-block d-lg-flex flex-lg-nowrap flex-lg-items-center"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Pricing <svg x="0" y="0" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"><path d="M1,1l6.2,6L13,1"></path></svg> </summary> <div class="dropdown-menu flex-auto rounded px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> <ul class="list-style-none f5 pb-1"> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Plans&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Plans;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="827cd22abd64f98ce59691008fbc2926c8648921e83621fb4c68c1615bf59f5b" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Plans&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Plans;&quot;}" href="/pricing"> Plans </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Compare plans&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Compare plans;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b4686e772843fa088a4f24093f7e151435bdba194866fe5d2eb5db84d30cdaff" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Compare plans&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Compare plans;&quot;}" href="/pricing#compare-features"> Compare plans </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Contact Sales&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Contact Sales;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="30f671aca51c3b9309dc31e1761b5d6965bd5a6f662b84b78e65ccfd025d129c" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Contact Sales&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Contact Sales;&quot;}" href="https://github.com/enterprise/contact"> Contact Sales </a> </li> <li> <a class="lh-condensed-ultra d-block no-underline position-relative Link--primary text-bold border-top pt-4 pb-2 mt-3" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Education&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Education;&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="64ac6738c3db29ad31aa93d341ed7a10086b4a292c1bba92bd300bc980e4f110" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Pricing&quot;,&quot;action&quot;:&quot;click to go to Education&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Education;&quot;}" href="https://education.github.com"> Education </a> </li> </ul> </div> </details> </li> </ul> </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-3 mb-lg-0"> <div class="header-search flex-auto js-site-search position-relative flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to" > <div class="position-relative"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="64700934" data-scoped-search-url="/OpenZeppelin/openzeppelin-contracts/search" data-owner-scoped-search-url="/orgs/OpenZeppelin/search" data-unscoped-search-url="/search" action="/OpenZeppelin/openzeppelin-contracts/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey=s,/ name="q" data-test-selector="nav-search-input" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="DBM2pDH/RcR+Brvut+6TOzHDx+AqCzB/mC6fSmljz5YOvJAQ2EvNNicjHxOGK7AH7XVJGxIe74Vw21etfTvMYQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <ul class="d-none js-jump-to-suggestions-template-container"> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-suggestion" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="" data-item-type="suggestion"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path> </svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path> </svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path> </svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> </ul> <ul class="d-none js-jump-to-no-results-template-container"> <li class="d-flex flex-justify-center flex-items-center f5 d-none js-jump-to-suggestion p-2"> <span class="color-fg-muted">No suggested jump to results</span> </li> </ul> <ul id="jump-to-results" role="listbox" class="p-0 m-0 js-navigation-container jump-to-suggestions-results-container js-jump-to-suggestions-results-container"> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search d-none" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="" data-item-type="scoped_search"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path> </svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path> </svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path> </svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-owner-scoped-search d-none" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="" data-item-type="owner_scoped_search"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path> </svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path> </svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path> </svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this organization"> In this organization </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-global-search d-none" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="" data-item-type="global_search"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path> </svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path fill-rule="evenodd" d="M1.75 0A1.75 1.75 0 000 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0016 14.25V1.75A1.75 1.75 0 0014.25 0H1.75zM1.5 1.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v12.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25V1.75zM11.75 3a.75.75 0 00-.75.75v7.5a.75.75 0 001.5 0v-7.5a.75.75 0 00-.75-.75zm-8.25.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5zM8 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 3z"></path> </svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path> </svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> </ul> </div> </label> </form> </div> </div> </div> <div class="position-relative mr-3 mb-4 mb-lg-0 d-inline-block"> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2FOpenZeppelin%2Fopenzeppelin-contracts%2Fblob%2Fmaster%2Fcontracts%2Faccess%2FOwnable.sol" class="HeaderMenu-link flex-shrink-0 no-underline" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="ff7d5b2297a134b3056d4e45eb202195a2c7260abbbf96b1511e14288426d86e" data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in"> Sign in </a> </div> <a href="/signup?ref_cta=Sign+up&amp;ref_loc=header+logged+out&amp;ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fblob%2Fshow&amp;source=header-repo&amp;source_repo=OpenZeppelin%2Fopenzeppelin-contracts" class="HeaderMenu-link flex-shrink-0 d-inline-block no-underline border color-border-default rounded px-2 py-1" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="ff7d5b2297a134b3056d4e45eb202195a2c7260abbbf96b1511e14288426d86e" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Sign up&quot;,&quot;action&quot;:&quot;click to sign up for account&quot;,&quot;label&quot;:&quot;ref_page:/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show;ref_cta:Sign up;ref_loc:header logged out&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="7860bf739e6f1588e56d84ccf55f3137d506c43eae25e20b2da7d897aa6a960e" data-analytics-event="{&quot;category&quot;:&quot;Sign up&quot;,&quot;action&quot;:&quot;click to sign up for account&quot;,&quot;label&quot;:&quot;ref_page:/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show;ref_cta:Sign up;ref_loc:header logged out&quot;}" > Sign up </a> </div> </div> </div> </header> </div> <div id="start-of-content" class="show-on-focus"></div> <div data-pjax-replace id="js-flash-container"> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class=" px-2" > <button class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path> </svg> </button> <div>{{ message }}</div> </div> </div> </template> </div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" data-pjax-container > <include-fragment src="/orgs/OpenZeppelin/survey_banner" data-test-selector="survey-banner-selector"> </include-fragment> <div id="repository-container-header" class="pt-3 hide-full-screen mb-5" style="background-color: var(--color-page-header-bg);" data-pjax-replace> <div class="d-flex mb-3 px-3 px-md-4 px-lg-5"> <div class="flex-auto min-width-0 width-fit mr-3"> <h1 class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path> </svg> <span class="author flex-self-stretch" itemprop="author"> <a class="url fn" rel="author" data-hovercard-type="organization" data-hovercard-url="/orgs/OpenZeppelin/hovercard" href="/OpenZeppelin">OpenZeppelin</a> </span> <span class="mx-1 flex-self-stretch color-fg-muted">/</span> <strong itemprop="name" class="mr-2 flex-self-stretch"> <a data-pjax="#repo-content-pjax-container" href="/OpenZeppelin/openzeppelin-contracts">openzeppelin-contracts</a> </strong> <span></span><span class="Label Label--secondary v-align-middle mr-1">Public</span> </h1> </div> <ul class="pagehead-actions flex-shrink-0 d-none d-md-inline" style="padding: 2px 0;"> <li> <a href="/login?return_to=%2FOpenZeppelin%2Fopenzeppelin-contracts" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="76384c93c68463d3fcda3c767a187066507561cbf28dbe18b1ecd9168bb3655c" aria-label="You must be signed in to change notification settings" data-view-component="true" class="tooltipped tooltipped-s btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"></path><path fill-rule="evenodd" d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"></path> </svg>Notifications </a> </li> <li> <a href="/login?return_to=%2FOpenZeppelin%2Fopenzeppelin-contracts" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;repo details fork button&quot;,&quot;repository_id&quot;:64700934,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="5a7b8dc02df0646fe0ff8d64ee691c1fc12c4665d7cb0a26b2fdecf7bfa9a820" aria-label="You must be signed in to fork a repository" data-view-component="true" class="tooltipped tooltipped-s btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path> </svg>Fork <span id="repo-network-counter" data-pjax-replace="true" title="7,393" data-view-component="true" class="Counter">7.4k</span> </a> </li> <li> <div data-view-component="true" class="BtnGroup d-flex"> <a href="/login?return_to=%2FOpenZeppelin%2Fopenzeppelin-contracts" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:64700934,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="1a6c712bfff99329c33e9eb129a5cc200a21fcd8d5efa146c92e5d5ba90be84a" aria-label="You must be signed in to star a repository" data-view-component="true" class="tooltipped tooltipped-s btn-sm btn BtnGroup-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path> </svg><span data-view-component="true" class="d-inline"> Star </span> <span id="repo-stars-counter-star" aria-label="14696 users starred this repository" data-singular-suffix="user starred this repository" data-plural-suffix="users starred this repository" data-pjax-replace="true" title="14,696" data-view-component="true" class="Counter js-social-count">14.7k</span> </a> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="M4.427 7.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 7H4.604a.25.25 0 00-.177.427z"></path> </svg> </button></div> </li> <li> </li> </ul> </div> <div id="responsive-meta-container" data-pjax-replace> </div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <ul data-view-component="true" class="UnderlineNav-body list-style-none"> <li data-view-component="true" class="d-inline-flex"> <a id="code-tab" href="/OpenZeppelin/openzeppelin-contracts" data-tab-item="i0code-tab" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages repo_deployments /OpenZeppelin/openzeppelin-contracts" data-pjax="#repo-content-pjax-container" data-hotkey="g c" data-ga-click="Repository, Navigation click, Code tab" aria-current="page" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item selected"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M4.72 3.22a.75.75 0 011.06 1.06L2.06 8l3.72 3.72a.75.75 0 11-1.06 1.06L.47 8.53a.75.75 0 010-1.06l4.25-4.25zm6.56 0a.75.75 0 10-1.06 1.06L13.94 8l-3.72 3.72a.75.75 0 101.06 1.06l4.25-4.25a.75.75 0 000-1.06l-4.25-4.25z"></path> </svg> <span data-content="Code">Code</span> <span id="code-repo-tab-count" data-pjax-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="issues-tab" href="/OpenZeppelin/openzeppelin-contracts/issues" data-tab-item="i1issues-tab" data-selected-links="repo_issues repo_labels repo_milestones /OpenZeppelin/openzeppelin-contracts/issues" data-pjax="#repo-content-pjax-container" data-hotkey="g i" data-ga-click="Repository, Navigation click, Issues tab" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path> </svg> <span data-content="Issues">Issues</span> <span id="issues-repo-tab-count" data-pjax-replace="" title="79" data-view-component="true" class="Counter">79</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="pull-requests-tab" href="/OpenZeppelin/openzeppelin-contracts/pulls" data-tab-item="i2pull-requests-tab" data-selected-links="repo_pulls checks /OpenZeppelin/openzeppelin-contracts/pulls" data-pjax="#repo-content-pjax-container" data-hotkey="g p" data-ga-click="Repository, Navigation click, Pull requests tab" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M7.177 3.073L9.573.677A.25.25 0 0110 .854v4.792a.25.25 0 01-.427.177L7.177 3.427a.25.25 0 010-.354zM3.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122v5.256a2.251 2.251 0 11-1.5 0V5.372A2.25 2.25 0 011.5 3.25zM11 2.5h-1V4h1a1 1 0 011 1v5.628a2.251 2.251 0 101.5 0V5A2.5 2.5 0 0011 2.5zm1 10.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0zM3.75 12a.75.75 0 100 1.5.75.75 0 000-1.5z"></path> </svg> <span data-content="Pull requests">Pull requests</span> <span id="pull-requests-repo-tab-count" data-pjax-replace="" title="15" data-view-component="true" class="Counter">15</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="actions-tab" href="/OpenZeppelin/openzeppelin-contracts/actions" data-tab-item="i3actions-tab" data-selected-links="repo_actions /OpenZeppelin/openzeppelin-contracts/actions" data-pjax="#repo-content-pjax-container" data-hotkey="g a" data-ga-click="Repository, Navigation click, Actions tab" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zM6.379 5.227A.25.25 0 006 5.442v5.117a.25.25 0 00.379.214l4.264-2.559a.25.25 0 000-.428L6.379 5.227z"></path> </svg> <span data-content="Actions">Actions</span> <span id="actions-repo-tab-count" data-pjax-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="security-tab" href="/OpenZeppelin/openzeppelin-contracts/security" data-tab-item="i4security-tab" data-selected-links="security overview alerts policy token_scanning code_scanning /OpenZeppelin/openzeppelin-contracts/security" data-pjax="#repo-content-pjax-container" data-hotkey="g s" data-ga-click="Repository, Navigation click, Security tab" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M7.467.133a1.75 1.75 0 011.066 0l5.25 1.68A1.75 1.75 0 0115 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.7 1.7 0 01-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 011.217-1.667l5.25-1.68zm.61 1.429a.25.25 0 00-.153 0l-5.25 1.68a.25.25 0 00-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.2.2 0 00.154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.25.25 0 00-.174-.237l-5.25-1.68zM9 10.5a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.75a.75.75 0 10-1.5 0v3a.75.75 0 001.5 0v-3z"></path> </svg> <span data-content="Security">Security</span> <include-fragment src="/OpenZeppelin/openzeppelin-contracts/security/overall-count" accept="text/fragment+html"></include-fragment> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="insights-tab" href="/OpenZeppelin/openzeppelin-contracts/pulse" data-tab-item="i5insights-tab" data-selected-links="repo_graphs repo_contributors dependency_graph dependabot_updates pulse people community /OpenZeppelin/openzeppelin-contracts/pulse" data-pjax="#repo-content-pjax-container" data-ga-click="Repository, Navigation click, Insights tab" data-view-component="true" class="UnderlineNav-item hx_underlinenav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path fill-rule="evenodd" d="M1.5 1.75a.75.75 0 00-1.5 0v12.5c0 .414.336.75.75.75h14.5a.75.75 0 000-1.5H1.5V1.75zm14.28 2.53a.75.75 0 00-1.06-1.06L10 7.94 7.53 5.47a.75.75 0 00-1.06 0L3.22 8.72a.75.75 0 001.06 1.06L7 7.06l2.47 2.47a.75.75 0 001.06 0l5.25-5.25z"></path> </svg> <span data-content="Insights">Insights</span> <span id="insights-repo-tab-count" data-pjax-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> </ul> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path> </svg> <span class="sr-only">More</span> </div> </summary> <div data-view-component="true"> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> <ul> <li data-menu-item="i0code-tab" hidden> <a role="menuitem" class="js-selected-navigation-item selected dropdown-item" aria-current="page" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages repo_deployments /OpenZeppelin/openzeppelin-contracts" href="/OpenZeppelin/openzeppelin-contracts"> Code </a> </li> <li data-menu-item="i1issues-tab" hidden> <a role="menuitem" class="js-selected-navigation-item dropdown-item" data-selected-links="repo_issues repo_labels repo_milestones /OpenZeppelin/openzeppelin-contracts/issues" href="/OpenZeppelin/openzeppelin-contracts/issues"> Issues </a> </li> <li data-menu-item="i2pull-requests-tab" hidden> <a role="menuitem" class="js-selected-navigation-item dropdown-item" data-selected-links="repo_pulls checks /OpenZeppelin/openzeppelin-contracts/pulls" href="/OpenZeppelin/openzeppelin-contracts/pulls"> Pull requests </a> </li> <li data-menu-item="i3actions-tab" hidden> <a role="menuitem" class="js-selected-navigation-item dropdown-item" data-selected-links="repo_actions /OpenZeppelin/openzeppelin-contracts/actions" href="/OpenZeppelin/openzeppelin-contracts/actions"> Actions </a> </li> <li data-menu-item="i4security-tab" hidden> <a role="menuitem" class="js-selected-navigation-item dropdown-item" data-selected-links="security overview alerts policy token_scanning code_scanning /OpenZeppelin/openzeppelin-contracts/security" href="/OpenZeppelin/openzeppelin-contracts/security"> Security </a> </li> <li data-menu-item="i5insights-tab" hidden> <a role="menuitem" class="js-selected-navigation-item dropdown-item" data-selected-links="repo_graphs repo_contributors dependency_graph dependabot_updates pulse people community /OpenZeppelin/openzeppelin-contracts/pulse" href="/OpenZeppelin/openzeppelin-contracts/pulse"> Insights </a> </li> </ul> </details-menu></div> </details></div> </nav> </div> <div class="clearfix new-discussion-timeline container-xl px-3 px-md-4 px-lg-5"> <div id="repo-content-pjax-container" class="repository-content " > <div> <a class="d-none js-permalink-shortcut" data-hotkey="y" href="/OpenZeppelin/openzeppelin-contracts/blob/a9f994f063b3c119f6fafd74ea7e51a5b5f98545/contracts/access/Ownable.sol">Permalink</a> <div class="d-flex flex-items-start flex-shrink-0 pb-3 flex-wrap flex-md-nowrap flex-justify-between flex-md-justify-start"> <div class="position-relative"> <details class="details-reset details-overlay mr-0 mb-0 " id="branch-select-menu"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path fill-rule="evenodd" d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"></path> </svg> <span class="css-truncate-target" data-menu-button>master</span> <span class="dropdown-caret"></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span class="SelectMenu-title">Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path> </svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" class="d-flex flex-column flex-auto overflow-auto" tabindex=""> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/OpenZeppelin/openzeppelin-contracts/refs" cache-key="v0:1641000891.890526" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="T3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHM=" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div> </template> <!-- TODO: this max-height is necessary or else the branch list won't scroll. why? --> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /> </svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/{{ urlEncodedRefName }}/contracts/access/Ownable.sol" class="SelectMenu-item" role="menuitemradio" rel="nofollow" aria-checked="{{ isCurrent }}" data-index="{{ index }}"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path> </svg> <span class="flex-1 css-truncate css-truncate-overflow {{ isFilteringClass }}">{{ refName }}</span> <span hidden="{{ isNotDefault }}" class="Label Label--secondary flex-self-start">default</span> </a> </template> <footer class="SelectMenu-footer"><a href="/OpenZeppelin/openzeppelin-contracts/branches">View all branches</a></footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" class="d-flex flex-column flex-auto overflow-auto" tabindex="" hidden> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/OpenZeppelin/openzeppelin-contracts/refs" cache-key="v0:1641000891.890526" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="T3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHM=" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/{{ urlEncodedRefName }}/contracts/access/Ownable.sol" class="SelectMenu-item" role="menuitemradio" rel="nofollow" aria-checked="{{ isCurrent }}" data-index="{{ index }}"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path> </svg> <span class="flex-1 css-truncate css-truncate-overflow {{ isFilteringClass }}">{{ refName }}</span> <span hidden="{{ isNotDefault }}" class="Label Label--secondary flex-self-start">default</span> </a> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" style="max-height: 330px" data-pjax="#repo-content-pjax-container"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /> </svg> </div> </div> <footer class="SelectMenu-footer"><a href="/OpenZeppelin/openzeppelin-contracts/tags">View all tags</a></footer> </ref-selector> </div> </tab-container> </input-demux> </div> </div> </details> </div> <h2 id="blob-path" class="breadcrumb flex-auto flex-self-center min-width-0 text-normal mx-2 width-full width-md-auto flex-order-1 flex-md-order-none mt-3 mt-md-0"> <span class="js-repo-root text-bold"><span class="js-path-segment d-inline-block wb-break-all"><a data-pjax="#repo-content-pjax-container" href="/OpenZeppelin/openzeppelin-contracts"><span>openzeppelin-contracts</span></a></span></span><span class="separator">/</span><span class="js-path-segment d-inline-block wb-break-all"><a data-pjax="#repo-content-pjax-container" href="/OpenZeppelin/openzeppelin-contracts/tree/master/contracts"><span>contracts</span></a></span><span class="separator">/</span><span class="js-path-segment d-inline-block wb-break-all"><a data-pjax="#repo-content-pjax-container" href="/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/access"><span>access</span></a></span><span class="separator">/</span><strong class="final-path">Ownable.sol</strong> </h2> <a href="/OpenZeppelin/openzeppelin-contracts/find/master" class="js-pjax-capture-input btn mr-2 d-none d-md-block" data-pjax data-hotkey="t"> Go to file </a> <details id="blob-more-options-details" data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true" class="btn"> <svg aria-label="More options" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path> </svg> </summary> <div data-view-component="true"> <ul class="dropdown-menu dropdown-menu-sw"> <li class="d-block d-md-none"> <a class="dropdown-item d-flex flex-items-baseline" data-hydro-click="{&quot;event_type&quot;:&quot;repository.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;FIND_FILE_BUTTON&quot;,&quot;repository_id&quot;:64700934,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="12ec3fad0531564c9444c57e2710723b50bfa6e4ac69b4175bf1c9d1194b1e07" data-ga-click="Repository, find file, location:repo overview" data-hotkey="t" data-pjax="true" href="/OpenZeppelin/openzeppelin-contracts/find/master"> <span class="flex-auto">Go to file</span> <span class="text-small color-fg-muted" aria-hidden="true">T</span> </a> </li> <li data-toggle-for="blob-more-options-details"> <button data-toggle-for="jumpto-line-details-dialog" type="button" data-view-component="true" class="dropdown-item btn-link"> <span class="d-flex flex-items-baseline"> <span class="flex-auto">Go to line</span> <span class="text-small color-fg-muted" aria-hidden="true">L</span> </span> </button> </li> <li class="dropdown-divider" role="none"></li> <li> <clipboard-copy data-toggle-for="blob-more-options-details" aria-label="Copy path" value="contracts/access/Ownable.sol" data-view-component="true" class="dropdown-item cursor-pointer"> Copy path </clipboard-copy> </li> <li> <clipboard-copy data-toggle-for="blob-more-options-details" aria-label="Copy permalink" value="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a9f994f063b3c119f6fafd74ea7e51a5b5f98545/contracts/access/Ownable.sol" data-view-component="true" class="dropdown-item cursor-pointer"> <span class="d-flex flex-items-baseline"> <span class="flex-auto">Copy permalink</span> </span> </clipboard-copy> </li> </ul> </div> </details> </div> <div class="Box d-flex flex-column flex-shrink-0 mb-3"> <div class="Box-header Details js-details-container"> <div class="d-flex flex-items-center"> <span class="flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1"> <a rel="contributor" data-skip-pjax="true" data-hovercard-type="user" data-hovercard-url="/users/frangio/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/frangio"><img class="avatar avatar-user" src="https://avatars.githubusercontent.com/u/481465?s=48&amp;v=4" width="24" height="24" alt="@frangio" /></a> </span> <div class="flex-1 d-flex flex-items-center ml-3 min-width-0"> <div class="css-truncate css-truncate-overflow"> <a class="text-bold Link--primary" rel="contributor" data-hovercard-type="user" data-hovercard-url="/users/frangio/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/frangio">frangio</a> <span class="markdown-title"> <a data-pjax="true" title="4.4.1" class="Link--secondary" href="/OpenZeppelin/openzeppelin-contracts/commit/6bd6b76d1156e20e45d1016f355d154141c7e5b9">4.4.1</a> </span> </div> <span class="ml-2"> <include-fragment accept="text/fragment+html" src="/OpenZeppelin/openzeppelin-contracts/commit/6bd6b76d1156e20e45d1016f355d154141c7e5b9/rollup?direction=e" class="d-inline"></include-fragment> </span> </div> <div class="ml-3 d-flex flex-shrink-0 flex-items-center flex-justify-end color-fg-muted no-wrap"> <span class="d-none d-md-inline"> <span>Latest commit</span> <a class="text-small text-mono Link--secondary" href="/OpenZeppelin/openzeppelin-contracts/commit/6bd6b76d1156e20e45d1016f355d154141c7e5b9" data-pjax>6bd6b76</a> <span itemprop="dateModified"><relative-time datetime="2021-12-14T16:14:39Z" class="no-wrap">Dec 14, 2021</relative-time></span> </span> <a data-pjax href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol" class="ml-3 no-wrap Link--primary no-underline"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path fill-rule="evenodd" d="M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z"></path> </svg> <span class="d-none d-sm-inline"> <strong>History</strong> </span> </a> </div> </div> </div> <div class="Box-body d-flex flex-items-center flex-auto border-bottom-0 flex-wrap" > <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default float-left mr-3" id="blob_contributors_box"> <summary class="Link--primary"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-people"> <path fill-rule="evenodd" d="M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"></path> </svg> <strong>6</strong> contributors </summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast" aria-label="Users who have contributed to this file" src="/OpenZeppelin/openzeppelin-contracts/contributors-list/master/contracts/access/Ownable.sol" preload> <div class="Box-header"> <button class="Box-btn-octicon btn-octicon float-right" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path> </svg> </button> <h3 class="Box-title"> Users who have contributed to this file </h3> </div> <include-fragment> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="my-3 mx-auto d-block anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /> </svg> </include-fragment> </details-dialog> </details> <span class=""> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/frangio/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=frangio"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/481465?s=48&amp;v=4" width="24" height="24" alt="@frangio" /> </a> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/Amxx/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=Amxx"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/2432299?s=48&amp;v=4" width="24" height="24" alt="@Amxx" /> </a> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/nventuro/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=nventuro"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/2530770?s=48&amp;v=4" width="24" height="24" alt="@nventuro" /> </a> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/elenadimitrova/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=elenadimitrova"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/703848?s=48&amp;v=4" width="24" height="24" alt="@elenadimitrova" /> </a> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/andrekorol/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=andrekorol"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/13073522?s=48&amp;v=4" width="24" height="24" alt="@andrekorol" /> </a> <a class="avatar-link" data-hovercard-type="user" data-hovercard-url="/users/psykeeper/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/OpenZeppelin/openzeppelin-contracts/commits/master/contracts/access/Ownable.sol?author=psykeeper"> <img class="avatar mr-2 avatar-user" src="https://avatars.githubusercontent.com/u/69228311?s=48&amp;v=4" width="24" height="24" alt="@psykeeper" /> </a> </span> </div> </div> <div data-target="readme-toc.content" class="Box mt-3 position-relative"> <div class="Box-header py-2 pr-2 d-flex flex-shrink-0 flex-md-row flex-items-center" > <div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1"> 76 lines (66 sloc) <span class="file-info-divider"></span> 2.4 KB </div> <div class="d-flex py-1 py-md-0 flex-auto flex-order-1 flex-md-order-2 flex-sm-grow-0 flex-justify-between hide-sm hide-md"> <div class="BtnGroup"> <a href="/OpenZeppelin/openzeppelin-contracts/raw/master/contracts/access/Ownable.sol" id="raw-url" data-view-component="true" class="btn-sm btn BtnGroup-item"> Raw </a> <a href="/OpenZeppelin/openzeppelin-contracts/blame/master/contracts/access/Ownable.sol" data-hotkey="b" data-view-component="true" class="js-update-url-with-hash btn-sm btn BtnGroup-item"> Blame </a> </div> <div> <a class="btn-octicon tooltipped tooltipped-nw js-remove-unless-platform" data-platforms="windows,mac" href="https://desktop.github.com" aria-label="Open this file in GitHub Desktop" data-ga-click="Repository, open with desktop"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-desktop"> <path fill-rule="evenodd" d="M1.75 2.5h12.5a.25.25 0 01.25.25v7.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25v-7.5a.25.25 0 01.25-.25zM14.25 1H1.75A1.75 1.75 0 000 2.75v7.5C0 11.216.784 12 1.75 12h3.727c-.1 1.041-.52 1.872-1.292 2.757A.75.75 0 004.75 16h6.5a.75.75 0 00.565-1.243c-.772-.885-1.193-1.716-1.292-2.757h3.727A1.75 1.75 0 0016 10.25v-7.5A1.75 1.75 0 0014.25 1zM9.018 12H6.982a5.72 5.72 0 01-.765 2.5h3.566a5.72 5.72 0 01-.765-2.5z"></path> </svg> </a> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2FOpenZeppelin%2Fopenzeppelin-contracts%2Fblob%2Fmaster%2Fcontracts%2Faccess%2FOwnable.sol" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-pencil"> <path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path> </svg> </a> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2FOpenZeppelin%2Fopenzeppelin-contracts%2Fblob%2Fmaster%2Fcontracts%2Faccess%2FOwnable.sol" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-trash"> <path fill-rule="evenodd" d="M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zm4.5 0V3h2.25a.75.75 0 010 1.5H2.75a.75.75 0 010-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75zM4.496 6.675a.75.75 0 10-1.492.15l.66 6.6A1.75 1.75 0 005.405 15h5.19c.9 0 1.652-.681 1.741-1.576l.66-6.6a.75.75 0 00-1.492-.149l-.66 6.6a.25.25 0 01-.249.225h-5.19a.25.25 0 01-.249-.225l-.66-6.6z"></path> </svg> </a> </div> </div> <div class="d-flex hide-lg hide-xl flex-order-2 flex-grow-0"> <details class="dropdown details-reset details-overlay d-inline-block"> <summary class="btn-octicon" aria-haspopup="true" aria-label="possible actions"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path> </svg> </summary> <ul class="dropdown-menu dropdown-menu-sw" style="width: 175px"> <li> <a class="dropdown-item tooltipped tooltipped-nw js-remove-unless-platform" data-platforms="windows,mac" href="https://desktop.github.com" data-ga-click="Repository, open with desktop"> Open with Desktop </a> </li> <li> <a class="dropdown-item" href="/OpenZeppelin/openzeppelin-contracts/raw/master/contracts/access/Ownable.sol"> View raw </a> </li> <li> </li> <li> <a class="dropdown-item" href="/OpenZeppelin/openzeppelin-contracts/blame/master/contracts/access/Ownable.sol"> View blame </a> </li> </ul> </details> </div> </div> <div itemprop="text" class="Box-body p-0 blob-wrapper data type-solidity gist-border-0"> <div class="js-check-bidi blob-code-content"> <template class="js-file-alert-template"> <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path> </svg> <span> This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. <a href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a> </span> <div data-view-component="true" class="flash-action"> <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn"> Show hidden characters </a> </div> </div></template> <template class="js-line-alert-template"> <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="bidi-line-alert tooltipped tooltipped-e"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path> </svg> </span></template> <table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-tab-size="4" data-paste-markdown-skip data-tagsearch-lang="Solidity" data-tagsearch-path="contracts/access/Ownable.sol"> <tr> <td id="L1" class="blob-num js-line-number js-code-nav-line-number" data-line-number="1"></td> <td id="LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// SPDX-License-Identifier: MIT</span></td> </tr> <tr> <td id="L2" class="blob-num js-line-number js-code-nav-line-number" data-line-number="2"></td> <td id="LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c">// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)</span></td> </tr> <tr> <td id="L3" class="blob-num js-line-number js-code-nav-line-number" data-line-number="3"></td> <td id="LC3" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L4" class="blob-num js-line-number js-code-nav-line-number" data-line-number="4"></td> <td id="LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">pragma</span> solidity <span class="pl-k">^</span><span class="pl-c1">0</span>.<span class="pl-c1">8</span>.<span class="pl-c1">0</span>;</td> </tr> <tr> <td id="L5" class="blob-num js-line-number js-code-nav-line-number" data-line-number="5"></td> <td id="LC5" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L6" class="blob-num js-line-number js-code-nav-line-number" data-line-number="6"></td> <td id="LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-k">import</span> <span class="pl-s">&quot;../utils/Context.sol&quot;</span>;</td> </tr> <tr> <td id="L7" class="blob-num js-line-number js-code-nav-line-number" data-line-number="7"></td> <td id="LC7" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L8" class="blob-num js-line-number js-code-nav-line-number" data-line-number="8"></td> <td id="LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-c">/**</span></td> </tr> <tr> <td id="L9" class="blob-num js-line-number js-code-nav-line-number" data-line-number="9"></td> <td id="LC9" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Contract module which provides a basic access control mechanism, where</span></td> </tr> <tr> <td id="L10" class="blob-num js-line-number js-code-nav-line-number" data-line-number="10"></td> <td id="LC10" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * there is an account (an owner) that can be granted exclusive access to</span></td> </tr> <tr> <td id="L11" class="blob-num js-line-number js-code-nav-line-number" data-line-number="11"></td> <td id="LC11" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * specific functions.</span></td> </tr> <tr> <td id="L12" class="blob-num js-line-number js-code-nav-line-number" data-line-number="12"></td> <td id="LC12" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> *</span></td> </tr> <tr> <td id="L13" class="blob-num js-line-number js-code-nav-line-number" data-line-number="13"></td> <td id="LC13" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * By default, the owner account will be the one that deploys the contract. This</span></td> </tr> <tr> <td id="L14" class="blob-num js-line-number js-code-nav-line-number" data-line-number="14"></td> <td id="LC14" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * can later be changed with {transferOwnership}.</span></td> </tr> <tr> <td id="L15" class="blob-num js-line-number js-code-nav-line-number" data-line-number="15"></td> <td id="LC15" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> *</span></td> </tr> <tr> <td id="L16" class="blob-num js-line-number js-code-nav-line-number" data-line-number="16"></td> <td id="LC16" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * This module is used through inheritance. It will make available the modifier</span></td> </tr> <tr> <td id="L17" class="blob-num js-line-number js-code-nav-line-number" data-line-number="17"></td> <td id="LC17" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * `onlyOwner`, which can be applied to your functions to restrict their use to</span></td> </tr> <tr> <td id="L18" class="blob-num js-line-number js-code-nav-line-number" data-line-number="18"></td> <td id="LC18" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * the owner.</span></td> </tr> <tr> <td id="L19" class="blob-num js-line-number js-code-nav-line-number" data-line-number="19"></td> <td id="LC19" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L20" class="blob-num js-line-number js-code-nav-line-number" data-line-number="20"></td> <td id="LC20" class="blob-code blob-code-inner js-file-line"><span class="pl-k">abstract</span> <span class="pl-k">contract<span class="pl-en"> Ownable</span> is <span class="pl-en">Context</span></span> {</td> </tr> <tr> <td id="L21" class="blob-num js-line-number js-code-nav-line-number" data-line-number="21"></td> <td id="LC21" class="blob-code blob-code-inner js-file-line"> <span class="pl-c1">address</span> <span class="pl-k">private</span> _owner;</td> </tr> <tr> <td id="L22" class="blob-num js-line-number js-code-nav-line-number" data-line-number="22"></td> <td id="LC22" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L23" class="blob-num js-line-number js-code-nav-line-number" data-line-number="23"></td> <td id="LC23" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">event <span class="pl-c1">OwnershipTransferred</span></span>(<span class="pl-c1">address</span> <span class="pl-k">indexed</span> <span class="pl-v">previousOwner</span>, <span class="pl-c1">address</span> <span class="pl-k">indexed</span> <span class="pl-v">newOwner</span>);</td> </tr> <tr> <td id="L24" class="blob-num js-line-number js-code-nav-line-number" data-line-number="24"></td> <td id="LC24" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L25" class="blob-num js-line-number js-code-nav-line-number" data-line-number="25"></td> <td id="LC25" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L26" class="blob-num js-line-number js-code-nav-line-number" data-line-number="26"></td> <td id="LC26" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Initializes the contract setting the deployer as the initial owner.</span></td> </tr> <tr> <td id="L27" class="blob-num js-line-number js-code-nav-line-number" data-line-number="27"></td> <td id="LC27" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L28" class="blob-num js-line-number js-code-nav-line-number" data-line-number="28"></td> <td id="LC28" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">constructor</span>() {</td> </tr> <tr> <td id="L29" class="blob-num js-line-number js-code-nav-line-number" data-line-number="29"></td> <td id="LC29" class="blob-code blob-code-inner js-file-line"> <span class="pl-c1">_transferOwnership</span>(<span class="pl-c1">_msgSender</span>());</td> </tr> <tr> <td id="L30" class="blob-num js-line-number js-code-nav-line-number" data-line-number="30"></td> <td id="LC30" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L31" class="blob-num js-line-number js-code-nav-line-number" data-line-number="31"></td> <td id="LC31" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L32" class="blob-num js-line-number js-code-nav-line-number" data-line-number="32"></td> <td id="LC32" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L33" class="blob-num js-line-number js-code-nav-line-number" data-line-number="33"></td> <td id="LC33" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Returns the address of the current owner.</span></td> </tr> <tr> <td id="L34" class="blob-num js-line-number js-code-nav-line-number" data-line-number="34"></td> <td id="LC34" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L35" class="blob-num js-line-number js-code-nav-line-number" data-line-number="35"></td> <td id="LC35" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">function<span class="pl-en"> owner</span></span>() <span class="pl-k">public</span> <span class="pl-k">view</span> <span class="pl-k">virtual</span> <span class="pl-k">returns</span> (<span class="pl-c1">address</span>) {</td> </tr> <tr> <td id="L36" class="blob-num js-line-number js-code-nav-line-number" data-line-number="36"></td> <td id="LC36" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> _owner;</td> </tr> <tr> <td id="L37" class="blob-num js-line-number js-code-nav-line-number" data-line-number="37"></td> <td id="LC37" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L38" class="blob-num js-line-number js-code-nav-line-number" data-line-number="38"></td> <td id="LC38" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L39" class="blob-num js-line-number js-code-nav-line-number" data-line-number="39"></td> <td id="LC39" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L40" class="blob-num js-line-number js-code-nav-line-number" data-line-number="40"></td> <td id="LC40" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Throws if called by any account other than the owner.</span></td> </tr> <tr> <td id="L41" class="blob-num js-line-number js-code-nav-line-number" data-line-number="41"></td> <td id="LC41" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L42" class="blob-num js-line-number js-code-nav-line-number" data-line-number="42"></td> <td id="LC42" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">modifier<span class="pl-en"> onlyOwner</span></span>() {</td> </tr> <tr> <td id="L43" class="blob-num js-line-number js-code-nav-line-number" data-line-number="43"></td> <td id="LC43" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">require</span>(<span class="pl-c1">owner</span>() <span class="pl-k">==</span> <span class="pl-c1">_msgSender</span>(), <span class="pl-s">&quot;Ownable: caller is not the owner&quot;</span>);</td> </tr> <tr> <td id="L44" class="blob-num js-line-number js-code-nav-line-number" data-line-number="44"></td> <td id="LC44" class="blob-code blob-code-inner js-file-line"> _;</td> </tr> <tr> <td id="L45" class="blob-num js-line-number js-code-nav-line-number" data-line-number="45"></td> <td id="LC45" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L46" class="blob-num js-line-number js-code-nav-line-number" data-line-number="46"></td> <td id="LC46" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L47" class="blob-num js-line-number js-code-nav-line-number" data-line-number="47"></td> <td id="LC47" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L48" class="blob-num js-line-number js-code-nav-line-number" data-line-number="48"></td> <td id="LC48" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Leaves the contract without owner. It will not be possible to call</span></td> </tr> <tr> <td id="L49" class="blob-num js-line-number js-code-nav-line-number" data-line-number="49"></td> <td id="LC49" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * `onlyOwner` functions anymore. Can only be called by the current owner.</span></td> </tr> <tr> <td id="L50" class="blob-num js-line-number js-code-nav-line-number" data-line-number="50"></td> <td id="LC50" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> *</span></td> </tr> <tr> <td id="L51" class="blob-num js-line-number js-code-nav-line-number" data-line-number="51"></td> <td id="LC51" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * NOTE: Renouncing ownership will leave the contract without an owner,</span></td> </tr> <tr> <td id="L52" class="blob-num js-line-number js-code-nav-line-number" data-line-number="52"></td> <td id="LC52" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * thereby removing any functionality that is only available to the owner.</span></td> </tr> <tr> <td id="L53" class="blob-num js-line-number js-code-nav-line-number" data-line-number="53"></td> <td id="LC53" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L54" class="blob-num js-line-number js-code-nav-line-number" data-line-number="54"></td> <td id="LC54" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">function<span class="pl-en"> renounceOwnership</span></span>() <span class="pl-k">public</span> <span class="pl-k">virtual</span> onlyOwner {</td> </tr> <tr> <td id="L55" class="blob-num js-line-number js-code-nav-line-number" data-line-number="55"></td> <td id="LC55" class="blob-code blob-code-inner js-file-line"> <span class="pl-c1">_transferOwnership</span>(<span class="pl-c1">address</span>(<span class="pl-c1">0</span>));</td> </tr> <tr> <td id="L56" class="blob-num js-line-number js-code-nav-line-number" data-line-number="56"></td> <td id="LC56" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L57" class="blob-num js-line-number js-code-nav-line-number" data-line-number="57"></td> <td id="LC57" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L58" class="blob-num js-line-number js-code-nav-line-number" data-line-number="58"></td> <td id="LC58" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L59" class="blob-num js-line-number js-code-nav-line-number" data-line-number="59"></td> <td id="LC59" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Transfers ownership of the contract to a new account (`newOwner`).</span></td> </tr> <tr> <td id="L60" class="blob-num js-line-number js-code-nav-line-number" data-line-number="60"></td> <td id="LC60" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * Can only be called by the current owner.</span></td> </tr> <tr> <td id="L61" class="blob-num js-line-number js-code-nav-line-number" data-line-number="61"></td> <td id="LC61" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L62" class="blob-num js-line-number js-code-nav-line-number" data-line-number="62"></td> <td id="LC62" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">function<span class="pl-en"> transferOwnership</span></span>(<span class="pl-c1">address</span> <span class="pl-v">newOwner</span>) <span class="pl-k">public</span> <span class="pl-k">virtual</span> onlyOwner {</td> </tr> <tr> <td id="L63" class="blob-num js-line-number js-code-nav-line-number" data-line-number="63"></td> <td id="LC63" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">require</span>(newOwner <span class="pl-k">!=</span> <span class="pl-c1">address</span>(<span class="pl-c1">0</span>), <span class="pl-s">&quot;Ownable: new owner is the zero address&quot;</span>);</td> </tr> <tr> <td id="L64" class="blob-num js-line-number js-code-nav-line-number" data-line-number="64"></td> <td id="LC64" class="blob-code blob-code-inner js-file-line"> <span class="pl-c1">_transferOwnership</span>(newOwner);</td> </tr> <tr> <td id="L65" class="blob-num js-line-number js-code-nav-line-number" data-line-number="65"></td> <td id="LC65" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L66" class="blob-num js-line-number js-code-nav-line-number" data-line-number="66"></td> <td id="LC66" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L67" class="blob-num js-line-number js-code-nav-line-number" data-line-number="67"></td> <td id="LC67" class="blob-code blob-code-inner js-file-line"> <span class="pl-c">/**</span></td> </tr> <tr> <td id="L68" class="blob-num js-line-number js-code-nav-line-number" data-line-number="68"></td> <td id="LC68" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * @dev Transfers ownership of the contract to a new account (`newOwner`).</span></td> </tr> <tr> <td id="L69" class="blob-num js-line-number js-code-nav-line-number" data-line-number="69"></td> <td id="LC69" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * Internal function without access restriction.</span></td> </tr> <tr> <td id="L70" class="blob-num js-line-number js-code-nav-line-number" data-line-number="70"></td> <td id="LC70" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> */</span></td> </tr> <tr> <td id="L71" class="blob-num js-line-number js-code-nav-line-number" data-line-number="71"></td> <td id="LC71" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">function<span class="pl-en"> _transferOwnership</span></span>(<span class="pl-c1">address</span> <span class="pl-v">newOwner</span>) <span class="pl-k">internal</span> <span class="pl-k">virtual</span> {</td> </tr> <tr> <td id="L72" class="blob-num js-line-number js-code-nav-line-number" data-line-number="72"></td> <td id="LC72" class="blob-code blob-code-inner js-file-line"> <span class="pl-c1">address</span> oldOwner = _owner;</td> </tr> <tr> <td id="L73" class="blob-num js-line-number js-code-nav-line-number" data-line-number="73"></td> <td id="LC73" class="blob-code blob-code-inner js-file-line"> _owner <span class="pl-k">=</span> newOwner;</td> </tr> <tr> <td id="L74" class="blob-num js-line-number js-code-nav-line-number" data-line-number="74"></td> <td id="LC74" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">emit</span> <span class="pl-c1">OwnershipTransferred</span>(oldOwner, newOwner);</td> </tr> <tr> <td id="L75" class="blob-num js-line-number js-code-nav-line-number" data-line-number="75"></td> <td id="LC75" class="blob-code blob-code-inner js-file-line"> }</td> </tr> <tr> <td id="L76" class="blob-num js-line-number js-code-nav-line-number" data-line-number="76"></td> <td id="LC76" class="blob-code blob-code-inner js-file-line">}</td> </tr> </table> </div> <details class="details-reset details-overlay BlobToolbar position-absolute js-file-line-actions dropdown d-none" aria-hidden="true"> <summary class="btn-octicon ml-0 px-2 p-0 color-bg-default border color-border-default rounded-1" aria-label="Inline file action toolbar"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path> </svg> </summary> <details-menu> <ul class="BlobToolbar-dropdown dropdown-menu dropdown-menu-se ml-2 mt-2" style="width:185px" > <li> <clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-lines" style="cursor:pointer;" aria-label="Copy lines"> Copy lines </clipboard-copy> </li> <li> <clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-permalink" style="cursor:pointer;" aria-label="Copy permalink"> Copy permalink </clipboard-copy> </li> <li><a class="dropdown-item js-update-url-with-hash" id="js-view-git-blame" role="menuitem" href="/OpenZeppelin/openzeppelin-contracts/blame/a9f994f063b3c119f6fafd74ea7e51a5b5f98545/contracts/access/Ownable.sol">View git blame</a></li> <li><a class="dropdown-item" id="js-new-issue" role="menuitem" href="/OpenZeppelin/openzeppelin-contracts/issues/new">Reference in new issue</a></li> </ul> </details-menu> </details> </div> </div> <details class="details-reset details-overlay details-overlay-dark" id="jumpto-line-details-dialog"> <summary data-hotkey="l" aria-label="Jump to line"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"> <input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" aria-label="Jump to line" autofocus> <button data-close-dialog="" type="submit" data-view-component="true" class="btn"> Go </button> </form> </details-dialog> </details> </div> </div> </div> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <ul class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <li class="mt-2 mt-lg-0 d-flex flex-items-center"> <a aria-label="Homepage" title="GitHub" class="footer-octicon mr-2" href="https://github.com"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path> </svg> </a> <span> &copy; 2022 GitHub, Inc. </span> </li> </ul> <ul class="list-style-none d-flex flex-wrap col-12 col-lg-8 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <li class="mr-3 mr-lg-0"><a href="https://docs.github.com/en/github/site-policy/github-terms-of-service" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to terms&quot;,&quot;label&quot;:&quot;text:terms&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="60dacd2555b126016954d73cfb54da0e1ab057f87cf41f3212716efea2167926" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to terms&quot;,&quot;label&quot;:&quot;text:terms&quot;}">Terms</a></li> <li class="mr-3 mr-lg-0"><a href="https://docs.github.com/en/github/site-policy/github-privacy-statement" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to privacy&quot;,&quot;label&quot;:&quot;text:privacy&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="521e27be8aeed50c3787a1886fc95e51ffa9b0da2a644643c91cf4cf8b4ddc84" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to privacy&quot;,&quot;label&quot;:&quot;text:privacy&quot;}">Privacy</a></li> <li class="mr-3 mr-lg-0"><a data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to security&quot;,&quot;label&quot;:&quot;text:security&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="8c3dee199ea76f390a3c04d77b6e4a669ae143fed79ac76ea317c6c78501bc52" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to security&quot;,&quot;label&quot;:&quot;text:security&quot;}" href="https://github.com/security">Security</a></li> <li class="mr-3 mr-lg-0"><a href="https://www.githubstatus.com/" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to status&quot;,&quot;label&quot;:&quot;text:status&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="d56cb7f4f5814fab8c73890cc7c727d5982f8a0ab34a7e35358481de9867a7d2" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to status&quot;,&quot;label&quot;:&quot;text:status&quot;}">Status</a></li> <li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to help, text:Docs" href="https://docs.github.com">Docs</a></li> <li class="mr-3 mr-lg-0"><a href="https://support.github.com?tags=dotcom-footer" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to contact&quot;,&quot;label&quot;:&quot;text:contact&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="03b75a75f4a988a73cc823f992af29487af46bc59da8c043d71ade6325e73890" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to contact&quot;,&quot;label&quot;:&quot;text:contact&quot;}">Contact GitHub</a></li> <li class="mr-3 mr-lg-0"><a href="https://github.com/pricing" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to Pricing&quot;,&quot;label&quot;:&quot;text:Pricing&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="1a386d8edd12cbcc1f01f306414c668ee3606c69461f2fb3ae379f448e339f03" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to Pricing&quot;,&quot;label&quot;:&quot;text:Pricing&quot;}">Pricing</a></li> <li class="mr-3 mr-lg-0"><a href="https://docs.github.com" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to api&quot;,&quot;label&quot;:&quot;text:api&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="8eaa5c716b3396a983ffb048513abdcd463b12e66b3e8281c3ea3e8a17e1c538" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to api&quot;,&quot;label&quot;:&quot;text:api&quot;}">API</a></li> <li class="mr-3 mr-lg-0"><a href="https://services.github.com" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to training&quot;,&quot;label&quot;:&quot;text:training&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="a2f8f90134e25e2cc088563186945e03be5a59f1ad5ad7d8a46dff6214367345" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to training&quot;,&quot;label&quot;:&quot;text:training&quot;}">Training</a></li> <li class="mr-3 mr-lg-0"><a href="https://github.blog" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to blog&quot;,&quot;label&quot;:&quot;text:blog&quot;,&quot;originating_url&quot;:&quot;https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="2e3ac9a3d10c051545fa9423b340857e4d361eac3730638a1e333150a3f8ca71" data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to blog&quot;,&quot;label&quot;:&quot;text:blog&quot;}">Blog</a></li> <li><a data-ga-click="Footer, go to about, text:about" href="https://github.com/about">About</a></li> </ul> </div> <div class="d-flex flex-justify-center pb-6"> <span class="f6 color-fg-muted"></span> </div> </footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path> </svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path> </svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path> </svg> <span class="js-stale-session-flash-signed-in" hidden>You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span> <span class="js-stale-session-flash-signed-out" hidden>You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal" aria-labelledby="box-title"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path> </svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details> </template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div> </div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path> </svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path> </svg> </clipboard-copy> </div> </template> </body> </html>
github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="30070e2749118f4864b7d78e3f52a418e2b1c0644bc49acaf9e8db41664de66d" data-analytics-event="{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Issues&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Issues;&quot;}" href="/features/issues">
<a class="lh-condensed-ultra d-block no-underline position-relative Link--secondary py-2" data-hydro-click="{&quot;event_type&quot;:&quot;analytics.event&quot;,&quot;payload&quot;:{&quot;category&quot;:&quot;Header dropdown (logged out), Why GitHub?&quot;,&quot;action&quot;:&quot;click to go to Issues&quot;,&quot;label&quot;:&quot;ref_page:/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol;ref_cta:Issues;&quot;,&quot;originating_url&quot;:&quot;https:
1,780,553
[ 1, 4625, 348, 7953, 560, 30, 6133, 18, 832, 19, 3678, 62, 881, 84, 292, 267, 19, 3190, 94, 881, 84, 292, 267, 17, 16351, 87, 19, 10721, 19, 7525, 19, 16351, 87, 19, 3860, 19, 5460, 429, 18, 18281, 10, 9270, 31, 16, 10, 9270, 31, 1355, 67, 350, 10, 9270, 31, 30, 2011, 23644, 501, 17, 18112, 9005, 17, 7475, 17, 19820, 1546, 19249, 7301, 73, 5324, 7616, 25652, 74, 8875, 1105, 70, 27, 72, 8285, 73, 23, 74, 9401, 69, 24, 2643, 73, 22, 70, 21, 71, 20, 22087, 13459, 7616, 1077, 1727, 29, 73, 28, 1966, 24, 2313, 1105, 323, 6028, 72, 6, 501, 17, 18466, 17, 2575, 21928, 10, 9270, 31, 4743, 10, 9270, 31, 30, 10, 9270, 31, 1864, 13972, 261, 19385, 596, 3631, 3497, 93, 15668, 35, 10, 9270, 31, 16, 10, 9270, 31, 1128, 10, 9270, 31, 30, 10, 9270, 31, 7475, 358, 1960, 358, 9310, 3610, 10, 9270, 31, 16, 10, 9270, 31, 1925, 10, 9270, 31, 30, 10, 9270, 31, 1734, 67, 2433, 27824, 3678, 62, 881, 84, 292, 267, 19, 3190, 94, 881, 84, 292, 267, 17, 16351, 87, 19, 10721, 19, 7525, 19, 16351, 87, 19, 3860, 19, 5460, 429, 18, 18281, 31, 1734, 67, 299, 69, 30, 17316, 23480, 9270, 31, 1532, 3897, 1546, 19, 7139, 19, 9618, 6441, 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, 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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 ]
[ 1, 565, 411, 69, 667, 1546, 80, 76, 17, 10013, 28003, 17, 332, 2033, 302, 17, 2629, 1158, 17, 9341, 1369, 1754, 17, 11626, 4048, 413, 19674, 2395, 17, 22, 6, 501, 17, 18112, 9005, 17, 7475, 21928, 10, 9270, 31, 2575, 67, 723, 10, 9270, 31, 30, 10, 9270, 31, 18466, 18, 2575, 10, 9270, 31, 16, 10, 9270, 31, 7648, 10, 9270, 31, 18611, 10, 9270, 31, 4743, 10, 9270, 31, 30, 10, 9270, 31, 1864, 13972, 261, 19385, 596, 3631, 3497, 93, 15668, 35, 10, 9270, 31, 16, 10, 9270, 31, 1128, 10, 9270, 31, 30, 10, 9270, 31, 7475, 358, 1960, 358, 9310, 3610, 10, 9270, 31, 16, 10, 9270, 31, 1925, 10, 9270, 31, 30, 10, 9270, 31, 1734, 67, 2433, 27824, 3678, 62, 881, 84, 292, 267, 19, 3190, 94, 881, 84, 292, 267, 17, 16351, 87, 19, 10721, 19, 7525, 19, 16351, 87, 19, 3860, 19, 5460, 429, 18, 18281, 31, 1734, 67, 299, 69, 30, 17316, 23480, 9270, 31, 16, 10, 9270, 31, 10012, 1776, 67, 718, 10, 9270, 31, 30, 10, 9270, 31, 4528, 30, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title StringConversions.sol - A utility solidity library for converting various things into a string format * @author Karsh Sinha <[email protected]> */ library StringConversions { /** * @dev Converts a decimal number to a string. The decimal number is represented by a int256 and always assuming two decimal places e.g. 435->"4.35"; -2843->"-28.43" * @param _value The decimal number (represented by int256) to convert to a string * @return result The string representation of the decimal number */ function decimalTwoSigFigsToStrings(int256 _value) external pure returns (string memory result) { int256 whole = _value / 100; int256 fractionInt = _value % 100; uint256 fraction = uint256(fractionInt >=0 ? fractionInt : -fractionInt); string memory fractionStr; if (fraction < 10) { fractionStr = string(abi.encodePacked("0", _toString(fraction))); } else { fractionStr = _toString(fraction); } result = string(abi.encodePacked( (_value >= -99 && _value < 0) ? "-": "", int256ToString(whole), ".", fractionStr )); } /** * @dev Converts a wallet address to its string representation * @param _address The wallet address to convert to a string * @return result The string representation of the wallet address */ function addressToString(address _address) external pure returns (string memory result) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { bytes1 b = bytes1(uint8(uint(uint160(_address)) / (2**(8*(19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2*i] = _char(hi); s[2*i+1] = _char(lo); } result = string(s); result = string(abi.encodePacked("0x", result)); } /** * @dev Convert an integer to a string * @param _value The int256 value to convert * @return result The string representation of the int256 value */ function int256ToString(int256 _value) public pure returns (string memory result) { uint256 _number = uint256((_value >= 0) ? _value : -_value); result = string(abi.encodePacked( (_value < 0) ? "-" : "", _toString(_number) )); } /** * @dev Convert an unsigned integer to a string * @param _value The uint256 value to convert * @return result The string representation of the uint256 */ function uint256ToString(uint256 _value) external pure returns (string memory result) { result = _toString(_value); } /** * @dev Convert a uint256 to a string. This function is a copy of the toString function in @openzeppelin/contracts/utils/Strings.sol * @param _value The uint256 to convert to string * @return result The string representation of the uint256 */ function _toString(uint256 _value) private pure returns (string memory result) { 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; } result = string(buffer); } function _char(bytes1 _b) private pure returns (bytes1 c) { if (uint8(_b) < 10) return bytes1(uint8(_b) + 0x30); else return bytes1(uint8(_b) + 0x57); } }
* @dev Converts a wallet address to its string representation @param _address The wallet address to convert to a string @return result The string representation of the wallet address/
function addressToString(address _address) external pure returns (string memory result) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { bytes1 b = bytes1(uint8(uint(uint160(_address)) / (2**(8*(19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2*i] = _char(hi); s[2*i+1] = _char(lo); } result = string(s); result = string(abi.encodePacked("0x", result)); }
1,014,583
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 20377, 279, 9230, 1758, 358, 2097, 533, 4335, 632, 891, 389, 2867, 1021, 9230, 1758, 358, 1765, 358, 279, 533, 632, 2463, 563, 1021, 533, 4335, 434, 326, 9230, 1758, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 11890, 28, 12, 11890, 12, 11890, 16874, 24899, 2867, 3719, 342, 261, 22, 636, 12, 28, 21556, 3657, 300, 277, 3719, 3719, 1769, 203, 5411, 1731, 21, 10118, 273, 1731, 21, 12, 11890, 28, 12, 70, 13, 342, 2872, 1769, 203, 5411, 1731, 21, 437, 273, 1731, 21, 12, 11890, 28, 12, 70, 13, 300, 2872, 380, 2254, 28, 12, 12266, 10019, 203, 5411, 272, 63, 22, 14, 77, 65, 273, 389, 3001, 12, 12266, 1769, 203, 5411, 272, 63, 22, 14, 77, 15, 21, 65, 273, 389, 3001, 12, 383, 1769, 2398, 203, 3639, 289, 203, 3639, 563, 273, 533, 12, 87, 1769, 203, 203, 3639, 563, 273, 533, 12, 21457, 18, 3015, 4420, 329, 2932, 20, 92, 3113, 563, 10019, 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 ]
pragma solidity ^0.5.16; pragma experimental ABIEncoderV2; import "openzeppelin-solidity-2.3.0/contracts/token/ERC20/SafeERC20.sol"; // Inheritance import "./Owned.sol"; import "./MixinSystemSettings.sol"; import "./interfaces/ICollateralLoan.sol"; // Libraries import "./SafeDecimalMath.sol"; // Internal references import "./interfaces/ICollateralUtil.sol"; import "./interfaces/ICollateralManager.sol"; import "./interfaces/ISystemStatus.sol"; import "./interfaces/IFeePool.sol"; import "./interfaces/IIssuer.sol"; import "./interfaces/ISynth.sol"; import "./interfaces/IExchangeRates.sol"; import "./interfaces/IExchanger.sol"; import "./interfaces/IShortingRewards.sol"; contract Collateral is ICollateralLoan, Owned, MixinSystemSettings { /* ========== LIBRARIES ========== */ using SafeMath for uint; using SafeDecimalMath for uint; using SafeERC20 for IERC20; /* ========== CONSTANTS ========== */ bytes32 private constant sUSD = "sUSD"; // ========== STATE VARIABLES ========== // The synth corresponding to the collateral. bytes32 public collateralKey; // Stores open loans. mapping(uint => Loan) public loans; ICollateralManager public manager; // The synths that this contract can issue. bytes32[] public synths; // Map from currency key to synth contract name. mapping(bytes32 => bytes32) public synthsByKey; // Map from currency key to the shorting rewards contract mapping(bytes32 => address) public shortingRewards; // ========== SETTER STATE VARIABLES ========== // The minimum collateral ratio required to avoid liquidation. uint public minCratio; // The minimum amount of collateral to create a loan. uint public minCollateral; bool public canOpenLoans = true; /* ========== ADDRESS RESOLVER CONFIGURATION ========== */ bytes32 private constant CONTRACT_SYSTEMSTATUS = "SystemStatus"; bytes32 private constant CONTRACT_EXRATES = "ExchangeRates"; bytes32 private constant CONTRACT_EXCHANGER = "Exchanger"; bytes32 private constant CONTRACT_FEEPOOL = "FeePool"; bytes32 private constant CONTRACT_SYNTHSUSD = "SynthsUSD"; bytes32 private constant CONTRACT_COLLATERALUTIL = "CollateralUtil"; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, ICollateralManager _manager, address _resolver, bytes32 _collateralKey, uint _minCratio, uint _minCollateral ) public Owned(_owner) MixinSystemSettings(_resolver) { manager = _manager; collateralKey = _collateralKey; minCratio = _minCratio; minCollateral = _minCollateral; } /* ========== VIEWS ========== */ function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = MixinSystemSettings.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](6); newAddresses[0] = CONTRACT_FEEPOOL; newAddresses[1] = CONTRACT_EXRATES; newAddresses[2] = CONTRACT_EXCHANGER; newAddresses[3] = CONTRACT_SYSTEMSTATUS; newAddresses[4] = CONTRACT_SYNTHSUSD; newAddresses[5] = CONTRACT_COLLATERALUTIL; bytes32[] memory combined = combineArrays(existingAddresses, newAddresses); addresses = combineArrays(combined, synths); } /* ---------- Related Contracts ---------- */ function _systemStatus() internal view returns (ISystemStatus) { return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS)); } function _synth(bytes32 synthName) internal view returns (ISynth) { return ISynth(requireAndGetAddress(synthName)); } function _synthsUSD() internal view returns (ISynth) { return ISynth(requireAndGetAddress(CONTRACT_SYNTHSUSD)); } function _exchangeRates() internal view returns (IExchangeRates) { return IExchangeRates(requireAndGetAddress(CONTRACT_EXRATES)); } function _exchanger() internal view returns (IExchanger) { return IExchanger(requireAndGetAddress(CONTRACT_EXCHANGER)); } function _feePool() internal view returns (IFeePool) { return IFeePool(requireAndGetAddress(CONTRACT_FEEPOOL)); } function _collateralUtil() internal view returns (ICollateralUtil) { return ICollateralUtil(requireAndGetAddress(CONTRACT_COLLATERALUTIL)); } /* ---------- Public Views ---------- */ function collateralRatio(uint id) public view returns (uint cratio) { Loan memory loan = loans[id]; return _collateralUtil().getCollateralRatio(loan, collateralKey); } function liquidationAmount(uint id) public view returns (uint liqAmount) { Loan memory loan = loans[id]; return _collateralUtil().liquidationAmount(loan, minCratio, collateralKey); } // The maximum number of synths issuable for this amount of collateral function maxLoan(uint amount, bytes32 currency) public view returns (uint max) { return _collateralUtil().maxLoan(amount, currency, minCratio, collateralKey); } function areSynthsAndCurrenciesSet(bytes32[] calldata _synthNamesInResolver, bytes32[] calldata _synthKeys) external view returns (bool) { if (synths.length != _synthNamesInResolver.length) { return false; } for (uint i = 0; i < _synthNamesInResolver.length; i++) { bytes32 synthName = _synthNamesInResolver[i]; if (synths[i] != synthName) { return false; } if (synthsByKey[_synthKeys[i]] != synths[i]) { return false; } } return true; } /* ---------- UTILITIES ---------- */ // Check the account has enough of the synth to make the payment function _checkSynthBalance( address payer, bytes32 key, uint amount ) internal view { require(IERC20(address(_synth(synthsByKey[key]))).balanceOf(payer) >= amount, "Not enough balance"); } // We set the interest index to 0 to indicate the loan has been closed. function _checkLoanAvailable(Loan memory loan) internal view { _isLoanOpen(loan.interestIndex); require(loan.lastInteraction.add(getInteractionDelay(address(this))) <= block.timestamp, "Recently interacted"); } function _isLoanOpen(uint interestIndex) internal pure { require(interestIndex != 0, "Loan is closed"); } function _issuanceRatio() internal view returns (uint ratio) { ratio = SafeDecimalMath.unit().divideDecimalRound(minCratio); } /* ========== MUTATIVE FUNCTIONS ========== */ /* ---------- Synths ---------- */ function addSynths(bytes32[] calldata _synthNamesInResolver, bytes32[] calldata _synthKeys) external onlyOwner { require(_synthNamesInResolver.length == _synthKeys.length, "Array length mismatch"); for (uint i = 0; i < _synthNamesInResolver.length; i++) { bytes32 synthName = _synthNamesInResolver[i]; synths.push(synthName); synthsByKey[_synthKeys[i]] = synthName; } // ensure cache has the latest rebuildCache(); } /* ---------- Rewards Contracts ---------- */ function addRewardsContracts(address rewardsContract, bytes32 synth) external onlyOwner { shortingRewards[synth] = rewardsContract; } /* ---------- LOAN INTERACTIONS ---------- */ function _open( uint collateral, uint amount, bytes32 currency, bool short ) internal rateIsValid issuanceIsActive returns (uint id) { // 0. Check if able to open loans. require(canOpenLoans, "Open disabled"); // 1. We can only issue certain synths. require(synthsByKey[currency] > 0, "Not allowed to issue"); // 2. Make sure the synth rate is not invalid. require(!_exchangeRates().rateIsInvalid(currency), "Invalid rate"); // 3. Collateral >= minimum collateral size. require(collateral >= minCollateral, "Not enough collateral"); // 4. Check we haven't hit the debt cap for non snx collateral. (bool canIssue, bool anyRateIsInvalid) = manager.exceedsDebtLimit(amount, currency); // 5. Check if we've hit the debt cap or any rate is invalid. require(canIssue && !anyRateIsInvalid, "Debt limit or invalid rate"); // 6. Require requested loan < max loan. require(amount <= maxLoan(collateral, currency), "Exceed max borrow power"); // 7. This fee is denominated in the currency of the loan. uint issueFee = amount.multiplyDecimalRound(getIssueFeeRate(address(this))); // 8. Calculate the minting fee and subtract it from the loan amount. uint loanAmountMinusFee = amount.sub(issueFee); // 9. Get a Loan ID. id = manager.getNewLoanId(); // 10. Create the loan struct. loans[id] = Loan({ id: id, account: msg.sender, collateral: collateral, currency: currency, amount: amount, short: short, accruedInterest: 0, interestIndex: 0, lastInteraction: block.timestamp }); // 11. Accrue interest on the loan. _accrueInterest(loans[id]); // 12. Pay the minting fees to the fee pool. _payFees(issueFee, currency); // 13. If its short, convert back to sUSD, otherwise issue the loan. if (short) { _synthsUSD().issue(msg.sender, _exchangeRates().effectiveValue(currency, loanAmountMinusFee, sUSD)); manager.incrementShorts(currency, amount); if (shortingRewards[currency] != address(0)) { IShortingRewards(shortingRewards[currency]).enrol(msg.sender, amount); } } else { _synth(synthsByKey[currency]).issue(msg.sender, loanAmountMinusFee); manager.incrementLongs(currency, amount); } // 14. Emit event for the newly opened loan. emit LoanCreated(msg.sender, id, amount, collateral, currency, issueFee); } function _close(address borrower, uint id) internal rateIsValid issuanceIsActive returns (uint amount, uint collateral) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Record loan as closed. (amount, collateral) = _closeLoan(borrower, borrower, loan); // 3. Emit the event for the closed loan. emit LoanClosed(borrower, id); } function _closeByLiquidation( address borrower, address liquidator, Loan storage loan ) internal returns (uint amount, uint collateral) { (amount, collateral) = _closeLoan(borrower, liquidator, loan); // Emit the event for the loan closed by liquidation. emit LoanClosedByLiquidation(borrower, loan.id, liquidator, amount, collateral); } function _closeLoan( address borrower, address liquidator, Loan storage loan ) internal returns (uint amount, uint collateral) { // 0. Work out the total amount owing on the loan. uint total = loan.amount.add(loan.accruedInterest); // 1. Store this for the event. amount = loan.amount; // 2. Return collateral to the child class so it knows how much to transfer. collateral = loan.collateral; // 3. Check that the liquidator has enough synths. _checkSynthBalance(liquidator, loan.currency, total); // 4. Burn the synths. _synth(synthsByKey[loan.currency]).burn(liquidator, total); // 5. Tell the manager. if (loan.short) { manager.decrementShorts(loan.currency, loan.amount); if (shortingRewards[loan.currency] != address(0)) { IShortingRewards(shortingRewards[loan.currency]).withdraw(borrower, loan.amount); } } else { manager.decrementLongs(loan.currency, loan.amount); } // 6. Pay fees. _payFees(loan.accruedInterest, loan.currency); // 7. Record loan as closed. _recordLoanAsClosed(loan); } function _closeLoanByRepayment(address borrower, uint id) internal returns (uint amount, uint collateral) { // 0. Get the loan. Loan storage loan = loans[id]; // 1. Repay the loan with its collateral. (amount, collateral) = _repayWithCollateral(borrower, id, loan.amount); // 2. Pay the service fee for collapsing the loan. uint serviceFee = amount.multiplyDecimalRound(getCollapseFeeRate(address(this))); _payFees(serviceFee, sUSD); collateral = collateral.sub(serviceFee); // 3. Record loan as closed. _recordLoanAsClosed(loan); // 4. Emit the event for the loan closed by repayment. emit LoanClosedByRepayment(borrower, id, amount, collateral); } function _deposit( address account, uint id, uint amount ) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. They sent some value > 0 require(amount > 0, "Deposit must be above 0"); // 1. Get the loan. // Owner is not important here, as it is a donation to the collateral of the loan Loan storage loan = loans[id]; // 2. Check loan hasn't been closed or liquidated. _isLoanOpen(loan.interestIndex); // 3. Accrue interest on the loan. _accrueInterest(loan); // 4. Add the collateral. loan.collateral = loan.collateral.add(amount); // 5. Emit the event for the deposited collateral. emit CollateralDeposited(account, id, amount, loan.collateral); return (loan.amount, loan.collateral); } function _withdraw(uint id, uint amount) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, msg.sender); // 1. Subtract the collateral. loan.collateral = loan.collateral.sub(amount); // 2. Check that the new amount does not put them under the minimum c ratio. _checkLoanRatio(loan); // 3. Emit the event for the withdrawn collateral. emit CollateralWithdrawn(msg.sender, id, amount, loan.collateral); return (loan.amount, loan.collateral); } function _liquidate( address borrower, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint collateralLiquidated) { require(payment > 0, "Payment must be above 0"); // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check they have enough balance to make the payment. _checkSynthBalance(msg.sender, loan.currency, payment); // 2. Check they are eligible for liquidation. // Note: this will revert if collateral is 0, however that should only be possible if the loan amount is 0. require(_collateralUtil().getCollateralRatio(loan, collateralKey) < minCratio, "Cratio above liq ratio"); // 3. Determine how much needs to be liquidated to fix their c ratio. uint liqAmount = _collateralUtil().liquidationAmount(loan, minCratio, collateralKey); // 4. Only allow them to liquidate enough to fix the c ratio. uint amountToLiquidate = liqAmount < payment ? liqAmount : payment; // 5. Work out the total amount owing on the loan. uint amountOwing = loan.amount.add(loan.accruedInterest); // 6. If its greater than the amount owing, we need to close the loan. if (amountToLiquidate >= amountOwing) { (, collateralLiquidated) = _closeByLiquidation(borrower, msg.sender, loan); return collateralLiquidated; } // 7. Check they have enough balance to liquidate the loan. _checkSynthBalance(msg.sender, loan.currency, amountToLiquidate); // 8. Process the payment to workout interest/principal split. _processPayment(loan, amountToLiquidate); // 9. Work out how much collateral to redeem. collateralLiquidated = _collateralUtil().collateralRedeemed(loan.currency, amountToLiquidate, collateralKey); loan.collateral = loan.collateral.sub(collateralLiquidated); // 10. Burn the synths from the liquidator. _synth(synthsByKey[loan.currency]).burn(msg.sender, amountToLiquidate); // 11. Emit the event for the partial liquidation. emit LoanPartiallyLiquidated(borrower, id, msg.sender, amountToLiquidate, collateralLiquidated); } function _repay( address borrower, address repayer, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan. // Owner is not important here, as it is a donation to repay the loan. Loan storage loan = loans[id]; // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Check the spender has enough synths to make the repayment _checkSynthBalance(repayer, loan.currency, payment); // 3. Accrue interest on the loan. _accrueInterest(loan); // 4. Process the payment. _processPayment(loan, payment); // 5. Burn synths from the payer _synth(synthsByKey[loan.currency]).burn(repayer, payment); // 6. Update the last interaction time. loan.lastInteraction = block.timestamp; // 7. Emit the event the repayment. emit LoanRepaymentMade(borrower, repayer, id, payment, loan.amount); // 8. Return the loan amount and collateral after repaying. return (loan.amount, loan.collateral); } function _repayWithCollateral( address borrower, uint id, uint payment ) internal rateIsValid issuanceIsActive returns (uint amount, uint collateral) { // 0. Get the loan to repay and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, borrower); // 1. Check loan is open and last interaction time. _checkLoanAvailable(loan); // 2. Repay the accrued interest. payment = payment.add(loan.accruedInterest); // 3. Make sure they are not overpaying. require(payment <= loan.amount.add(loan.accruedInterest), "Payment too high"); // 4. Get the expected amount for the exchange from borrowed synth -> sUSD. (uint expectedAmount, uint fee, ) = _exchanger().getAmountsForExchange(payment, loan.currency, sUSD); // 5. Reduce the collateral by the amount repaid (minus the exchange fees). loan.collateral = loan.collateral.sub(expectedAmount); // 6. Process the payment and pay the exchange fees if needed. _processPayment(loan, payment); _payFees(fee, sUSD); // 7. Update the last interaction time. loan.lastInteraction = block.timestamp; // 8. Emit the event for the collateral repayment. emit LoanRepaymentMade(borrower, borrower, id, payment, loan.amount); // 9. Return the amount repaid and the remaining collateral. return (payment, loan.collateral); } function _draw(uint id, uint amount) internal rateIsValid issuanceIsActive returns (uint, uint) { // 0. Get the loan and accrue interest. Loan storage loan = _getLoanAndAccrueInterest(id, msg.sender); // 1. Check last interaction time. _checkLoanAvailable(loan); // 2. Add the requested amount. loan.amount = loan.amount.add(amount); // 3. If it is below the minimum, don't allow this draw. _checkLoanRatio(loan); // 4. This fee is denominated in the currency of the loan uint issueFee = amount.multiplyDecimalRound(getIssueFeeRate(address(this))); // 5. Calculate the minting fee and subtract it from the draw amount uint amountMinusFee = amount.sub(issueFee); // 6. If its short, issue the synths. if (loan.short) { manager.incrementShorts(loan.currency, amount); _synthsUSD().issue(msg.sender, _exchangeRates().effectiveValue(loan.currency, amountMinusFee, sUSD)); if (shortingRewards[loan.currency] != address(0)) { IShortingRewards(shortingRewards[loan.currency]).enrol(msg.sender, amount); } } else { manager.incrementLongs(loan.currency, amount); _synth(synthsByKey[loan.currency]).issue(msg.sender, amountMinusFee); } // 7. Pay the minting fees to the fee pool _payFees(issueFee, loan.currency); // 8. Update the last interaction time. loan.lastInteraction = block.timestamp; // 9. Emit the event for the draw down. emit LoanDrawnDown(msg.sender, id, amount); return (loan.amount, loan.collateral); } // Update the cumulative interest rate for the currency that was interacted with. function _accrueInterest(Loan storage loan) internal { (uint differential, uint newIndex) = manager.accrueInterest(loan.interestIndex, loan.currency, loan.short); // If the loan was just opened, don't record any interest. Otherwise multiply by the amount outstanding. uint interest = loan.interestIndex == 0 ? 0 : loan.amount.multiplyDecimal(differential); // Update the loan. loan.accruedInterest = loan.accruedInterest.add(interest); loan.interestIndex = newIndex; } // Works out the amount of interest and principal after a repayment is made. function _processPayment(Loan storage loan, uint payment) internal { require(payment > 0, "Payment must be above 0"); if (loan.accruedInterest > 0) { uint interestPaid = payment > loan.accruedInterest ? loan.accruedInterest : payment; loan.accruedInterest = loan.accruedInterest.sub(interestPaid); payment = payment.sub(interestPaid); _payFees(interestPaid, loan.currency); } // If there is more payment left after the interest, pay down the principal. if (payment > 0) { loan.amount = loan.amount.sub(payment); // And get the manager to reduce the total long/short balance. if (loan.short) { manager.decrementShorts(loan.currency, payment); if (shortingRewards[loan.currency] != address(0)) { IShortingRewards(shortingRewards[loan.currency]).withdraw(loan.account, payment); } } else { manager.decrementLongs(loan.currency, payment); } } } // Take an amount of fees in a certain synth and convert it to sUSD before paying the fee pool. function _payFees(uint amount, bytes32 synth) internal { if (amount > 0) { if (synth != sUSD) { amount = _exchangeRates().effectiveValue(synth, amount, sUSD); } _synthsUSD().issue(_feePool().FEE_ADDRESS(), amount); _feePool().recordFeePaid(amount); } } function _recordLoanAsClosed(Loan storage loan) internal { loan.amount = 0; loan.collateral = 0; loan.accruedInterest = 0; loan.interestIndex = 0; loan.lastInteraction = block.timestamp; } function _getLoanAndAccrueInterest(uint id, address owner) internal returns (Loan storage loan) { loan = loans[id]; // Make sure the loan is open and it is the borrower. _isLoanOpen(loan.interestIndex); require(loan.account == owner, "Must be borrower"); _accrueInterest(loan); } function _checkLoanRatio(Loan storage loan) internal view { if (loan.amount == 0) { return; } require(collateralRatio(loan.id) > minCratio, "Cratio too low"); } // ========== MODIFIERS ========== modifier rateIsValid() { _requireRateIsValid(); _; } function _requireRateIsValid() private view { require(!_exchangeRates().rateIsInvalid(collateralKey), "Invalid rate"); } modifier issuanceIsActive() { _requireIssuanceIsActive(); _; } function _requireIssuanceIsActive() private view { _systemStatus().requireIssuanceActive(); } // ========== EVENTS ========== // Loans event LoanCreated(address indexed account, uint id, uint amount, uint collateral, bytes32 currency, uint issuanceFee); event LoanClosed(address indexed account, uint id); event CollateralDeposited(address indexed account, uint id, uint amountDeposited, uint collateralAfter); event CollateralWithdrawn(address indexed account, uint id, uint amountWithdrawn, uint collateralAfter); event LoanRepaymentMade(address indexed account, address indexed repayer, uint id, uint amountRepaid, uint amountAfter); event LoanDrawnDown(address indexed account, uint id, uint amount); event LoanPartiallyLiquidated( address indexed account, uint id, address liquidator, uint amountLiquidated, uint collateralLiquidated ); event LoanClosedByLiquidation( address indexed account, uint id, address indexed liquidator, uint amountLiquidated, uint collateralLiquidated ); event LoanClosedByRepayment(address indexed account, uint id, uint amountRepaid, uint collateralAfter); }
14. Emit event for the newly opened loan.
emit LoanCreated(msg.sender, id, amount, collateral, currency, issueFee);
6,456,514
[ 1, 4625, 348, 7953, 560, 30, 225, 5045, 18, 16008, 871, 364, 326, 10894, 10191, 28183, 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,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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 ]
./partial_match/1/0x3220034C7B2365f35BbD92D9f512B5c78eb5951B/sources/ETHGuru.sol
owner.transfer(msg.value);
function upgradeTier() external payable { User storage user = users[msg.sender]; require(user.refLink != 0); require(user.tier < 2); require(msg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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 202, 915, 8400, 15671, 1435, 3903, 8843, 429, 288, 203, 202, 202, 1299, 2502, 729, 273, 3677, 63, 3576, 18, 15330, 15533, 203, 202, 202, 6528, 12, 1355, 18, 1734, 2098, 480, 374, 1769, 203, 202, 202, 6528, 12, 1355, 18, 88, 2453, 411, 576, 1769, 203, 202, 202, 6528, 12, 3576, 18, 1132, 422, 17742, 31862, 63, 1355, 18, 88, 2453, 397, 404, 19226, 203, 202, 202, 17300, 12, 3576, 18, 15330, 1769, 203, 202, 202, 1355, 18, 88, 2453, 9904, 31, 203, 202, 97, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity 0.6.12; contract USDTex { using SafeMath for uint256; using SafeERC20 for IERC20; // USDT contract Decimals: 6 IERC20 public investToken; uint256 constant public INVEST_MIN_AMOUNT = 1e7; // 10 usdt uint256 constant public PERCENTS_DIVIDER = 1e13 ;//1000; uint256 constant public BASE_PERCENT = 1e11; uint256 constant public MAX_PERCENT = 18*(1e12); uint256 constant public MARKETING_FEE = 5*(1e11); uint256 constant public PROJECT_FEE = 5*(1e11); uint256 constant public REFERRAL_PERCENTS = 1e11; uint256 constant public TIME_STEP = 1 days ; //days uint256 constant public BASE_AMOUNT_DALIY = 1e12; // 100w USDT uint256 constant public START_POINT = 1603036800; // contract start timestample uint256 constant public PERCENT_INVEST = 10; // increase percent pre Invest uint256 constant public PERCENT_WITHDRAW = 15; // decreased percent pre Withdraw uint256 public presentPercent = 1e11; uint256 public presentDayAmount = BASE_AMOUNT_DALIY; uint256 public presentDaysInterval = 0; uint256 public totalLottery; //sum of latest 100 ticker uint256 public totalLotteryReward; //sum of 5% of invest uint256 public totalUsers; uint256 public totalInvested; uint256 public totalWithdrawn; uint256 public totalDeposits; bool public announceWinner; // announce Winners address public marketingAddress; address public projectAddress; struct Deposit { uint256 amount; uint256 withdrawn; uint256 start; } struct User { Deposit[] deposits; uint256 checkpoint; address referrer; uint256 bonus; uint256 totalInvested; // invite reward uint256 totalBonus; uint256 missedBonus; //lottery reward uint256 lotteryBonus; } struct LotteryTicket { address user; uint256 amount; } // modifier uniqueHash() { // require(_owner == msg.hash, "Ownable: caller is not the owner"); // _; // } mapping (address => User) internal users; mapping (uint256 => uint256) internal daliyInvestAmount; mapping(address => uint256[]) public userLotteryTicker; LotteryTicket[] public lotteryPool; event Newbie(address user); event NewDeposit(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RefBonus(address indexed referrer, address indexed referral, uint256 indexed level, uint256 amount); event FeePayed(address indexed user, uint256 totalAmount); event WithdrawWinning(address indexed user, uint256 amount); constructor(address _investToken, address marketingAddr, address projectAddr) public { require(!isContract(marketingAddr) && !isContract(projectAddr)); marketingAddress = marketingAddr; projectAddress = projectAddr; investToken = IERC20(_investToken); } function updateTodayAmount(uint daysInterval) private { if(daysInterval > presentDaysInterval) { uint power = daysInterval - presentDaysInterval; // presentDayAmount = presentDayAmount.mul(11**power).div(10**power); for (uint index = 0; index < power; index++) { presentDayAmount = presentDayAmount.mul(11).div(10); } presentDaysInterval = daysInterval; } } function invest(address referrer , uint256 _amount) public { require(_amount >= INVEST_MIN_AMOUNT, "Less than minimum"); require(!isContract(msg.sender), "cannot call from contract"); require(!announceWinner, "Game Over"); // game over! uint daysInterval = getDaysInterval(); // count days passed updateTodayAmount(daysInterval); uint todayAmount = presentDayAmount.sub(daliyInvestAmount[daysInterval]); require(todayAmount>0, "Sold out today"); uint amount = _amount > todayAmount ? _amount.sub(todayAmount) : _amount; investToken.safeTransferFrom(address(msg.sender), address(this), amount); investToken.safeTransfer( address(marketingAddress), amount.mul(PROJECT_FEE).div(PERCENTS_DIVIDER)); investToken.safeTransfer( address(projectAddress), amount.mul(PROJECT_FEE).div(PERCENTS_DIVIDER)); // emit FeePayed(msg.sender, amount.mul(MARKETING_FEE.add(PROJECT_FEE)).div(PERCENTS_DIVIDER)); User storage user = users[msg.sender]; if (user.referrer == address(0) && users[referrer].deposits.length > 0 && referrer != msg.sender) { user.referrer = referrer; } if (user.referrer != address(0)) { address upline = user.referrer; for (uint256 i = 0; i < 10; i++) { if (upline != address(0)) { uint256 bonuAmount = amount.mul(REFERRAL_PERCENTS).div(PERCENTS_DIVIDER); if (users[upline].totalBonus.add(bonuAmount) <= users[upline].totalInvested) { users[upline].bonus = users[upline].bonus.add(bonuAmount); users[upline].totalBonus = users[upline].totalBonus.add(bonuAmount); emit RefBonus(upline, msg.sender, i, bonuAmount); } else { users[upline].missedBonus = users[upline].missedBonus.add(bonuAmount); } upline = users[upline].referrer; } else break; } } if (user.deposits.length == 0) { user.checkpoint = block.timestamp; totalUsers = totalUsers.add(1); // emit Newbie(msg.sender); } user.deposits.push(Deposit(amount, 0, block.timestamp)); user.totalInvested = user.totalInvested.add(amount); updateRate(amount, true); addLotteryTicket(msg.sender, amount); daliyInvestAmount[daysInterval] = daliyInvestAmount[daysInterval].add(amount); totalInvested = totalInvested.add(amount); totalDeposits = totalDeposits.add(1); emit NewDeposit(msg.sender, amount); } function addLotteryTicket(address _user, uint256 _amount) private { uint256 index = totalDeposits % 100;//100 totalDeposits from 0 LotteryTicket[] storage lotPool = lotteryPool; if (lotPool.length == 100) { //reuse 100 totalLottery = totalLottery.add(_amount).sub(lotPool[index].amount); lotPool[index].amount = _amount; lotPool[index].user = _user; } else { lotPool.push(LotteryTicket({ user : _user, amount : _amount })); totalLottery = totalLottery.add(_amount); } userLotteryTicker[_user].push(index); totalLotteryReward = totalLotteryReward.add( _amount.div(20) ); } function withdrawWinning() public { require(announceWinner, "Not allowed"); uint256 winning = winningAmount(msg.sender); require(winning > 0, "No winnings"); User storage user = users[msg.sender]; user.lotteryBonus = user.lotteryBonus.add(winning); investToken.safeTransfer( msg.sender, winning); emit WithdrawWinning(msg.sender, winning); } function winningAmount(address _user) public view returns (uint256) { uint256[] memory useTickers = userLotteryTicker[_user]; if (useTickers.length == 0 ) { return 0; } uint userAmount; LotteryTicket[] memory lotPool = lotteryPool; for (uint i = useTickers.length - 1 ; i < useTickers.length; i--) { if(lotPool[useTickers[i]].user == _user) { userAmount = userAmount.add(lotPool[useTickers[i]].amount); }else break; } return userAmount.mul(totalLotteryReward).div(totalLottery).sub(users[msg.sender].lotteryBonus); } function withdraw() public { require(!announceWinner, "Game Over"); // game over! User storage user = users[msg.sender]; uint256 userPercentRate = presentPercent; uint256 totalAmount; uint256 dividends; for (uint256 i = 0; i < user.deposits.length; i++) { if (user.deposits[i].withdrawn < user.deposits[i].amount.mul(18).div(10)) { if (user.deposits[i].start > user.checkpoint) { dividends = (user.deposits[i].amount.mul(userPercentRate).div(PERCENTS_DIVIDER)) .mul(block.timestamp.sub(user.deposits[i].start)) .div(TIME_STEP); } else { dividends = (user.deposits[i].amount.mul(userPercentRate).div(PERCENTS_DIVIDER)) .mul(block.timestamp.sub(user.checkpoint)) .div(TIME_STEP); } if (user.deposits[i].withdrawn.add(dividends) > user.deposits[i].amount.mul(18).div(10)) { dividends = (user.deposits[i].amount.mul(18).div(10)).sub(user.deposits[i].withdrawn); } user.deposits[i].withdrawn = user.deposits[i].withdrawn.add(dividends); /// changing of storage data totalAmount = totalAmount.add(dividends); } } uint256 referralBonus = getUserReferralBonus(msg.sender); if (referralBonus > 0) { totalAmount = totalAmount.add(referralBonus); user.bonus = 0; } require(totalAmount > 0, "User has no dividends"); // balance = ERC20.balanceOf().sub(totalLotteryReward); uint256 contractBalance = investToken.balanceOf(address(this)).sub(totalLotteryReward); if (contractBalance <= totalAmount) { totalAmount = contractBalance; // Announce Winner, Game Over announceWinner = true; } user.checkpoint = block.timestamp; investToken.safeTransfer( msg.sender, totalAmount); totalWithdrawn = totalWithdrawn.add(totalAmount); updateRate(totalAmount, false); emit Withdrawn(msg.sender, totalAmount); } function getDailyAmount() public view returns (uint256) { //146 uint256 timePower = getDaysInterval().sub(presentDaysInterval); uint presentAmount = presentDayAmount; for (uint index = 0; index < timePower; index++) { // 10% increase daily presentAmount = presentAmount.mul(11).div(10); } return presentAmount; } function getDaysInterval() public view returns (uint256) { return now.sub(START_POINT).div(TIME_STEP); } function getContractBalance() public view returns (uint256) { return investToken.balanceOf(address(this)); } function updateRate(uint256 _amount, bool _invest) private { if (_invest) { presentPercent = presentPercent.add( _amount.mul(PERCENT_INVEST) ); if ( presentPercent > MAX_PERCENT ) { presentPercent = MAX_PERCENT; } } else { uint decrease = _amount.mul(PERCENT_WITHDRAW); if ( presentPercent < BASE_PERCENT.add(decrease) ) { presentPercent = BASE_PERCENT; } else { presentPercent = presentPercent.sub(decrease); } } } function getUserDividends(address userAddress) public view returns (uint256) { User storage user = users[userAddress]; uint256 userPercentRate = presentPercent; uint256 totalDividends; uint256 dividends; for (uint256 i = 0; i < user.deposits.length; i++) { if (user.deposits[i].withdrawn < user.deposits[i].amount.mul(18).div(10)) { if (user.deposits[i].start > user.checkpoint) { dividends = (user.deposits[i].amount.mul(userPercentRate).div(PERCENTS_DIVIDER)) .mul(block.timestamp.sub(user.deposits[i].start)) .div(TIME_STEP); } else { dividends = (user.deposits[i].amount.mul(userPercentRate).div(PERCENTS_DIVIDER)) .mul(block.timestamp.sub(user.checkpoint)) .div(TIME_STEP); } if (user.deposits[i].withdrawn.add(dividends) > user.deposits[i].amount.mul(18).div(10)) { dividends = (user.deposits[i].amount.mul(18).div(10)).sub(user.deposits[i].withdrawn); } totalDividends = totalDividends.add(dividends); /// no update of withdrawn because that is view function } } return totalDividends; } function getStartPoint() public pure returns(uint256) { return START_POINT; } function getUserPercent() public view returns(uint256) { return presentPercent.div(1e9); } function getBasePercent() public pure returns(uint256) { return BASE_PERCENT.div(1e9); } function getContractPercent() public view returns(uint256) { return presentPercent.sub(BASE_PERCENT).div(1e9); } function getTodayAmount() public view returns(uint256) { return getDailyAmount().sub(daliyInvestAmount[getDaysInterval()]); } function getUserCheckpoint(address userAddress) public view returns(uint256) { return users[userAddress].checkpoint; } function getUserMissedBonus(address userAddress) public view returns(uint256) { return users[userAddress].missedBonus; } function getUserTotalBonus(address userAddress) public view returns(uint256) { return users[userAddress].totalBonus; } function getUserReferrer(address userAddress) public view returns(address) { return users[userAddress].referrer; } function getUserReferralBonus(address userAddress) public view returns(uint256) { return users[userAddress].bonus; } function getUserAvailable(address userAddress) public view returns(uint256) { return getUserReferralBonus(userAddress).add(getUserDividends(userAddress)); } function getUserDepositInfo(address userAddress, uint256 index) public view returns(uint256, uint256, uint256) { User storage user = users[userAddress]; return (user.deposits[index].amount, user.deposits[index].withdrawn, user.deposits[index].start); } function getUserAmountOfDeposits(address userAddress) public view returns(uint256) { return users[userAddress].deposits.length; } function getUserTotalDeposits(address userAddress) public view returns(uint256) { User storage user = users[userAddress]; uint256 amount; for (uint256 i = 0; i < user.deposits.length; i++) { amount = amount.add(user.deposits[i].amount); } return amount; } function getUserTotalWithdrawn(address userAddress) public view returns(uint256) { User storage user = users[userAddress]; uint256 amount; for (uint256 i = 0; i < user.deposits.length; i++) { amount = amount.add(user.deposits[i].withdrawn); } return amount; } function isContract(address addr) internal view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } }
10% increase daily
for (uint index = 0; index < timePower; index++) {
10,613,134
[ 1, 4625, 348, 7953, 560, 30, 225, 1728, 9, 10929, 18872, 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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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, 202, 202, 1884, 261, 11890, 770, 273, 374, 31, 770, 411, 813, 13788, 31, 770, 27245, 288, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/* Copyright 2017-2018 Phillip A. Elsasser Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.4.24; import "../MarketContract.sol"; /// @title MarketContract first example of a MarketProtocol contract using Oraclize services /// @author Phil Elsasser <[email protected]> contract MarketContractOraclize is MarketContract { // constants string public ORACLE_DATA_SOURCE; string public ORACLE_QUERY; address public ORACLE_HUB_ADDRESS; /// @param contractName viewable name of this contract (BTC/ETH, LTC/ETH, etc) /// @param baseAddresses array of 2 addresses needed for our contract including: /// creatorAddress address of the person creating the contract /// collateralTokenAddress address of the ERC20 token that will be used for collateral and pricing /// collateralPoolAddress address of our collateral pool contract /// @param oracleHubAddress address of our oracle hub providing the callbacks /// @param contractSpecs array of unsigned integers including: /// floorPrice minimum tradeable price of this contract, contract enters settlement if breached /// capPrice maximum tradeable price of this contract, contract enters settlement if breached /// priceDecimalPlaces number of decimal places to convert our queried price from a floating point to /// an integer /// qtyMultiplier multiply traded qty by this value from base units of collateral token. /// expirationTimeStamp seconds from epoch that this contract expires and enters settlement /// @param oracleDataSource a data-source such as "URL", "WolframAlpha", "IPFS" /// see http://docs.oraclize.it/#ethereum-quick-start-simple-query /// @param oracleQuery see http://docs.oraclize.it/#ethereum-quick-start-simple-query for examples constructor( string contractName, address[3] baseAddresses, address oracleHubAddress, uint[5] contractSpecs, string oracleDataSource, string oracleQuery ) MarketContract( contractName, baseAddresses, contractSpecs ) public { ORACLE_DATA_SOURCE = oracleDataSource; ORACLE_QUERY = oracleQuery; ORACLE_HUB_ADDRESS = oracleHubAddress; // Future timestamp must be within 60 days from now. // https://docs.oraclize.it/#ethereum-quick-start-schedule-a-query-in-the-future require(EXPIRATION - now <= 60 days); } /* // PUBLIC METHODS */ /// @dev called only by our oracle hub when a new price is available provided by our oracle. /// @param price lastPrice provided by the oracle. function oracleCallBack(uint256 price) public onlyOracleHub { require(!isSettled); lastPrice = price; emit UpdatedLastPrice(price); checkSettlement(); // Verify settlement at expiration or requested early settlement. } /// @dev allows calls only from the oracle hub. modifier onlyOracleHub() { require(msg.sender == ORACLE_HUB_ADDRESS); _; } }
@dev allows calls only from the oracle hub.
modifier onlyOracleHub() { require(msg.sender == ORACLE_HUB_ADDRESS); _; }
1,040,584
[ 1, 4625, 348, 7953, 560, 30,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, 565, 9606, 1338, 23601, 8182, 1435, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 4869, 2226, 900, 67, 44, 3457, 67, 15140, 1769, 203, 3639, 389, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0xBe195aC3Ac406579cccCd8ab778A22BC9AEDD9e5/sources/MasterChef.sol
The block number when distribution to the DAO starts
uint256 public daoStartBlock;
4,208,444
[ 1, 4625, 348, 7953, 560, 30, 225, 1021, 1203, 1300, 1347, 7006, 358, 326, 463, 20463, 2542, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 2254, 5034, 1071, 15229, 1685, 1768, 31, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/1/0x8281f2bECfF37326Eb6cBE33527434611558B031/sources/BundleController.sol
burn corresponding nft -> as a result bundle looses its owner
function burn(uint256 bundleId) external override onlyRiskpoolService { Bundle storage bundle = _bundles[bundleId]; require(bundle.state == BundleState.Closed, "ERROR:BUC-016:BUNDLE_NOT_CLOSED"); require(bundle.balance == 0, "ERROR:BUC-017:BUNDLE_HAS_BALANCE"); _token.burn(bundleId); _unburntBundlesForRiskpoolId[bundle.riskpoolId] -= 1; _changeState(bundleId, BundleState.Burned); }
4,153,805
[ 1, 4625, 348, 7953, 560, 30, 225, 18305, 4656, 290, 1222, 317, 487, 279, 563, 3440, 437, 538, 281, 2097, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 18305, 12, 11890, 5034, 3440, 548, 13, 377, 203, 3639, 3903, 3849, 203, 3639, 1338, 54, 10175, 6011, 1179, 203, 565, 288, 203, 3639, 8539, 2502, 3440, 273, 389, 22773, 63, 9991, 548, 15533, 203, 3639, 2583, 12, 9991, 18, 2019, 422, 8539, 1119, 18, 7395, 16, 315, 3589, 30, 3000, 39, 17, 24171, 30, 30245, 67, 4400, 67, 28475, 8863, 203, 3639, 2583, 12, 9991, 18, 12296, 422, 374, 16, 315, 3589, 30, 3000, 39, 17, 1611, 27, 30, 30245, 67, 27765, 67, 38, 1013, 4722, 8863, 203, 203, 3639, 389, 2316, 18, 70, 321, 12, 9991, 548, 1769, 203, 3639, 389, 318, 70, 321, 88, 16151, 1290, 54, 10175, 6011, 548, 63, 9991, 18, 86, 10175, 6011, 548, 65, 3947, 404, 31, 203, 203, 3639, 389, 3427, 1119, 12, 9991, 548, 16, 8539, 1119, 18, 38, 321, 329, 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 ]
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; // ============ External Imports ============ import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; library GovernanceMessage { using TypedMemView for bytes; using TypedMemView for bytes29; // Batch message characteristics // * 1 item - the type uint256 private constant BATCH_PREFIX_ITEMS = 1; // * type is 1 byte long uint256 private constant BATCH_PREFIX_LEN = 1; // * Length of a Batch message // * type + batch hash uint256 private constant BATCH_MESSAGE_LEN = 1 + 32; // Serialized Call[] characteristics // * 1 item - the type uint256 private constant CALLS_PREFIX_ITEMS = 1; // * type is 1 byte long uint256 private constant CALLS_PREFIX_LEN = 1; // Serialized Call characteristics // * Location of the data blob in a serialized call // * address + length uint256 private constant CALL_DATA_OFFSET = 32 + 4; // Transfer Governance message characteristics // * Length of a Transfer Governance message // * type + domain + address uint256 private constant TRANSFER_GOV_MESSAGE_LEN = 1 + 4 + 32; struct Call { bytes32 to; bytes data; } enum Types { Invalid, // 0 Batch, // 1 - A Batch message TransferGovernor // 2 - A TransferGovernor message } // Read the type of a message function messageType(bytes29 _view) internal pure returns (Types) { return Types(uint8(_view.typeOf())); } // Read the message identifer (first byte) of a message function identifier(bytes29 _view) internal pure returns (uint8) { return uint8(_view.indexUint(0, 1)); } /* * Message Type: BATCH * struct Call { * identifier, // message ID -- 1 byte * batchHash // Hash of serialized calls (see below) -- 32 bytes * } * * struct Call { * to, // address to call -- 32 bytes * dataLen, // call data length -- 4 bytes, * data // call data -- 0+ bytes (variable) * } * * struct Calls * numCalls, // number of calls -- 1 byte * calls[] // serialized Call -- 0+ bytes * } */ // create a Batch message from a list of calls function formatBatch(Call[] memory _calls) internal view returns (bytes memory) { return abi.encodePacked(Types.Batch, getBatchHash(_calls)); } // serialize a call to memory and return a reference function serializeCall(Call memory _call) internal pure returns (bytes29) { return abi .encodePacked(_call.to, uint32(_call.data.length), _call.data) .ref(0); } function getBatchHash(Call[] memory _calls) internal view returns (bytes32) { // length prefix + 1 entry for each bytes29[] memory _encodedCalls = new bytes29[]( _calls.length + CALLS_PREFIX_ITEMS ); _encodedCalls[0] = abi.encodePacked(uint8(_calls.length)).ref(0); for (uint256 i = 0; i < _calls.length; i++) { _encodedCalls[i + CALLS_PREFIX_ITEMS] = serializeCall(_calls[i]); } return keccak256(TypedMemView.join(_encodedCalls)); } function isValidBatch(bytes29 _view) internal pure returns (bool) { return identifier(_view) == uint8(Types.Batch) && _view.len() == BATCH_MESSAGE_LEN; } function isBatch(bytes29 _view) internal pure returns (bool) { return isValidBatch(_view) && messageType(_view) == Types.Batch; } function tryAsBatch(bytes29 _view) internal pure returns (bytes29) { if (isValidBatch(_view)) { return _view.castTo(uint40(Types.Batch)); } return TypedMemView.nullView(); } function mustBeBatch(bytes29 _view) internal pure returns (bytes29) { return tryAsBatch(_view).assertValid(); } // Types.Batch function batchHash(bytes29 _view) internal pure returns (bytes32) { return _view.index(BATCH_PREFIX_LEN, 32); } /* * Message Type: TRANSFER GOVERNOR * struct TransferGovernor { * identifier, // message ID -- 1 byte * domain, // domain of new governor -- 4 bytes * addr // address of new governor -- 32 bytes * } */ function formatTransferGovernor(uint32 _domain, bytes32 _governor) internal view returns (bytes memory _msg) { _msg = TypedMemView.clone( mustBeTransferGovernor( abi .encodePacked(Types.TransferGovernor, _domain, _governor) .ref(0) ) ); } function isValidTransferGovernor(bytes29 _view) internal pure returns (bool) { return identifier(_view) == uint8(Types.TransferGovernor) && _view.len() == TRANSFER_GOV_MESSAGE_LEN; } function isTransferGovernor(bytes29 _view) internal pure returns (bool) { return isValidTransferGovernor(_view) && messageType(_view) == Types.TransferGovernor; } function tryAsTransferGovernor(bytes29 _view) internal pure returns (bytes29) { if (isValidTransferGovernor(_view)) { return _view.castTo(uint40(Types.TransferGovernor)); } return TypedMemView.nullView(); } function mustBeTransferGovernor(bytes29 _view) internal pure returns (bytes29) { return tryAsTransferGovernor(_view).assertValid(); } // Types.TransferGovernor function domain(bytes29 _view) internal pure returns (uint32) { return uint32(_view.indexUint(1, 4)); } // Types.TransferGovernor function governor(bytes29 _view) internal pure returns (bytes32) { return _view.index(5, 32); } }
Read the message identifer (first byte) of a message
function identifier(bytes29 _view) internal pure returns (uint8) { return uint8(_view.indexUint(0, 1)); }
12,881,821
[ 1, 4625, 348, 7953, 560, 30, 225, 2720, 326, 883, 3390, 21549, 261, 3645, 1160, 13, 434, 279, 883, 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, 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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 ]
[ 1, 565, 445, 2756, 12, 3890, 5540, 389, 1945, 13, 2713, 16618, 1135, 261, 11890, 28, 13, 288, 203, 3639, 327, 2254, 28, 24899, 1945, 18, 1615, 5487, 12, 20, 16, 404, 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 ]
./partial_match/4/0xCFDad4CeB8a9135FF18FC850031208B2c0024b25/sources/Pawnshop.sol
* @dev Returns true if the key is in the map. O(1)./
function contains(AddressToSupportStateMap storage map, address key) internal view returns (bool) { return _contains(map._inner, bytes32(uint256(key))); }
8,690,295
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 2860, 638, 309, 326, 498, 353, 316, 326, 852, 18, 531, 12, 21, 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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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 ]
[ 1, 565, 445, 1914, 12, 1887, 774, 6289, 1119, 863, 2502, 852, 16, 1758, 498, 13, 2713, 1476, 1135, 261, 6430, 13, 288, 203, 3639, 327, 389, 12298, 12, 1458, 6315, 7872, 16, 1731, 1578, 12, 11890, 5034, 12, 856, 3719, 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, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/42220/0x6Fbd4a4A602c8B564028a10D16e1deA8E67eD11e/sources/project_/contracts/ReserveController.sol
Calculate supplied token value
uint256 myShare = _amountIn / totalSupply;
16,325,178
[ 1, 4625, 348, 7953, 560, 30, 225, 9029, 4580, 1147, 460, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0x114d647B099D53237be9E03A540DFFaa24351E87/sources/contracts/interfaces/IParallaxOrbital.sol
* @notice Withdraw params with compoundAmountsOutMin./
struct WithdrawAndCompoundParams { bool toMakeCompound; uint256[] compoundAmountsOutMin; WithdrawParams withdrawParams; }
3,107,557
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 3423, 9446, 859, 598, 11360, 6275, 87, 1182, 2930, 18, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1958, 3423, 9446, 1876, 16835, 1370, 288, 203, 3639, 1426, 358, 6464, 16835, 31, 203, 3639, 2254, 5034, 8526, 11360, 6275, 87, 1182, 2930, 31, 203, 3639, 3423, 9446, 1370, 598, 9446, 1370, 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 ]
./full_match/137/0x5F6d37E9ae4004a9B7426d4CF99fa44949Ee3653/sources/contracts/NewRoll.sol
Settle bet. Function can only be called by fulfillRandomness function, which in turn can only be called by Chainlink VRF. Validation checks. Fetch bet parameters into local variables (to save gas). Do a roll by taking a modulo of random number. Win amount if gambler wins this bet Roll reward if gambler loses this bet Actual win amount by gambler. Determine dice outcome. For small modulo games, check the outcome against a bit mask. For larger modulos, check inclusion into half-open interval. Send prize to winner, add ROLL reward to loser, and update house profit.
function settleBet(bytes32 requestId, uint randomNumber) internal nonReentrant { uint betId = betMap[requestId]; Bet storage bet = bets[betId]; uint amount = bet.amount; require(amount > 0, "Bet does not exist"); require(bet.isSettled == false, "Bet is settled already"); uint modulo = bet.modulo; uint rollUnder = bet.rollUnder; address payable gambler = bet.gambler; uint outcome = randomNumber % modulo; uint possibleWinAmount = getWinAmount(amount, modulo, rollUnder); uint rollReward = getRollReward(amount, modulo, rollUnder); uint winAmount = 0; if (modulo <= MAX_MASK_MODULO) { if ((2 ** outcome) & bet.mask != 0) { winAmount = possibleWinAmount; rollReward = 0; } if (outcome < rollUnder) { winAmount = possibleWinAmount; rollReward = 0; } } bet.winAmount = winAmount; bet.outcome = outcome; if (winAmount > 0) { houseProfit -= int(winAmount - amount); gambler.transfer(winAmount); houseProfit += int(amount); miner.addReward(gambler, rollReward); } }
4,678,917
[ 1, 4625, 348, 7953, 560, 30, 225, 1000, 5929, 2701, 18, 4284, 848, 1338, 506, 2566, 635, 22290, 8529, 4496, 445, 16, 1492, 316, 7005, 848, 1338, 506, 2566, 635, 7824, 1232, 776, 12918, 18, 5684, 4271, 18, 8065, 2701, 1472, 1368, 1191, 3152, 261, 869, 1923, 16189, 2934, 2256, 279, 5824, 635, 13763, 279, 26109, 434, 2744, 1300, 18, 21628, 3844, 309, 314, 2536, 749, 31307, 333, 2701, 31291, 19890, 309, 314, 2536, 749, 437, 2420, 333, 2701, 23788, 5657, 3844, 635, 314, 2536, 749, 18, 10229, 302, 1812, 12884, 18, 2457, 5264, 26109, 28422, 16, 866, 326, 12884, 5314, 279, 2831, 3066, 18, 2457, 10974, 13340, 538, 16, 866, 26485, 1368, 8816, 17, 3190, 3673, 18, 2479, 846, 554, 358, 5657, 1224, 16, 527, 534, 30922, 19890, 358, 437, 550, 16, 471, 1089, 23867, 450, 7216, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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548, 273, 2701, 863, 63, 2293, 548, 15533, 203, 3639, 605, 278, 2502, 2701, 273, 324, 2413, 63, 70, 278, 548, 15533, 203, 3639, 2254, 3844, 273, 2701, 18, 8949, 31, 203, 540, 203, 3639, 2583, 12, 8949, 405, 374, 16, 315, 38, 278, 1552, 486, 1005, 8863, 203, 3639, 2583, 12, 70, 278, 18, 291, 694, 88, 1259, 422, 629, 16, 315, 38, 278, 353, 26319, 1259, 1818, 8863, 203, 203, 3639, 2254, 26109, 273, 2701, 18, 1711, 26478, 31, 203, 3639, 2254, 5824, 14655, 273, 2701, 18, 2693, 14655, 31, 203, 3639, 1758, 8843, 429, 314, 2536, 749, 273, 2701, 18, 75, 2536, 749, 31, 203, 203, 3639, 2254, 12884, 273, 2744, 1854, 738, 26109, 31, 203, 203, 3639, 2254, 3323, 18049, 6275, 273, 13876, 267, 6275, 12, 8949, 16, 26109, 16, 5824, 14655, 1769, 203, 203, 3639, 2254, 5824, 17631, 1060, 273, 4170, 22382, 17631, 1060, 12, 8949, 16, 26109, 16, 5824, 14655, 1769, 203, 203, 3639, 2254, 5657, 6275, 273, 374, 31, 203, 203, 3639, 309, 261, 1711, 26478, 1648, 4552, 67, 11704, 67, 6720, 57, 1502, 13, 288, 203, 5411, 309, 14015, 22, 2826, 12884, 13, 473, 2701, 18, 4455, 480, 374, 13, 288, 203, 7734, 5657, 6275, 273, 3323, 18049, 6275, 31, 203, 7734, 5824, 17631, 1060, 273, 374, 31, 203, 5411, 289, 203, 5411, 309, 261, 21672, 411, 5824, 14655, 13, 288, 203, 7734, 5657, 6275, 273, 3323, 18049, 6275, 31, 203, 7734, 5824, 17631, 1060, 273, 374, 31, 203, 5411, 289, 203, 3639, 289, 203, 203, 203, 3639, 2701, 18, 8082, 6275, 273, 5657, 6275, 31, 203, 3639, 2701, 18, 21672, 273, 12884, 31, 203, 203, 3639, 309, 261, 8082, 6275, 405, 374, 13, 288, 203, 5411, 23867, 626, 7216, 3947, 509, 12, 8082, 6275, 300, 3844, 1769, 203, 5411, 314, 2536, 749, 18, 13866, 12, 8082, 6275, 1769, 203, 5411, 23867, 626, 7216, 1011, 509, 12, 8949, 1769, 203, 5411, 1131, 264, 18, 1289, 17631, 1060, 12, 75, 2536, 749, 16, 5824, 17631, 1060, 1769, 203, 3639, 289, 203, 540, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x3642189B7754302DF84B6F3FE1aE34D2026647A7/sources/src/ConveyorRouterV1.sol
@notice Current Nonce for affiliate addresses.
uint16 public affiliateNonce;
3,016,243
[ 1, 4625, 348, 7953, 560, 30, 632, 20392, 6562, 25261, 364, 7103, 330, 3840, 6138, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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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, 565, 2254, 2313, 1071, 7103, 330, 3840, 13611, 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 ]
pragma solidity ^0.4.23; contract IERC223Token { function name() public view returns (string); function symbol() public view returns (string); function decimals() public view returns (uint8); function totalSupply() public view returns (uint256); function balanceOf(address _holder) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool success); function transfer(address _to, uint _value, bytes _data) public returns (bool success); function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success); event Transfer(address indexed _from, address indexed _to, uint _value, bytes _data); } contract IERC223Receiver { /** * @dev Standard ERC223 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint _value, bytes _data) public returns(bool); } contract IOwned { // this function isn't abstract since the compiler emits automatically generated getter functions as external function owner() public pure returns (address) {} event OwnerUpdate(address _prevOwner, address _newOwner); function transferOwnership(address _newOwner) public; function acceptOwnership() public; } contract ICalled is IOwned { // this function isn't abstract since the compiler emits automatically generated getter functions as external function callers(address) public pure returns (bool) { } function appendCaller(address _caller) public; // ownerOnly function removeCaller(address _caller) public; // ownerOnly event AppendCaller(ICaller _caller); event RemoveCaller(ICaller _caller); } contract ICaller{ function calledUpdate(address _oldCalled, address _newCalled) public; // ownerOnly event CalledUpdate(address _oldCalled, address _newCalled); } contract IERC20Token { function name() public view returns (string); function symbol() public view returns (string); function decimals() public view returns (uint8); function totalSupply() public view returns (uint256); function balanceOf(address _holder) public view returns (uint256); function allowance(address _from, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _holder, address indexed _spender, uint256 _value); } contract IDummyToken is IERC20Token, IERC223Token, IERC223Receiver, ICaller, IOwned{ // these function isn't abstract since the compiler emits automatically generated getter functions as external function operator() public pure returns(ITokenOperator) {} //ITokenOperator public operator; } contract ISmartToken{ function disableTransfers(bool _disable) public; function issue(address _to, uint256 _amount) public; function destroy(address _from, uint256 _amount) public; //function() public payable; } contract ITokenOperator is ISmartToken, ICalled, ICaller { // this function isn't abstract since the compiler emits automatically generated getter functions as external function dummy() public pure returns (IDummyToken) {} function emitEventTransfer(address _from, address _to, uint256 _amount) public; function updateChanges(address) public; function updateChangesByBrother(address, uint256, uint256) public; function token_name() public view returns (string); function token_symbol() public view returns (string); function token_decimals() public view returns (uint8); function token_totalSupply() public view returns (uint256); function token_balanceOf(address _owner) public view returns (uint256); function token_allowance(address _from, address _spender) public view returns (uint256); function token_transfer(address _from, address _to, uint256 _value) public returns (bool success); function token_transfer(address _from, address _to, uint _value, bytes _data) public returns (bool success); function token_transfer(address _from, address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success); function token_transferFrom(address _spender, address _from, address _to, uint256 _value) public returns (bool success); function token_approve(address _from, address _spender, uint256 _value) public returns (bool success); function fallback(address _from, bytes _data) public payable; // eth input function token_fallback(address _token, address _from, uint _value, bytes _data) public returns(bool); // token input from IERC233 } contract IsContract { //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) internal view returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } } contract Owned is IOwned { address public owner; address public newOwner; /** @dev constructor */ constructor() public { owner = msg.sender; } // allows execution by the owner only modifier ownerOnly { assert(msg.sender == owner); _; } /** @dev allows transferring the contract ownership the new owner still needs to accept the transfer can only be called by the contract owner @param _newOwner new contract owner */ function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } /** @dev used by a new owner to accept an ownership transfer */ function acceptOwnership() public { require(msg.sender == newOwner); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0x0); } } contract Constant { bytes32 internal constant _$FM_ = "$FM"; bytes32 internal constant _$FM2_ = "$FM2"; bytes32 internal constant _$FI_ = "$FI"; bytes32 internal constant _$FO_ = "$FO"; bytes32 internal constant _$FD_ = "$FD"; bytes32 internal constant _$FD2_ = "$FD2"; bytes32 internal constant _$F_ = "$F"; bytes32 internal constant _$F2R_ = "$F2R"; bytes32 internal constant _$FR_ = "$FR"; bytes32 internal constant _ETHER_ = "ETHER";//EtherToken will be registered to Data in XCoin.js => registerContract bytes32 internal constant _Eventer_ = "Eventer";//Eventer will be registered to Data in XCoin.js => registerContract bytes32 internal constant _$FOD_ = "$FOD"; bytes32 internal constant _totalSupply_ = "totalSupply"; bytes32 internal constant _balanceOf_ = "balanceOf"; bytes32 internal constant _lastTime_ = "lastTime"; bytes32 internal constant _factorDrawLots_ = "factorDrawLots"; bytes32 internal constant _eraDrawLots_ = "eraDrawLots"; //bytes32 internal constant _drawLots_ = "drawLots"; bytes32 internal constant _weightIssue_ = "weightIssue"; bytes32 internal constant _privatePlacing_ = "privatePlacing"; bytes32 internal constant _priceInit_ = "priceInit"; bytes32 internal constant _softCap_ = "softCap"; bytes32 internal constant _ratioGiftMax_ = "ratioGiftMax"; bytes32 internal constant _weightOfReserve_ = "weightOfReserve"; bytes32 internal constant _weightOfTarget_ = "weightOfTarget"; bytes32 internal constant _decelerationRatioDividend_ = "decelerationRatioDividend"; bytes32 internal constant _ratioDividend_ = "ratioDividend"; bytes32 internal constant _investmentSF_ = "investmentSF"; bytes32 internal constant _investmentEth_ = "investmentEth"; bytes32 internal constant _profitSF_ = "profitSF"; bytes32 internal constant _profitEth_ = "profitEth"; bytes32 internal constant _returnSF_ = "returnSF"; bytes32 internal constant _returnEth_ = "returnEth"; bytes32 internal constant _emaDailyYieldSF_ = "emaDailyYieldSF"; bytes32 internal constant _emaDailyYield_ = "emaDailyYield"; bytes32 internal constant _timeLastMiningSF_ = "timeLastMiningSF"; bytes32 internal constant _timeLastMining_ = "timeLastMining"; bytes32 internal constant _factorMining_ = "factorMining"; bytes32 internal constant _projectStatus_ = "projectStatus"; bytes32 internal constant _projectAddr_ = "projectAddr"; bytes32 internal constant _projectID_ = "projectID"; bytes32 internal constant _proposeID_ = "proposeID"; bytes32 internal constant _disproposeID_ = "disproposeID"; bytes32 internal constant _projects_ = "projects"; bytes32 internal constant _projectsVoting_ = "projectsVoting"; bytes32 internal constant _thresholdPropose_ = "thresholdPropose"; bytes32 internal constant _divisorAbsent_ = "divisorAbsent"; bytes32 internal constant _timePropose_ = "timePropose"; bytes32 internal constant _votes_ = "votes"; bytes32 internal constant _factorDividend_ = "factorDividend"; bytes32 internal constant _projectIdCount_ = "projectIdCount"; bytes32 internal constant _projectInfo_ = "projectInfo"; bytes32 internal constant _recommenders_ = "recommenders"; bytes32 internal constant _recommendations_ = "recommendations"; bytes32 internal constant _rewardRecommend_ = "rewardRecommend"; bytes32 internal constant _halfRewardBalanceOfRecommender_ = "halfRewardBalanceOfRecommender"; bytes32 internal constant _agents_ = "agents"; bytes32 internal constant _factorInvitationOfAgent_ = "factorInvitationOfAgent"; bytes32 internal constant _factorPerformanceOfAgent_ = "factorPerformanceOfAgent"; bytes32 internal constant _performanceOfAgent_ = "performanceOfAgent"; bytes32 internal constant _lastPerformanceOfAgent_ = "lastPerformanceOfAgent"; //bytes32 internal constant _invitationOfAgentLock_ = "invitationOfAgentLock"; bytes32 internal constant _invitationOfAgent_ = "invitationOfAgent"; //bytes32 internal constant _lockedOfAgent_ = "lockedOfAgent"; bytes32 internal constant _unlockedOfAgent_ = "unlockedOfAgent"; bytes32 internal constant _agentIssuable_ = "agentIssuable"; bytes32 internal constant _agentThreshold_ = "agentThreshold"; bytes32 internal constant _rewardAgent_ = "rewardAgent"; bytes32 internal constant _$FP_ = "$FP"; bytes32 internal constant _invitation_ = "invitation"; bytes32 internal constant _agent_ = "agent"; bytes32 internal constant _channel_ = "channel"; bytes32 internal constant _channels_ = "channels"; bytes32 internal constant _rewardChannel_ = "rewardChannel"; bytes32 internal constant _rate0DrawLotsOrder_ = "rate0DrawLotsOrder"; bytes32 internal constant _thresholdAccelDequeueOrder_ = "thresholdAccelDequeueOrder"; bytes32 internal constant _periodQuotaOrder_ = "periodQuotaOrder"; bytes32 internal constant _project$f_ = "project$f"; bytes32 internal constant _projectEth_ = "projectEth"; bytes32 internal constant _etherAmount_ = "etherAmount"; bytes32 internal constant _Recommend_ = "Recommend"; bytes32 internal constant _Price_ = 0xdedeab50b97b0ea258580c72638be71c84db2913f449665c5275cdb7f93c0409; //keccak256("Price(bytes32,uint256,int256,uint256,uint256,uint256,uint256,uint256)"); // bytes32 internal constant _Weight_ = 0x3656cc39179451c68688a96cd746a26d3368cf97102e851c0c60a0bad65bfaf4; //keccak256("Weight(bytes32,uint256,uint256,uint256,uint256,uint256,uint256,uint256)"); // bytes32 internal constant _WeightIssue_ = 0xee865ae6bcc111b5853d9ac0495880f947e4aebeb181b1a6d904d58299e1cced; //keccak256("WeightIssue(address,address,uint256,uint256,uint256,uint256)"); // bytes32 internal constant _PrivatePlacement_ = 0x94eb37bbe0c54785ce84a078083aede618c2abba7d7b271e7b625ddf4d1282ee; //keccak256("PrivatePlacement(address,address,uint256,uint256,uint256)"); // bytes32 internal constant _Propose_ = 0x87ada46c836271e669e6bc9ba0bc9669495237e101c5291363d524bc8fc32568; //keccak256("Propose(address,bytes32,bytes32,address,uint256,uint256)"); // bytes32 internal constant _Dispropose_ = 0xc85e60c2ee8acdaa9f49d4541531b118e86d4018c9c2a0ff7556076a5ff01870; //keccak256("Dispropose(address,bytes32,bytes32)"); // bytes32 internal constant _UpdateProject_ = 0xa7f00da0cc536d861fb6f017f8234042f6e26699f3cd9103da6895e93c118125; //keccak256("UpdateProject(address,bytes32,address,address)"); // bytes32 internal constant _ReturnProfit_ = 0xba17bd6ee981e52122b986aa98e10567c311e15b7d6dad085bf94e896ed65e66; //keccak256("ReturnProfit(address,bytes32,uint256,uint256)"); // bytes32 internal constant _ReturnDisinvestment_ = 0x95211a7460b6a58c8ba08a59a584a7bf992e651f1c6379ed788ddefc41bee305; //keccak256("ReturnDisinvestment(address,bytes32,uint256,uint256)"); // bytes32 internal constant _RegisterRecommender_ = 0xfcb064cbe1c349ea06a55b745fcd262396cc7cdbee9589806d350b65df959bc4; //keccak256("RegisterRecommender(address,bytes32,bool,uint256)"); // bytes32 internal constant _RegisterAgent_ = 0x2afb1b2d5349ff0163b230509f92d4c12ab9854d4c76bc5f25339e2816a3d48a; //keccak256("RegisterAgent(address,uint256,uint256)"); // bytes32 internal constant _AgentAppend_ = 0x5ac70b7391396d39d0973d5ffa4bd81a1c430996801ef8c5661cc43d348c94c9; //keccak256("AgentAppend(address,uint256,uint256)"); // bytes32 internal constant _AgentLock_ = 0x12bb003ebbc79a167959a883f0e69272f5040dfc75d4b47e59fd84a803bf74a9; //keccak256("AgentLock(address,uint256,uint256)"); // bytes32 internal constant _IssueInvitationOfAgent_ = 0x03ffb74238869c35f07683aa632e0c375c3a24a1c57eb9d4c98c2aa7ec703ff7; //keccak256("IssueInvitationOfAgent(address,uint256)"); // bytes32 internal constant _AgentUnlock_ = 0xe172d5d2fe66445fce354d0d2be616095b5b12adbdb7bef4ebfba1ee9b7f2831; //keccak256("AgentUnlock(address,uint256)"); // bytes32 internal constant _BindRecommender_ = 0xe4d100017ba2dd1d43322b2387da2814945070a0503d88bf058d454061c44fca; //keccak256("BindRecommender(address,address,bytes32,address)"); // bytes32 internal constant _Transfer_ = 0x5f2147fb558c977441fbdfebcf8cd5776606adc8da5ff95566fc2a4137e54d13; //keccak256("Transfer(address,address,uint256,address)"); // bytes32 internal constant _Dequeue_ = 0x8ed4de10d9e943b936b256947298f9d79289495a4db8b55f9452da76721f0791; //keccak256("Dequeue(address,uint256,address,uint256)"); // bytes32 internal constant _DequeueOrder_ = 0xcc45326a7be89070b5e24ad2502035f73c92d306b6aab85d5116f3e9538bd9cf; //keccak256("DequeueOrder(address,uint256,uint256)"); // bytes32 internal constant _DequeueIngot_ = 0xbd1f3a5aca027a47b1833e8de51edf3d32ec6ffce34268ff5d3022f70bde1794; //keccak256("DequeueIngot(address,uint256,uint256)"); // bytes32 internal constant _Vote_ = 0xea430f6241d8ab7a4a7da7b9487de059426309628c9c8e7b3e9438f0f431f39e; //keccak256("Vote(address,bytes32,bytes32,uint256)"); // bytes32 internal constant _VoteResult_ = 0xa0de2ad353f45bfcc398ad86d3575629f76b3c353ca88ce789602fb9ae5d207c; //keccak256("VoteResult(bytes32,bytes32,bool,uint256,uint256,uint256)"); // bytes32 internal constant _Config_ = 0x4691be92868fa80845b397f0e016905e1b4322422075895b96f9b4a8f1d918cf; //keccak256("Config(bytes32,bytes32,uint256)"); // bytes32 internal constant _Invest_ = 0x130d745954fedb61791b614172f696ffb5219aa14649d625534e8ff825bd68cd; //keccak256("Invest(bytes32,address,uint256,uint256)"); // bytes32 internal constant _Disinvest_ = 0x386d6f5f13437a36e2cf423819da85f6dd09bdbc5f4be7e41c0680904b10d7fd; //keccak256("Disinvest(bytes32,address)"); // bytes32 internal constant _DepositEth_ = 0x7034bb05cfe54b0d147fc0574ed166101e7f0313eb404e113974fbe2a998ca83; //keccak256("DepositEth(address,uint256)"); // bytes32 internal constant _WithdrawEth_ = 0xb48511ae3e574699605a84740498056f77d218c60c8d7e0e1dee31b9c90fd745; //keccak256("WithdrawEth(address,address,uint256,bool)"); // bytes32 internal constant _Forging_ = 0x5409965f0a48c519c9ae4c920bd726a7d8ee91475b3d372ac7484ce2989ffc37; //keccak256("Forging(address,uint256)"); // bytes32 internal constant _Purchase_ = 0x3a53f56a211d9f64ed2c86f99e1aa48b4837ed6d63abc0f07ac29d32fe75e230; //keccak256("Purchase(address,bytes32,uint256,bool,bool)"); // bytes32 internal constant _CancelOrder_ = 0xc0e68d6b69f741c21e955cad2ae4d505b6f6735c7e7b278251b3f6283a5f07eb; //keccak256("CancelOrder(address,uint256)"); // bytes32 internal constant _Lock4Dividend_ = 0xdfd1f12277f9150ae1d758207187dfe823fe860e003119517a71ab60b3d10809; //keccak256("Lock4Dividend(address,uint256)"); // bytes32 internal constant _Unlock4Circulate_ = 0x5dd61c8c2501b31d45e1deddbdac925d30d8075094ef1d89588d6353f89a4821; //keccak256("Unlock4Circulate(address,uint256)"); // bytes32 internal constant _Apply4Redeem_ = 0xb117f62e1089a5c238e5631cb0a8903798ecfe12e1bb415d18856d168f7b70ec; //keccak256("Apply4Redeem(address,uint256)"); // bytes32 internal constant _CancelRedeem_ = 0x56d7520e387607a8daa892e3fed116badc2a636307bdc794b1c1aed97ae203f4; //keccak256("CancelRedeem(address,uint256)"); // bytes32 internal constant _Redeem_ = 0x222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a6; //keccak256("Redeem(address,uint256)"); bytes32 internal constant _RecommendPerformance_ = 0xdff59f3289527807a9634eaf83388e1f449e1f0fd75b01141ed33783d13763bb; //keccak256("RecommendPerformance(address,address,bytes32,uint256,uint256)"); bytes32 internal constant _RecommendReward_ = 0xea4e2775055f2f3a80aed6e1fd67888ab02b8cdd276b2983ac96b18965c864ca; //keccak256("RecommendReward(address,address,bytes32,uint256,uint256,uint256)"); //uint256 internal constant PROJECT_STATUS_PROPOSING = uint256(bytes32("PROJECT_STATUS_PROPOSING")); uint256 internal constant PROJECT_STATUS_VOTING = uint256(bytes32("PROJECT_STATUS_VOTING")); uint256 internal constant PROJECT_STATUS_FAIL = uint256(bytes32("PROJECT_STATUS_FAIL")); uint256 internal constant PROJECT_STATUS_PASS = uint256(bytes32("PROJECT_STATUS_PASS")); uint256 internal constant PROJECT_STATUS_INVESTED = uint256(bytes32("PROJECT_STATUS_INVESTED")); //uint256 internal constant PROJECT_STATUS_DISPROPOSING = uint256(bytes32("PROJECT_STATUS_DISPROPOSING")); uint256 internal constant PROJECT_STATUS_DISVOTING = uint256(bytes32("PROJECT_STATUS_DISVOTING")); uint256 internal constant PROJECT_STATUS_DISINVESTING = uint256(bytes32("PROJECT_STATUS_DISINVESTING")); uint256 internal constant PROJECT_STATUS_DISINVESTED = uint256(bytes32("PROJECT_STATUS_DISINVESTED")); //uint256 internal constant VOTE_YES = uint256(bytes32("VOTE_YES")); //uint256 internal constant VOTE_NO = uint256(bytes32("VOTE_NO")); //uint256 internal constant VOTE_CANCEL = uint256(bytes32("VOTE_CANCEL")); bytes32 internal constant VOTE_YES = "VOTE_YES"; bytes32 internal constant VOTE_NO = "VOTE_NO"; bytes32 internal constant VOTE_CANCEL = "VOTE_CANCEL"; } contract IFund { function returnProfit(bytes32 _projectID, uint256 _eth, uint256 _sf) public; function returnDisinvestment(bytes32 _projectID, uint256 _eth, uint256 _sf) public; } contract IProject is ICaller { function invest(bytes32 _projectID, uint256 _eth, uint256 _sf) public; function disinvest() public; } contract IData is ICalled{ // these function isn't abstract since the compiler emits automatically generated getter functions as external function bu(bytes32) public pure returns(uint256) {} function ba(bytes32) public pure returns(address) {} //function bi(bytes32) public pure returns(int256) {} //function bs(bytes32) public pure returns(string) {} //function bb(bytes32) public pure returns(bytes) {} function bau(bytes32, address) public pure returns(uint256) {} //function baa(bytes32, address) public pure returns(address) {} //function bai(bytes32, address) public pure returns(int256) {} //function bas(bytes32, address) public pure returns(string) {} //function bab(bytes32, address) public pure returns(bytes) {} function bbu(bytes32, bytes32) public pure returns(uint256) {} function bbs(bytes32, bytes32) public pure returns(string) {} function buu(bytes32, uint256) public pure returns(uint256) {} function bua(bytes32, uint256) public pure returns(address) {} function bus(bytes32, uint256) public pure returns(string) {} function bas(bytes32, address) public pure returns(string) {} //function bui(bytes32, uint256) public pure returns(int256) {} //function bus(bytes32, uint256) public pure returns(string) {} //function bub(bytes32, uint256) public pure returns(bytes) {} function bauu(bytes32, address, uint256) public pure returns(uint256) {} //function baau(bytes32, address, address) public pure returns(uint256) {} function bbau(bytes32, bytes32, address) public pure returns(uint256) {} //function buuu(bytes32, uint256, uint256) public pure returns(uint256) {} function bbaau(bytes32, bytes32, address, address) public pure returns(uint256) {} function setBU(bytes32 _key, uint256 _value) public; function setBA(bytes32 _key, address _value) public; //function setBI(bytes32 _key, int256 _value) public; //function setBS(bytes32 _key, string _value) public; //function setBB(bytes32 _key, bytes _value) public; function setBAU(bytes32 _key, address _addr, uint256 _value) public; //function setBAA(bytes32 _key, address _addr, address _value) public; //function setBAI(bytes32 _key, address _addr, int256 _value) public; //function setBAS(bytes32 _key, address _addr, string _value) public; //function setBAB(bytes32 _key, address _addr, bytes _value) public; function setBBU(bytes32 _key, bytes32 _id, uint256 _value) public; function setBBS(bytes32 _key, bytes32 _id, string _value) public; function setBUU(bytes32 _key, uint256 _index, uint256 _value) public; function setBUA(bytes32 _key, uint256 _index, address _addr) public; function setBUS(bytes32 _key, uint256 _index, string _str) public; //function setBUI(bytes32 _key, uint256 _index, int256 _value) public; //function setBUB(bytes32 _key, uint256 _index, bytes _value) public; //function setBAAU(bytes32 _key, address _token, address _addr, uint256 _value) public; function setBAUU(bytes32 _key, address _addr, uint256 _index, uint256 _value) public; function setBBAU(bytes32 _key, bytes32 _id, address _holder, uint256 _value) public; //function setBUUU(bytes32 _key, uint256 _index, uint256 _index2, uint256 _value) public; function setBBAAU(bytes32 _key, bytes32 _id, address _from, address _to, uint256 _value) public; } contract I$martFund is IFund, IOwned, ICaller { function checkQuotaPropose(uint256 _eth, uint256 _sf) public view returns(bool); function propose(bytes32 _projectID, bytes32 _proposeID, IProject _project, uint256 _eth, uint256 _sf, string _mixInfo) public; function dispropose(bytes32 _projectID, bytes32 _disproposeID, string _mixInfo) public; function getVotes(bytes32 _ID, bytes32 _vote) public view returns(uint256); function vote(bytes32 _ID, bytes32 _vote) public; function forging(uint256 _msm) public; function purchase(bool _wantDividend, bool _nonInvate, bytes32 _channel, bytes32 _recommendation) public payable; function cancelOrder(uint256 _mso) public returns(uint256 eth); function lock4Dividend(uint256 _msd2_ms) public returns(uint256 msd); function unlock4Circulate(uint256 _msd) public returns(uint256 msd2); function transferMS(address _to, uint256 _ms) public returns (bool success); function transferMSI(address _to, uint256 _msi) public returns (bool success); function transferMSM(address _to, uint256 _msm) public returns (bool success); function apply4Redeem(uint256 _ms) public returns(uint256 ms2r); function cancelRedeem(uint256 _ms2r_msr) public returns(uint256 ms); function redeem(uint256 msr) public returns(uint256 eth); } contract SafeMath { // Overflow protected math functions /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x + _y; require(z >= _x); //assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) internal pure returns (uint256) { require(_x >= _y); //assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x * _y; require(_x == 0 || z / _x == _y); //assert(_x == 0 || z / _x == _y); return z; } function safeDiv(uint256 _x, uint256 _y)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 _x / _y; } function ceilDiv(uint256 _x, uint256 _y)internal pure returns (uint256){ return (_x + _y - 1) / _y; } } contract Sqrt { function sqrt(uint x)public pure returns(uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } contract DataCaller is Owned, ICaller { IData public data; constructor(IData _data) public { data = IData(_data); } function calledUpdate(address _oldCalled, address _newCalled) public ownerOnly { if(data == _oldCalled) { data = IData(_newCalled); emit CalledUpdate(_oldCalled, _newCalled); } } } contract GetBU is DataCaller { function getBU(bytes32 _key) internal view returns(uint256) { return data.bu(_key); } } contract SetBU is DataCaller { function setBU(bytes32 _key, uint256 _value) internal { data.setBU(_key, _value); } } contract Disable is Owned { bool public disabled; modifier enabled { assert(!disabled); _; } function disable(bool _disable) public ownerOnly { disabled = _disable; } } contract IReserve is ICalled { // these function isn't abstract since the compiler emits automatically generated getter functions as external function balanceOfColdWallet() public pure returns(uint256) {} function balanceOfShares() public pure returns(uint256) {} function balanceOfOrder() public pure returns(uint256) {} function balanceOfMineral() public pure returns(uint256) {} function balanceOfProject() public pure returns(uint256) {} function balanceOfQueue() public pure returns(uint256) {} function headOfQueue() public pure returns(uint256){} function tailOfQueue() public view returns(uint256); function setColdWallet(address _coldWallet, uint256 _ratioAutoSave, uint256 _ratioAutoRemain) public; function saveToColdWallet(uint256 _amount) public; function restoreFromColdWallet() public payable; function depositShares() public payable; function depositOrder() public payable; function depositMineral() public payable; function depositProject() public payable; function order2Shares(uint256 _amount) public; function mineral2Shares(uint256 _amount) public; function shares2Project(uint256 _amount)public; function project2Shares(uint256 _amount)public; function project2Mineral(uint256 _amount) public; function withdrawShares(uint256 _amount) public returns(bool atonce); function withdrawSharesTo(address _to, uint256 _amount) public returns(bool atonce); function withdrawOrder(uint256 _amount) public returns(bool atonce); function withdrawOrderTo(address _to, uint256 _amount) public returns(bool atonce); function withdrawMineral(uint256 _amount) public returns(bool atonce); function withdrawMineralTo(address _to, uint256 _amount) public returns(bool atonce); function withdrawProject(uint256 _amount)public returns(bool atonce); function withdrawProjectTo(address _to, uint256 _amount)public returns(bool atonce); function() public payable; } contract IFormula is IOwned, ICaller { uint8 public constant MAX_PRECISION = 127; uint32 public constant MAX_WEIGHT = 1000000; function reserve() public pure returns(IReserve) { } function totalSupply() public view returns (uint256); function balanceOf(address _addr)public view returns(uint256); function price() view public returns(uint256); //function costOfTxShares() view public returns(uint256); function calcTimedQuota(uint256 _rest, uint256 _full, uint256 _timespan, uint256 _period) public pure returns (uint256); function calcEma(uint256 _emaPre, uint256 _value, uint32 _timeSpan, uint256 _period) public view returns(uint256); //function calcFactorReward(uint256 _dailyYield) public view returns(uint256); function calcFactorMining(uint256 _roi) public view returns(uint256); function calcOrderTo$fAmount(uint256) public view returns(uint256); //function calc$martFundAmount(uint256 _amount, uint256 _factorRestrain) public view returns(uint256); function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) public constant returns (uint256); function calculateRedeemReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _sellAmount) public constant returns (uint256); function power(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) public view returns (uint256, uint8); function power2(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) public view returns (uint256, uint8); function ln(uint256 _numerator, uint256 _denominator) public pure returns (uint256); } contract I$martFundImpl is ICalled, ICaller { uint256 public constant DEQUEUE_DEFAULT = 0; uint256 public constant DEQUEUE_ORDER = 1; uint256 public constant DEQUEUE_INGOT = 2; uint256 public constant DEQUEUE_DOUBLE = 3; uint256 public constant DEQUEUE_DOUBLE_REVERSELY = 4; uint256 public constant DEQUEUE_NONE = 5; function data() public pure returns(IData){} function reserve() public pure returns(IReserve){} function formula() public pure returns(IFormula){} function dequeueOrder(uint256 gaslimit, bool force) public returns(uint256 dealt); function dequeueIngot(uint256 gaslimit, bool force) public returns(uint256 dealt); function dequeueAlternately(uint256 gaslimit, bool force) public returns(uint256 dealt); function dequeueDouble(uint256 gaslimit, bool force) public returns(uint256 dealt); function dequeue(bytes32 _when) public returns(uint256 dealt); function getVotes(bytes32 _ID, bytes32 _vote) public view returns(uint256); function impl_vote(address _holder, bytes32 _ID, bytes32 _vote) public; function impl_forging(address _from, uint256 _msm) public; function impl_purchase(address _from, bool _wantDividend, bool _nonInvate, bytes32 _channel) public payable; function impl_cancelOrder(address _from, uint256 _msm) public returns(uint256 eth); function impl_lock4Dividend(address _from, uint256 _msd2_ms) public returns(uint256 msd); function impl_unlock4Circulate(address _from, uint256 _msd) public returns(uint256 msd2); function impl_quotaApply4Redeem() view public returns(uint256); function impl_apply4Redeem(address _from, uint256 _ms) public returns(uint256 ms2r); function impl_cancelRedeem(address _from, uint256 _ms2r_msr) public returns(uint256 ms); function impl_redeem(address _from, uint256 msr) public returns(uint256 eth); } contract Enabled is Disable, GetBU { modifier enabled2 { require(!disabled && getBU("dappEnabled") != 0); _; } } contract DisableDapp is SetBU { function disableDapp(bool _disable) public ownerOnly { setBU("dappEnabled", _disable ? 0 : 1); } } contract GetBA is DataCaller { function getBA(bytes32 _key) internal view returns(address) { return data.ba(_key); } } contract SetBA is DataCaller { function setBA(bytes32 _key, address _value) internal { data.setBA(_key, _value); } } contract GetBAU is DataCaller { function getBAU(bytes32 _key, address _addr) internal view returns(uint256) { return data.bau(_key, _addr); } } contract SetBAU is DataCaller { function setBAU(bytes32 _key, address _addr, uint256 _value) internal { data.setBAU(_key, _addr, _value); } } contract GetBBU is DataCaller { function getBBU(bytes32 _key, bytes32 _id) internal view returns(uint256) { return data.bbu(_key, _id); } } contract SetBBU is DataCaller { function setBBU(bytes32 _key, bytes32 _id, uint256 _value) internal { data.setBBU(_key, _id, _value); } } contract GetBBS is DataCaller { function getBBS(bytes32 _key, bytes32 _id) internal view returns(string) { return data.bbs(_key, _id); } } contract SetBBS is DataCaller { function setBBS(bytes32 _key, bytes32 _id, string _value) internal { data.setBBS(_key, _id, _value); } } contract GetBUU is DataCaller { function getBUU(bytes32 _key, uint256 _index) internal view returns(uint256) { return data.buu(_key, _index); } } contract SetBUU is DataCaller { function setBUU(bytes32 _key, uint256 _index, uint256 _value) internal { data.setBUU(_key, _index, _value); } } contract GetBUA is DataCaller { function getBUA(bytes32 _key, uint256 _index) internal view returns(address) { return data.bua(_key, _index); } } contract SetBUA is DataCaller { function setBUA(bytes32 _key, uint256 _index, address _addr) internal { data.setBUA(_key, _index, _addr); } } contract GetBUS is DataCaller { function getBUS(bytes32 _key, uint256 _index) internal view returns(string) { return data.bus(_key, _index); } } contract SetBUS is DataCaller { function setBUS(bytes32 _key, uint256 _index, string _str) internal { data.setBUS(_key, _index, _str); } } contract GetBAUU is DataCaller { function getBAUU(bytes32 _key, address _addr, uint256 _index) internal view returns(uint256) { return data.bauu(_key, _addr, _index); } } contract SetBAUU is DataCaller { function setBAUU(bytes32 _key, address _addr, uint256 _index, uint256 _value) internal { data.setBAUU(_key, _addr, _index, _value); } } contract GetBBAU is DataCaller { function getBBAU(bytes32 _key, bytes32 _id, address _holder) internal view returns(uint256) { return data.bbau(_key, _id, _holder); } } contract SetBBAU is DataCaller { function setBBAU(bytes32 _key, bytes32 _id, address _holder, uint256 _value) internal { data.setBBAU(_key, _id, _holder, _value); } } contract GetBBAAU is DataCaller { function getBBAAU(bytes32 _key, bytes32 _id, address _from, address _to) internal view returns(uint256) { return data.bbaau(_key, _id, _from, _to); } } contract SetBBAAU is DataCaller { function setBBAAU(bytes32 _key, bytes32 _id, address _from, address _to, uint256 _value) internal { data.setBBAAU(_key, _id, _from, _to, _value); } } contract Destructor is Owned{ function destruct() public ownerOnly { selfdestruct(owner); } } contract $martFund is Constant, I$martFund, IERC223Receiver, SafeMath, Sqrt, DataCaller, Enabled, DisableDapp, GetBA, GetBAU, SetBAU, GetBUA, SetBUA, GetBUU, SetBUU, GetBBU, SetBBU, GetBBAU, GetBUS, SetBUS, GetBAUU, Destructor{ //, RLPReader { IReserve public reserve; IFormula public formula; I$martFundImpl public impl; constructor(IData _data, IReserve _reserve, IFormula _formula, I$martFundImpl _impl) DataCaller(_data) public { reserve = _reserve; formula = _formula; impl = _impl; } function calledUpdate(address _oldCalled, address _newCalled) public ownerOnly { if(data == _oldCalled){ data = IData(_newCalled); }else if(reserve == _oldCalled){ reserve = IReserve(_newCalled); }else if(formula == _oldCalled){ formula = IFormula(_newCalled); }else if(impl == _oldCalled){ impl = I$martFundImpl(_newCalled); }else{ return; } emit CalledUpdate(_oldCalled, _newCalled); } function updateEmaDailyYieldSF(uint256 _value) internal/*public*/ returns(uint256) { uint256 ema = getBU("emaDailyYieldSF"); uint32 timeSpan = uint32(safeSub(now, getBU("timeLastMiningSF"))); setBU("timeLastMiningSF", now); ema = formula.calcEma(ema, _value, timeSpan, 1 days); setBU("emaDailyYieldSF", ema); return ema; } function checkQuotaPropose(uint256 _eth, uint256 _sf) public view returns(bool) { uint256 totalSupply_ = formula.totalSupply(); uint256 reserve_ = reserve.balanceOfShares(); if(_sf * 1 ether > totalSupply_ * getBU("quotaPerProposeSF") || _eth * 1 ether > reserve_ * getBU("quotaPerProposeEth")) return false; for(uint256 id = getBUU(_projectsVoting_, 0x0); id != 0x0; id = getBUU(_projectsVoting_, id)) { _sf += getBUU(_investmentSF_, id); _eth += getBUU(_investmentEth_, id); } return _sf * 1 ether <= totalSupply_ * getBU("quotaAllProposeSF") && _eth * 1 ether <= reserve_ * getBU("quotaAllProposeEth"); } event Propose(address indexed _holder, bytes32 indexed _projectID, bytes32 _proposeID, IProject _project, uint256 _eth, uint256 _sf); function propose(bytes32 _projectID, bytes32 _proposeID, IProject _project, uint256 _eth, uint256 _sf, string _mixInfo) public enabled2 { emit Propose(msg.sender, _proposeID, _projectID, _project, _eth, _sf); // emitEvent(_Propose_, bytes32(msg.sender), _projectID, uint256(_proposeID), uint256(_project), _eth, _sf); IDummyToken $fd = IDummyToken(getBA(_$FD_)); require($fd.balanceOf(msg.sender) * 1 ether >= $fd.totalSupply() * getBU(_thresholdPropose_)); //, "Proponent has not enough $FD!" if(address(_project) != address(0x0)) require(checkQuotaPropose(_eth, _sf)); //, "Too much financing!" if(_projectID == _proposeID) { // first invest of the _projectID uint256 projectID = getBAU(_projectID_, _project); uint256 status = getBUU(_projectStatus_, projectID); require(projectID == 0 || status == PROJECT_STATUS_FAIL || status == PROJECT_STATUS_DISINVESTED); projectID = uint256(_projectID); setBAU(_projectID_, _project, projectID); }else{ projectID = uint256(_projectID); require(getBAU(_projectID_, _project) == projectID); require(getBUU(_projectStatus_, projectID) == PROJECT_STATUS_INVESTED); //, "Can't repropose a project which had not INVESTED!" uint256 proposeID = getBUU(_proposeID_, projectID); require(proposeID == 0 || proposeID == projectID || getBUU(_projectStatus_, proposeID) != PROJECT_STATUS_VOTING); uint256 disproposeID = getBUU(_disproposeID_, projectID); require(disproposeID == 0 || getBUU(_projectStatus_, disproposeID) == PROJECT_STATUS_FAIL); } proposeID = uint256(_proposeID); require(getBUU(_projectStatus_, proposeID) == 0x0); //, "Can't propose same proposeID again!" setBUU(_proposeID_, projectID, proposeID); setBUU(_projectID_, proposeID, projectID); setBUU(_projectStatus_, proposeID, PROJECT_STATUS_VOTING); setBUU(_timePropose_, proposeID, now); setBUA(_projectAddr_, proposeID, _project); setBUU(_investmentSF_, proposeID, _sf); setBUU(_investmentEth_, proposeID, _eth); setBUS(_projectInfo_, proposeID, _mixInfo); setBUU(_projects_, proposeID, getBUU(_projects_, 0x0)); // join projects list setBUU(_projects_, 0x0, proposeID); setBUU(_projectsVoting_, proposeID, getBUU(_projectsVoting_, 0x0)); setBUU(_projectsVoting_, 0x0, proposeID); vote(_proposeID, VOTE_YES); } event Dispropose(address indexed _holder, bytes32 indexed _projectID, bytes32 _disproposeID); function dispropose(bytes32 _projectID, bytes32 _disproposeID, string _mixInfo) public enabled2 { emit Dispropose(msg.sender, _projectID, _disproposeID); // emitEvent(_Dispropose_, bytes32(msg.sender), _projectID, uint256(_disproposeID)); uint256 projectID = uint256(_projectID); require(getBUU(_projectStatus_, projectID) == PROJECT_STATUS_INVESTED); //, "Can't dispropose a project which had not INVESTED!" uint256 proposeID = getBUU(_proposeID_, projectID); require(proposeID == 0 || proposeID == projectID || getBUU(_projectStatus_, proposeID) != PROJECT_STATUS_VOTING); uint256 disproposeID = getBUU(_disproposeID_, projectID); require(disproposeID == 0 || getBUU(_projectStatus_, disproposeID) == PROJECT_STATUS_FAIL); //, "The dispropose of the project already exist!" disproposeID = uint256(_disproposeID); require(getBUU(_projectStatus_, disproposeID) == 0x0); //, "Can't dispropose same disproposeID again!" setBUU(_disproposeID_, projectID, disproposeID); setBUU(_projectID_, disproposeID, projectID); IDummyToken $fd = IDummyToken(getBA(_$FD_)); require($fd.balanceOf(msg.sender) * 1 ether >= $fd.totalSupply() * getBU(_thresholdPropose_)); //, "Proponent has not enough $FD!" setBUU(_projectStatus_, disproposeID, PROJECT_STATUS_DISVOTING); setBUU(_timePropose_, disproposeID, now); setBUS(_projectInfo_, disproposeID, _mixInfo); setBUU(_projects_, disproposeID, getBUU(_projects_, 0x0)); // join projects list setBUU(_projects_, 0x0, disproposeID); setBUU(_projectsVoting_, disproposeID, getBUU(_projectsVoting_, 0x0)); setBUU(_projectsVoting_, 0x0, disproposeID); vote(_disproposeID, VOTE_YES); } function getVotes(bytes32 _ID, bytes32 _vote) public view returns(uint256) { return impl.getVotes(_ID, _vote); } function vote(bytes32 _ID, bytes32 _vote) public enabled2 { uint256 status = getBUU(_projectStatus_, uint256(_ID)); require(status == PROJECT_STATUS_VOTING || status == PROJECT_STATUS_DISVOTING); //, "Project status is not VOTING or DISVOTING!" impl.impl_vote(msg.sender, _ID, _vote); } function voteYes(bytes32 _projectID) public { vote(_projectID, VOTE_YES); } function voteNo(bytes32 _projectID) public { vote(_projectID, VOTE_NO); } function voteCancle(bytes32 _projectID) public { vote(_projectID, VOTE_CANCEL); } event UpdateProject(address indexed _sender, bytes32 indexed _projectID, address _oldProject, address _newProject); function updateProject(address _oldProject, address _newProject) public ownerOnly { // assert(getBU("UpdateContract") == uint256(oldProject)); uint256 id = getBAU(_projectID_, _oldProject); setBAU(_projectID_, _newProject, id); setBAU(_projectID_, _oldProject, 0); setBUA(_projectAddr_, id, _newProject); emit UpdateProject(msg.sender, bytes32(id), _oldProject, _newProject); // emitEvent(_UpdateProject_, bytes32(msg.sender), bytes32(id), uint256(_oldProject), uint256(_newProject)); } event ReturnProfit(address indexed _sender, bytes32 indexed _projectID, uint256 _eth, uint256 _sf); function returnProfit(bytes32 _projectID, uint256 _eth, uint256 _sf) public enabled2 { emit ReturnProfit(msg.sender, _projectID, _eth, _sf); // emitEvent(_ReturnProfit_, bytes32(msg.sender), _projectID, _eth, _sf); uint256 projectID = uint256(_projectID); if(_sf > 0) { setBUU(_profitSF_, projectID, safeAdd(getBUU(_profitSF_, projectID), _sf)); setBU(_profitSF_, safeAdd(getBU(_profitSF_), _sf)); uint256 ema = updateEmaDailyYieldSF(_sf); I$FM2_Operator addrMSM2O = I$FM2_Operator(IDummyToken(getBA(_$FM2_)).operator()); uint256 ratioDividend = addrMSM2O.updateRatioDividend(_sf, ema); uint256 dividend = _sf * ratioDividend / 1 ether; uint256 supplyOld = formula.totalSupply(); uint256 supplyNew = safeSub(supplyOld+dividend, _sf); uint256 weightOld = getBU(_weightOfReserve_); uint256 weightNew = weightOld * supplyOld / supplyNew; setBU(_weightOfReserve_, weightNew); uint256 reserve_ = reserve.balanceOfShares(); emit Weight("returnProfit", weightNew, weightOld, reserve_, reserve_, supplyNew, supplyOld, reserve_*1 ether/weightOld*1 ether/supplyOld); // emitEvent(_Weight_, "returnProfit", bytes32(0), weightNew, weightOld, reserve_, reserve_, supplyNew, supplyOld, reserve_*1 ether/weightOld*1 ether/supplyOld); IDummyToken(getBA(_$F_)).operator().destroy(getBUA(_projectAddr_, projectID), _sf); addrMSM2O.dividend(dividend); setBU(_returnSF_, safeSub(safeAdd(getBU(_returnSF_), _sf), dividend)); } if(_eth > 0) { setBUU(_profitEth_, projectID, getBUU(_profitEth_, projectID) + _eth); setBU(_profitEth_, getBU(_profitEth_) + _eth); reserve.project2Mineral(_eth); IEtherToken(getBA(_ETHER_)).destroy(getBUA(_projectAddr_, projectID), _eth); //updateEmaDailyYield(msg.value); //updateFactorReward(); //setBU("hasNonceMark", hasNonceMark ? 1 : 0); setBAU(_projectID_, msg.sender, projectID); ITokenOperator(IDummyToken(getBA(_$FM_)).operator()).issue(msg.sender, _eth); impl.dequeue("dequeueWhenMining"); } } event Weight(bytes32 indexed _cause, uint256 _weightNew, uint256 _weightOld, uint256 _reserveNew, uint256 _reserveOld, uint256 _supplyNew, uint256 _supplyOld, uint256 _price); event ReturnDisinvestment(address indexed _sender, bytes32 indexed _projectID, uint256 _eth, uint256 _sf); function returnDisinvestment(bytes32 _projectID, uint256 _eth, uint256 _sf) public enabled2 { emit ReturnDisinvestment(msg.sender, _projectID, _eth, _sf); // emitEvent(_ReturnDisinvestment_, bytes32(msg.sender), _projectID, _eth, _sf); setBUU(_projectStatus_, uint256(_projectID), PROJECT_STATUS_DISINVESTED); setBUU(_disproposeID_, uint256(_projectID), 0); address project = getBUA(_projectAddr_, uint256(_projectID)); setBAU(_projectID_, project, 0);//detach project with _projectID uint256 supply = formula.totalSupply(); uint256 reserve_ = reserve.balanceOfShares(); if(_sf > 0) { setBUU(_profitSF_, uint256(_projectID), safeAdd(getBUU(_profitSF_, uint256(_projectID)), _sf)); setBU(_profitSF_, safeAdd(getBU(_profitSF_), _sf)); setBU(_returnSF_, safeAdd(getBU(_returnSF_), _sf)); uint256 weightOld = getBU(_weightOfReserve_); uint256 weightNew = weightOld * supply / safeSub(supply, _sf); setBU(_weightOfReserve_, weightNew); emit Weight("returnDisinvestment", weightNew, weightOld, reserve_, reserve_, safeSub(supply, _sf), supply, reserve_*1 ether/weightOld*1 ether/supply); // emitEvent(_Weight_, "returnDisinvestment", bytes32(0), weightNew, weightOld, reserve_, reserve_, safeSub(supply, _sf), supply, reserve_*1 ether/weightOld*1 ether/supply); IDummyToken(getBA(_$F_)).operator().destroy(project, _sf); } if(_eth > 0) { setBUU(_profitEth_, uint256(_projectID), getBUU(_profitEth_, uint256(_projectID)) + _eth); setBU(_profitEth_, getBU(_profitEth_) + _eth); setBU(_returnEth_, getBU(_returnEth_) + _eth); weightOld = getBU(_weightOfReserve_); weightNew = weightOld * (reserve_+_eth) / reserve_; setBU(_weightOfReserve_, weightNew); emit Weight("returnDisinvestment", weightNew, weightOld, reserve_+_eth, reserve_, supply, supply, reserve_*1 ether/weightOld*1 ether/supply); // emitEvent(_Weight_, "returnDisinvestment", bytes32(0), weightNew, weightOld, reserve_+_eth, reserve_, supply, supply, reserve_*1 ether/weightOld*1 ether/supply); // reserve.depositShares.value(_eth)(); IEtherToken(getBA(_ETHER_)).destroy(project, _eth); reserve.project2Shares(_eth); } } function forging(uint256 _msm) public enabled { return impl.impl_forging(msg.sender, _msm); } function purchase(bool _wantDividend, bool _nonInvate, bytes32 _channel, bytes32 _recommendation) public payable enabled { if(_recommendation != 0) IRecommend(getBA(_Recommend_)).bindRecommenderImpl(msg.sender, _recommendation); if(msg.value > 0) return impl.impl_purchase.value(msg.value)(msg.sender, _wantDividend, _nonInvate, _channel); } function cancelOrder(uint256 _mso) public enabled returns(uint256 eth) { return impl.impl_cancelOrder(msg.sender, _mso); } function lock4Dividend(uint256 _msd2_ms) public enabled returns(uint256 msd) { return impl.impl_lock4Dividend(msg.sender, _msd2_ms); } function unlock4Circulate(uint256 _msd) public enabled returns(uint256 msd2) { return impl.impl_unlock4Circulate(msg.sender, _msd); } event Transfer(address indexed _from, address indexed _to, uint256 _value, address _token); function transferMS(address _to, uint256 _ms) public enabled returns(bool success) { return IDummyToken(getBA(_$F_)).operator().token_transfer(msg.sender, _to, _ms); emit Transfer(msg.sender, _to, _ms, getBA(_$F_)); // emitEvent(_Transfer_, bytes32(msg.sender), bytes32(_to), _ms, uint256(getBA(_$F_))); } function transferMSI(address _to, uint256 _msi) public enabled returns(bool success) { return IDummyToken(getBA(_$FI_)).operator().token_transfer(msg.sender, _to, _msi); emit Transfer(msg.sender, _to, _msi, getBA(_$FI_)); // emitEvent(_Transfer_, bytes32(msg.sender), bytes32(_to), _msi, uint256(getBA(_$FI_))); } function transferMSM(address _to, uint256 _msm) public enabled returns(bool success) { return IDummyToken(getBA(_$FM_)).operator().token_transfer(msg.sender, _to, _msm); emit Transfer(msg.sender, _to, _msm, getBA(_$FM_)); // emitEvent(_Transfer_, bytes32(msg.sender), bytes32(_to), _msm, uint256(getBA(_$FM_))); } function apply4Redeem(uint256 _ms) public enabled returns(uint256 msr) { return impl.impl_apply4Redeem(msg.sender, _ms); } function cancelRedeem(uint256 _ms2r_msr) public enabled returns(uint256 ms) { return impl.impl_cancelRedeem(msg.sender, _ms2r_msr); } function redeem(uint256 _msr) public enabled returns(uint256 eth) { return impl.impl_redeem(msg.sender, _msr); } //event Dequeue(address indexed _holder, uint256 _dealt, address _token, uint256 _gaslimit); event DequeueOrder(address indexed _holder, uint256 _dealt, uint256 _gaslimit); function dequeueOrder(uint256 gaslimit) public enabled returns(uint256 dealt) { // for urge order dealt = impl.dequeueOrder(gaslimit, true); //emit Dequeue(msg.sender, dealt, getBA(_$FO_), gaslimit); emit DequeueOrder(msg.sender, dealt, gaslimit); //emitEvent(_Dequeue_, bytes32(msg.sender), bytes32(0), dealt, uint256(getBA(_$FO_)), gaslimit); // emitEvent(_DequeueOrder_, bytes32(msg.sender), bytes32(0), dealt, gaslimit); } event DequeueIngot(address indexed _holder, uint256 _dealt, uint256 _gaslimit); function dequeueIngot(uint256 gaslimit) public enabled returns(uint256 dealt) { dealt = impl.dequeueIngot(gaslimit, true); //emit Dequeue(msg.sender, dealt, getBA(_$FM2_), gaslimit); emit DequeueIngot(msg.sender, dealt, gaslimit); //emitEvent(_Dequeue_, bytes32(msg.sender), bytes32(0), dealt, uint256(getBA(_$FM2_)), gaslimit); // emitEvent(_DequeueIngot_, bytes32(msg.sender), bytes32(0), dealt, gaslimit); } function nop()public{ } function tokenFallback(address _from, uint _value, bytes _data) public enabled2 returns(bool){ if(msg.sender == getBA(_$F_)) return true; return false; _from; _value; _data; } function() public payable{ purchase(false, false, 0x0, 0x0); } } contract IRecommend{ function bindRecommenderImpl(address _sender, bytes32 _recommendation) public returns(bool); } contract I$FM2_Operator { function updateRatioDividend(uint256 _amount, uint256 _ema) public returns(uint256 ratioDividend); function dequeueIngot(uint256 gaslimit, bool force) public returns(uint256); function dividend(uint256 _amount) public; } contract IEtherToken { function destroy(address _from, uint256 _eth) public; }
, "Can't repropose a project which had not INVESTED!"
require(getBUU(_projectStatus_, projectID) == PROJECT_STATUS_INVESTED);
12,732,820
[ 1, 4625, 348, 7953, 560, 30, 269, 315, 2568, 1404, 283, 685, 4150, 279, 1984, 1492, 9323, 486, 2120, 3412, 882, 2056, 4442, 203, 2, 0, 0, 0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706, 3412, 882, 2056, 1769, 202, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0xA70e346Ca3825b46EB4c8d0d94Ff204DB76BC289/sources/browser/saave.sol
max approve `sushiSwapRouter` spender to swap SUSHI into ETH from this contract
sushiToken.approve(address(sushiSwapRouter), type(uint256).max);
8,371,526
[ 1, 4625, 348, 7953, 560, 30, 225, 943, 6617, 537, 1375, 87, 1218, 77, 12521, 8259, 68, 17571, 264, 358, 7720, 11726, 2664, 45, 1368, 512, 2455, 628, 333, 6835, 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,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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, 272, 1218, 77, 1345, 18, 12908, 537, 12, 2867, 12, 87, 1218, 77, 12521, 8259, 3631, 618, 12, 11890, 5034, 2934, 1896, 1769, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./partial_match/3/0x8aE19df1A7ACB73C9AA93E0a9315056422136AEe/sources/LoanManager.sol
/ / Events / Model interface selector / Meta / / Getters / / Metadata / / State interface / / Utils /
abstract contract Model is IERC165, IDebtStatus { @dev This emits when create a new debt. event Created(bytes32 indexed _id); @dev This emits when the status of debt change. @param _timestamp Timestamp of the registry @param _status New status of the registry event ChangedStatus(bytes32 indexed _id, uint256 _timestamp, Status _status); @dev This emits when the obligation of debt change. @param _timestamp Timestamp of the registry @param _debt New debt of the registry event ChangedObligation(bytes32 indexed _id, uint256 _timestamp, uint256 _debt); @dev This emits when the frequency of debt change. @param _timestamp Timestamp of the registry @param _frequency New frequency of each installment event ChangedFrequency(bytes32 indexed _id, uint256 _timestamp, uint256 _frequency); @param _timestamp Timestamp of the registry event ChangedDueTime(bytes32 indexed _id, uint256 _timestamp, Status _status); @param _timestamp Timestamp of the registry @param _dueTime New dueTime of each installment event ChangedFinalTime(bytes32 indexed _id, uint256 _timestamp, uint64 _dueTime); @dev This emits when the call addDebt function. @param _amount New amount of the debt, old amount plus added event AddedDebt(bytes32 indexed _id, uint256 _amount); @dev This emits when the call addPaid function. If the registry is fully paid on the call and the amount parameter exceeds the required payment amount, the event emits the real amount paid on the payment. @param _paid Real amount paid event AddedPaid(bytes32 indexed _id, uint256 _paid); bytes4 internal constant MODEL_INTERFACE = 0xaf498c35; @return Identifier of the model function modelId() external view virtual returns (bytes32); Returns the address of the contract used as Descriptor of the model @dev The descriptor contract should follow the ModelDescriptor.sol scheme @return Address of the descriptor function descriptor() external view virtual returns (address); If called for any address with the ability to modify the state of the model registries, this method should return True. @dev Some contracts may check if the DebtEngine is an operator to know if the model is operative or not. @param operator Address of the target request operator @return canOperate True if operator is able to modify the state of the model function isOperator(address operator) external view virtual returns (bool canOperate); Validates the data for the creation of a new registry, if returns True the same data should be compatible with the create method. @dev This method can revert the call or return false, and both meant an invalid data. @param data Data to validate @return isValid True if the data can be used to create a new registry function validate(bytes calldata data) external view virtual returns (bool isValid); Exposes the current status of the registry. The possible values are: 1: Ongoing - The debt is still ongoing and waiting to be paid 2: Paid - The debt is already paid and 4: Error - There was an Error with the registry @dev This method should always be called by the DebtEngine @param id Id of the registry @return status The current status value function getStatus(bytes32 id) external view virtual returns (Status status); Returns the total paid amount on the registry. @dev it should equal to the sum of all real addPaid @param id Id of the registry @return paid Total paid amount(without debt engine fee) function getPaid(bytes32 id) external view virtual returns (uint256 paid); If the returned amount does not depend on any interactions and only on the model logic, the defined flag will be True; if the amount is an estimation of the future debt, the flag will be set to False. If timestamp equals the current moment, the defined flag should always be True. @dev This can be a gas-intensive method to call, consider calling the run method before. @param id Id of the registry @param timestamp Timestamp of the obligation query @return amount Amount(with debt engine fee) pending to pay on the given timestamp @return defined True If the amount returned is fixed and can't change function getObligation(bytes32 id, uint64 timestamp) external view virtual returns (uint256 amount, bool defined); The amount required to fully paid a registry. All registries should be payable in a single time, even when it has multiple installments. If the registry discounts interest for early payment, those discounts should be taken into account in the returned amount. @dev This can be a gas-intensive method to call, consider calling the run method before. @param id Id of the registry @return amount Amount(with debt engine fee) required to fully paid the loan on the current timestamp function getClosingObligation(bytes32 id) external view virtual returns (uint256 amount); The timestamp of the next required payment. After this moment, if the payment goal is not met the debt will be considered overdue. The getObligation method can be used to know the required payment on the future timestamp. @param id Id of the registry @return timestamp The timestamp of the next due time function getDueTime(bytes32 id) external view virtual returns (uint256 timestamp); If the loan has multiple installments returns the duration of each installment in seconds, if the loan has not installments it should return 1. @param id Id of the registry @return frequency Frequency of each installment function getFrequency(bytes32 id) external view virtual returns (uint256 frequency); If the loan has multiple installments returns the total of installments, if the loan has not installments it should return 1. @param id Id of the registry @return installments Total of installments function getInstallments(bytes32 id) external view virtual returns (uint256 installments); The registry could be paid before or after the date, but the debt will always be considered overdue if paid after this timestamp. This is the estimated final payment date of the debt if it's always paid on each exact dueTime. @param id Id of the registry @return timestamp Timestamp of the final due time function getFinalTime(bytes32 id) external view virtual returns (uint256 timestamp); Similar to getFinalTime returns the expected payment remaining if paid always on the exact dueTime. If the model has no interest discounts for early payments, this method should return the same value as getClosingObligation. @param id Id of the registry @return amount Expected payment amount(with debt engine fee) function getEstimateObligation(bytes32 id) external view virtual returns (uint256 amount); Creates a new registry using the provided data and id, it should fail if the id already exists or if calling validate(data) returns false or throws. @dev This method should only be callable by an operator @param id Id of the registry to create @param data Data to construct the new registry @return success True if the registry was created function create(bytes32 id, bytes calldata data) external virtual returns (bool success); If the registry is fully paid on the call and the amount parameter exceeds the required payment amount, the method returns the real amount used on the payment. The payment taken should always be the same as the requested unless the registry is fully paid on the process. @dev This method should only be callable by an operator @param id If of the registry @param amount Amount to pay(without debt engine fee) @return real Real amount paid function addPaid(bytes32 id, uint256 amount) external virtual returns (uint256 real); Adds a new amount(without debt engine fee) to be paid on the debt model, each model can handle the addition of more debt freely. @dev This method should only be callable by an operator @param id Id of the registry @param amount Debt amount(without debt engine fee) to add to the registry @return added True if the debt was added function addDebt(bytes32 id, uint256 amount) external virtual returns (bool added); Runs the internal clock of a registry, this is used to compute the last changes on the state. It can make transactions cheaper by avoiding multiple calculations when calling views. Not all models have internal clocks, a model without an internal clock should always return false. Calls to this method should be possible from any address, multiple calls to run shouldn't affect the internal calculations of the model. @dev If the call had no effect the method would return False, that is no sign of things going wrong, and the call shouldn't be wrapped on a require @param id If of the registry @return effect True if the run performed a change on the state function run(bytes32 id) external virtual returns (bool effect); The abstract contract Model defines the whole lifecycle of a debt on the DebtEngine. }
5,087,870
[ 1, 4625, 348, 7953, 560, 30, 342, 342, 9043, 342, 3164, 1560, 3451, 342, 6565, 342, 342, 968, 5432, 342, 342, 6912, 342, 342, 3287, 1560, 342, 342, 6091, 342, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 3639, 632, 5206, 1220, 24169, 1347, 326, 1267, 434, 18202, 88, 2549, 18, 203, 203, 3639, 632, 891, 389, 5508, 8159, 434, 326, 4023, 203, 3639, 632, 891, 389, 2327, 1166, 1267, 434, 326, 4023, 203, 565, 871, 27707, 1482, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 5508, 16, 2685, 389, 2327, 1769, 203, 203, 3639, 632, 5206, 1220, 24169, 1347, 326, 320, 31627, 367, 434, 18202, 88, 2549, 18, 203, 203, 3639, 632, 891, 389, 5508, 8159, 434, 326, 4023, 203, 3639, 632, 891, 389, 323, 23602, 1166, 18202, 88, 434, 326, 4023, 203, 565, 871, 27707, 51, 31627, 367, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 5508, 16, 2254, 5034, 389, 323, 23602, 1769, 203, 203, 3639, 632, 5206, 1220, 24169, 1347, 326, 8670, 434, 18202, 88, 2549, 18, 203, 203, 3639, 632, 891, 389, 5508, 8159, 434, 326, 4023, 203, 3639, 632, 891, 389, 14092, 1166, 8670, 434, 1517, 3799, 475, 203, 565, 871, 27707, 13865, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 5508, 16, 2254, 5034, 389, 14092, 1769, 203, 203, 3639, 632, 891, 389, 5508, 8159, 434, 326, 4023, 203, 565, 871, 27707, 30023, 950, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 5508, 16, 2685, 389, 2327, 1769, 203, 203, 3639, 632, 891, 389, 5508, 8159, 434, 326, 4023, 203, 3639, 632, 891, 389, 24334, 950, 1166, 6541, 950, 434, 1517, 3799, 475, 203, 565, 871, 27707, 7951, 950, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 5508, 16, 2254, 1105, 389, 24334, 950, 1769, 203, 203, 3639, 632, 5206, 1220, 24169, 1347, 326, 745, 527, 758, 23602, 445, 18, 203, 203, 3639, 632, 891, 389, 8949, 1166, 3844, 434, 326, 18202, 88, 16, 1592, 3844, 8737, 3096, 203, 565, 871, 25808, 758, 23602, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 8949, 1769, 203, 203, 3639, 632, 5206, 1220, 24169, 1347, 326, 745, 527, 16507, 350, 445, 18, 203, 203, 3639, 971, 326, 4023, 353, 7418, 30591, 603, 326, 745, 471, 326, 3844, 1569, 14399, 326, 1931, 203, 5411, 5184, 3844, 16, 326, 871, 24169, 326, 2863, 3844, 30591, 603, 326, 5184, 18, 203, 203, 3639, 632, 891, 389, 29434, 15987, 3844, 30591, 203, 565, 871, 25808, 16507, 350, 12, 3890, 1578, 8808, 389, 350, 16, 2254, 5034, 389, 29434, 1769, 203, 203, 565, 1731, 24, 2713, 5381, 21700, 67, 18865, 273, 374, 92, 1727, 7616, 28, 71, 4763, 31, 203, 203, 203, 3639, 632, 2463, 10333, 434, 326, 938, 203, 565, 445, 25468, 1435, 3903, 1476, 5024, 1135, 261, 3890, 1578, 1769, 203, 203, 3639, 2860, 326, 1758, 434, 326, 6835, 1399, 487, 12823, 434, 326, 938, 203, 203, 3639, 632, 5206, 1021, 4950, 6835, 1410, 2805, 326, 3164, 3187, 18, 18281, 4355, 203, 203, 3639, 632, 2463, 5267, 434, 326, 4950, 203, 565, 445, 4950, 1435, 3903, 1476, 5024, 1135, 261, 2867, 1769, 203, 203, 3639, 971, 2566, 364, 1281, 1758, 598, 326, 7123, 358, 5612, 326, 919, 434, 326, 938, 960, 22796, 16, 203, 5411, 333, 707, 1410, 327, 1053, 18, 203, 203, 3639, 632, 5206, 10548, 20092, 2026, 866, 309, 326, 1505, 23602, 4410, 353, 203, 5411, 392, 3726, 358, 5055, 309, 326, 938, 353, 2255, 1535, 578, 486, 18, 203, 203, 3639, 632, 891, 3726, 5267, 434, 326, 1018, 590, 3726, 203, 203, 3639, 632, 2463, 848, 3542, 340, 1053, 309, 3726, 353, 7752, 358, 5612, 326, 919, 434, 326, 938, 203, 565, 445, 353, 5592, 12, 2867, 3726, 13, 3903, 1476, 5024, 1135, 261, 6430, 848, 3542, 340, 1769, 203, 203, 3639, 2364, 815, 326, 501, 364, 326, 6710, 434, 279, 394, 4023, 16, 309, 1135, 1053, 326, 203, 5411, 1967, 501, 1410, 506, 7318, 598, 326, 752, 707, 18, 203, 203, 3639, 632, 5206, 1220, 707, 848, 15226, 326, 745, 578, 327, 629, 16, 471, 3937, 20348, 392, 2057, 501, 18, 203, 203, 3639, 632, 891, 501, 1910, 358, 1954, 203, 203, 3639, 632, 2463, 4908, 1053, 309, 326, 501, 848, 506, 1399, 358, 752, 279, 394, 4023, 203, 565, 445, 1954, 12, 3890, 745, 892, 501, 13, 3903, 1476, 5024, 1135, 261, 6430, 4908, 1769, 203, 203, 203, 3639, 1312, 10522, 326, 783, 1267, 434, 326, 4023, 18, 1021, 3323, 924, 854, 30, 203, 203, 3639, 404, 30, 2755, 8162, 300, 1021, 18202, 88, 353, 4859, 30542, 471, 7336, 358, 506, 30591, 203, 3639, 576, 30, 453, 20736, 300, 1021, 18202, 88, 353, 1818, 30591, 471, 203, 3639, 1059, 30, 1068, 300, 6149, 1703, 392, 1068, 598, 326, 4023, 203, 203, 3639, 632, 5206, 1220, 707, 1410, 3712, 506, 2566, 635, 326, 1505, 23602, 4410, 203, 203, 3639, 632, 891, 612, 3124, 434, 326, 4023, 203, 203, 3639, 632, 2463, 1267, 1021, 783, 1267, 460, 203, 565, 445, 5870, 12, 3890, 1578, 612, 13, 3903, 1476, 5024, 1135, 261, 1482, 1267, 1769, 203, 203, 3639, 2860, 326, 2078, 30591, 3844, 603, 326, 4023, 18, 203, 203, 3639, 632, 5206, 518, 1410, 3959, 358, 326, 2142, 434, 777, 2863, 527, 16507, 350, 203, 203, 3639, 632, 891, 612, 3124, 434, 326, 4023, 203, 203, 3639, 632, 2463, 30591, 10710, 30591, 3844, 12, 13299, 18202, 88, 4073, 14036, 13, 203, 565, 445, 1689, 20736, 12, 3890, 1578, 612, 13, 3903, 1476, 5024, 1135, 261, 11890, 5034, 30591, 1769, 203, 203, 3639, 971, 326, 2106, 3844, 1552, 486, 2447, 603, 1281, 23877, 471, 1338, 603, 326, 938, 4058, 16, 203, 5411, 326, 2553, 2982, 903, 506, 1053, 31, 309, 326, 3844, 353, 392, 29284, 434, 326, 3563, 18202, 88, 16, 203, 5411, 326, 2982, 903, 506, 444, 358, 1083, 18, 203, 203, 3639, 971, 2858, 1606, 326, 783, 10382, 16, 326, 2553, 2982, 1410, 3712, 506, 1053, 18, 203, 203, 3639, 632, 5206, 1220, 848, 506, 279, 16189, 17, 474, 14315, 707, 358, 745, 16, 5260, 4440, 326, 1086, 707, 1865, 18, 203, 203, 2 ]
// Copyright 2021 Cartesi Pte. Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. pragma solidity ^0.8.0; import "@cartesi/pos/contracts/IWorkerManagerAuthManager.sol"; import "./interfaces/StakingPoolWorker.sol"; import "./StakingPoolData.sol"; contract StakingPoolWorkerImpl is StakingPoolWorker, StakingPoolData { IWorkerManagerAuthManager immutable workerManager; // all immutable variables can stay at the constructor constructor(address _workerManager) { require( _workerManager != address(0), "parameter can not be zero address" ); workerManager = IWorkerManagerAuthManager(_workerManager); } receive() external payable {} function __StakingPoolWorkerImpl_update(address _pos) internal { workerManager.authorize(address(this), _pos); pos = IPoS(_pos); } /// @notice allows for the pool to act on its own behalf when producing blocks. function selfhire() external payable override { // pool needs to be both user and worker workerManager.hire{value: msg.value}(payable(address(this))); workerManager.authorize(address(this), address(pos)); workerManager.acceptJob(); payable(msg.sender).transfer(msg.value); } /// @notice Asks the worker to work for the sender. Sender needs to pay something. /// @param workerAddress address of the worker function hire(address payable workerAddress) external payable override onlyOwner { workerManager.hire{value: msg.value}(workerAddress); workerManager.authorize(workerAddress, address(pos)); } /// @notice Called by the user to cancel a job offer /// @param workerAddress address of the worker node function cancelHire(address workerAddress) external override onlyOwner { workerManager.cancelHire(workerAddress); } /// @notice Called by the user to retire his worker. /// @param workerAddress address of the worker to be retired /// @dev this also removes all authorizations in place function retire(address payable workerAddress) external override onlyOwner { workerManager.retire(workerAddress); } }
@notice Asks the worker to work for the sender. Sender needs to pay something. @param workerAddress address of the worker
function hire(address payable workerAddress) external payable override onlyOwner { workerManager.authorize(workerAddress, address(pos)); }
2,576,920
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 2970, 7904, 326, 4322, 358, 1440, 364, 326, 5793, 18, 15044, 4260, 358, 8843, 5943, 18, 632, 891, 4322, 1887, 1758, 434, 326, 4322, 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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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 ]
[ 1, 565, 445, 366, 577, 12, 2867, 8843, 429, 4322, 1887, 13, 203, 3639, 3903, 203, 3639, 8843, 429, 203, 3639, 3849, 203, 3639, 1338, 5541, 203, 565, 288, 203, 3639, 4322, 1318, 18, 22488, 12, 10124, 1887, 16, 1758, 12, 917, 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 ]
// File: @openzeppelin\contracts\token\ERC20\IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: node_modules\@openzeppelin\contracts\math\SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: node_modules\@openzeppelin\contracts\utils\Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin\contracts\token\ERC20\SafeERC20.sol pragma solidity ^0.6.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin\contracts\utils\EnumerableSet.sol pragma solidity ^0.6.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.0.0, only sets of type `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]; } // 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(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(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(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(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: node_modules\@openzeppelin\contracts\GSN\Context.sol pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin\contracts\access\Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin\contracts\token\ERC20\ERC20.sol pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin 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; using Address for address; 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 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. 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 returns (uint8) { return _decimals; } /** * @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 _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 { _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 { } } // File: contracts\PigstyToken.sol pragma solidity ^0.6.2; // SushiToken with Governance. contract PigstyToken is ERC20("PigstyToken", "STY"), Ownable { // START OF Pigsty SUSHI SPECIFIC CODE // Pigsty sushi is an exact copy of sushi except for the // https://etherscan.io/token/0x6b3595068778dd592e39a122f4f5a5cf09c90fe2 // every transfer 1% gets burned and % gets transfered to vault using SafeMath for uint256; address public vaultAddress = 0xac66953a0163594194b1b42fB734222feb46E7Ae; bool public hardCapReached = false; uint256 private bp150 = 150; //1.5% uint256 private bp125 = 125; //1.25% uint256 private bp100 = 100; // 1% uint256 private bp200 = 200; // 2% uint256 public onepointfiveperc = 150 ether; //150 STY 1.5% uint256 public onepointtwentyfiveperc = 125 ether; //125 STY 1.25% uint256 public oneperc = 100 ether; //100 STY 1% uint256 public vaultFee = 20; //2% constructor() public {} function transfer(address recipient, uint256 amount) public virtual override returns (bool) { uint256 burnAmount = amount.div(1000).mul(10); if (hardCapReached) { oneperc = bp100.mul(totalSupply().sub(burnAmount)).div(10000); onepointtwentyfiveperc = bp125 .mul(totalSupply().sub(burnAmount)) .div(10000); onepointfiveperc = bp150.mul(totalSupply().sub(burnAmount)).div( 10000 ); vaultFee = bp200.mul(totalSupply()).div(10000); uint256 vaultBalance = balanceOf(vaultAddress); if (vaultBalance <= oneperc) { //100 STY vaultFee = 80; //8% } else if (vaultBalance <= onepointtwentyfiveperc) { //125 STY vaultFee = 60; //6% } else if (vaultBalance <= onepointfiveperc) { //150 STY vaultFee = 40; //4% } else { vaultFee = 20; //2% } } uint256 _amount; // burn amount is 1% _amount = burnAmount; uint256 vaultAmount = amount.div(1000).mul(vaultFee); _amount = _amount.add(vaultAmount); // sender loses the 1% of the STY _burn(msg.sender, burnAmount); //transfer vaultFee to vault super.transfer(vaultAddress, vaultAmount); // sender transfers the rest return super.transfer(recipient, amount.sub(_amount)); } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { uint256 burnAmount = amount.div(1000).mul(10); // sender loses the 1% of the STY _burn(sender, burnAmount); return super.transferFrom(sender, recipient, amount.sub(burnAmount)); } // END OF Pigsty SUSHI SPECIFIC CODE /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (PigstyChef). function mint(address _to, uint256 _amount) public onlyOwner { require( totalSupply().add(_amount) <= 10000 ether, "Can't mint more than 10k max supply" ); _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } function mintToFull(address _to) public onlyOwner { uint256 maxSupply = 10000 ether; uint256 diff = maxSupply.sub(totalSupply()); if (diff.add(totalSupply()) != maxSupply) { uint256 real = diff.add(totalSupply()); uint256 xd = maxSupply.sub(real); _mint(_to, xd); _moveDelegates(address(0), _delegates[_to], xd); } else { _mint(_to, diff); _moveDelegates(address(0), _delegates[_to], diff); } hardCapReached = true; } function setVaultAddress(address _address) public onlyOwner { vaultAddress = _address; } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping(address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256( "Delegation(address delegatee,uint256 nonce,uint256 expiry)" ); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "SUSHI::delegateBySig: invalid signature" ); require( nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce" ); require(now <= expiry, "SUSHI::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SUSHIs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "SUSHI::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // File: contracts\PigstyChef.sol pragma solidity ^0.6.2; interface IMigratorChef { // Perform LP token migration from legacy UniswapV2 to SushiSwap. // Take the current LP token address and return the new LP token address. // Migrator should have full access to the caller's LP token. // Return the new LP token address. // // XXX Migrator must have allowance access to UniswapV2 LP tokens. // SushiSwap must mint EXACTLY the same amount of SushiSwap LP tokens or // else something bad will happen. Traditional UniswapV2 does not // do that so be careful! function migrate(IERC20 token) external returns (IERC20); } // PigstyChef is an exact copy of Sushi https://etherscan.io/address/0xc2edad668740f1aa35e4d8f227fb8e17dca888cd // we have commented an few lines to remove the dev fund // the rest is exactly the same // PigstyChef is the master of Sushi. He can make Sushi and he is a fair guy. // // Note that it's ownable and the owner wields tremendous power. The ownership // will be transferred to a governance smart contract once SUSHI is sufficiently // distributed and the community can show to govern itself. // // Have fun reading it. Hopefully it's bug-free. God bless. contract PigstyChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of SUSHIs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accSushiPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accSushiPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. SUSHIs to distribute per block. uint256 lastRewardBlock; // Last block number that SUSHIs distribution occurs. uint256 accSushiPerShare; // Accumulated SUSHIs per share, times 1e12. See below. } // The SUSHI TOKEN! PigstyToken public sushi; // Dev address. // Pigsty swap does not have a dev fund // address public devaddr; // Block number when bonus SUSHI period ends. uint256 public bonusEndBlock; // SUSHI tokens created per block. uint256 public sushiPerBlock; // Bonus muliplier for early sushi makers. uint256 public constant BONUS_MULTIPLIER = 2; // The migrator contract. It has a lot of power. Can only be set through governance (owner). IMigratorChef public migrator; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when SUSHI mining starts. uint256 public startBlock; uint256 public constant maxTokenSupply = 10000 ether; bool public maxCapReached = false; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw( address indexed user, uint256 indexed pid, uint256 amount ); constructor( PigstyToken _sushi, // Pigsty swap does not have a dev fund // address _devaddr, uint256 _sushiPerBlock, //100000000000000000000 uint256 _startBlock, uint256 _bonusEndBlock ) public { sushi = _sushi; // devaddr = _devaddr; sushiPerBlock = _sushiPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add( uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push( PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accSushiPerShare: 0 }) ); } // Update the given pool's SUSHI allocation point. Can only be called by the owner. function set( uint256 _pid, uint256 _allocPoint, bool _withUpdate ) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add( _allocPoint ); poolInfo[_pid].allocPoint = _allocPoint; } function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner { bonusEndBlock = _bonusEndBlock; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( _to.sub(bonusEndBlock) ); } } // View function to see pending SUSHIs on frontend. function pendingSushi(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accSushiPerShare = pool.accSushiPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { if (maxCapReached) { uint256 styBalance = sushi.balanceOf(address(this)); uint256 sushiReward = styBalance.mul(pool.allocPoint).div( totalAllocPoint ); accSushiPerShare = accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); } else { uint256 multiplier = getMultiplier( pool.lastRewardBlock, block.number ); uint256 sushiReward = multiplier .mul(sushiPerBlock) .mul(pool.allocPoint) .div(totalAllocPoint); accSushiPerShare = accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); } } return user.amount.mul(accSushiPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 sushiReward = multiplier .mul(sushiPerBlock) .mul(pool.allocPoint) .div(totalAllocPoint); if (maxCapReached) { pool.accSushiPerShare = pool.accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); pool.lastRewardBlock = block.number; } else { if (sushi.totalSupply().add(sushiReward) < maxTokenSupply) { //checks if total supply + sushireward are higher than max allowed total supply //mints if the amounts are smaller sushi.mint(address(this), sushiReward); pool.accSushiPerShare = pool.accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); pool.lastRewardBlock = block.number; } else { if (!maxCapReached) { sushi.mintToFull(address(this)); maxCapReached = true; //if this is triggered, then the reward scheme is changed to only take the contracts token balance. } pool.accSushiPerShare = pool.accSushiPerShare.add( sushiReward.mul(1e12).div(lpSupply) ); pool.lastRewardBlock = block.number; } } } // Deposit LP tokens to PigstyChef for SUSHI allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user .amount .mul(pool.accSushiPerShare) .div(1e12) .sub(user.rewardDebt); safeSushiTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom( address(msg.sender), address(this), _amount ); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accSushiPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from PigstyChef. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accSushiPerShare).div(1e12).sub( user.rewardDebt ); safeSushiTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accSushiPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe sushi transfer function, just in case if rounding error causes pool to not have enough SUSHIs. function safeSushiTransfer(address _to, uint256 _amount) internal { uint256 sushiBal = sushi.balanceOf(address(this)); if (_amount > sushiBal) { sushi.transfer(_to, sushiBal); } else { sushi.transfer(_to, _amount); } } // Pigsty swap does not have a dev fund // Update dev address by the previous dev. // function dev(address _devaddr) public { // require(msg.sender == devaddr, "dev: wut?"); // devaddr = _devaddr; // } }
SushiToken with Governance. START OF Pigsty SUSHI SPECIFIC CODE Pigsty sushi is an exact copy of sushi except for the https:etherscan.io/token/0x6b3595068778dd592e39a122f4f5a5cf09c90fe2 every transfer 1% gets burned and % gets transfered to vault
contract PigstyToken is ERC20("PigstyToken", "STY"), Ownable { using SafeMath for uint256; address public vaultAddress = 0xac66953a0163594194b1b42fB734222feb46E7Ae; bool public hardCapReached = false; function transfer(address recipient, uint256 amount) public virtual override returns (bool) constructor() public {} { uint256 burnAmount = amount.div(1000).mul(10); if (hardCapReached) { oneperc = bp100.mul(totalSupply().sub(burnAmount)).div(10000); onepointtwentyfiveperc = bp125 .mul(totalSupply().sub(burnAmount)) .div(10000); onepointfiveperc = bp150.mul(totalSupply().sub(burnAmount)).div( 10000 ); vaultFee = bp200.mul(totalSupply()).div(10000); uint256 vaultBalance = balanceOf(vaultAddress); if (vaultBalance <= oneperc) { } } uint256 _amount; uint256 vaultAmount = amount.div(1000).mul(vaultFee); _amount = _amount.add(vaultAmount); } { uint256 burnAmount = amount.div(1000).mul(10); if (hardCapReached) { oneperc = bp100.mul(totalSupply().sub(burnAmount)).div(10000); onepointtwentyfiveperc = bp125 .mul(totalSupply().sub(burnAmount)) .div(10000); onepointfiveperc = bp150.mul(totalSupply().sub(burnAmount)).div( 10000 ); vaultFee = bp200.mul(totalSupply()).div(10000); uint256 vaultBalance = balanceOf(vaultAddress); if (vaultBalance <= oneperc) { } } uint256 _amount; uint256 vaultAmount = amount.div(1000).mul(vaultFee); _amount = _amount.add(vaultAmount); } { uint256 burnAmount = amount.div(1000).mul(10); if (hardCapReached) { oneperc = bp100.mul(totalSupply().sub(burnAmount)).div(10000); onepointtwentyfiveperc = bp125 .mul(totalSupply().sub(burnAmount)) .div(10000); onepointfiveperc = bp150.mul(totalSupply().sub(burnAmount)).div( 10000 ); vaultFee = bp200.mul(totalSupply()).div(10000); uint256 vaultBalance = balanceOf(vaultAddress); if (vaultBalance <= oneperc) { } } uint256 _amount; uint256 vaultAmount = amount.div(1000).mul(vaultFee); _amount = _amount.add(vaultAmount); } } else if (vaultBalance <= onepointtwentyfiveperc) { } else if (vaultBalance <= onepointfiveperc) { } else { _amount = burnAmount; _burn(msg.sender, burnAmount); super.transfer(vaultAddress, vaultAmount); return super.transfer(recipient, amount.sub(_amount)); function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { uint256 burnAmount = amount.div(1000).mul(10); _burn(sender, burnAmount); return super.transferFrom(sender, recipient, amount.sub(burnAmount)); } function mint(address _to, uint256 _amount) public onlyOwner { require( totalSupply().add(_amount) <= 10000 ether, "Can't mint more than 10k max supply" ); _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } function mintToFull(address _to) public onlyOwner { uint256 maxSupply = 10000 ether; uint256 diff = maxSupply.sub(totalSupply()); if (diff.add(totalSupply()) != maxSupply) { uint256 real = diff.add(totalSupply()); uint256 xd = maxSupply.sub(real); _mint(_to, xd); _moveDelegates(address(0), _delegates[_to], xd); _mint(_to, diff); _moveDelegates(address(0), _delegates[_to], diff); } hardCapReached = true; } function mintToFull(address _to) public onlyOwner { uint256 maxSupply = 10000 ether; uint256 diff = maxSupply.sub(totalSupply()); if (diff.add(totalSupply()) != maxSupply) { uint256 real = diff.add(totalSupply()); uint256 xd = maxSupply.sub(real); _mint(_to, xd); _moveDelegates(address(0), _delegates[_to], xd); _mint(_to, diff); _moveDelegates(address(0), _delegates[_to], diff); } hardCapReached = true; } } else { function setVaultAddress(address _address) public onlyOwner { vaultAddress = _address; } mapping(address => address) internal _delegates; struct Checkpoint { uint32 fromBlock; uint256 votes; } "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); "Delegation(address delegatee,uint256 nonce,uint256 expiry)" ); address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); address indexed delegate, uint256 previousBalance, uint256 newBalance ); mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; mapping(address => uint32) public numCheckpoints; bytes32 public constant DOMAIN_TYPEHASH = keccak256( bytes32 public constant DELEGATION_TYPEHASH = keccak256( mapping(address => uint256) public nonces; event DelegateChanged( event DelegateVotesChanged( function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, v, r, s); require( signatory != address(0), "SUSHI::delegateBySig: invalid signature" ); require( nonce == nonces[signatory]++, "SUSHI::delegateBySig: invalid nonce" ); require(now <= expiry, "SUSHI::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "SUSHI::getPriorVotes: not yet determined" ); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; lower = center; upper = center - 1; } } return checkpoints[account][lower].votes; } } else if (cp.fromBlock < blockNumber) { } else { function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _moveDelegates( address srcRep, address dstRep, uint256 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "SUSHI::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "SUSHI::_writeCheckpoint: block number exceeds 32 bits" ); if ( nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber ) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; checkpoints[delegatee][nCheckpoints] = Checkpoint( blockNumber, newVotes ); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } } else { function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } function getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
639,775
[ 1, 4625, 348, 7953, 560, 30, 225, 348, 1218, 77, 1345, 598, 611, 1643, 82, 1359, 18, 10485, 15932, 453, 360, 334, 93, 11726, 2664, 45, 22872, 22183, 11128, 453, 360, 334, 93, 272, 1218, 77, 353, 392, 5565, 1610, 434, 272, 1218, 77, 1335, 364, 326, 2333, 30, 546, 414, 4169, 18, 1594, 19, 2316, 19, 20, 92, 26, 70, 4763, 29, 3361, 9470, 4700, 28, 449, 6162, 22, 73, 5520, 69, 22266, 74, 24, 74, 25, 69, 25, 8522, 5908, 71, 9349, 3030, 22, 3614, 7412, 404, 9, 5571, 18305, 329, 471, 738, 5571, 7412, 329, 358, 9229, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 16351, 453, 360, 334, 93, 1345, 353, 4232, 39, 3462, 2932, 52, 360, 334, 93, 1345, 3113, 315, 882, 61, 6, 3631, 14223, 6914, 288, 203, 565, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 565, 1758, 1071, 9229, 1887, 273, 374, 92, 1077, 6028, 29, 8643, 69, 1611, 4449, 6162, 24, 15613, 70, 21, 70, 9452, 74, 38, 27, 5026, 28855, 3030, 70, 8749, 41, 27, 37, 73, 31, 203, 565, 1426, 1071, 7877, 4664, 23646, 273, 629, 31, 203, 203, 203, 565, 445, 7412, 12, 2867, 8027, 16, 2254, 5034, 3844, 13, 203, 3639, 1071, 203, 3639, 5024, 203, 3639, 3849, 203, 3639, 1135, 261, 6430, 13, 203, 203, 565, 3885, 1435, 1071, 2618, 203, 565, 288, 203, 3639, 2254, 5034, 18305, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 2163, 1769, 203, 203, 3639, 309, 261, 20379, 4664, 23646, 13, 288, 203, 5411, 1245, 457, 71, 273, 9107, 6625, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 11246, 319, 93, 74, 688, 457, 71, 273, 9107, 18473, 203, 7734, 263, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 3719, 203, 7734, 263, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 74, 688, 457, 71, 273, 9107, 23014, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 203, 7734, 12619, 203, 5411, 11272, 203, 5411, 9229, 14667, 273, 9107, 6976, 18, 16411, 12, 4963, 3088, 1283, 1435, 2934, 2892, 12, 23899, 1769, 203, 5411, 2254, 5034, 9229, 13937, 273, 11013, 951, 12, 26983, 1887, 1769, 203, 5411, 309, 261, 26983, 13937, 1648, 1245, 457, 71, 13, 288, 203, 5411, 289, 203, 3639, 289, 203, 3639, 2254, 5034, 389, 8949, 31, 203, 3639, 2254, 5034, 9229, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 26983, 14667, 1769, 203, 3639, 389, 8949, 273, 389, 8949, 18, 1289, 12, 26983, 6275, 1769, 203, 203, 203, 565, 289, 203, 203, 565, 288, 203, 3639, 2254, 5034, 18305, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 2163, 1769, 203, 203, 3639, 309, 261, 20379, 4664, 23646, 13, 288, 203, 5411, 1245, 457, 71, 273, 9107, 6625, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 11246, 319, 93, 74, 688, 457, 71, 273, 9107, 18473, 203, 7734, 263, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 3719, 203, 7734, 263, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 74, 688, 457, 71, 273, 9107, 23014, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 203, 7734, 12619, 203, 5411, 11272, 203, 5411, 9229, 14667, 273, 9107, 6976, 18, 16411, 12, 4963, 3088, 1283, 1435, 2934, 2892, 12, 23899, 1769, 203, 5411, 2254, 5034, 9229, 13937, 273, 11013, 951, 12, 26983, 1887, 1769, 203, 5411, 309, 261, 26983, 13937, 1648, 1245, 457, 71, 13, 288, 203, 5411, 289, 203, 3639, 289, 203, 3639, 2254, 5034, 389, 8949, 31, 203, 3639, 2254, 5034, 9229, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 26983, 14667, 1769, 203, 3639, 389, 8949, 273, 389, 8949, 18, 1289, 12, 26983, 6275, 1769, 203, 203, 203, 565, 289, 203, 203, 565, 288, 203, 3639, 2254, 5034, 18305, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 2163, 1769, 203, 203, 3639, 309, 261, 20379, 4664, 23646, 13, 288, 203, 5411, 1245, 457, 71, 273, 9107, 6625, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 11246, 319, 93, 74, 688, 457, 71, 273, 9107, 18473, 203, 7734, 263, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 3719, 203, 7734, 263, 2892, 12, 23899, 1769, 203, 5411, 1245, 1153, 74, 688, 457, 71, 273, 9107, 23014, 18, 16411, 12, 4963, 3088, 1283, 7675, 1717, 12, 70, 321, 6275, 13, 2934, 2892, 12, 203, 7734, 12619, 203, 5411, 11272, 203, 5411, 9229, 14667, 273, 9107, 6976, 18, 16411, 12, 4963, 3088, 1283, 1435, 2934, 2892, 12, 23899, 1769, 203, 5411, 2254, 5034, 9229, 13937, 273, 11013, 951, 12, 26983, 1887, 1769, 203, 5411, 309, 261, 26983, 13937, 1648, 1245, 457, 71, 13, 288, 203, 5411, 289, 203, 3639, 289, 203, 3639, 2254, 5034, 389, 8949, 31, 203, 3639, 2254, 5034, 9229, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 26983, 14667, 1769, 203, 3639, 389, 8949, 273, 389, 8949, 18, 1289, 12, 26983, 6275, 1769, 203, 203, 203, 565, 289, 203, 203, 5411, 289, 469, 309, 261, 26983, 13937, 1648, 1245, 1153, 11246, 319, 93, 74, 688, 457, 71, 13, 288, 203, 5411, 289, 469, 309, 261, 26983, 13937, 1648, 1245, 1153, 74, 688, 457, 71, 13, 288, 203, 5411, 289, 469, 288, 203, 3639, 389, 8949, 273, 18305, 6275, 31, 203, 3639, 389, 70, 321, 12, 3576, 18, 15330, 16, 18305, 6275, 1769, 203, 3639, 2240, 18, 13866, 12, 26983, 1887, 16, 9229, 6275, 1769, 203, 3639, 327, 2240, 18, 13866, 12, 20367, 16, 3844, 18, 1717, 24899, 8949, 10019, 203, 565, 445, 7412, 1265, 12, 203, 3639, 1758, 5793, 16, 203, 3639, 1758, 8027, 16, 203, 3639, 2254, 5034, 3844, 203, 565, 262, 1071, 5024, 3849, 1135, 261, 6430, 13, 288, 203, 3639, 2254, 5034, 18305, 6275, 273, 3844, 18, 2892, 12, 18088, 2934, 16411, 12, 2163, 1769, 203, 203, 3639, 389, 70, 321, 12, 15330, 16, 18305, 6275, 1769, 203, 203, 3639, 327, 2240, 18, 13866, 1265, 12, 15330, 16, 8027, 16, 3844, 18, 1717, 12, 70, 321, 6275, 10019, 203, 565, 289, 203, 203, 203, 565, 445, 312, 474, 12, 2867, 389, 869, 16, 2254, 5034, 389, 8949, 13, 1071, 1338, 5541, 288, 203, 3639, 2583, 12, 203, 5411, 2078, 3088, 1283, 7675, 1289, 24899, 8949, 13, 1648, 12619, 225, 2437, 16, 203, 5411, 315, 2568, 1404, 312, 474, 1898, 2353, 1728, 79, 943, 14467, 6, 203, 3639, 11272, 203, 3639, 389, 81, 474, 24899, 869, 16, 389, 8949, 1769, 203, 3639, 389, 8501, 15608, 815, 2 ]
/** * PERSONO.ID is WEB 3.0 cornerstone. * Human first. UBI out of the box. Inevitable. * This contract is a crowdsale of transitional GUT tokens for ETH. * Join early. Don't miss the rise of the great, and impressive bounties. * Open site() at GUT token address 0xbA01AfF9EF5198B5e691D2ac61E3cC126F25491d **/ pragma solidity ^0.4.24; /** * @title ERC20 interface */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @title SafeMath * @dev Math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. 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; } } /** * @title Standard ERC20 token * * @notice The full implementation is in the token. Here it is just for correct compilation. */ contract ERC20 is IERC20 { /** * @dev Internal ERC20 token function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @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; } /** * @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(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); 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)); return role.bearer[account]; } } contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private minters; constructor() internal { _addMinter(msg.sender); } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { minters.remove(account); emit MinterRemoved(account); } } /** * @title ERC20Mintable * @dev ERC20 minting logic. Shortened. Full contract is in the GutTCO.token() contract. */ contract ERC20Mintable is ERC20, MinterRole { /** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address to, uint256 value ) public onlyMinter returns (bool) { _mint(to, value); return true; } } /** * @title SafeERC20 * @notice Shortened Wrappers around ERC20 operations that throw on failure. */ library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { require(token.transfer(to, value)); } } /** * @title Helps contracts guard against reentrancy attacks. * @author Remco Bloemen <remco@2π.com>, Eenae <[email protected]> * @dev If you mark a function `nonReentrant`, you should also * mark it `external`. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor() internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @notice Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter); } } /** * @title Crowdsale * @notice Crowdsale is a base contract for managing a token crowdsale, * allowing investors to purchase tokens with ether. This contract implements * such functionality in its most fundamental form and is extended by other contracts here to provide additional * functionality and custom behavior. */ contract Crowdsale is ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; // The token being sold IERC20 private _token; // Address where funds are collected address private _wallet; // How many token units a buyer would get per wei. // Usually is the conversion between wei and the smallest and indivisible token unit. // Overridden by IcreasingPriceTCO contract logic. uint256 private _rate; // Amount of wei raised uint256 private _weiRaised; /** * 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 TokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); /** * @param rate Number of token units a buyer gets per wei * @dev 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 ERC20Detailed token * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. * @param wallet Address where collected funds will be forwarded to * @param token Address of the token being sold */ constructor(uint256 rate, address wallet, IERC20 token) internal { require(rate > 0); require(wallet != address(0)); require(token != address(0)); _rate = rate; _wallet = wallet; _token = token; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** * Note that other contracts will transfer fund with a base gas stipend * of 2300, which is not enough to call buyTokens. Consider calling * buyTokens directly when purchasing tokens from a contract. */ function () external payable { buyTokens(msg.sender); } /** * @return the token being sold. */ function token() public view returns(IERC20) { return _token; } /** * @return the address where funds are collected. */ function wallet() public view returns(address) { return _wallet; } /** * @return the number of token units a buyer gets per wei. */ function rate() public view returns(uint256) { return _rate; } /** * @return the amount of wei raised. */ function weiRaised() public view returns (uint256) { return _weiRaised; } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * This function has a non-reentrancy guard, so it shouldn't be called by * another `nonReentrant` function. * @param beneficiary Recipient of the token purchase */ function buyTokens(address beneficiary) public nonReentrant payable { uint256 weiAmount = msg.value; _preValidatePurchase(beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state _weiRaised = _weiRaised.add(weiAmount); _processPurchase(beneficiary, tokens); emit TokensPurchased( msg.sender, beneficiary, weiAmount, tokens ); _updatePurchasingState(beneficiary, weiAmount); //check and manage current exchange rate and hard cap _forwardFunds(); //save funds to a Persono.id Foundation address _postValidatePurchase(beneficiary, weiAmount); } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations. * Example from CappedCrowdsale.sol's _preValidatePurchase method: * super._preValidatePurchase(beneficiary, weiAmount); * require(weiRaised().add(weiAmount) <= cap); * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal view { require(beneficiary != address(0)); require(weiAmount != 0); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _postValidatePurchase( address beneficiary, uint256 weiAmount ) internal view { // optional override } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param beneficiary Address performing the token purchase * @param tokenAmount Number of tokens to be emitted */ function _deliverTokens( address beneficiary, uint256 tokenAmount ) internal { _token.safeTransfer(beneficiary, tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send 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 for extensions that require an internal state to check for validity (current user contributions, etc.) * @param beneficiary Address receiving the tokens * @param weiAmount Value in wei involved in the purchase */ function _updatePurchasingState( address beneficiary, uint256 weiAmount ) internal { // optional override } /** * @dev Override to extend the way in which ether is converted to tokens. * @param weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return weiAmount.mul(_rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { _wallet.transfer(msg.value); } } /** * @title IncreasingPriceTCO * @notice Extension of Crowdsale contract that increases the price of tokens according to price ranges. * Early adopters get up to 24 times more benefits. */ contract IncreasingPriceTCO is Crowdsale { using SafeMath for uint256; uint256[2][] private _rates; //_rates[i][0] - upper limit of total weiRaised to apply _rates[i][1] exchange rate at the uint8 private _currentRateIndex; // Index of the current rate: _rates[_currentIndex][1] is the current rate index event NewRateIsSet( uint8 rateIndex, uint256 exRate, uint256 weiRaisedRange, uint256 weiRaised ); /** * @param initRates Is an array of pairs [weiRaised, exchangeRate]. Deteremine the exchange rate depending on the total wei raised before the transaction. */ constructor(uint256[2][] memory initRates) internal { require(initRates.length > 1, 'Rates array should contain more then one value'); _rates = initRates; _currentRateIndex = 0; } function getCurrentRate() public view returns(uint256) { return _rates[_currentRateIndex][1]; } modifier ifExRateNeedsUpdate { if(weiRaised() >= _rates[_currentRateIndex][0] && _currentRateIndex < _rates.length - 1) _; } /** * @notice The new exchange rate is set if total weiRased() exceeds the current exchange rate range */ function _updateCurrentRate() internal ifExRateNeedsUpdate { uint256 _weiRaised = weiRaised(); _currentRateIndex++; //the modifier ifExRateNeedsUpdate means the exchange rate is changed, so we move to the next range right away while(_currentRateIndex < _rates.length - 1 && _rates[_currentRateIndex][0] <= _weiRaised) { _currentRateIndex++; } emit NewRateIsSet(_currentRateIndex, //new exchange rate index _rates[_currentRateIndex][1], //new exchange rate _rates[_currentRateIndex][0], //new exchange rate _weiRaised limit _weiRaised); //amount of _weiRaised by the moment the new exchange rate is applied } /** * @notice The base rate function is overridden to revert, since this crowdsale doens't use it, and * all calls to it are a mistake. */ function rate() public view returns(uint256) { revert(); } /** * @notice Overrides function applying multiple increasing price exchange rates concept */ function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return getCurrentRate().mul(weiAmount); } /** * @notice Overrides a "hook" from the base Crowdsale contract. Checks and updates the current exchange rate. */ function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { _updateCurrentRate(); } } contract KeeperRole { using Roles for Roles.Role; event KeeperAdded(address indexed account); event KeeperRemoved(address indexed account); Roles.Role private keepers; constructor() internal { _addKeeper(msg.sender); } modifier onlyKeeper() { require(isKeeper(msg.sender), 'Only Keeper is allowed'); _; } function isKeeper(address account) public view returns (bool) { return keepers.has(account); } function addKeeper(address account) public onlyKeeper { _addKeeper(account); } function renounceKeeper() public { _removeKeeper(msg.sender); } function _addKeeper(address account) internal { keepers.add(account); emit KeeperAdded(account); } function _removeKeeper(address account) internal { keepers.remove(account); emit KeeperRemoved(account); } } contract PauserRole { using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private pausers; constructor() internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { pausers.remove(account); emit PauserRemoved(account); } } /** * @title Haltable * @dev Base contract which allows children to implement an emergency pause mechanism * and close irreversibly */ contract Haltable is KeeperRole, PauserRole { event Paused(address account); event Unpaused(address account); event Closed(address account); bool private _paused; bool private _closed; constructor() internal { _paused = false; _closed = false; } /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } /** * @return true if the contract is closed, false otherwise. */ function isClosed() public view returns(bool) { return _closed; } /** * @return true if the contract is not closed, false otherwise. */ function notClosed() public view returns(bool) { return !_closed; } /** * @notice Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, 'The contract is paused'); _; } /** * @notice Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, 'The contract is not paused'); _; } /** * @dev Modifier to make a function callable only when the contract is closed. */ modifier whenClosed(bool orCondition) { require(_closed, 'The contract is not closed'); _; } /** * @dev Modifier to make a function callable only when the contract is closed or an external condition is met. */ modifier whenClosedOr(bool orCondition) { require(_closed || orCondition, "It must be closed or what is set in 'orCondition'"); _; } /** * @dev Modifier to make a function callable only when the contract is not closed. */ modifier whenNotClosed() { require(!_closed, "Reverted because it is closed"); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } /** * @dev Called by a Keeper to close a contract. This is irreversible. */ function close() internal whenNotClosed { _closed = true; emit Closed(msg.sender); } } /** * @title CappedCrowdsale * @dev Crowdsale with a limit for total contributions. */ contract CappedTCO is Crowdsale { using SafeMath for uint256; uint256 private _cap; /** * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. * @param cap Max amount of wei to be contributed */ constructor(uint256 cap) internal { require(cap > 0, 'Hard cap must be > 0'); _cap = cap; } /** * @return the cap of the crowdsale. */ function cap() public view returns(uint256) { return _cap; } /** * @dev Checks whether the cap has been reached. * @return Whether the cap was not reached */ function capNotReached() public view returns (bool) { return weiRaised() < _cap; } /** * @dev Checks whether the cap has been reached. * @return Whether the cap was reached */ function capReached() public view returns (bool) { return weiRaised() >= _cap; } } /** * @title PostDeliveryCappedCrowdsale * @notice Hardcapped crowdsale with the gained tokens locked from withdrawal until the crowdsale ends. */ contract PostDeliveryCappedTCO is CappedTCO, Haltable { using SafeMath for uint256; mapping(address => uint256) private _balances; //token balances storage until the crowdsale ends uint256 private _totalSupply; //total GUT distributed amount event TokensWithdrawn( address indexed beneficiary, uint256 amount ); constructor() internal {} /** * @notice Withdraw tokens only after the crowdsale ends (closed). * @param beneficiary is an address whose tokens will be withdrawn. Allows to use a separate address * @notice Withdrawal is suspended in case the crowdsale is paused. */ function withdrawTokensFrom(address beneficiary) public whenNotPaused whenClosedOr(capReached()) { uint256 amount = _balances[beneficiary]; require(amount > 0, 'The balance should be positive for withdrawal. Please check the balance in the token contract.'); _balances[beneficiary] = 0; _deliverTokens(beneficiary, amount); emit TokensWithdrawn(beneficiary, amount); } /** * @notice If calling this function (wothdrawing) from a contract, use withdrawTokensFrom(address beneficiary) * Check that crowdsale is finished: GutTCO.isClosed() == true before running this function (withdrawing tokens). */ function withdrawTokens() public { withdrawTokensFrom(address(msg.sender)); } /** * @notice Total amount of tokens supplied */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @return the balance of an account. */ function balanceOf(address account) public view returns(uint256) { return _balances[account]; } /** * @dev Extend parent behavior requiring purchase to respect the funding cap. * @param beneficiary Token purchaser * @param weiAmount Amount of wei contributed */ function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal view { require(capNotReached(),"Hardcap is reached."); require(notClosed(), "TCO is finished, sorry."); super._preValidatePurchase(beneficiary, weiAmount); } /** * @dev Overrides parent by storing balances instead of issuing tokens right away * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _processPurchase( address beneficiary, uint256 tokenAmount ) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _totalSupply = _totalSupply.add(tokenAmount); } } /** * @notice If you transfer funds (ETH) from a contract, the default gas stipend 2300 will not be enough * to complete transaction to your contract address. Please, consider calling buyTokens() directly when * purchasing tokens from a contract. */ contract GutTCO is PostDeliveryCappedTCO, IncreasingPriceTCO, MinterRole { bool private _finalized; event CrowdsaleFinalized(); constructor( uint256 _rate, address _wallet, uint256 _cap, ERC20Mintable _token ) public Crowdsale(_rate, _wallet, _token) CappedTCO(_cap) IncreasingPriceTCO(initRates()) { _finalized = false; } /** * @notice Initializes exchange rates ranges. */ function initRates() internal pure returns(uint256[2][] memory ratesArray) { ratesArray = new uint256[2][](4); ratesArray[0] = [uint256(100000 ether), 3000]; //first 100000 ether are given 3000 GUT each ratesArray[1] = [uint256(300000 ether), 1500]; //next 200000 (up to 300000) ether are exchanged at 1500 GUT/ether ratesArray[2] = [uint256(700000 ether), 500]; //next 400000 ether will go to Persono.id Foundation at 500 GUT/ether ratesArray[3] = [uint256(1500000 ether), 125]; //the rest 800000 ether are exchanged at 125 GUT/ether } function closeTCO() public onlyMinter { if(notFinalized()) _finalize(); } /** * @return true if the crowdsale is finalized, false otherwise. */ function finalized() public view returns (bool) { return _finalized; } /** * @return true if the crowdsale is finalized, false otherwise. */ function notFinalized() public view returns (bool) { return !finalized(); } /** * @notice Is called after TCO finished to close() TCO and transfer (mint) supplied tokens to the token's contract. */ function _finalize() private { require(notFinalized(), 'TCO already finalized'); if(notClosed()) close(); _finalization(); emit CrowdsaleFinalized(); } function _finalization() private { if(totalSupply() > 0) require(ERC20Mintable(address(token())).mint(address(this), totalSupply()), 'Error when being finalized at minting totalSupply() to the token'); _finalized = true; } /** * @notice Overrides IncreasingPriceTCO. Auto finalize TCO when the cap is reached. */ function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { super._updatePurchasingState(beneficiary, weiAmount); if(capReached()) _finalize(); } }
* @title Helps contracts guard against reentrancy attacks. @author Remco Bloemen <remco@2π.com>, Eenae <[email protected]> @dev If you mark a function `nonReentrant`, you should also mark it `external`./
contract ReentrancyGuard { uint256 private _guardCounter; constructor() internal { _guardCounter = 1; } modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter); } }
980,071
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 670, 292, 1121, 20092, 11026, 5314, 283, 8230, 12514, 28444, 18, 632, 4161, 2663, 2894, 605, 383, 351, 275, 411, 2764, 2894, 36, 22, 144, 227, 18, 832, 20401, 512, 275, 8906,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, 4789, 273, 404, 31, 203, 225, 289, 203, 203, 225, 9606, 1661, 426, 8230, 970, 1435, 288, 203, 565, 389, 24594, 4789, 1011, 404, 31, 203, 565, 2254, 5034, 1191, 4789, 273, 389, 24594, 4789, 31, 203, 565, 389, 31, 203, 565, 2583, 12, 3729, 4789, 422, 389, 24594, 4789, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x9624CA52F22cD8dac0674F20c760Db330aFDE833/sources/contracts/Presale.sol
* Presale Contract Distribute a token that is priced on base currency of a network Set distributed amount, price, Withdrawal unlocks at a certain timestamp Depositing locks at a certain timestamp Finish ends the sale and transfers the gathered amount Finish unlocks at a certain timestamp/
constructor(address acceptedToken) { require(acceptedToken.isContract(), "The accepted token address must be a deployed contract!"); max_base_allocated = 5 ether; withdrawal_unlock_time = 1634380815; finish_unlock_time = 1634381415; deposit_lock_time = 1634380215; start_time = 0; max_allowed_base = 6 ether; min_allowed_base = 4 ether; sale_finished = false; token = IERC20(acceptedToken); dev_address = payable(msg.sender); whitelist[msg.sender] = true; }
7,123,956
[ 1, 4625, 348, 7953, 560, 30, 380, 18346, 5349, 13456, 3035, 887, 279, 1147, 716, 353, 6205, 72, 603, 1026, 5462, 434, 279, 2483, 1000, 16859, 3844, 16, 6205, 16, 3423, 9446, 287, 7186, 87, 622, 279, 8626, 2858, 4019, 538, 305, 310, 13046, 622, 279, 8626, 2858, 18560, 3930, 326, 272, 5349, 471, 29375, 326, 11090, 329, 3844, 18560, 7186, 87, 622, 279, 8626, 2858, 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,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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 ]
[ 1, 225, 3885, 12, 2867, 8494, 1345, 13, 288, 203, 565, 2583, 12, 23847, 1345, 18, 291, 8924, 9334, 315, 1986, 8494, 1147, 1758, 1297, 506, 279, 19357, 6835, 4442, 1769, 203, 565, 943, 67, 1969, 67, 28172, 273, 1381, 225, 2437, 31, 203, 565, 598, 9446, 287, 67, 26226, 67, 957, 273, 2872, 5026, 23, 3672, 28, 3600, 31, 203, 565, 4076, 67, 26226, 67, 957, 273, 2872, 5026, 7414, 3461, 3600, 31, 203, 565, 443, 1724, 67, 739, 67, 957, 273, 2872, 5026, 7414, 3103, 3600, 31, 203, 565, 787, 67, 957, 273, 374, 31, 203, 565, 943, 67, 8151, 67, 1969, 273, 1666, 225, 2437, 31, 203, 565, 1131, 67, 8151, 67, 1969, 273, 1059, 225, 2437, 31, 203, 565, 272, 5349, 67, 13527, 273, 629, 31, 203, 203, 565, 1147, 273, 467, 654, 39, 3462, 12, 23847, 1345, 1769, 203, 565, 4461, 67, 2867, 273, 8843, 429, 12, 3576, 18, 15330, 1769, 203, 565, 10734, 63, 3576, 18, 15330, 65, 273, 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 ]
./full_match/43113/0x9B21EB2E30D8320c3c1b8d8465284D78E58cB971/sources/contracts/PriceOracle/PriceOracleV1.sol
* @dev emitted when a pending anchor is set @param asset Asset for which to set a pending anchor @param oldScaledPrice if an unused pending anchor was present, its value; otherwise 0. @param newScaledPrice the new scaled pending anchor price/
event NewPendingAnchor(address anchorAdmin, address asset, uint256 oldScaledPrice, uint256 newScaledPrice);
7,198,131
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 17826, 1347, 279, 4634, 6984, 353, 444, 632, 891, 3310, 10494, 364, 1492, 358, 444, 279, 4634, 6984, 632, 891, 1592, 55, 12825, 5147, 309, 392, 10197, 4634, 6984, 1703, 3430, 16, 2097, 460, 31, 3541, 374, 18, 632, 891, 30826, 12825, 5147, 326, 394, 12304, 4634, 6984, 6205, 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,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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 ]
[ 1, 565, 871, 1166, 8579, 11605, 12, 2867, 6984, 4446, 16, 1758, 3310, 16, 2254, 5034, 1592, 55, 12825, 5147, 16, 2254, 5034, 30826, 12825, 5147, 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 ]
./full_match/137/0x675c241A921E3C966e0BE5acAA22d57643282F1D/sources/contract-a58c1ca99b.sol
@custom:security-contact [email protected]
contract PeacemenCollection is ERC721, ERC721Enumerable, ERC721URIStorage, Pausable, Ownable, EIP712, ERC721Votes { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; constructor() ERC721("Peacemen Collection", "PCM") EIP712("Peacemen Collection", "1") pragma solidity ^0.8.4; {} function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function safeMint(address to, string memory uri) public onlyOwner { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); _setTokenURI(tokenId, uri); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _afterTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Votes) { super._afterTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
3,737,174
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 3662, 30, 7462, 17, 8994, 19439, 36, 347, 623, 27617, 18, 832, 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, 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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, 16351, 19622, 623, 27617, 2532, 353, 4232, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3572, 25121, 16, 4232, 39, 27, 5340, 3098, 3245, 16, 21800, 16665, 16, 14223, 6914, 16, 512, 2579, 27, 2138, 16, 4232, 39, 27, 5340, 29637, 288, 203, 565, 1450, 9354, 87, 364, 9354, 87, 18, 4789, 31, 203, 203, 565, 9354, 87, 18, 4789, 3238, 389, 2316, 548, 4789, 31, 203, 203, 565, 3885, 1435, 203, 3639, 4232, 39, 27, 5340, 2932, 11227, 623, 27617, 2200, 3113, 315, 3513, 49, 7923, 203, 3639, 512, 2579, 27, 2138, 2932, 11227, 623, 27617, 2200, 3113, 315, 21, 7923, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 24, 31, 203, 565, 2618, 203, 565, 445, 11722, 1435, 1071, 1338, 5541, 288, 203, 3639, 389, 19476, 5621, 203, 565, 289, 203, 203, 565, 445, 640, 19476, 1435, 1071, 1338, 5541, 288, 203, 3639, 389, 318, 19476, 5621, 203, 565, 289, 203, 203, 565, 445, 4183, 49, 474, 12, 2867, 358, 16, 533, 3778, 2003, 13, 1071, 1338, 5541, 288, 203, 3639, 2254, 5034, 1147, 548, 273, 389, 2316, 548, 4789, 18, 2972, 5621, 203, 3639, 389, 2316, 548, 4789, 18, 15016, 5621, 203, 3639, 389, 4626, 49, 474, 12, 869, 16, 1147, 548, 1769, 203, 3639, 389, 542, 1345, 3098, 12, 2316, 548, 16, 2003, 1769, 203, 565, 289, 203, 203, 565, 445, 389, 5771, 1345, 5912, 12, 2867, 628, 16, 1758, 358, 16, 2254, 5034, 1147, 548, 13, 203, 3639, 2713, 203, 3639, 1347, 1248, 28590, 203, 3639, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3572, 25121, 13, 203, 565, 288, 203, 3639, 2240, 6315, 5771, 1345, 5912, 12, 2080, 16, 358, 16, 1147, 548, 1769, 203, 565, 289, 203, 203, 203, 565, 445, 389, 5205, 1345, 5912, 12, 2867, 628, 16, 1758, 358, 16, 2254, 5034, 1147, 548, 13, 203, 3639, 2713, 203, 3639, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 29637, 13, 203, 565, 288, 203, 3639, 2240, 6315, 5205, 1345, 5912, 12, 2080, 16, 358, 16, 1147, 548, 1769, 203, 565, 289, 203, 203, 565, 445, 389, 70, 321, 12, 11890, 5034, 1147, 548, 13, 2713, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3098, 3245, 13, 288, 203, 3639, 2240, 6315, 70, 321, 12, 2316, 548, 1769, 203, 565, 289, 203, 203, 565, 445, 1147, 3098, 12, 11890, 5034, 1147, 548, 13, 203, 3639, 1071, 203, 3639, 1476, 203, 3639, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3098, 3245, 13, 203, 3639, 1135, 261, 1080, 3778, 13, 203, 565, 288, 203, 3639, 327, 2240, 18, 2316, 3098, 12, 2316, 548, 1769, 203, 565, 289, 203, 203, 565, 445, 6146, 1358, 12, 3890, 24, 1560, 548, 13, 203, 3639, 1071, 203, 3639, 1476, 203, 3639, 3849, 12, 654, 39, 27, 5340, 16, 4232, 39, 27, 5340, 3572, 25121, 13, 203, 3639, 1135, 261, 6430, 13, 203, 565, 288, 203, 3639, 327, 2240, 18, 28064, 1358, 12, 5831, 548, 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 ]
//Address: 0xFA1Bcd27Da169C69bfbeda681c2A8277b8E08171 //Contract name: Documents //Balance: 0 Ether //Verification Date: 5/21/2017 //Transacion Count: 40 // CODE STARTS HERE pragma solidity ^0.4.2; /* Родительский контракт */ contract Owned { /* Адрес владельца контракта*/ address owner; /* Конструктор контракта, вызывается при первом запуске */ function Owned() { owner = msg.sender; } /* Изменить владельца контракта, newOwner - адрес нового владельца */ function changeOwner(address newOwner) onlyowner { owner = newOwner; } /* Модификатор для ограничения доступа к функциям только для владельца */ modifier onlyowner() { if (msg.sender==owner) _; } /* Удалить контракт */ function kill() onlyowner { if (msg.sender == owner) suicide(owner); } } /* Основной контракт, наследует контракт Owned */ contract Documents is Owned { /* Структура представляющая документ */ struct Document { string hash; string link; string data; address creator; uint date; uint signsCount; mapping (uint => Sign) signs; } /* Структура представляющая подпись */ struct Sign { address member; uint date; } /* Маппинг ID документа -> документ */ mapping (uint => Document) public documentsIds; /* Кол-во документов */ uint documentsCount = 0; /* Событие при подписи документа участником, параметры - адрес участника, ID документа */ event DocumentSigned(uint id, address member); /* Событие при регистрации документа, параметры - ID документа */ event DocumentRegistered(uint id, string hash); /* Конструктор контракта, вызывается при первом запуске */ function Documents() { } /* функция добавления документа, параметры - хэш, ссылка, дополнительные данные, создатель. Если не передаётся адрес создателя, то будет указан адрес отправителя, в конце вызовется событие DocumentRegistered с параметрами id - документа (позиция в массиве documents) и hash - хэш сумма */ function registerDocument(string hash, string link, string data) { address creator = msg.sender; uint id = documentsCount + 1; documentsIds[id] = Document({ hash: hash, link: link, data: data, creator: creator, date: now, signsCount: 0 }); documentsCount = id; DocumentRegistered(id, hash); } /* функция добавления подписи в документ, параметры - ID Документа, адрес подписчика. Если не передаётся адрес подписчика, то будет указан адрес отправителя, в конце вызовется событие DocumentSigned */ function addSignature(uint id) { address member = msg.sender; Document d = documentsIds[id]; uint count = d.signsCount; bool signed = false; if (count != 0) { for (uint i = 0; i < count; i++) { if (d.signs[i].member == member) { signed = true; break; } } } if (!signed) { d.signs[count] = Sign({ member: member, date: now }); documentsIds[id].signsCount = count + 1; DocumentSigned(id, member); } } /* Функция получения количества документов */ function getDocumentsCount() constant returns (uint) { return documentsCount; } /* Функция получения документа по ID */ function getDocument(uint id) constant returns (string hash, string link, string data, address creator, uint date, uint count) { Document d = documentsIds[id]; hash = d.hash; link = d.link; data = d.data; creator = d.creator; date = d.date; } /* Функция получения количества подписей по ID документа */ function getDocumentSignsCount(uint id) constant returns (uint) { Document d = documentsIds[id]; return d.signsCount; } /* Функция получения подписи документов, параметры - ID документа, позиция подписи в массиве */ function getDocumentSign(uint id, uint index) constant returns ( address member, uint date) { Document d = documentsIds[id]; Sign s = d.signs[index]; member = s.member; date = s.date; } }
Событие при подписи документа участником, параметры - адрес участника, ID документа */
event DocumentSigned(uint id, address member);
7,326,142
[ 1, 4625, 348, 7953, 560, 30, 225, 225, 145, 99, 145, 127, 145, 114, 146, 238, 146, 229, 145, 121, 145, 118, 225, 145, 128, 146, 227, 145, 121, 225, 145, 128, 145, 127, 145, 117, 145, 128, 145, 121, 146, 228, 145, 121, 225, 145, 117, 145, 127, 145, 123, 146, 230, 145, 125, 145, 118, 145, 126, 146, 229, 145, 113, 225, 146, 230, 146, 234, 145, 113, 146, 228, 146, 229, 145, 126, 145, 121, 145, 123, 145, 127, 145, 125, 16, 225, 145, 128, 145, 113, 146, 227, 145, 113, 145, 125, 145, 118, 146, 229, 146, 227, 146, 238, 300, 225, 145, 113, 145, 117, 146, 227, 145, 118, 146, 228, 225, 146, 230, 146, 234, 145, 113, 146, 228, 146, 229, 145, 126, 145, 121, 145, 123, 145, 113, 16, 1599, 225, 145, 117, 145, 127, 145, 123, 146, 230, 145, 125, 145, 118, 145, 126, 146, 229, 145, 113, 1195, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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758, 3140, 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 ]
// SPDX-License-Identifier: MIT pragma solidity >=0.7.2; pragma experimental ABIEncoderV2; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import { AirswapBase } from '../utils/AirswapBase.sol'; import { RollOverBase } from '../utils/RollOverBase.sol'; import { SwapTypes } from '../libraries/SwapTypes.sol'; import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import { SafeERC20 } from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import { SafeMath } from '@openzeppelin/contracts/math/SafeMath.sol'; import { IController } from '../interfaces/IController.sol'; import { IAction } from '../interfaces/IAction.sol'; import { IOracle } from '../interfaces/IOracle.sol'; import { IOToken } from '../interfaces/IOToken.sol'; contract ShortOTokenActionWithSwap is IAction, OwnableUpgradeable, AirswapBase, RollOverBase { using SafeERC20 for IERC20; using SafeMath for uint256; /// @dev 100% uint256 constant public BASE = 10000; /// @dev the minimum strike price of the option chosen needs to be at least 105% of spot. /// This is set expecting the contract to be a strategy selling calls. For puts should change this. // TODO: change back to 10500 for prod uint256 constant public MIN_STRIKE = 0; //TODO: change back to 100 for prod uint256 constant public MIN_PROFITS = 0; // 1% uint256 public lockedAsset; uint256 public rolloverTime; address public immutable vault; address public immutable asset; IController public controller; IOracle public oracle; constructor( address _vault, address _asset, address _swap, address _opynWhitelist, address _controller, uint256 _vaultType ) { vault = _vault; asset = _asset; // enable vault to take all the asset back and re-distribute. IERC20(_asset).safeApprove(_vault, uint256(-1)); controller = IController(_controller); // enable pool contract to pull asset from this contract to mint options. address pool = controller.pool(); oracle = IOracle(controller.oracle()); IERC20(_asset).safeApprove(pool, uint256(-1)); _initSwapContract(_swap); _initRollOverBase(_opynWhitelist); __Ownable_init(); _openVault(_vaultType); } modifier onlyVault() { require(msg.sender == vault, "!VAULT"); _; } /** * @dev return the net worth of this strategy, in terms of asset. * if the action has an opened gamma vault, see if there's any short position */ function currentValue() external view override returns (uint256) { uint256 assetBalance = IERC20(asset).balanceOf(address(this)); return assetBalance.add(lockedAsset); // todo: caclulate cash value to avoid not early withdraw to avoid loss. } /** * @dev the function that the vault will call when the round is over */ function closePosition() external onlyVault override { require(canClosePosition(), "Cannot close position"); if(_canSettleVault()) { _settleVault(); } // this function can only be called when it's `Activated` // go to the next step, which will enable owner to commit next oToken _setActionIdle(); lockedAsset = 0; } /** * @dev the function that the vault will call when the new round is starting */ function rolloverPosition() external onlyVault override { // this function can only be called when it's `Committed` _rollOverNextOTokenAndActivate(); rolloverTime = block.timestamp; } /** * @dev owner only function to mint options with "assets" and sell otokens in this contract * by filling an order on AirSwap. * this can only be done in "activated" state. which is achievable by calling `rolloverPosition` */ function mintAndSellOToken(uint256 _collateralAmount, uint256 _otokenAmount, SwapTypes.Order memory _order) external onlyOwner onlyActivated { require(_order.sender.wallet == address(this), '!Sender'); require(_order.sender.token == otoken, 'Can only sell otoken'); require(_order.signer.token == asset, 'Can only sell for asset'); require(_collateralAmount.mul(MIN_PROFITS).div(BASE) <= _order.signer.amount, 'Need minimum option premium'); _mintOTokens(_collateralAmount, _otokenAmount); IERC20(otoken).safeApprove(address(airswap), _order.sender.amount); _fillAirswapOrder(_order); } /** * @notice the function will return when someone can close a position. 1 day after rollover, * if the option wasn't sold, anyone can close the position. */ function canClosePosition() public view returns(bool) { if (otoken != address(0) && lockedAsset != 0) { return _canSettleVault(); } return block.timestamp > rolloverTime + 1 days; } /** * @dev open vault with vaultId 1. this should only be performed once when contract is initiated */ function _openVault(uint256 _vaultType) internal { bytes memory data; if (_vaultType != 0) { data = abi.encode(_vaultType); } // this action will always use vault id 0 IController.ActionArgs[] memory actions = new IController.ActionArgs[](1); actions[0] = IController.ActionArgs( IController.ActionType.OpenVault, address(this), // owner address(0), // second address address(0), // asset, otoken 1, // vaultId 0, // amount 0, // index data // data ); controller.operate(actions); } /** * @dev mint otoken in vault 0 */ function _mintOTokens(uint256 _collateralAmount, uint256 _otokenAmount) internal { // this action will always use vault id 0 IController.ActionArgs[] memory actions = new IController.ActionArgs[](2); actions[0] = IController.ActionArgs( IController.ActionType.DepositCollateral, address(this), // vault owner address(this), // deposit from this address asset, // collateral asset 1, // vaultId _collateralAmount, // amount 0, // index "" // data ); actions[1] = IController.ActionArgs( IController.ActionType.MintShortOption, address(this), // vault owner address(this), // mint to this address otoken, // otoken 1, // vaultId _otokenAmount, // amount 0, // index "" // data ); lockedAsset = lockedAsset.add(_collateralAmount); controller.operate(actions); } /** * @dev settle vault 0 and withdraw all locked collateral */ function _settleVault() internal { IController.ActionArgs[] memory actions = new IController.ActionArgs[](1); // this action will always use vault id 1 actions[0] = IController.ActionArgs( IController.ActionType.SettleVault, address(this), // owner address(this), // recipient address(0), // asset 1, // vaultId 0, // amount 0, // index "" // data ); controller.operate(actions); } /** * @dev checks if the current vault can be settled */ function _canSettleVault() internal view returns (bool) { if (lockedAsset != 0 && otoken != address(0)) { return controller.isSettlementAllowed(otoken); } return false; } /** * @dev funtion to add some custom logic to check the next otoken is valid to this strategy * this hook is triggered while action owner calls "commitNextOption" * so accessing otoken will give u the current otoken. */ function _customOTokenCheck(address _nextOToken) internal view override { // Can override or replace this. IOToken otokenToCheck = IOToken(_nextOToken); require(_isValidStrike(otokenToCheck.strikePrice()), 'Strike Price Too Low'); require (_isValidExpiry(otokenToCheck.expiryTimestamp()), 'Invalid expiry'); /** * e.g. * check otoken strike price is lower than current spot price for put. * check it's no more than x day til the current otoken expires. (can't commit too early) * check there's no previously committed otoken. * check otoken expiry is expected */ } /** * @dev funtion to check that the otoken being sold meets a minimum valid strike price * this hook is triggered in the _customOtokenCheck function. */ function _isValidStrike(uint256 strikePrice) internal view returns (bool) { // TODO: override with your filler code. uint256 spotPrice = oracle.getPrice(asset); // checks that the strike price set is > than 105% of current price return strikePrice >= spotPrice.mul(MIN_STRIKE).div(BASE); } /** * @dev funtion to check that the otoken being sold meets certain expiry conditions * this hook is triggered in the _customOtokenCheck function. */ function _isValidExpiry(uint256 expiry) internal view returns (bool) { // TODO: override with your filler code. // Checks that the token committed to expires within 15 days of commitment. return (block.timestamp).add(15 days) >= expiry; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; pragma experimental ABIEncoderV2; import { ISwap } from "../interfaces/ISwap.sol"; import { SwapTypes } from "../libraries/SwapTypes.sol"; contract AirswapBase { ISwap public airswap; function _initSwapContract(address _airswap) internal { require(_airswap != address(0), "Invalid airswap address"); airswap = ISwap(_airswap); } function _fillAirswapOrder(SwapTypes.Order memory _order) internal { airswap.swap(_order); } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; pragma experimental ABIEncoderV2; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import { AirswapBase } from './AirswapBase.sol'; import { SwapTypes } from '../libraries/SwapTypes.sol'; import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import { SafeERC20 } from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import { IWhitelist } from '../interfaces/IWhitelist.sol'; contract RollOverBase is OwnableUpgradeable { address public otoken; address public nextOToken; //TODO: update to 18 hours for official deployment uint256 constant public MIN_COMMIT_PERIOD = 0 hours; uint256 public commitStateStart; enum ActionState { // action will go "idle" after the vault close this position, and before the next otoken is committed. Idle, // onwer already set the next otoken this vault is trading. // during this phase, all funds are already back in the vault and waiting for re-distribution // users who don't agree with the setting of next round can withdraw. Committed, // after vault calls "rollover", owner can start minting / buying / selling according to each action. Activated } ActionState public state; IWhitelist public opynWhitelist; modifier onlyCommitted () { require(state == ActionState.Committed, "!COMMITED"); _; } modifier onlyActivated () { require(state == ActionState.Activated, "!Activated"); _; } function _initRollOverBase(address _opynWhitelist) internal { state = ActionState.Idle; opynWhitelist = IWhitelist(_opynWhitelist); } /** * owner can commit the next otoken, if it's in idle state. * or re-commit it if needed during the commit phase. */ function commitOToken(address _nextOToken) external onlyOwner { require(state != ActionState.Activated, "Activated"); _checkOToken(_nextOToken); nextOToken = _nextOToken; state = ActionState.Committed; commitStateStart = block.timestamp; } function _setActionIdle() internal onlyActivated { // wait for the owner to set the next option state = ActionState.Idle; } function _rollOverNextOTokenAndActivate() internal onlyCommitted { require(block.timestamp - commitStateStart > MIN_COMMIT_PERIOD, "COMMIT_PHASE_NOT_OVER"); otoken = nextOToken; nextOToken = address(0); state = ActionState.Activated; } function _checkOToken(address _nextOToken) private view { require(opynWhitelist.isWhitelistedOtoken(_nextOToken), '!OTOKEN'); _customOTokenCheck(_nextOToken); } /** * cutom otoken check hook to be overriden by each */ function _customOTokenCheck(address _nextOToken) internal view virtual {} } // SPDX-License-Identifier: Apache /* Copyright 2020 Swap Holdings Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.7.2; pragma experimental ABIEncoderV2; /** * @title Types: Library of Swap Protocol Types and Hashes */ library SwapTypes { struct Order { uint256 nonce; // Unique per order and should be sequential uint256 expiry; // Expiry in seconds since 1 January 1970 Party signer; // Party to the trade that sets terms Party sender; // Party to the trade that accepts terms Party affiliate; // Party compensated for facilitating (optional) Signature signature; // Signature of the order } struct Party { bytes4 kind; // Interface ID of the token address wallet; // Wallet address of the party address token; // Contract address of the token uint256 amount; // Amount for ERC-20 or ERC-1155 uint256 id; // ID for ERC-721 or ERC-1155 } struct Signature { address signatory; // Address of the wallet used to sign address validator; // Address of the intended swap contract bytes1 version; // EIP-191 signature version uint8 v; // `v` value of an ECDSA signature bytes32 r; // `r` value of an ECDSA signature bytes32 s; // `s` value of an ECDSA signature } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; pragma experimental ABIEncoderV2; interface IController { enum ActionType { OpenVault, MintShortOption, BurnShortOption, DepositLongOption, WithdrawLongOption, DepositCollateral, WithdrawCollateral, SettleVault, Redeem, Call } struct ActionArgs { ActionType actionType; address owner; address secondAddress; address asset; uint256 vaultId; uint256 amount; uint256 index; bytes data; } struct Vault { address[] shortOtokens; address[] longOtokens; address[] collateralAssets; uint256[] shortAmounts; uint256[] longAmounts; uint256[] collateralAmounts; } function pool() external view returns (address); function getPayout(address _otoken, uint256 _amount) external view returns (uint256); function operate(ActionArgs[] calldata _actions) external; function getAccountVaultCounter(address owner) external view returns (uint256); function oracle() external view returns (address); function getVault(address _owner, uint256 _vaultId) external view returns (Vault memory); function getProceed(address _owner, uint256 _vaultId) external view returns (uint256); function isSettlementAllowed( address otoken ) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; interface IAction { /** * The function used to determin how much asset the current action is controlling. * this will impact the withdraw and deposit amount calculated from the vault. */ function currentValue() external view returns (uint256); /** * The function for the vault to call at the end of each vault's round. * after calling this function, the vault will try to pull assets back from the action and enable withdraw. */ function closePosition() external; /** * The function for the vault to call when the vault is ready to start the next round. * the vault will push assets to action before calling this function, but the amount can change compare to * the last round. So each action should check their asset balance instead of using any cached balance. * * Each action can also add additional checks and revert the `rolloverPosition` call if the action * is not ready to go into the next round. */ function rolloverPosition() external; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.2; interface IOracle { function isDisputePeriodOver(address _asset, uint256 _expiryTimestamp) external view returns (bool); function getExpiryPrice(address _asset, uint256 _expiryTimestamp) external view returns (uint256, bool); function setAssetPricer(address _asset, address _pricer) external; function setExpiryPrice( address _asset, uint256 _expiryTimestamp, uint256 _price ) external; function getPrice(address _asset) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; interface IOToken { function underlyingAsset() external view returns (address); function strikeAsset() external view returns (address); function collateralAsset() external view returns (address); function strikePrice() external view returns (uint256); function expiryTimestamp() external view returns (uint256); function isPut() external view returns (bool); function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with 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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } 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; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; 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 a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // 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); } 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: Apache /* Copyright 2020 Swap Holdings Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.7.2; pragma experimental ABIEncoderV2; import {SwapTypes} from "../libraries/SwapTypes.sol"; interface ISwap { /** * @notice Atomic Token Swap * @param order Types.Order */ function swap(SwapTypes.Order calldata order) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.7.2; interface IWhitelist { function isWhitelistedOtoken(address _otoken) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
* @dev funtion to add some custom logic to check the next otoken is valid to this strategy this hook is triggered while action owner calls "commitNextOption" so accessing otoken will give u the current otoken./ Can override or replace this.
function _customOTokenCheck(address _nextOToken) internal view override { IOToken otokenToCheck = IOToken(_nextOToken); require(_isValidStrike(otokenToCheck.strikePrice()), 'Strike Price Too Low'); require (_isValidExpiry(otokenToCheck.expiryTimestamp()), 'Invalid expiry');
574,382
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 9831, 24252, 358, 527, 2690, 1679, 4058, 358, 866, 326, 1024, 320, 2316, 353, 923, 358, 333, 6252, 333, 3953, 353, 10861, 1323, 1301, 3410, 4097, 315, 7371, 2134, 1895, 6, 1427, 19531, 320, 2316, 903, 8492, 582, 326, 783, 320, 2316, 18, 19, 4480, 3849, 578, 1453, 333, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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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, 225, 445, 389, 3662, 51, 1345, 1564, 12, 2867, 389, 4285, 51, 1345, 13, 2713, 1476, 3849, 288, 203, 377, 1665, 1345, 320, 2316, 18126, 273, 1665, 1345, 24899, 4285, 51, 1345, 1769, 203, 377, 2583, 24899, 26810, 1585, 2547, 12, 352, 969, 18126, 18, 701, 2547, 5147, 1435, 3631, 296, 1585, 2547, 20137, 15869, 23629, 8284, 203, 377, 2583, 261, 67, 26810, 14633, 12, 352, 969, 18126, 18, 22409, 4921, 1435, 3631, 296, 1941, 10839, 8284, 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 ]
./full_match/5/0xe679bd4247C507AA0c1C6411b631BA4f733a50D4/sources/contracts/SmokeStake.sol
daily percentage return
dpr = (apy * magnitude) / 360;
7,069,255
[ 1, 4625, 348, 7953, 560, 30, 225, 18872, 11622, 327, 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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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 ]
[ 1, 3639, 302, 683, 273, 261, 438, 93, 380, 13463, 13, 342, 12360, 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 ]
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /* gOHM SINGLE STAKING OPTION VAULT Mints covered calls while farming yield on single sided gOHM staking farm */ // Libraries import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; import {Clones} from '@openzeppelin/contracts/proxy/Clones.sol'; import {BokkyPooBahsDateTimeLibrary} from '../../external/libraries/BokkyPooBahsDateTimeLibrary.sol'; import {SafeERC20} from '../../external/libraries/SafeERC20.sol'; // Contracts import {ReentrancyGuard} from '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import {ERC20PresetMinterPauserUpgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol'; import {Pausable} from '@openzeppelin/contracts/security/Pausable.sol'; import {ContractWhitelist} from '../../helper/ContractWhitelist.sol'; // Interfaces import {IChainlinkV3Aggregator} from '../../external/interfaces/IChainlinkV3Aggregator.sol'; import {IVolatilityOracle} from '../../interfaces/IVolatilityOracle.sol'; import {IOptionPricing} from '../../interfaces/IOptionPricing.sol'; import {IERC20SSOV} from '../../interfaces/IERC20SSOV.sol'; import {IERC20} from '../../external/interfaces/IERC20.sol'; import {IFeeStrategy} from '../../fees/IFeeStrategy.sol'; interface IPriceOracle { function getPriceInUSD() external view returns (uint256); } contract GohmSSOVV2 is Pausable, ReentrancyGuard, IERC20SSOV, ContractWhitelist { using BokkyPooBahsDateTimeLibrary for uint256; using Strings for uint256; using SafeERC20 for IERC20; /// @dev ERC20PresetMinterPauserUpgradeable implementation address address public immutable erc20Implementation; /// @dev Current epoch for ssov uint256 public override currentEpoch; /// @dev Expire delay tolerance uint256 public expireDelayTolerance = 5 minutes; /// @dev The list of contract addresses the contract uses mapping(bytes32 => address) public addresses; /// @dev epoch => the epoch start time mapping(uint256 => uint256) public epochStartTimes; /// @notice Is epoch expired /// @dev epoch => whether the epoch is expired mapping(uint256 => bool) public isEpochExpired; /// @notice Is vault ready for next epoch /// @dev epoch => whether the vault is ready (boostrapped) mapping(uint256 => bool) public isVaultReady; /// @dev Mapping of strikes for each epoch mapping(uint256 => uint256[]) public override epochStrikes; /// @dev Mapping of (epoch => (strike => tokens)) mapping(uint256 => mapping(uint256 => address)) public override epochStrikeTokens; /// @notice Total epoch deposits for specific strikes /// @dev mapping (epoch => (strike => deposits)) mapping(uint256 => mapping(uint256 => uint256)) public totalEpochStrikeDeposits; /// @notice Total epoch deposits across all strikes /// @dev mapping (epoch => deposits) mapping(uint256 => uint256) public totalEpochDeposits; /// @notice Epoch deposits by user for each strike /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user deposits)) mapping(uint256 => mapping(bytes32 => uint256)) public userEpochDeposits; /// @notice Epoch gOHM balance per strike after accounting for rewards /// @dev mapping (epoch => (strike => balance)) mapping(uint256 => mapping(uint256 => uint256)) public totalEpochStrikeGohmBalance; // Calls purchased for each strike in an epoch /// @dev mapping (epoch => (strike => calls purchased)) mapping(uint256 => mapping(uint256 => uint256)) public totalEpochCallsPurchased; /// @notice Calls purchased by user for each strike /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user calls purchased)) mapping(uint256 => mapping(bytes32 => uint256)) public userEpochCallsPurchased; /// @notice Premium collected per strike for an epoch /// @dev mapping (epoch => (strike => premium)) mapping(uint256 => mapping(uint256 => uint256)) public totalEpochPremium; /// @notice User premium collected per strike for an epoch /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user premium)) mapping(uint256 => mapping(bytes32 => uint256)) public userEpochPremium; /// @dev epoch => settlement price mapping(uint256 => uint256) public settlementPrices; /*==== EVENTS ====*/ event ExpireDelayToleranceUpdate(uint256 expireDelayTolerance); event AddressSet(bytes32 indexed name, address indexed destination); event EmergencyWithdraw(address sender, uint256 gohmWithdrawn); event ExpireEpoch(uint256 epoch, uint256 settlementPrice); event NewStrike(uint256 epoch, uint256 strike); event Bootstrap(uint256 epoch); event NewDeposit( uint256 epoch, uint256 strike, uint256 amount, address user, address sender ); event NewPurchase( uint256 epoch, uint256 strike, uint256 amount, uint256 premium, uint256 fee, address user, address sender ); event NewSettle( uint256 epoch, uint256 strike, address user, uint256 amount, uint256 pnl ); event NewWithdraw( uint256 epoch, uint256 strike, address user, uint256 amount, uint256 gohmAmount ); /*==== CONSTRUCTOR ====*/ constructor( address _gohm, address _optionPricing, address _gohmPriceOracle, address _volatilityOracle, address _feeDistributor, address _feeStrategy ) { require(_gohm != address(0), 'E1'); require(_optionPricing != address(0), 'E1'); require(_gohmPriceOracle != address(0), 'E1'); require(_volatilityOracle != address(0), 'E1'); require(_feeStrategy != address(0), 'E1'); addresses['gOHM'] = _gohm; addresses['OptionPricing'] = _optionPricing; addresses['GohmPriceOracle'] = _gohmPriceOracle; addresses['VolatilityOracle'] = _volatilityOracle; addresses['FeeDistributor'] = _feeDistributor; addresses['FeeStrategy'] = _feeStrategy; addresses['Governance'] = msg.sender; erc20Implementation = address(new ERC20PresetMinterPauserUpgradeable()); } /*==== SETTER METHODS ====*/ /// @notice Pauses the vault for emergency cases /// @dev Can only be called by governance /// @return Whether it was successfully paused function pause() external onlyGovernance returns (bool) { _pause(); _updateFinalEpochBalances(false); return true; } /// @notice Unpauses the vault /// @dev Can only be called by governance /// @return Whether it was successfully unpaused function unpause() external onlyGovernance returns (bool) { _unpause(); return true; } /// @notice Updates the delay tolerance for the expiry epoch function /// @dev Can only be called by governance /// @return Whether it was successfully updated function updateExpireDelayTolerance(uint256 _expireDelayTolerance) external onlyGovernance returns (bool) { expireDelayTolerance = _expireDelayTolerance; emit ExpireDelayToleranceUpdate(_expireDelayTolerance); return true; } /// @notice Sets (adds) a list of addresses to the address list /// @param names Names of the contracts /// @param destinations Addresses of the contract /// @return Whether the addresses were set function setAddresses( bytes32[] calldata names, address[] calldata destinations ) external onlyOwner returns (bool) { require(names.length == destinations.length, 'E2'); for (uint256 i = 0; i < names.length; i++) { bytes32 name = names[i]; address destination = destinations[i]; addresses[name] = destination; emit AddressSet(name, destination); } return true; } /*==== METHODS ====*/ /// @notice Transfers all funds to msg.sender /// @dev Can only be called by governance /// @return Whether emergency withdraw was successful function emergencyWithdraw() external onlyGovernance whenPaused returns (bool) { IERC20 gohm = IERC20(getAddress('gOHM')); uint256 gohmBalance = gohm.balanceOf(address(this)); gohm.safeTransfer(msg.sender, gohmBalance); emit EmergencyWithdraw(msg.sender, gohmBalance); return true; } /// @notice Sets the current epoch as expired. /// @return Whether expire was successful function expireEpoch() external whenNotPaused nonReentrant returns (bool) { require(!isEpochExpired[currentEpoch], 'E3'); (, uint256 epochExpiry) = getEpochTimes(currentEpoch); require((block.timestamp >= epochExpiry), 'E4'); require(block.timestamp <= epochExpiry + expireDelayTolerance, 'E23'); settlementPrices[currentEpoch] = getUsdPrice(); _updateFinalEpochBalances(true); isEpochExpired[currentEpoch] = true; emit ExpireEpoch(currentEpoch, settlementPrices[currentEpoch]); return true; } /// @notice Sets the current epoch as expired. /// @dev Only callable by governace in case the delay tolerance was exceeded /// @param settlementPrice The settlement price /// @return Whether expire was successful function expireEpoch(uint256 settlementPrice) external whenNotPaused nonReentrant onlyGovernance returns (bool) { require(!isEpochExpired[currentEpoch], 'E3'); (, uint256 epochExpiry) = getEpochTimes(currentEpoch); require((block.timestamp > epochExpiry + expireDelayTolerance), 'E4'); settlementPrices[currentEpoch] = settlementPrice; _updateFinalEpochBalances(true); isEpochExpired[currentEpoch] = true; emit ExpireEpoch(currentEpoch, settlementPrices[currentEpoch]); return true; } /// @dev Updates the final epoch gOHM balances per strike of the vault /// @param accountPremiums Should account premiums into calculations function _updateFinalEpochBalances(bool accountPremiums) internal { uint256[] memory strikes = epochStrikes[currentEpoch]; for (uint256 i = 0; i < strikes.length; i++) { uint256 settlement = calculatePnl( settlementPrices[currentEpoch], strikes[i], totalEpochCallsPurchased[currentEpoch][strikes[i]] ); // Update final eth balances for epoch and strike totalEpochStrikeGohmBalance[currentEpoch][strikes[i]] = totalEpochStrikeDeposits[currentEpoch][strikes[i]] - settlement; if (accountPremiums) { totalEpochStrikeGohmBalance[currentEpoch][ strikes[i] ] += totalEpochPremium[currentEpoch][strikes[i]]; } } } /** * @notice Bootstraps a new epoch and mints option tokens equivalent to user deposits for the epoch * @return Whether bootstrap was successful */ function bootstrap() external onlyOwner whenNotPaused returns (bool) { uint256 nextEpoch = currentEpoch + 1; require(!isVaultReady[nextEpoch], 'E5'); require(epochStrikes[nextEpoch].length > 0, 'E6'); if (currentEpoch > 0) { // Previous epoch must be expired require(isEpochExpired[currentEpoch], 'E7'); } for (uint256 i = 0; i < epochStrikes[nextEpoch].length; i++) { uint256 strike = epochStrikes[nextEpoch][i]; string memory name = concatenate('gOHM-CALL', strike.toString()); name = concatenate(name, '-EPOCH-'); name = concatenate(name, (nextEpoch).toString()); // Create doTokens representing calls for selected strike in epoch ERC20PresetMinterPauserUpgradeable _erc20 = ERC20PresetMinterPauserUpgradeable( Clones.clone(erc20Implementation) ); _erc20.initialize(name, name); epochStrikeTokens[nextEpoch][strike] = address(_erc20); // Mint tokens equivalent to deposits for strike in epoch _erc20.mint( address(this), totalEpochStrikeDeposits[nextEpoch][strike] ); } // Mark vault as ready for epoch isVaultReady[nextEpoch] = true; // Increase the current epoch currentEpoch = nextEpoch; emit Bootstrap(nextEpoch); return true; } /** * @notice Sets strikes for next epoch * @param strikes Strikes to set for next epoch * @return Whether strikes were set */ function setStrikes(uint256[] memory strikes) external onlyOwner whenNotPaused returns (bool) { uint256 nextEpoch = currentEpoch + 1; require(totalEpochDeposits[nextEpoch] == 0, 'E8'); if (currentEpoch > 0) { (, uint256 epochExpiry) = getEpochTimes(currentEpoch); require((block.timestamp > epochExpiry), 'E9'); } // Set the next epoch strikes epochStrikes[nextEpoch] = strikes; // Set the next epoch start time epochStartTimes[nextEpoch] = block.timestamp; for (uint256 i = 0; i < strikes.length; i++) emit NewStrike(nextEpoch, strikes[i]); return true; } /** * @notice Deposits gOHM into the ssov to mint options in the next epoch for selected strikes * @param strikeIndex Index of strike * @param user Address of the user to deposit for * @return Whether deposit was successful */ function deposit( uint256 strikeIndex, uint256 amount, address user ) external nonReentrant returns (bool) { _deposit(strikeIndex, amount, user); IERC20(getAddress('gOHM')).safeTransferFrom( msg.sender, address(this), amount ); return true; } /** * @notice Deposit gOHM multiple times into different strike * @param strikeIndices Indices of strikes to deposit into * @param amounts Amount of gOHM to deposit into each strike index * @param user Address of the user to deposit for * @return Whether deposits went through successfully */ function depositMultiple( uint256[] memory strikeIndices, uint256[] memory amounts, address user ) external nonReentrant returns (bool) { require(strikeIndices.length == amounts.length, 'E2'); uint256 totalAmount; for (uint256 i = 0; i < amounts.length; i++) { totalAmount += amounts[i]; } for (uint256 i = 0; i < strikeIndices.length; i++) { _deposit(strikeIndices[i], amounts[i], user); } IERC20(getAddress('gOHM')).safeTransferFrom( msg.sender, address(this), totalAmount ); return true; } /** * @notice Internal function to handle gOHM deposits * @param strikeIndex Index of strike * @param amount Amout of gOHM to deposit */ function _deposit( uint256 strikeIndex, uint256 amount, address user ) internal whenNotPaused isEligibleSender { uint256 nextEpoch = currentEpoch + 1; if (currentEpoch > 0) { require( isEpochExpired[currentEpoch] && !isVaultReady[nextEpoch], 'E19' ); } // Must be a valid strikeIndex require(strikeIndex < epochStrikes[nextEpoch].length, 'E10'); // Must +ve amount require(amount > 0, 'E11'); // Must be a valid strike uint256 strike = epochStrikes[nextEpoch][strikeIndex]; require(strike != 0, 'E12'); bytes32 userStrike = keccak256(abi.encodePacked(user, strike)); // Add to user epoch deposits userEpochDeposits[nextEpoch][userStrike] += amount; // Add to total epoch strike deposits totalEpochStrikeDeposits[nextEpoch][strike] += amount; // Add to total epoch deposits totalEpochDeposits[nextEpoch] += amount; emit NewDeposit(nextEpoch, strike, amount, user, msg.sender); } /** * @notice Purchases calls for the current epoch * @param strikeIndex Strike index for current epoch * @param amount Amount of calls to purchase * @param user User to purchase options for * @return Whether purchase was successful */ function purchase( uint256 strikeIndex, uint256 amount, address user ) external whenNotPaused nonReentrant isEligibleSender returns (uint256, uint256) { (, uint256 epochExpiry) = getEpochTimes(currentEpoch); require((block.timestamp < epochExpiry), 'E24'); require(isVaultReady[currentEpoch], 'E20'); require(strikeIndex < epochStrikes[currentEpoch].length, 'E10'); require(amount > 0, 'E11'); uint256 strike = epochStrikes[currentEpoch][strikeIndex]; require(strike != 0, 'E12'); bytes32 userStrike = keccak256(abi.encodePacked(user, strike)); uint256 currentPrice = getUsdPrice(); // Get total premium for all calls being purchased uint256 premium = calculatePremium(strike, amount); // total fees charged uint256 totalFee = calculatePurchaseFees(currentPrice, strike, amount); uint256 finalTotal = premium + totalFee; // Add to total epoch calls purchased totalEpochCallsPurchased[currentEpoch][strike] += amount; // Add to user epoch calls purchased userEpochCallsPurchased[currentEpoch][userStrike] += amount; // Add to total epoch premium + fees totalEpochPremium[currentEpoch][strike] += premium; // Add to user epoch premium + fees userEpochPremium[currentEpoch][userStrike] += premium; // Transfer premium + fees from user IERC20(getAddress('gOHM')).safeTransferFrom( msg.sender, address(this), finalTotal ); if (totalFee > 0) { // Transfer fee to FeeDistributor IERC20(getAddress('gOHM')).safeTransfer( getAddress('FeeDistributor'), totalFee ); } // Transfer doTokens to user IERC20(epochStrikeTokens[currentEpoch][strike]).safeTransfer( user, amount ); emit NewPurchase( currentEpoch, strike, amount, premium, totalFee, user, msg.sender ); return (premium, totalFee); } /** * @notice Settle calculates the PnL for the user with the settlement price and withdraws the PnL in gOHM to the user. Will also the burn the option tokens from the user. * @param strikeIndex Strike index for current epoch * @param amount Amount of calls to exercise * @return pnl */ function settle( uint256 strikeIndex, uint256 amount, uint256 epoch ) external override whenNotPaused nonReentrant isEligibleSender returns (uint256 pnl) { require(isEpochExpired[epoch], 'E17'); require(strikeIndex < epochStrikes[epoch].length, 'E10'); require(amount > 0, 'E11'); uint256 strike = epochStrikes[epoch][strikeIndex]; require(strike != 0, 'E12'); require( IERC20(epochStrikeTokens[epoch][strike]).balanceOf(msg.sender) >= amount, 'E16' ); // Calculate PnL (in gOHM) pnl = calculatePnl(settlementPrices[epoch], strike, amount); // Total fee charged uint256 totalFee = calculateSettlementFees( settlementPrices[epoch], pnl, amount ); require(pnl > 0, 'E15'); IERC20 gohm = IERC20(getAddress('gOHM')); // Burn user option tokens ERC20PresetMinterPauserUpgradeable(epochStrikeTokens[epoch][strike]) .burnFrom(msg.sender, amount); if (totalFee > 0) { // Transfer fee to FeeDistributor gohm.safeTransfer(getAddress('FeeDistributor'), totalFee); } // Transfer PnL to user gohm.safeTransfer(msg.sender, pnl - totalFee); emit NewSettle(epoch, strike, msg.sender, amount, pnl); } /** * @notice Withdraws balances for a strike in a completed epoch * @param withdrawEpoch Epoch to withdraw from * @param strikeIndex Index of strike * @return gOHM withdrawn */ function withdraw(uint256 withdrawEpoch, uint256 strikeIndex) external whenNotPaused nonReentrant isEligibleSender returns (uint256[1] memory) { require(isEpochExpired[withdrawEpoch], 'E17'); require(strikeIndex < epochStrikes[withdrawEpoch].length, 'E10'); uint256 strike = epochStrikes[withdrawEpoch][strikeIndex]; require(strike != 0, 'E12'); bytes32 userStrike = keccak256(abi.encodePacked(msg.sender, strike)); uint256 userStrikeDeposits = userEpochDeposits[withdrawEpoch][ userStrike ]; require(userStrikeDeposits > 0, 'E18'); // Calculate amount of gOHM to transfer to user uint256 userGohmAmount = (totalEpochStrikeGohmBalance[withdrawEpoch][ strike ] * userStrikeDeposits) / totalEpochStrikeDeposits[withdrawEpoch][strike]; userEpochDeposits[withdrawEpoch][userStrike] = 0; // Transfer gOHM to user IERC20(getAddress('gOHM')).safeTransfer(msg.sender, userGohmAmount); emit NewWithdraw( withdrawEpoch, strike, msg.sender, userStrikeDeposits, userGohmAmount ); return [userGohmAmount]; } /*==== PURE FUNCTIONS ====*/ /// @notice Calculates the monthly expiry from a solidity date /// @param timestamp Timestamp from which the monthly expiry is to be calculated /// @return The monthly expiry function getMonthlyExpiryFromTimestamp(uint256 timestamp) public pure returns (uint256) { uint256 lastDay = BokkyPooBahsDateTimeLibrary.timestampFromDate( timestamp.getYear(), timestamp.getMonth() + 1, 0 ); if (lastDay.getDayOfWeek() < 5) { lastDay = BokkyPooBahsDateTimeLibrary.timestampFromDate( lastDay.getYear(), lastDay.getMonth(), lastDay.getDay() - 7 ); } uint256 lastFridayOfMonth = BokkyPooBahsDateTimeLibrary .timestampFromDateTime( lastDay.getYear(), lastDay.getMonth(), lastDay.getDay() + 5 - lastDay.getDayOfWeek(), 8, 0, 0 ); if (lastFridayOfMonth <= timestamp) { uint256 temp = BokkyPooBahsDateTimeLibrary.timestampFromDate( timestamp.getYear(), timestamp.getMonth() + 2, 0 ); if (temp.getDayOfWeek() < 5) { temp = BokkyPooBahsDateTimeLibrary.timestampFromDate( temp.getYear(), temp.getMonth(), temp.getDay() - 7 ); } lastFridayOfMonth = BokkyPooBahsDateTimeLibrary .timestampFromDateTime( temp.getYear(), temp.getMonth(), temp.getDay() + 5 - temp.getDayOfWeek(), 8, 0, 0 ); } return lastFridayOfMonth; } /** * @notice Returns a concatenated string of a and b * @param a string a * @param b string b */ function concatenate(string memory a, string memory b) internal pure returns (string memory) { return string(abi.encodePacked(a, b)); } /// @notice Calculate Pnl /// @param price price of gOHM /// @param strike strike price of the the gOHM option /// @param amount amount of options function calculatePnl( uint256 price, uint256 strike, uint256 amount ) public pure returns (uint256) { return price > strike ? (((price - strike) * amount) / price) : 0; } /*==== VIEWS ====*/ /// @notice Calculate premium for an option /// @param _strike Strike price of the option /// @param _amount Amount of options function calculatePremium(uint256 _strike, uint256 _amount) public view returns (uint256 premium) { uint256 currentPrice = getUsdPrice(); premium = (IOptionPricing(getAddress('OptionPricing')).getOptionPrice( false, getMonthlyExpiryFromTimestamp(block.timestamp), _strike, currentPrice, IVolatilityOracle(getAddress('VolatilityOracle')).getVolatility() ) * _amount) / currentPrice; } /// @notice Calculate Fees for purchase /// @param price price of DPX /// @param strike strike price of the the DPX option /// @param amount amount of options being bought function calculatePurchaseFees( uint256 price, uint256 strike, uint256 amount ) public view returns (uint256) { return IFeeStrategy(getAddress('FeeStrategy')).calculatePurchaseFees( price, strike, amount ); } /// @notice Calculate Fees for settlement /// @param settlementPrice settlement price of DPX /// @param pnl total pnl /// @param amount amount of options being settled function calculateSettlementFees( uint256 settlementPrice, uint256 pnl, uint256 amount ) public view returns (uint256) { return IFeeStrategy(getAddress('FeeStrategy')).calculateSettlementFees( settlementPrice, pnl, amount ); } /** * @notice Returns start and end times for an epoch * @param epoch Target epoch */ function getEpochTimes(uint256 epoch) public view epochGreaterThanZero(epoch) returns (uint256 start, uint256 end) { return ( epochStartTimes[epoch], getMonthlyExpiryFromTimestamp(epochStartTimes[epoch]) ); } /** * @notice Returns epoch strikes array for an epoch * @param epoch Target epoch */ function getEpochStrikes(uint256 epoch) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { return epochStrikes[epoch]; } /** * Returns epoch strike tokens array for an epoch * @param epoch Target epoch */ function getEpochStrikeTokens(uint256 epoch) external view epochGreaterThanZero(epoch) returns (address[] memory) { uint256 length = epochStrikes[epoch].length; address[] memory _epochStrikeTokens = new address[](length); for (uint256 i = 0; i < length; i++) { _epochStrikeTokens[i] = epochStrikeTokens[epoch][ epochStrikes[epoch][i] ]; } return _epochStrikeTokens; } /** * @notice Returns total epoch strike deposits array for an epoch * @param epoch Target epoch */ function getTotalEpochStrikeDeposits(uint256 epoch) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _totalEpochStrikeDeposits = new uint256[](length); for (uint256 i = 0; i < length; i++) { _totalEpochStrikeDeposits[i] = totalEpochStrikeDeposits[epoch][ epochStrikes[epoch][i] ]; } return _totalEpochStrikeDeposits; } /** * @notice Returns user epoch deposits array for an epoch * @param epoch Target epoch * @param user Address of the user */ function getUserEpochDeposits(uint256 epoch, address user) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _userEpochDeposits = new uint256[](length); for (uint256 i = 0; i < length; i++) { uint256 strike = epochStrikes[epoch][i]; bytes32 userStrike = keccak256(abi.encodePacked(user, strike)); _userEpochDeposits[i] = userEpochDeposits[epoch][userStrike]; } return _userEpochDeposits; } /** * @notice Returns total epoch calls purchased array for an epoch * @param epoch Target epoch */ function getTotalEpochCallsPurchased(uint256 epoch) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _totalEpochCallsPurchased = new uint256[](length); for (uint256 i = 0; i < length; i++) { _totalEpochCallsPurchased[i] = totalEpochCallsPurchased[epoch][ epochStrikes[epoch][i] ]; } return _totalEpochCallsPurchased; } /** * @notice Returns user epoch calls purchased array for an epoch * @param epoch Target epoch * @param user Address of the user */ function getUserEpochCallsPurchased(uint256 epoch, address user) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _userEpochCallsPurchased = new uint256[](length); for (uint256 i = 0; i < length; i++) { uint256 strike = epochStrikes[epoch][i]; bytes32 userStrike = keccak256(abi.encodePacked(user, strike)); _userEpochCallsPurchased[i] = userEpochCallsPurchased[epoch][ userStrike ]; } return _userEpochCallsPurchased; } /** * @notice Returns total epoch premium array for an epoch * @param epoch Target epoch */ function getTotalEpochPremium(uint256 epoch) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _totalEpochPremium = new uint256[](length); for (uint256 i = 0; i < length; i++) { _totalEpochPremium[i] = totalEpochPremium[epoch][ epochStrikes[epoch][i] ]; } return _totalEpochPremium; } /** * @notice Returns user epoch premium array for an epoch * @param epoch Target epoch * @param user Address of the user */ function getUserEpochPremium(uint256 epoch, address user) external view epochGreaterThanZero(epoch) returns (uint256[] memory) { uint256 length = epochStrikes[epoch].length; uint256[] memory _userEpochPremium = new uint256[](length); for (uint256 i = 0; i < length; i++) { uint256 strike = epochStrikes[epoch][i]; bytes32 userStrike = keccak256(abi.encodePacked(user, strike)); _userEpochPremium[i] = userEpochPremium[epoch][userStrike]; } return _userEpochPremium; } /** * @notice Returns gOHM price in USD in 1e8 */ function getUsdPrice() public view returns (uint256 price) { return IPriceOracle(getAddress('GohmPriceOracle')).getPriceInUSD(); } /** * @notice Gets the address of a set contract * @param name Name of the contract * @return The address of the contract */ function getAddress(bytes32 name) public view override returns (address) { return addresses[name]; } /*==== MODIFIERS ====*/ modifier onlyGovernance() { require(msg.sender == getAddress('Governance'), 'E22'); _; } modifier epochGreaterThanZero(uint256 epoch) { require(epoch > 0, 'E13'); _; } } // ERROR MAPPING: // { // "E1": "SSOV: Address cannot be a zero address", // "E2": "SSOV: Input lengths must match", // "E3": "SSOV: Epoch must not be expired", // "E4": "SSOV: Cannot expire epoch before epoch's expiry", // "E5": "SSOV: Already bootstrapped", // "E6": "SSOV: Strikes have not been set for next epoch", // "E7": "SSOV: Previous epoch has not expired", // "E8": "SSOV: Deposit already started", // "E9": "SSOV: Cannot set next strikes before current epoch's expiry", // "E10": "SSOV: Invalid strike index", // "E11": "SSOV: Invalid amount", // "E12": "SSOV: Invalid strike", // "E13": "SSOV: Epoch passed must be greater than 0", // "E14": "SSOV: Option must be in exercise window", // "E15": "SSOV: Cannot exercise with a smaller PnL", // "E16": "SSOV: Option token balance is not enough", // "E17": "SSOV: Epoch must be expired", // "E18": "SSOV: User strike deposit amount must be greater than zero", // "E19": "SSOV: Deposit is only available between epochs", // "E20": "SSOV: Not bootstrapped", // "E21": "SSOV: Can not call function in exercise window", // "E22": "SSOV: Caller is not governance", // "E23": "SSOV: Expire delay tolerance exceeded", // "E24": "SSOV: Cannot purchase past expiry" // }
* @notice Deposits gOHM into the ssov to mint options in the next epoch for selected strikes @param strikeIndex Index of strike @param user Address of the user to deposit for @return Whether deposit was successful/
function deposit( uint256 strikeIndex, uint256 amount, address user ) external nonReentrant returns (bool) { _deposit(strikeIndex, amount, user); IERC20(getAddress('gOHM')).safeTransferFrom( msg.sender, address(this), amount ); return true; }
12,608,489
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 4019, 538, 1282, 314, 51, 44, 49, 1368, 326, 5202, 1527, 358, 312, 474, 702, 316, 326, 1024, 7632, 364, 3170, 609, 25235, 632, 891, 609, 2547, 1016, 3340, 434, 609, 2547, 632, 891, 729, 5267, 434, 326, 729, 358, 443, 1724, 364, 632, 2463, 17403, 443, 1724, 1703, 6873, 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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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 ]
[ 1, 565, 445, 443, 1724, 12, 203, 3639, 2254, 5034, 609, 2547, 1016, 16, 203, 3639, 2254, 5034, 3844, 16, 203, 3639, 1758, 729, 203, 565, 262, 3903, 1661, 426, 8230, 970, 1135, 261, 6430, 13, 288, 203, 3639, 389, 323, 1724, 12, 701, 2547, 1016, 16, 3844, 16, 729, 1769, 203, 203, 3639, 467, 654, 39, 3462, 12, 588, 1887, 2668, 75, 51, 44, 49, 6134, 2934, 4626, 5912, 1265, 12, 203, 5411, 1234, 18, 15330, 16, 203, 5411, 1758, 12, 2211, 3631, 203, 5411, 3844, 203, 3639, 11272, 203, 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.4.19; /** * @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&#39;t hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @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 ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); 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) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender&#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; } } /** * @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 = true; /** * @dev Modifier to make a function callable only when the contract is not paused * or when the owner is invoking the function. */ modifier whenNotPaused() { require(!paused || msg.sender == owner); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract LMDA is PausableToken { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; /** * Constructor initializes the name, symbol, decimals and total * supply of the token. The owner of the contract which is initially * the ICO contract will receive the entire total supply. * */ function LMDA() public { name = "LaMonedaCoin"; symbol = "LMDA"; decimals = 18; totalSupply = 500000000e18; balances[owner] = totalSupply; Transfer(address(this), owner, totalSupply); } } contract ICO is Ownable { using SafeMath for uint256; event AidropInvoked(); event MainSaleActivated(); event TokenPurchased(address recipient, uint256 tokens); event DeadlineExtended(uint256 daysExtended); event DeadlineShortened(uint256 daysShortenedBy); event OffChainPurchaseMade(address recipient, uint256 tokensBought); event TokenPriceChanged(string stage, uint256 newTokenPrice); event ExchangeRateChanged(string stage, uint256 newRate); event BonusChanged(string stage, uint256 newBonus); event TokensWithdrawn(address to, uint256 LMDA); event TokensUnpaused(); event ICOPaused(uint256 timeStamp); event ICOUnpaused(uint256 timeStamp); address public receiverOne; address public receiverTwo; address public receiverThree; address public reserveAddress; address public teamAddress; uint256 public endTime; uint256 public tokenPriceForPreICO; uint256 public rateForPreICO; uint256 public tokenPriceForMainICO; uint256 public rateForMainICO; uint256 public tokenCapForPreICO; uint256 public tokenCapForMainICO; uint256 public bonusForPreICO; uint256 public bonusForMainICO; uint256 public tokensSold; uint256 public timePaused; bool public icoPaused; enum StateOfICO { PRE, MAIN } StateOfICO public stateOfICO; LMDA public lmda; mapping (address => uint256) public investmentOf; /** * Functions with this modifier can only be called when the ICO * is not paused. * */ modifier whenNotPaused { require(!icoPaused); _; } /** * Constructor functions creates a new instance of the LMDA token * and automatically distributes tokens to the reserve and team * addresses. The constructor also initializes all of the state * variables of the ICO contract. * */ function ICO() public { lmda = new LMDA(); receiverOne = 0x43adebFC525FEcf9b2E91a4931E4a003a1F0d959; //Pre ICO receiverTwo = 0xB447292181296B8c7F421F1182be20640dc8Bb05; //Pre ICO receiverThree = 0x3f68b06E7C0E87828647Dbba0b5beAef3822b7Db; //Main ICO reserveAddress = 0x7d05F660124B641b74b146E9aDA60D7D836dcCf5; teamAddress = 0xAD942E5085Af6a7A4C31f17ac687F8d5d7C0225C; lmda.transfer(reserveAddress, 90000000e18); lmda.transfer(teamAddress, 35500000e18); stateOfICO = StateOfICO.PRE; endTime = now.add(21 days); tokenPriceForPreICO = 0.00005 ether; rateForPreICO = 20000; tokenPriceForMainICO = 0.00007 ether; rateForMainICO = 14285; // should be 14,285.7143 tokenCapForPreICO = 144000000e18; tokenCapForMainICO = 374500000e18; bonusForPreICO = 20; bonusForMainICO = 15; tokensSold = 0; icoPaused= false; } /** * This function allows the owner of the contract to airdrop LMDA tokens * to a list of addresses, so long as a list of values is also provided. * * @param _addrs The list of recipient addresses * @param _values The number of tokens each address will receive * */ function airdrop(address[] _addrs, uint256[] _values) public onlyOwner { require(lmda.balanceOf(address(this)) >= getSumOfValues(_values)); require(_addrs.length <= 100 && _addrs.length == _values.length); for(uint i = 0; i < _addrs.length; i++) { lmda.transfer(_addrs[i], _values[i]); } AidropInvoked(); } /** * Function is called internally by the airdrop() function to ensure that * there are enough tokens remaining to execute the airdrop. * * @param _values The list of values representing the tokens to be sent * @return Returns the sum of all the values * */ function getSumOfValues(uint256[] _values) internal pure returns(uint256 sum) { sum = 0; for(uint i = 0; i < _values.length; i++) { sum = sum.add(_values[i]); } } /** * Function allows the owner to activate the main sale. * */ function activateMainSale() public onlyOwner whenNotPaused { require(now >= endTime || tokensSold >= tokenCapForPreICO); stateOfICO = StateOfICO.MAIN; endTime = now.add(49 days); MainSaleActivated(); } /** * Fallback function invokes the buyToknes() method when ETH is recieved * to enable the automatic distribution of tokens to investors. * */ function() public payable { buyTokens(msg.sender); } /** * Allows investors to buy tokens for themselves or others by explicitly * invoking the function using the ABI / JSON Interface of the contract. * * @param _addr The address of the recipient * */ function buyTokens(address _addr) public payable whenNotPaused { require(now <= endTime && _addr != 0x0); require(lmda.balanceOf(address(this)) > 0); if(stateOfICO == StateOfICO.PRE && tokensSold >= tokenCapForPreICO) { revert(); } else if(stateOfICO == StateOfICO.MAIN && tokensSold >= tokenCapForMainICO) { revert(); } uint256 toTransfer = msg.value.mul(getRate().mul(getBonus())).div(100).add(getRate()); lmda.transfer(_addr, toTransfer); tokensSold = tokensSold.add(toTransfer); investmentOf[msg.sender] = investmentOf[msg.sender].add(msg.value); TokenPurchased(_addr, toTransfer); forwardFunds(); } /** * Allows the owner to send tokens to investors who paid with other currencies. * * @param _recipient The address of the receiver * @param _value The total amount of tokens to be sent * */ function processOffChainPurchase(address _recipient, uint256 _value) public onlyOwner { require(lmda.balanceOf(address(this)) >= _value); require(_value > 0 && _recipient != 0x0); lmda.transfer(_recipient, _value); tokensSold = tokensSold.add(_value); OffChainPurchaseMade(_recipient, _value); } /** * Function is called internally by the buyTokens() function in order to send * ETH to owners of the ICO automatically. * */ function forwardFunds() internal { if(stateOfICO == StateOfICO.PRE) { receiverOne.transfer(msg.value.div(2)); receiverTwo.transfer(msg.value.div(2)); } else { receiverThree.transfer(msg.value); } } /** * Allows the owner to extend the deadline of the current ICO phase. * * @param _daysToExtend The number of days to extend the deadline by. * */ function extendDeadline(uint256 _daysToExtend) public onlyOwner { endTime = endTime.add(_daysToExtend.mul(1 days)); DeadlineExtended(_daysToExtend); } /** * Allows the owner to shorten the deadline of the current ICO phase. * * @param _daysToShortenBy The number of days to shorten the deadline by. * */ function shortenDeadline(uint256 _daysToShortenBy) public onlyOwner { if(now.sub(_daysToShortenBy.mul(1 days)) < endTime) { endTime = now; } endTime = endTime.sub(_daysToShortenBy.mul(1 days)); DeadlineShortened(_daysToShortenBy); } /** * Allows the owner to change the token price of the current phase. * This function will automatically calculate the new exchange rate. * * @param _newTokenPrice The new price of the token. * */ function changeTokenPrice(uint256 _newTokenPrice) public onlyOwner { require(_newTokenPrice > 0); if(stateOfICO == StateOfICO.PRE) { if(tokenPriceForPreICO == _newTokenPrice) { revert(); } tokenPriceForPreICO = _newTokenPrice; rateForPreICO = uint256(1e18).div(tokenPriceForPreICO); TokenPriceChanged("Pre ICO", _newTokenPrice); } else { if(tokenPriceForMainICO == _newTokenPrice) { revert(); } tokenPriceForMainICO = _newTokenPrice; rateForMainICO = uint256(1e18).div(tokenPriceForMainICO); TokenPriceChanged("Main ICO", _newTokenPrice); } } /** * Allows the owner to change the exchange rate of the current phase. * This function will automatically calculate the new token price. * * @param _newRate The new exchange rate. * */ function changeRateOfToken(uint256 _newRate) public onlyOwner { require(_newRate > 0); if(stateOfICO == StateOfICO.PRE) { if(rateForPreICO == _newRate) { revert(); } rateForPreICO = _newRate; tokenPriceForPreICO = uint256(1e18).div(rateForPreICO); ExchangeRateChanged("Pre ICO", _newRate); } else { if(rateForMainICO == _newRate) { revert(); } rateForMainICO = _newRate; rateForMainICO = uint256(1e18).div(rateForMainICO); ExchangeRateChanged("Main ICO", _newRate); } } /** * Allows the owner to change the bonus of the current phase. * * @param _newBonus The new bonus percentage. * */ function changeBonus(uint256 _newBonus) public onlyOwner { if(stateOfICO == StateOfICO.PRE) { if(bonusForPreICO == _newBonus) { revert(); } bonusForPreICO = _newBonus; BonusChanged("Pre ICO", _newBonus); } else { if(bonusForMainICO == _newBonus) { revert(); } bonusForMainICO = _newBonus; BonusChanged("Main ICO", _newBonus); } } /** * Allows the owner to withdraw all unsold tokens to his wallet. * */ function withdrawUnsoldTokens() public onlyOwner { TokensWithdrawn(owner, lmda.balanceOf(address(this))); lmda.transfer(owner, lmda.balanceOf(address(this))); } /** * Allows the owner to unpause the LMDA token. * */ function unpauseToken() public onlyOwner { TokensUnpaused(); lmda.unpause(); } /** * Allows the owner to claim back ownership of the LMDA token contract. * */ function transferTokenOwnership() public onlyOwner { lmda.transferOwnership(owner); } /** * Allows the owner to pause the ICO. * */ function pauseICO() public onlyOwner whenNotPaused { require(now < endTime); timePaused = now; icoPaused = true; ICOPaused(now); } /** * Allows the owner to unpause the ICO. * */ function unpauseICO() public onlyOwner { endTime = endTime.add(now.sub(timePaused)); timePaused = 0; ICOUnpaused(now); } /** * @return The total amount of tokens that have been sold. * */ function getTokensSold() public view returns(uint256 _tokensSold) { _tokensSold = tokensSold; } /** * @return The current bonuse percentage. * */ function getBonus() public view returns(uint256 _bonus) { if(stateOfICO == StateOfICO.PRE) { _bonus = bonusForPreICO; } else { _bonus = bonusForMainICO; } } /** * @return The current exchange rate. * */ function getRate() public view returns(uint256 _exchangeRate) { if(stateOfICO == StateOfICO.PRE) { _exchangeRate = rateForPreICO; } else { _exchangeRate = rateForMainICO; } } /** * @return The current token price. * */ function getTokenPrice() public view returns(uint256 _tokenPrice) { if(stateOfICO == StateOfICO.PRE) { _tokenPrice = tokenPriceForPreICO; } else { _tokenPrice = tokenPriceForMainICO; } } }
* Allows the owner to change the bonus of the current phase. @param _newBonus The new bonus percentage. /
function changeBonus(uint256 _newBonus) public onlyOwner { if(stateOfICO == StateOfICO.PRE) { bonusForPreICO = _newBonus; BonusChanged("Pre ICO", _newBonus); bonusForMainICO = _newBonus; BonusChanged("Main ICO", _newBonus); } }
2,407,355
[ 1, 4625, 348, 7953, 560, 30, 380, 25619, 326, 3410, 358, 2549, 326, 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 11890, 5034, 389, 2704, 38, 22889, 13, 1071, 1338, 5541, 288, 203, 3639, 309, 12, 2019, 951, 2871, 51, 422, 3287, 951, 2871, 51, 18, 3670, 13, 288, 203, 5411, 324, 22889, 1290, 1386, 2871, 51, 273, 389, 2704, 38, 22889, 31, 203, 5411, 605, 22889, 5033, 2932, 1386, 467, 3865, 3113, 389, 2704, 38, 22889, 1769, 203, 5411, 324, 22889, 1290, 6376, 2871, 51, 273, 389, 2704, 38, 22889, 31, 203, 5411, 605, 22889, 5033, 2932, 6376, 467, 3865, 3113, 389, 2704, 38, 22889, 1769, 203, 3639, 289, 203, 565, 289, 203, 377, 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 ]
./partial_match/1/0xB0B3F0241336fcF4539ba222E05EACB7c8873873/sources/contracts/erc-721/ArtistCollection.sol
@dev allows the artist (and potentially other 3rd parties) permission to mint on behalf of the artist/* @dev Allows minting via signable mint (an off-chain signature from a `MINTER_ROLE` user is still required)/
function getSignableMinting() public view returns (bool){ return _signableMinting; }
4,370,798
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 5360, 326, 15469, 261, 464, 13935, 1308, 890, 13623, 1087, 606, 13, 4132, 358, 312, 474, 603, 12433, 6186, 434, 326, 15469, 20308, 632, 5206, 25619, 312, 474, 310, 3970, 1573, 429, 312, 474, 261, 304, 3397, 17, 5639, 3372, 628, 279, 1375, 6236, 2560, 67, 16256, 68, 729, 353, 4859, 1931, 13176, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 14167, 429, 49, 474, 310, 1435, 1071, 1476, 1135, 261, 6430, 15329, 203, 3639, 327, 389, 2977, 429, 49, 474, 310, 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 ]
pragma solidity ^0.4.17; /** * @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; } } /** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage role, address addr) internal { role.bearer[addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage role, address addr) internal { role.bearer[addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage role, address addr) view internal { require(has(role, addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage role, address addr) view internal returns (bool) { return role.bearer[addr]; } } /** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * @dev Supports unlimited numbers of roles and addresses. * @dev See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. * It's also recommended that you define constants in the contract, like ROLE_ADMIN below, * to avoid typos. */ contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address addr, string roleName); event RoleRemoved(address addr, string roleName); /** * @dev reverts if addr does not have role * @param addr address * @param roleName the name of the role * // reverts */ function checkRole(address addr, string roleName) view public { roles[roleName].check(addr); } /** * @dev determine if addr has role * @param addr address * @param roleName the name of the role * @return bool */ function hasRole(address addr, string roleName) view public returns (bool) { return roles[roleName].has(addr); } /** * @dev add a role to an address * @param addr address * @param roleName the name of the role */ function addRole(address addr, string roleName) internal { roles[roleName].add(addr); emit RoleAdded(addr, roleName); } /** * @dev remove a role from an address * @param addr address * @param roleName the name of the role */ function removeRole(address addr, string roleName) internal { roles[roleName].remove(addr); emit RoleRemoved(addr, roleName); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param roleName the name of the role * // reverts */ modifier onlyRole(string roleName) { checkRole(msg.sender, roleName); _; } /** * @dev modifier to scope access to a set of roles (uses msg.sender as addr) * @param roleNames the names of the roles to scope access to * // reverts * * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this * see: https://github.com/ethereum/solidity/issues/2467 */ // modifier onlyRoles(string[] roleNames) { // bool hasAnyRole = false; // for (uint8 i = 0; i < roleNames.length; i++) { // if (hasRole(msg.sender, roleNames[i])) { // hasAnyRole = true; // break; // } // } // require(hasAnyRole); // _; // } } /** * @title RBACWithAdmin * @author Matt Condon (@Shrugs) * @dev It's recommended that you define constants in the contract, * @dev like ROLE_ADMIN below, to avoid typos. */ contract RBACWithAdmin is RBAC { /** * A constant role name for indicating admins. */ string public constant ROLE_ADMIN = "admin"; /** * @dev modifier to scope access to admins * // reverts */ modifier onlyAdmin() { checkRole(msg.sender, ROLE_ADMIN); _; } /** * @dev constructor. Sets msg.sender as admin by default */ function RBACWithAdmin() public { addRole(msg.sender, ROLE_ADMIN); } /** * @dev add a role to an address * @param addr address * @param roleName the name of the role */ function adminAddRole(address addr, string roleName) onlyAdmin public { addRole(addr, roleName); } /** * @dev remove a role from an address * @param addr address * @param roleName the name of the role */ function adminRemoveRole(address addr, string roleName) onlyAdmin public { removeRole(addr, roleName); } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Crowdsale * @dev Crowdsale is a base contract for managing a token crowdsale, * allowing investors to purchase tokens with ether. This contract implements * such functionality in its most fundamental form and can be extended to provide additional * functionality and/or custom behavior. * The external interface represents the basic interface for purchasing tokens, and conform * the base architecture for crowdsales. They are *not* intended to be modified / overriden. * The internal interface conforms the extensible and modifiable surface of crowdsales. Override * the methods to add functionality. Consider using 'super' where appropiate to concatenate * behavior. */ contract Crowdsale { using SafeMath for uint256; // The token being sold ERC20 public token; // Address where funds are collected address public wallet; // How many token units a buyer gets per wei uint256 public rate; // Amount of wei raised uint256 public weiRaised; /** * 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); /** * @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 */ function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- /** * @dev fallback function ***DO NOT OVERRIDE*** */ function () external payable { buyTokens(msg.sender); } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } // ----------------------------------------- // Internal interface (extensible) // ----------------------------------------- /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its 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 for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens * @param _weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Override to extend the way in which ether is converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { wallet.transfer(msg.value); } } // NbtToken crowdsale-valuable interface contract NbtToken { uint256 public saleableTokens; uint256 public MAX_SALE_VOLUME; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function moveTokensFromSaleToCirculating(address _to, uint256 _amount) public returns (bool); } /// @title Nbt Token Crowdsale Contract // Main crowdsale contract contract NbtCrowdsale is Crowdsale, Pausable, RBACWithAdmin { /*** EVENTS ***/ event NewStart(uint256 start); event NewDeadline(uint256 deadline); event NewRate(uint256 rate); event NewWallet(address new_address); event Sale(address indexed buyer, uint256 tokens_with_bonuses); /*** CONSTANTS ***/ uint256 public DECIMALS = 8; uint256 public BONUS1 = 100; // % uint256 public BONUS1_LIMIT = 150000000 * 10**DECIMALS; uint256 public BONUS2 = 60; // % uint256 public BONUS2_LIMIT = 250000000 * 10**DECIMALS; uint256 public MIN_TOKENS = 1000 * 10**DECIMALS; NbtToken public token; /*** STORAGE ***/ uint256 public start; uint256 public deadline; bool crowdsaleClosed = false; /*** MODIFIERS ***/ modifier afterDeadline() { if (now > deadline) _; } modifier beforeDeadline() { if (now <= deadline) _; } modifier afterStart() { if (now >= start) _; } modifier beforeStart() { if (now < start) _; } /*** CONSTRUCTOR ***/ /** * @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 * @param _start Start date of the crowdsale * @param _deadline Deadline of the crowdsale */ function NbtCrowdsale(uint256 _rate, address _wallet, NbtToken _token, uint256 _start, uint256 _deadline) Crowdsale(_rate, _wallet, ERC20(_token)) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); require(_start < _deadline); start = _start; deadline = _deadline; rate = _rate; wallet = _wallet; token = _token; } /*** PUBLIC AND EXTERNAL FUNCTIONS ***/ /** * @dev set new start date for crowdsale. * @param _start The new start timestamp */ function setStart(uint256 _start) onlyAdmin whenPaused public returns (bool) { require(_start < deadline); start = _start; emit NewStart(start); return true; } /** * @dev set new start date for crowdsale. * @param _deadline The new deadline timestamp */ function setDeadline(uint256 _deadline) onlyAdmin whenPaused public returns (bool) { require(start < _deadline); deadline = _deadline; emit NewDeadline(_deadline); return true; } /** * @dev set new wallet address * @param _addr The new wallet address */ function setWallet(address _addr) onlyAdmin public returns (bool) { require(_addr != address(0) && _addr != address(this)); wallet = _addr; emit NewWallet(wallet); return true; } /** * @dev set new rate for crowdsale. * @param _rate Number of token units a buyer gets per wei */ function setRate(uint256 _rate) onlyAdmin public returns (bool) { require(_rate > 0); rate = _rate; emit NewRate(rate); return true; } /** * @dev called by the admin to pause, triggers stopped state */ function pause() onlyAdmin whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the admin to unpause, returns to normal state */ function unpause() onlyAdmin whenPaused public { paused = false; emit Unpause(); } function getCurrentBonus() public view returns (uint256) { if (token.MAX_SALE_VOLUME().sub(token.saleableTokens()) < BONUS1_LIMIT) { return BONUS1; } else if (token.MAX_SALE_VOLUME().sub(token.saleableTokens()) < BONUS2_LIMIT) { return BONUS2; } else { return 0; } } function getTokenAmount(uint256 _weiAmount) public view returns (uint256) { return _getTokenAmount(_weiAmount); } /** * Close the crowdsale */ function closeCrowdsale() onlyAdmin afterDeadline public { crowdsaleClosed = true; } /*** INTERNAL FUNCTIONS ***/ /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) whenNotPaused afterStart beforeDeadline internal { require(!crowdsaleClosed); require(_weiAmount >= 1000000000000); require(_getTokenAmount(_weiAmount) <= token.balanceOf(this)); require(_getTokenAmount(_weiAmount) >= MIN_TOKENS); super._preValidatePurchase(_beneficiary, _weiAmount); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.moveTokensFromSaleToCirculating(_beneficiary, _tokenAmount); token.transfer(_beneficiary, _tokenAmount); emit Sale(_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 for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens * @param _weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { // optional override } /** * @dev Override to extend the way in which ether is converted to tokens. * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 _current_bonus = getCurrentBonus(); if (_current_bonus == 0) { return _weiAmount.mul(rate).div(1000000000000); // token amount for 1 szabo } else { return _weiAmount.mul(rate).mul(_current_bonus.add(100)).div(100).div(1000000000000); // token amount for 1 szabo } } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { wallet.transfer(msg.value); } }
* @title RBACWithAdmin @author Matt Condon (@Shrugs) @dev It's recommended that you define constants in the contract, @dev like ROLE_ADMIN below, to avoid typos./
contract RBACWithAdmin is RBAC { string public constant ROLE_ADMIN = "admin"; modifier onlyAdmin() } { checkRole(msg.sender, ROLE_ADMIN); _; } function RBACWithAdmin() public { addRole(msg.sender, ROLE_ADMIN); } function adminAddRole(address addr, string roleName) onlyAdmin public { addRole(addr, roleName); } function adminRemoveRole(address addr, string roleName) onlyAdmin public { removeRole(addr, roleName); } }
1,013,284
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 534, 38, 2226, 1190, 4446, 632, 4161, 490, 4558, 735, 19752, 261, 36, 1555, 8653, 564, 13, 632, 5206, 2597, 1807, 14553, 716, 1846, 4426, 6810, 316, 326, 6835, 16, 632, 5206, 3007, 22005, 67, 15468, 5712, 16, 358, 4543, 3815, 538, 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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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, 16351, 534, 38, 2226, 1190, 4446, 353, 534, 38, 2226, 288, 203, 565, 533, 1071, 5381, 22005, 67, 15468, 273, 315, 3666, 14432, 203, 203, 565, 9606, 1338, 4446, 1435, 203, 97, 203, 565, 288, 203, 3639, 866, 2996, 12, 3576, 18, 15330, 16, 22005, 67, 15468, 1769, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 445, 534, 38, 2226, 1190, 4446, 1435, 203, 565, 1071, 203, 565, 288, 203, 3639, 527, 2996, 12, 3576, 18, 15330, 16, 22005, 67, 15468, 1769, 203, 565, 289, 203, 203, 565, 445, 3981, 986, 2996, 12, 2867, 3091, 16, 533, 19746, 13, 203, 565, 1338, 4446, 203, 565, 1071, 203, 565, 288, 203, 3639, 527, 2996, 12, 4793, 16, 19746, 1769, 203, 565, 289, 203, 203, 565, 445, 3981, 3288, 2996, 12, 2867, 3091, 16, 533, 19746, 13, 203, 565, 1338, 4446, 203, 565, 1071, 203, 565, 288, 203, 3639, 1206, 2996, 12, 4793, 16, 19746, 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 ]
./full_match/1/0xd712A863766dE7e7cA13289A97997E01832A6571/sources/@mimic-fi/v2-smart-vaults-base/contracts/permissions/PermissionsHelpers.sol
* @dev Executes a list of permission changes @param self Permissions manager to be used @param where Address of the contract where the permission change will be executed @param whos List of addresses of the accounts that will be affected @param whats List of function selectors to be affected @param grant Whether the permissions should be granted or revoked/
function execute( PermissionsManager self, IAuthorizer where, address[] memory whos, bytes4[] memory whats, bool grant ) private { PermissionChangeRequest[] memory requests = new PermissionChangeRequest[](1); requests[0].target = where; requests[0].changes = new PermissionChange[](whos.length * whats.length); for (uint256 i = 0; i < whos.length; i++) { for (uint256 j = 0; j < whats.length; j++) { uint256 index = (i * whats.length) + j; requests[0].changes[index] = change(grant, whos[i], whats[j]); } } self.execute(requests); }
2,974,092
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 3889, 993, 279, 666, 434, 4132, 3478, 632, 891, 365, 15684, 3301, 358, 506, 1399, 632, 891, 1625, 5267, 434, 326, 6835, 1625, 326, 4132, 2549, 903, 506, 7120, 632, 891, 600, 538, 987, 434, 6138, 434, 326, 9484, 716, 903, 506, 9844, 632, 891, 600, 2323, 987, 434, 445, 11424, 358, 506, 9844, 632, 891, 7936, 17403, 326, 4371, 1410, 506, 17578, 578, 22919, 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,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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 ]
[ 1, 565, 445, 1836, 12, 203, 3639, 15684, 1318, 365, 16, 203, 3639, 467, 17170, 1625, 16, 203, 3639, 1758, 8526, 3778, 600, 538, 16, 203, 3639, 1731, 24, 8526, 3778, 600, 2323, 16, 203, 3639, 1426, 7936, 203, 565, 262, 3238, 288, 203, 3639, 8509, 3043, 691, 8526, 3778, 3285, 273, 394, 8509, 3043, 691, 8526, 12, 21, 1769, 203, 3639, 3285, 63, 20, 8009, 3299, 273, 1625, 31, 203, 3639, 3285, 63, 20, 8009, 6329, 273, 394, 8509, 3043, 8526, 12, 3350, 538, 18, 2469, 380, 600, 2323, 18, 2469, 1769, 203, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 600, 538, 18, 2469, 31, 277, 27245, 288, 203, 5411, 364, 261, 11890, 5034, 525, 273, 374, 31, 525, 411, 600, 2323, 18, 2469, 31, 525, 27245, 288, 203, 7734, 2254, 5034, 770, 273, 261, 77, 380, 600, 2323, 18, 2469, 13, 397, 525, 31, 203, 7734, 3285, 63, 20, 8009, 6329, 63, 1615, 65, 273, 2549, 12, 16243, 16, 600, 538, 63, 77, 6487, 600, 2323, 63, 78, 19226, 203, 5411, 289, 203, 3639, 289, 203, 203, 3639, 365, 18, 8837, 12, 11420, 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 ]
./full_match/84531/0xBf175FCC7086b4f9bd59d5EAE8eA67b8f940DE0d/sources/@gelatonetwork/relay-context/contracts/GelatoRelayContext.sol
Only use with previous onlyGelatoRelay or `_isGelatoRelay` checks
function _getFeeToken() internal pure returns (address) { return _getFeeTokenRelayContext(); }
11,515,895
[ 1, 4625, 348, 7953, 560, 30, 225, 5098, 999, 598, 2416, 1338, 43, 292, 31093, 27186, 578, 1375, 67, 291, 43, 292, 31093, 27186, 68, 4271, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 588, 14667, 1345, 1435, 2713, 16618, 1135, 261, 2867, 13, 288, 203, 3639, 327, 389, 588, 14667, 1345, 27186, 1042, 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, -100, -100, -100, -100, -100, -100, -100, -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://dank.finance Author: James Seibel https://www.twitter.com/seibelj Whitepaper: https://docs.google.com/document/d/1eHQeZFpix2LqVOGVmXxliiFWEyiGAI8fxI8qTZPCu2I/edit?usp=sharing This code will allow LP Farming with DANK 10x bonus period for the first 7 days (1000 dank per block. deviation from 100 dank per block standard) Farming begins at height: 11,100,000 News will be launched within 24hrs before farming begins. */ pragma solidity ^0.6.12; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev 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); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @title 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"); } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @dev 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; using Address for address; 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 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. 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 returns (uint8) { return _decimals; } /** * @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 _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 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 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 { _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 { } } // DankToken with Governance. contract DankToken is ERC20("DankToken", "DANK"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (DankFarmer). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } } contract DankFarmer is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of DANKs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accDankPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accDankPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. DANKs to distribute per block. uint256 lastRewardBlock; // Last block number that DANKs distribution occurs. uint256 accDankPerShare; // Accumulated DANKs per share, times 1e12. See below. } // The DANK TOKEN! DankToken public dank; // Dev address. address public devaddr; // Block number when bonus DANK period ends. uint256 public bonusEndBlock; // DANK tokens created per block. uint256 public dankPerBlock; // Bonus muliplier for early dank makers. uint256 public constant BONUS_MULTIPLIER = 10; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when DANK mining starts. uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( DankToken _dank, address _devaddr, uint256 _dankPerBlock, uint256 _startBlock, uint256 _bonusEndBlock ) public { dank = _dank; devaddr = _devaddr; dankPerBlock = _dankPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accDankPerShare: 0 })); } // Update the given pool's DANK allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( _to.sub(bonusEndBlock) ); } } // View function to see pending DANKs on frontend. function pendingDank(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accDankPerShare = pool.accDankPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 dankReward = multiplier.mul(dankPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accDankPerShare = accDankPerShare.add(dankReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accDankPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function mint(uint256 amount) public onlyOwner{ dank.mint(devaddr, amount); } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 dankReward = multiplier.mul(dankPerBlock).mul(pool.allocPoint).div(totalAllocPoint); dank.mint(devaddr, dankReward.div(50)); // 2% dank.mint(address(this), dankReward); pool.accDankPerShare = pool.accDankPerShare.add(dankReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to DankFarmer for DANK allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accDankPerShare).div(1e12).sub(user.rewardDebt); safeDankTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accDankPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from DankFarmer. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accDankPerShare).div(1e12).sub(user.rewardDebt); safeDankTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accDankPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe dank transfer function, just in case if rounding error causes pool to not have enough DANKs. function safeDankTransfer(address _to, uint256 _amount) internal { uint256 dankBal = dank.balanceOf(address(this)); if (_amount > dankBal) { dank.transfer(_to, dankBal); } else { dank.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } }
Add a new lp to the pool. Can only be called by the owner. XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accDankPerShare: 0 })); }
13,679,645
[ 1, 4625, 348, 7953, 560, 30, 225, 1436, 279, 394, 12423, 358, 326, 2845, 18, 4480, 1338, 506, 2566, 635, 326, 3410, 18, 11329, 5467, 4269, 527, 326, 1967, 511, 52, 1147, 1898, 2353, 3647, 18, 534, 359, 14727, 903, 506, 15216, 730, 731, 309, 1846, 741, 18, 2, 0, 0, 0, 0, 0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203, 3639, 289, 203, 3639, 2254, 5034, 1142, 17631, 1060, 1768, 273, 1203, 18, 2696, 405, 787, 1768, 692, 1203, 18, 2696, 294, 787, 1768, 31, 203, 3639, 2078, 8763, 2148, 273, 2078, 8763, 2148, 18, 1289, 24899, 9853, 2148, 1769, 203, 3639, 2845, 966, 18, 6206, 12, 2864, 966, 12590, 203, 5411, 12423, 1345, 30, 389, 9953, 1345, 16, 203, 5411, 4767, 2148, 30, 389, 9853, 2148, 16, 203, 5411, 1142, 17631, 1060, 1768, 30, 1142, 17631, 1060, 1768, 16, 203, 5411, 4078, 40, 2304, 2173, 9535, 30, 374, 203, 3639, 289, 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 ]
./full_match/1/0x54d8D8ec5E331D2d266836C4eF814DC8C8dFFD5D/sources/contracts/protocol/libraries/helpers/Errors.sol
'The li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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 ]
[ 1, 225, 533, 1071, 5381, 511, 3513, 67, 9347, 67, 58, 8412, 67, 20339, 67, 15140, 273, 296, 4763, 13506, 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 ]
/** * Description: * Smart contract wallet with 2-step authentication based on OTPs generated by CSPRNG and aggregated by Merkle tree. * */ pragma solidity ^0.5.8; contract WalletHandle { uint8 constant MAX_LEN_OF_PROOF = 20; // delimits the max. height of subtree as well as height difference from the parent tree uint8 constant MIN_HEIGHT_SUBTREE = 1; // Min height of a subtree enum OperationType { TRANSFER, SET_DAILY_LIMIT, SET_LAST_RESORT_ADDRESS, SET_LAST_RESORT_TIMEOUT, DESTRUCT_WALLET, NOP} struct RequestedOperation { address payable addr; // depending on operation type: 1) address of the recepient of funds OR 2) address of the last ressort destination 3) Child root hash uint param; // depending on operation type: 1) amount to send to addr (in Wei), 2) new daily limit, 3) timeout of last resort, 4) depth of cached layer bool pending; // indicates whether operation is still pending or it was already confirmed OperationType operation; // indicates the type of authenticated operation } struct DailyLimits { uint dailyLimit; // in Ether. If it is zero than no daily limit is used. Can be modified only by special init/confirm method. uint dailyAlreadySpent; // in Ether. NOTE: this value can be stale when retrieving from client API (check always relatedDay) uint64 relatedDay; // as days since epoch (== timestamp / 1 days). } struct LastResortInfo { address payable addr; // this address is used for sending all the funds either after specified time of inactivity or depleting all the OTPs uint64 lastActiveDay; // as days since epoch (== timestamp / 1 days). uint64 timeoutDays; // selfdestruct can be called after this time interval, causing send of funds to addr. 0 means disabled last resort functionality. } address public owner; DailyLimits public dailyLimits; // This variable holds information about daily limits and expenses LastResortInfo public lastResort; RequestedOperation[] public pendingOpers; // pendingOpers.length is an increment only "pointer" to the actual leaf of paren MT, which is bounded to an operation with 2FA // MT info could be in a single or two structs, once ABI will be more mature. bytes16[] public MT_child_cachedLayer; bytes16 public MT_child_rootHash; uint8 public MT_child_height; // The height of MT tree (e.g., MT with 8 leaves has height 3) uint8 public MT_child_depthOfCachedLayer; // The depth of 'MT_child_cachedLayer' from the top of MT uint32 public MT_child_numberOfOTPs; // this must not change ever uint16 public MT_hash_chain_len; bytes16 public MT_parent_rootHash; uint8 public MT_parent_height; // this is the whole height including the height of child trees uint32 public MT_parent_numberOfOTPs; // The number of OTPs in the parent MT. It is set in the constructor - once a lifetime of a contract. uint32 public MT_parent_currentChildTreeIdx = 0; // it is increment only uint32 public MT_parent_currentParentTreeIdx = 0; // it is increment only // Overhead for the operation adding a new parent root hash - can be modified only when last OTP of parent tree was reached bytes16[] public NewParentTree_1stStageBuffer; // contains entries in form: h(root_hash || last OTP) bytes16[] public NewParentTree_2ndStageBuffer; // contains root hash entries ///////////// Events for Client //////////////// event InitOperEvent(string message, address addr, uint32 otpID, uint param, OperationType operation); event DailyLimitChangedEvent(string message, uint new_daly_limit); event TransferEvent(string message, address recepient, uint amount); event LastResortAddrEvent(string message, address addr); event LastResortTimeoutEvent(string message, uint64 timeout); event DebugEvent(string message, bytes16 providedCM, bytes16 expectedCM); event DebugEvent2(string message, bytes16 confirmMatWithIndex); event DebugEvent3(string message, bytes32 concatenatedMaterial, bytes16 a, bytes16 b); event DebugEvent4(string message, bytes1 b); event DebugEvent5(string message, bytes16 providedToken, bytes16 expectedToken); event DebugEvent6(string message, bytes32 hashResult); event DebugEvent7(string message, uint32 expetedChIdx, uint32 providedChIdx); event DebugEvent8(string message, uint32 hashChainCnt); event UknownOperationEvent(string message); ///////////// Modifiers (working as macros) //////////////// modifier m_checkOnlyOwner { require(msg.sender == owner, "Only contract owner can call this function."); _; } modifier m_checkMaxMinHeight (uint8 requestedHeightChild) { require(requestedHeightChild <= MAX_LEN_OF_PROOF, "Currently, maximum height of child Merkle Tree is 20."); require(requestedHeightChild >= MIN_HEIGHT_SUBTREE, "Currently, minimum height of a child Merkle Tree is 1."); // log0(strToBytes32("Requirement m_checkMaxMinHeight satisfied...")); _; } modifier m_checkLengthOfCachedLayer (uint8 requestedHeight, uint8 _depthOfLayer, bytes16[] memory providedLayerOfMT){ require(providedLayerOfMT.length <= uint32(2) ** requestedHeight, "The provided cached layer does not fit boundaries of tree." ); require(providedLayerOfMT.length == uint32(2) ** _depthOfLayer, "The length of provided cached layer does not correspond to its provided depth." ); // log2(strToBytes32("Requirement on length of cached layer satisfied..."), bytes32(_depthOfLayer), bytes32(providedLayerOfMT.length)); _; } modifier m_checkEnoughBallance(uint requestedAmount, OperationType operation) { if (OperationType.TRANSFER == operation) { // TODO: involve gas consumption here when settled require(requestedAmount <= address(this).balance, "Requested amount in transfer exceeds the current available balance of the wallet contract." ); } _; } modifier m_checkDailyLimits(uint requestedAmount, OperationType operation) { if (OperationType.TRANSFER == operation && 0 != dailyLimits.dailyLimit) { if (now / 1 days == dailyLimits.relatedDay) { // there are some previous transfers within the current day require(requestedAmount + dailyLimits.dailyAlreadySpent <= dailyLimits.dailyLimit , "Daily limit is exceeded."); } else{ //there are no previous transfers within the current day require(requestedAmount <= dailyLimits.dailyLimit , "Daily limit is exceeded."); } } _; } modifier m_checkLastResortElapsedTime() { if (0 != lastResort.timeoutDays) { require(now / 1 days >= lastResort.lastActiveDay + lastResort.timeoutDays, "Not enought time has elapsed since the last confirmed operation."); _; // Body of function can be run only when timeout != 0 } } modifier m_checkConfirmMaterialLength(bytes16[] memory confirmMaterial) { require(confirmMaterial.length == MT_child_height - MT_child_depthOfCachedLayer + 1, "Confirmation material has wrong length."); _; } modifier m_checkNotLastParentTreeOperation(){ require(pendingOpers.length < MT_parent_numberOfOTPs - 1, // the last OTP is reserved for a new parent root hash "Last parent tree operation can be used only for introducing a new parent tree." ); _; } modifier m_checkLastParentTreeOperation(){ require(pendingOpers.length == MT_parent_numberOfOTPs - 1, "Introducing a new parent root hash can only be done as the last operation." ); _; } modifier m_checkNotDepletedChildTreeOperations(){ require(pendingOpers.length < MT_child_numberOfOTPs * (MT_parent_currentChildTreeIdx + 1) - 1, "Child tree operations are depleted => new child tree needs to be adjusted using the last child tree OTP." ); _; } modifier m_checkDepletedChildTreeOperations() { require(pendingOpers.length == MT_child_numberOfOTPs * (MT_parent_currentChildTreeIdx + 1) - 1, "Child tree operations must be depleted, except the last one, before establishing a new child tree." ); _; } modifier m_checkBoundariesOfChildTree(uint32 otpID){ require(otpID >= MT_parent_currentChildTreeIdx * MT_child_numberOfOTPs && otpID < (MT_parent_currentChildTreeIdx + 1) * MT_child_numberOfOTPs, "Requested OTP ID is out of boundaries for the current child tree." ); _; } ///////////// Transaction-Based Public Methods //////////////// /* Fallback function that receives Ether sent on the contract's address. */ function() external payable { } /** * Stores root hash and cached layer of authenticator's Merkle Tree * PRE validators: height of the tree ; length of cached layer * POST validators: consistency / derivation of the root hash. */ constructor(bytes16 parent_rootHash, uint8 parent_height, uint8 child_heightOfMT, uint8 child_depthOfCachedLayer, bytes16[] memory child_cachedLayerOfMT, bytes16[] memory authPath_childTree, bytes20 sides_childTree, // authPath enables to verify integrity of child root hash (in authPath_childTree[0]) uint16 _hashChainLen, uint _dailyLimit, address payable _lastResortAddr, uint64 _maxInactiveDays) public m_checkMaxMinHeight(child_heightOfMT) m_checkLengthOfCachedLayer(child_heightOfMT, child_depthOfCachedLayer, child_cachedLayerOfMT) { // require(parent_height - child_heightOfMT <= MAX_LEN_OF_PROOF, "Maximum height of parent tree minus height of child tree is exceeded."); owner = tx.origin; // considering this method to be called from contract factory created beforehand (user should check the correct value after deploy) MT_hash_chain_len = _hashChainLen; MT_parent_rootHash = parent_rootHash; MT_parent_height = parent_height; MT_parent_numberOfOTPs = (uint32(2) ** parent_height) * _hashChainLen; MT_child_rootHash = authPath_childTree[0]; MT_child_height = child_heightOfMT; MT_child_numberOfOTPs = (uint32(2) ** child_heightOfMT) * _hashChainLen; MT_child_depthOfCachedLayer = child_depthOfCachedLayer; for (uint32 i = 0; i < child_cachedLayerOfMT.length; i++) { // copy from calldata to storage MT_child_cachedLayer.push(child_cachedLayerOfMT[i]); } lastResort.addr = _lastResortAddr; lastResort.lastActiveDay = uint64(now / 1 days); lastResort.timeoutDays = _maxInactiveDays; dailyLimits.relatedDay = uint64(now / 1 days); dailyLimits.dailyLimit = _dailyLimit; _postCheckChildTreeConsistency(authPath_childTree, sides_childTree, 0); } /** * This is the initialization part of the operation. If the type is TRANSFER, no balance checking is made here, but postponed to the confirmation part. * NOTE: We opted for generalization of operations into two shared steps for all operations (init and confirm), which can save additional storage and * code logic required for coping with race conditions. */ function initNewOper(address payable _addr, uint _param, OperationType _operation) public m_checkOnlyOwner() m_checkNotLastParentTreeOperation() // order of precedence is important (check on child tree depletion must be done afterwards) m_checkNotDepletedChildTreeOperations() { _enqueueNewPendingOperation(_addr, _param, true, _operation); emit InitOperEvent("Operation was initiated.", _addr, uint32(pendingOpers.length - 1), _param, _operation); } /** * This is the confirmation part of the operation. Checking of enough balance and daily limits are made here if the operation is TRANSFER. * The 'confirmMaterials' represnets secret OTP + all hashes of compact proof up to the node in cached layer. * The 'sides' distinguishes whether a particular item in 'confirmMaterials' is the left or right one. * The max size of sides is equal to MAX_LEN_OF_PROOF. */ function confirmOper(bytes16[] memory confirmMaterial, bytes20 sides, uint32 otpID) public // m_checkOnlyOwner() // optional m_checkEnoughBallance(pendingOpers[otpID].param, pendingOpers[otpID].operation) m_checkDailyLimits(pendingOpers[otpID].param, pendingOpers[otpID].operation) // early check to save gas for 2FA verification if daily limits are exceeded { _checkProofOf2FA(otpID, confirmMaterial, sides); // After this point is 2FA successful. _executeOperation(pendingOpers[otpID]); pendingOpers[otpID].pending = false; // set just pending status to save 6K gas in contrast to 'delete pendingOpers[otpID]' } /** * This method introduces a new child tree and can be executed by owner only when child OTPs are depleted. * Although consistency of the new child tree is verified against parent root hash a 2FA would not be needed here, * we use 2FA here to avoid desynchronization of authenticator device. * 2FA is peformed in a single step, which enables in the worst case an attacker to submit inefficient layer of child Merkle tree, * making a cost of follow-up transactions non-optimal. */ function adjustNewChildTree(uint8 newDepthOfCachedLayer, bytes16[] memory newCachedLayerOfMT, bytes16[] memory authPath_childTree, bytes20 sides_childTree, bytes16[] memory confirmMaterial, bytes20 sides ) public m_checkOnlyOwner() // this is optional, but it enables to minimize attack surface of an attacker "deoptimizing a cost of further transactions" m_checkNotLastParentTreeOperation() // order of precedence is important (check on child tree depletion must be done afterwards) m_checkDepletedChildTreeOperations() m_checkLengthOfCachedLayer(MT_child_height, newDepthOfCachedLayer, newCachedLayerOfMT) { _checkProofOf2FA(uint32(pendingOpers.length), confirmMaterial, sides); // after this point is 2FA successful // add nop operation into pendingOperations aray to preserve indices == OTP IDs _enqueueNewPendingOperation(address(0), 0, false, OperationType.NOP); assert(newDepthOfCachedLayer == MT_child_depthOfCachedLayer); // TBD: later remove and resolve reallocation when needed for (uint32 i = 0; i < newCachedLayerOfMT.length; i++) { // store new cached layer MT_child_cachedLayer[i] = newCachedLayerOfMT[i]; } // MT_child_depthOfCachedLayer = newDepthOfCachedLayer; // TBD MT_child_rootHash = authPath_childTree[0]; MT_parent_currentChildTreeIdx++; _postCheckChildTreeConsistency(authPath_childTree, sides_childTree, MT_parent_currentChildTreeIdx); } /** * This appendes h(candidate on a new parent root hash || last OTP) to the 1st stage buffer */ function adjustNewParentTree_stage1(bytes16 hashOfRootAndOTP) public m_checkOnlyOwner() m_checkLastParentTreeOperation() { NewParentTree_1stStageBuffer.push(hashOfRootAndOTP); } /** * This apends candidate on a new parent root hash to the 1st stage buffer */ function adjustNewParentTree_stage2(bytes16 newRootHash) public m_checkOnlyOwner() m_checkLastParentTreeOperation() { NewParentTree_2ndStageBuffer.push(newRootHash); } /** * The method verifies OTP against the first macthing entry in 2nd stage buffer and 1st stage buffer. * If matched, then the current parent root hash is changed to matched entry and other additional data related to child root hash are updated as well. * The number of OTPs (i.e., ~parent height) cannot be changed. */ function adjustNewParentTree_stage3(bytes16[] memory confirmMaterial, bytes20 sides, uint8 child_depthOfCachedLayer, bytes16[] memory child_cachedLayerOfMT, bytes16[] memory authPath_childTree, bytes20 sides_childTree ) public m_checkOnlyOwner() m_checkLastParentTreeOperation() { bytes16 otp = confirmMaterial[0]; _checkProofOf2FA(MT_parent_numberOfOTPs - 1, confirmMaterial, sides); // After this point is 2FA successful. for (uint64 i = 0; i < NewParentTree_2ndStageBuffer.length; i++) { for (uint64 j = 0; j < NewParentTree_1stStageBuffer.length; j++) { // find a candidate on a new root hash submitted by a user if(bytes16(keccak256(abi.encodePacked(NewParentTree_2ndStageBuffer[i], otp))) == NewParentTree_1stStageBuffer[j]){ _resetAllDataRespectingNewParentTree(NewParentTree_2ndStageBuffer[i], child_depthOfCachedLayer, child_cachedLayerOfMT, authPath_childTree, sides_childTree ); NewParentTree_1stStageBuffer.length = 0; NewParentTree_2ndStageBuffer.length = 0; return; } } } } /** * If the condition for elapsed time since the last operation is met, then funds are tranferred to the last resort address. * Anyone can call this method. */ function sendFundsToLastResortAddress() public m_checkLastResortElapsedTime() // nothing happen when last resort timeout is 0 { selfdestruct(lastResort.addr); } function getCurrentOtpID() view public returns (uint32) { return uint32(pendingOpers.length); } function getSizeOfNPT_stage1Buf() view public returns (uint) { return NewParentTree_1stStageBuffer.length; } function getSizeOfNPT_stage2Buf() view public returns (uint) { return NewParentTree_2ndStageBuffer.length; } // function computeNstepsOfHashChain(uint16 N) public { // bytes16 h = 1; // for (uint16 i = 0; i < N; i++) { // h = bytes16(keccak256(h)); // } // emit DebugEvent6("computed hash chain", bytes32(h)); // } // function computeNstepsOfHashChainAndConcat(uint16 N) public { // bytes16 h = 1; // bytes16 toConcat = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // for (uint16 i = 0; i < N; i++) { // h = bytes16(keccak256(abi.encodePacked(h, toConcat))); // } // emit DebugEvent6("computed hash chain", bytes32(h)); // } ///////////// Transaction-Based Private Methods (modifying the state) //////////////// function _postCheckChildTreeConsistency(bytes16[] memory authPath, bytes20 sides, uint32 newChildTreeIdx) private view { // check consistency of cached layer against child root hash require(_isCachedLayerConsistent(), "Cached layer of child Merkle tree is not consistent."); // check consistency of child root hash against parent root hash require(_deriveChildTreeIdx(sides) == newChildTreeIdx, "Provided child tree index does not correspond to the expected one."); assert(authPath[0] == MT_child_rootHash); bytes16 providedAnswer = _reduceAuthPath(authPath, sides); require(providedAnswer == MT_parent_rootHash, "Child root hash is not consistent with the parent root hash."); } function _checkProofOf2FA(uint32 otpID, bytes16[] memory confirmMaterial, bytes20 sides) internal m_checkBoundariesOfChildTree(otpID) m_checkConfirmMaterialLength(confirmMaterial) { uint32 childOTPOffset = (otpID - MT_parent_currentChildTreeIdx * MT_child_numberOfOTPs); // offset in a current subtree uint32 childLeafID = childOTPOffset % (MT_child_numberOfOTPs / MT_hash_chain_len); // ~Beta uint32 expectedIdx =_getExpectedChildIdxAgainstCachedLayer(childLeafID); // emit DebugEvent7("Indices of child:", expectedIdx, _deriveChildIdxAgainstCachedLayer(sides)); require(_deriveChildIdxAgainstCachedLayer(sides) == expectedIdx, "Attempt to confirm by confirmation material with wrong ID."); // check whether cm is authenticated against node in a cache uint32 childHashchainCnt = (childOTPOffset / (MT_child_numberOfOTPs / MT_hash_chain_len)); // ~(P - alpha + 1) emit DebugEvent8("Hash chain count:", childHashchainCnt); _checkNotInvalidatedIterationLayer(childHashchainCnt); bytes16 providedAnswer = _reduceConfirmMaterial(confirmMaterial, sides, childHashchainCnt); uint32 rootIdxInCachedLayer = childLeafID / (uint32(2) ** (MT_child_height - MT_child_depthOfCachedLayer)); // emit DebugEvent5("Comparison of provided OTP and expected", providedAnswer, MT_child_cachedLayer[rootIdxInCachedLayer]); require(providedAnswer == MT_child_cachedLayer[rootIdxInCachedLayer], "OTP-based authentication unsuccessfull."); } function _enqueueNewPendingOperation(address payable addr, uint param, bool isPending, OperationType operation) internal { RequestedOperation memory newOper = RequestedOperation(addr, param, isPending, operation); pendingOpers.push(newOper); } /** * Compare iteration layer of requested OTP with the iteration layer of the top of pending operation list */ function _checkNotInvalidatedIterationLayer(uint32 hashChainCntOTP) internal view { uint32 offsetOfTOPinChildTree = (uint32(pendingOpers.length - 1) - MT_parent_currentChildTreeIdx * MT_child_numberOfOTPs); // offset in a current subtree uint32 hashChainCntTOP = (offsetOfTOPinChildTree / (MT_child_numberOfOTPs / MT_hash_chain_len)); require(hashChainCntTOP == hashChainCntOTP, "Requested OTP ID lays in already invalidated iteration layer of a subtree."); } function _executeOperation(RequestedOperation storage requestedOper) internal { if (OperationType.TRANSFER == requestedOper.operation) { requestedOper.addr.transfer(requestedOper.param); _updateDailyExpenses(requestedOper.param); emit TransferEvent("Transfer confirmed by 2FA.", requestedOper.addr, requestedOper.param); } else if (OperationType.SET_DAILY_LIMIT == requestedOper.operation) { dailyLimits.dailyLimit = requestedOper.param; emit DailyLimitChangedEvent("Daily limit changed.", requestedOper.param); } else if (OperationType.SET_LAST_RESORT_TIMEOUT == requestedOper.operation) { lastResort.timeoutDays = uint64(requestedOper.param); emit LastResortTimeoutEvent("Last resort timeout adjusted.", uint64(requestedOper.param)); } else if (OperationType.SET_LAST_RESORT_ADDRESS == requestedOper.operation) { lastResort.addr = requestedOper.addr; emit LastResortAddrEvent("Last resort address adjusted.", requestedOper.addr); } else if(OperationType.DESTRUCT_WALLET == requestedOper.operation) { selfdestruct(requestedOper.addr); } else { // This should not happen if client works properly. Client should always check operation type and info after the INIT. revert("Unknown type of requested operation."); } // This has to be done after 2FA, as an attacker saboteur may refresh the activity and delay a user in receiveing funds on last resort address. lastResort.lastActiveDay = uint64(now / 1 days); } /** * This method is called when new parent tree is bootstrapped. The number of OTPS cannot be changed, only height of child tree, * including its depth of cached layer. */ function _resetAllDataRespectingNewParentTree(bytes16 newParentRootHash, uint8 child_depthOfCachedLayer, bytes16[] memory child_cachedLayerOfMT, bytes16[] memory authPath_childTree, bytes20 sides_childTree ) internal m_checkLengthOfCachedLayer(MT_child_height, child_depthOfCachedLayer, child_cachedLayerOfMT) { MT_parent_rootHash = newParentRootHash; // update a new parent root hash MT_parent_currentChildTreeIdx = 0; MT_parent_currentParentTreeIdx += 1; MT_child_rootHash = authPath_childTree[0]; MT_child_depthOfCachedLayer = child_depthOfCachedLayer; assert(child_depthOfCachedLayer == MT_child_depthOfCachedLayer); // TBD: later remove and resolve reallocation when needed for (uint32 i = 0; i < child_cachedLayerOfMT.length; i++) { // copy from calldata to storage MT_child_cachedLayer[i] = child_cachedLayerOfMT[i]; } delete pendingOpers; assert(0 == pendingOpers.length); _postCheckChildTreeConsistency(authPath_childTree, sides_childTree, 0); } function _updateDailyExpenses(uint amount) internal { // No checks are made here, as they've been already done in PRE validators. if (0 != dailyLimits.dailyLimit) { if (now / 1 days == dailyLimits.relatedDay) { dailyLimits.dailyAlreadySpent += amount; // there are some previous Opers within the same day } else{ dailyLimits.dailyAlreadySpent = amount; // there are no previous Opers in the current day dailyLimits.relatedDay = uint64(now / 1 days); // update a current day } } } ///////////// Call-Based Private Methods (not modifying the state) //////////////// function _isCachedLayerConsistent() private view returns (bool) { return (_reduceMT(MT_child_cachedLayer, uint32(MT_child_cachedLayer.length)) == MT_child_rootHash) ? true : false; } function _reduceMT(bytes16[] memory layer, uint32 length) private pure returns (bytes16) { if (1 == length) return layer[0]; for (uint32 i = 0; i <= (length / 2) - 1; i++) { layer[i] = bytes16(keccak256(abi.encodePacked(layer[2 * i], layer[2 * i + 1]))); } return _reduceMT(layer, length / 2); } /** * Based on the depth of cached layer, the 'MT_child_depthOfCachedLayer' of most significant bits in childLeadIF are set to zero. * The resulting value has index that addresses position of childLeafID against a corresponding node in the cached layer. * Corresponding node stands for the one on the path from leaf to the child root. */ function _getExpectedChildIdxAgainstCachedLayer(uint32 childLeafID) private view returns (uint32){ uint32 mask = 0xFFFFFFFF; uint32 retId = childLeafID; for (uint8 i = MT_child_height - MT_child_depthOfCachedLayer ; i < MT_child_height ; i++){ uint32 bitToClear = uint32(0x01) << i; retId &= mask ^ bitToClear; } return retId; } /** * Based on the information about left/right sides of items in confirmation material, the function determines the index of the leaf node * that is associated with the passed confirmation material against corresponding node in the cached layer. Corresponding node stands * for the one on the path from the leaf node to the root. */ function _deriveChildIdxAgainstCachedLayer(bytes20 sides) private view returns (uint32) { uint32 derivedIdx = 0; // derive OTPID from bottom to cached layer for(uint8 i = 0 ; i < MT_child_height - MT_child_depthOfCachedLayer ; i++){ if(byte(0x01) == sides[i]){ derivedIdx |= uint32(0x01) << i; } } return derivedIdx; } function _deriveChildTreeIdx(bytes20 sides) private view returns (uint32) { uint32 derivedIdx = 0; // derive child tree Idx from the level of child root to the the parent root for(uint8 i = 0 ; i < MT_parent_height - MT_child_height ; i++){ if(byte(0x01) == sides[i]){ derivedIdx |= uint32(0x01) << i; } } return derivedIdx; } /** * The function first resolve hashchain in order to get leaf node of the child tree and then reduces passed * confirmation material in 'confirmMaterial' and auxiliary information about left/ritgh side of items in it. * The pairs of items in confirmation material are joined by a concatenation. */ function _reduceConfirmMaterial(bytes16[] memory confirmMaterial, bytes20 sides, uint32 hchainCnt) internal view returns (bytes16) { uint32 alpha = MT_hash_chain_len - hchainCnt - 1; for (uint32 i = 0; i < hchainCnt; i++) { confirmMaterial[0] = bytes16(keccak256(abi.encodePacked(alpha + i + 1, confirmMaterial[0]))); // Resolve hash chain to get OTP } // and then compute h(OTP) to get the leaf of the tree confirmMaterial[0] = bytes16(keccak256(abi.encodePacked(confirmMaterial[0]))); return _reduceAuthPath(confirmMaterial, sides); } function _reduceAuthPath(bytes16[] memory authPath, bytes20 sides) internal pure returns (bytes16){ for (uint8 i = 1; i < authPath.length ; i++) { if(byte(0x00) == sides[i - 1]){ authPath[0] = bytes16(keccak256(abi.encodePacked(authPath[0], authPath[i]))); } else{ authPath[0] = bytes16(keccak256(abi.encodePacked(authPath[i], authPath[0]))); } } return authPath[0]; } function _concatB32(bytes16 bytes_a, bytes16 bytes_b) private pure returns (bytes32 bytes_c){ bytes_c = bytes32(bytes_a) | (bytes32(bytes_b) >> (16 * 8)); } }
The height of MT tree (e.g., MT with 8 leaves has height 3)
uint8 public MT_child_height;
12,858,721
[ 1, 4625, 348, 7953, 560, 30, 225, 1021, 2072, 434, 22068, 2151, 261, 73, 18, 75, 12990, 22068, 598, 1725, 15559, 711, 2072, 890, 13, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity =0.6.6; interface IUniSlurmFactory { 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; } library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } interface IUniSlurmRouter01 { 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 IUniSlurmRouter is IUniSlurmRouter01 { 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 IUniSlurmPair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } library UniSlurmLibrary { 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, 'UniSlurmLibrary: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniSlurmLibrary: 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'0be71d18f6482a4de264944fa2ad43dcf3fb43e0977e34be4e85cfb3c8a63b7d' // 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,) = IUniSlurmPair(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, 'UniSlurmLibrary: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniSlurmLibrary: 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, 'UniSlurmLibrary: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniSlurmLibrary: 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, 'UniSlurmLibrary: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniSlurmLibrary: 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, 'UniSlurmLibrary: 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, 'UniSlurmLibrary: 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); } } } 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'); } } 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 UniSlurmRouter is IUniSlurmRouter { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'UniSlurmRouter: 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 (IUniSlurmFactory(factory).getPair(tokenA, tokenB) == address(0)) { IUniSlurmFactory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = UniSlurmLibrary.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniSlurmLibrary.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'UniSlurmRouter: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniSlurmLibrary.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'UniSlurmRouter: 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 = UniSlurmLibrary.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IUniSlurmPair(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 = UniSlurmLibrary.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IUniSlurmPair(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 = UniSlurmLibrary.pairFor(factory, tokenA, tokenB); IUniSlurmPair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniSlurmPair(pair).burn(to); (address token0,) = UniSlurmLibrary.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'UniSlurmRouter: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'UniSlurmRouter: 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 = UniSlurmLibrary.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IUniSlurmPair(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 = UniSlurmLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniSlurmPair(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 = UniSlurmLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniSlurmPair(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,) = UniSlurmLibrary.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 ? UniSlurmLibrary.pairFor(factory, output, path[i + 2]) : _to; IUniSlurmPair(UniSlurmLibrary.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 = UniSlurmLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniSlurmRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniSlurmLibrary.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 = UniSlurmLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniSlurmRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniSlurmLibrary.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, 'UniSlurmRouter: INVALID_PATH'); amounts = UniSlurmLibrary.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniSlurmRouter: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniSlurmLibrary.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, 'UniSlurmRouter: INVALID_PATH'); amounts = UniSlurmLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniSlurmRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniSlurmLibrary.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, 'UniSlurmRouter: INVALID_PATH'); amounts = UniSlurmLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniSlurmRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniSlurmLibrary.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, 'UniSlurmRouter: INVALID_PATH'); amounts = UniSlurmLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'UniSlurmRouter: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniSlurmLibrary.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,) = UniSlurmLibrary.sortTokens(input, output); IUniSlurmPair pair = IUniSlurmPair(UniSlurmLibrary.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 = UniSlurmLibrary.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniSlurmLibrary.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, UniSlurmLibrary.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, 'UniSlurmRouter: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'UniSlurmRouter: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(UniSlurmLibrary.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, 'UniSlurmRouter: 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, 'UniSlurmRouter: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniSlurmLibrary.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'UniSlurmRouter: 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 UniSlurmLibrary.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return UniSlurmLibrary.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return UniSlurmLibrary.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniSlurmLibrary.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniSlurmLibrary.getAmountsIn(factory, amountOut, path); } }
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, 'UniSlurmLibrary: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniSlurmLibrary: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); }
2,199,926
[ 1, 4625, 348, 7953, 560, 30, 225, 864, 392, 876, 3844, 434, 392, 3310, 471, 3082, 400, 264, 3324, 16, 1135, 279, 1931, 810, 3844, 434, 326, 1308, 3310, 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 ]
[ 1, 565, 445, 24418, 382, 12, 11890, 3844, 1182, 16, 2254, 20501, 382, 16, 2254, 20501, 1182, 13, 2713, 16618, 1135, 261, 11890, 3844, 382, 13, 288, 203, 3639, 2583, 12, 8949, 1182, 405, 374, 16, 296, 984, 77, 3738, 27430, 9313, 30, 2120, 6639, 42, 1653, 7266, 2222, 67, 15527, 67, 2192, 51, 5321, 8284, 203, 3639, 2583, 12, 455, 6527, 382, 405, 374, 597, 20501, 1182, 405, 374, 16, 296, 984, 77, 3738, 27430, 9313, 30, 2120, 6639, 42, 1653, 7266, 2222, 67, 2053, 53, 3060, 4107, 8284, 203, 3639, 2254, 16730, 273, 20501, 382, 18, 16411, 12, 8949, 1182, 2934, 16411, 12, 18088, 1769, 203, 3639, 2254, 15030, 273, 20501, 1182, 18, 1717, 12, 8949, 1182, 2934, 16411, 12, 2733, 27, 1769, 203, 3639, 3844, 382, 273, 261, 2107, 7385, 342, 15030, 2934, 1289, 12, 21, 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 ]
// "SPDX-License-Identifier: Apache-2.0" pragma solidity ^0.6.11; import "../../external/BokkyPooBah/BokkyPooBahsDateTimeLibrary.sol"; import "../ACTUSTypes.sol"; /** * @title BusinessDayConventions * @notice Contains conventions of how to handle non-business days when generating schedules of events. * The events schedule time can be shifted or not, if shifted it is possible that it is shifted to the next * or previous valid business days, etc. */ contract BusinessDayConventions { /** * @notice Used in POFs and STFs for DCFs. * No shifting is applied if a Calc/Shift instead of Shift/Calc BDC is provided. */ function shiftCalcTime( uint256 timestamp, BusinessDayConvention convention, Calendar calendar, uint256 maturityDate ) internal pure returns (uint256) { if ( convention == BusinessDayConvention.CSF || convention == BusinessDayConvention.CSMF || convention == BusinessDayConvention.CSP || convention == BusinessDayConvention.CSMP ) { return timestamp; } return shiftEventTime(timestamp, convention, calendar, maturityDate); } /* * @notice Used for generating event schedules (for single events and event cycles schedules). * This convention assumes that when shifting the events schedule time according * to a BDC, the time is shifted first and calculations are performed thereafter. * (Calculations in POFs and STFs are based on the shifted time as well) */ function shiftEventTime( uint256 timestamp, BusinessDayConvention convention, Calendar calendar, uint256 maturityDate ) internal pure returns (uint256) { // do not shift if equal to maturity date if (timestamp == maturityDate) return timestamp; // Shift/Calc Following, Calc/Shift following if (convention == BusinessDayConvention.SCF || convention == BusinessDayConvention.CSF) { return getClosestBusinessDaySameDayOrFollowing(timestamp, calendar); // Shift/Calc Modified Following, Calc/Shift Modified following // Same as unmodified if shifted date is in the same month, if not it returns the previous buiness-day } else if (convention == BusinessDayConvention.SCMF || convention == BusinessDayConvention.CSMF) { uint256 followingOrSameBusinessDay = getClosestBusinessDaySameDayOrFollowing(timestamp, calendar); if (BokkyPooBahsDateTimeLibrary.getMonth(followingOrSameBusinessDay) == BokkyPooBahsDateTimeLibrary.getMonth(timestamp)) { return followingOrSameBusinessDay; } return getClosestBusinessDaySameDayOrPreceeding(timestamp, calendar); // Shift/Calc Preceeding, Calc/Shift Preceeding } else if (convention == BusinessDayConvention.SCP || convention == BusinessDayConvention.CSP) { return getClosestBusinessDaySameDayOrPreceeding(timestamp, calendar); // Shift/Calc Modified Preceeding, Calc/Shift Modified Preceeding // Same as unmodified if shifted date is in the same month, if not it returns the following buiness-day } else if (convention == BusinessDayConvention.SCMP || convention == BusinessDayConvention.CSMP) { uint256 preceedingOrSameBusinessDay = getClosestBusinessDaySameDayOrPreceeding(timestamp, calendar); if (BokkyPooBahsDateTimeLibrary.getMonth(preceedingOrSameBusinessDay) == BokkyPooBahsDateTimeLibrary.getMonth(timestamp)) { return preceedingOrSameBusinessDay; } return getClosestBusinessDaySameDayOrFollowing(timestamp, calendar); } return timestamp; } /** * @notice Returns the following business day if a non-business day is provided. * (Returns the same day if calendar != MondayToFriday) */ function getClosestBusinessDaySameDayOrFollowing(uint256 timestamp, Calendar calendar) internal pure returns (uint256) { if (calendar == Calendar.MF) { if (BokkyPooBahsDateTimeLibrary.getDayOfWeek(timestamp) == 6) { return BokkyPooBahsDateTimeLibrary.addDays(timestamp, 2); } else if (BokkyPooBahsDateTimeLibrary.getDayOfWeek(timestamp) == 7) { return BokkyPooBahsDateTimeLibrary.addDays(timestamp, 1); } } return timestamp; } /** * @notice Returns the previous buiness day if a non-businessday is provided. * (Returns the same day if calendar != MondayToFriday) */ function getClosestBusinessDaySameDayOrPreceeding(uint256 timestamp, Calendar calendar) internal pure returns (uint256) { if (calendar == Calendar.MF) { if (BokkyPooBahsDateTimeLibrary.getDayOfWeek(timestamp) == 6) { return BokkyPooBahsDateTimeLibrary.subDays(timestamp, 1); } else if (BokkyPooBahsDateTimeLibrary.getDayOfWeek(timestamp) == 7) { return BokkyPooBahsDateTimeLibrary.subDays(timestamp, 2); } } return timestamp; } }
Shift/Calc Modified Preceeding, Calc/Shift Modified Preceeding Same as unmodified if shifted date is in the same month, if not it returns the following buiness-day
} else if (convention == BusinessDayConvention.SCMP || convention == BusinessDayConvention.CSMP) {
12,970,376
[ 1, 4625, 348, 7953, 560, 30, 225, 21444, 19, 25779, 21154, 2962, 5288, 310, 16, 29128, 19, 10544, 21154, 2962, 5288, 310, 17795, 487, 30481, 309, 21340, 1509, 353, 316, 326, 1967, 3138, 16, 309, 486, 518, 1135, 326, 3751, 25666, 6336, 17, 2881, 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, 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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 ]
[ 1, 3639, 289, 469, 309, 261, 591, 11111, 422, 21759, 4245, 25947, 18, 2312, 4566, 747, 15797, 422, 21759, 4245, 25947, 18, 4596, 4566, 13, 288, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/11155111/0xAE7B2dd60CAB9fdbb594b6f6E8D15c4eF55e6684/sources/contracts/libraries/FixedPointMulDiv.sol
@dev How many trailing decimals can be represented. @dev Largest power of two divisor of SCALE. @dev SCALE inverted mod 2^256. @notice Multiplies two unsigned 60.18-decimal fixed-point numbers together, returning a new unsigned 60.18-decimal fixed-point number. @dev See the documentation for the "PRBMath.mulDivFixedPoint" function. @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. @param y The multiplier as an unsigned 60.18-decimal fixed-point number. @return result The product as an unsigned 60.18-decimal fixed-point number.
function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = mulDivFixedPoint(x, y); }
3,837,625
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 9017, 4906, 7341, 15105, 848, 506, 10584, 18, 632, 5206, 511, 11475, 7212, 434, 2795, 15013, 434, 25844, 18, 632, 5206, 25844, 18150, 681, 576, 66, 5034, 18, 632, 20392, 5991, 5259, 2795, 9088, 4752, 18, 2643, 17, 12586, 5499, 17, 1153, 5600, 9475, 16, 5785, 279, 394, 9088, 4752, 18, 2643, 17, 12586, 5499, 17, 1153, 1300, 18, 632, 5206, 2164, 326, 7323, 364, 326, 315, 8025, 38, 10477, 18, 16411, 7244, 7505, 2148, 6, 445, 18, 632, 891, 619, 1021, 3309, 1780, 464, 487, 392, 9088, 4752, 18, 2643, 17, 12586, 5499, 17, 1153, 1300, 18, 632, 891, 677, 1021, 15027, 487, 392, 9088, 4752, 18, 2643, 17, 12586, 5499, 17, 1153, 1300, 18, 632, 2463, 563, 1021, 3017, 487, 392, 9088, 4752, 18, 2643, 17, 12586, 5499, 17, 1153, 1300, 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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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 ]
[ 1, 565, 445, 14064, 12, 11890, 5034, 619, 16, 2254, 5034, 677, 13, 2713, 16618, 1135, 261, 11890, 5034, 563, 13, 288, 203, 3639, 563, 273, 14064, 7244, 7505, 2148, 12, 92, 16, 677, 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 ]
./full_match/5/0x0289a6f885dBcF5EC8034efb87d50CB5431749EC/sources/project_/contracts/HuxleyComicsOps.sol
@dev Returns if user already has a token
function isFirstToken() internal view returns (bool) { uint256 balance = huxleyComics.balanceOf(msg.sender); return balance == 0; }
1,872,971
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 2860, 309, 729, 1818, 711, 279, 1147, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 17447, 1345, 1435, 2713, 1476, 1135, 261, 6430, 13, 288, 203, 3639, 2254, 5034, 11013, 273, 366, 2616, 30678, 799, 2102, 18, 12296, 951, 12, 3576, 18, 15330, 1769, 203, 3639, 327, 11013, 422, 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, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/1/0xA4c4808777c16F5A846C92173592272198103DaE/sources/contracts/RockPaperScissors_V8.sol
@dev Add game data to storage
function _addGameData( address _creator, bytes32 _hiddenMove, address _currency, uint256 _amount, address _playerB ) internal returns (uint256) { gameIds ++; uint256 newGameId = gameIds; GameData storage data = gamesData[newGameId]; data.gameId = newGameId; data.currency = _currency; data.gameBalance = _amount; data.playerA = Player({ playerAddress: _creator, move: Moves.None, encrMove: _hiddenMove }); data.stage = Stages.WaitForOpponent; data.active = true; gamesData[newGameId] = data; if (_playerB != address(0)) { data.playerB.playerAddress = _playerB; emit CreatedPrivateGame(newGameId, _creator, _playerB); } emit GameDataAdded(newGameId, _creator); return newGameId; } event CreatedPrivateGame( uint256 indexed id, address indexed playerA, address indexed playerB );
3,130,739
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 1436, 7920, 501, 358, 2502, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 11890, 5034, 13, 288, 203, 3639, 7920, 2673, 965, 31, 203, 3639, 2254, 5034, 394, 12496, 548, 273, 7920, 2673, 31, 203, 203, 3639, 14121, 751, 2502, 501, 273, 28422, 751, 63, 2704, 12496, 548, 15533, 203, 3639, 501, 18, 13957, 548, 273, 394, 12496, 548, 31, 203, 3639, 501, 18, 7095, 273, 389, 7095, 31, 203, 3639, 501, 18, 13957, 13937, 273, 389, 8949, 31, 203, 203, 3639, 501, 18, 14872, 37, 273, 19185, 12590, 203, 5411, 7291, 1887, 30, 389, 20394, 16, 203, 5411, 3635, 30, 490, 10829, 18, 7036, 16, 203, 5411, 2446, 86, 7607, 30, 389, 6345, 7607, 203, 3639, 15549, 203, 203, 3639, 501, 18, 12869, 273, 934, 1023, 18, 29321, 3817, 1029, 31, 203, 3639, 501, 18, 3535, 273, 638, 31, 203, 203, 3639, 28422, 751, 63, 2704, 12496, 548, 65, 273, 501, 31, 203, 203, 3639, 309, 261, 67, 14872, 38, 480, 1758, 12, 20, 3719, 288, 203, 5411, 501, 18, 14872, 38, 18, 14872, 1887, 273, 389, 14872, 38, 31, 203, 203, 5411, 3626, 12953, 6014, 12496, 12, 2704, 12496, 548, 16, 389, 20394, 16, 389, 14872, 38, 1769, 203, 3639, 289, 203, 203, 3639, 3626, 14121, 751, 8602, 12, 2704, 12496, 548, 16, 389, 20394, 1769, 203, 203, 3639, 327, 394, 12496, 548, 31, 203, 565, 289, 203, 203, 565, 871, 12953, 6014, 12496, 12, 203, 3639, 2254, 5034, 8808, 612, 16, 203, 3639, 1758, 8808, 7291, 37, 16, 203, 3639, 1758, 8808, 7291, 38, 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 ]
./full_match/5/0x81c7a9d494c74F113cCa32d174925352bD3875f1/sources/_connext/nxtp-contracts/contracts/core/relayer-fee/libraries/RelayerFeeMessage.sol
before: 1 byte identifier + 20 bytes recipient + 32 bytes length + 32 bytes 1 transfer id = 85 bytes
uint256 private constant MIN_CLAIM_LEN = 85;
1,910,577
[ 1, 4625, 348, 7953, 560, 30, 225, 1865, 30, 404, 1160, 2756, 397, 4200, 1731, 8027, 397, 3847, 1731, 769, 397, 3847, 1731, 404, 7412, 612, 273, 19692, 1731, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3238, 5381, 6989, 67, 15961, 3445, 67, 13017, 273, 19692, 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 ]
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {MerkleProofUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; import {AbstractMerkleDistributer, IERC20Metadata} from "./AbstractMerkleDistributer.sol"; // WARNING: This contract is working-in-progress status. Never use this on production yet. contract VersioningMerkleDistributer is AbstractMerkleDistributer { struct Detail { mapping(address => bool) hasClaimed; bytes32 merkleRoot; } uint256 public currentVersion; // default value is 0 mapping(uint256 => Detail) public versionToDetailMap; function initialize(address initialToken, bytes32 initialMerkleRoot) public initializer { AbstractMerkleDistributer.initialize(); token = IERC20Metadata(initialToken); currentVersion = currentVersion + 1; // Version starts from 1 versionToDetailMap[currentVersion].merkleRoot = initialMerkleRoot; } function setMerkleRoot(bytes32 newMerkleRoot) public onlyAdminOrModeratorRoles { currentVersion = currentVersion + 1; versionToDetailMap[currentVersion].merkleRoot = newMerkleRoot; } function setCurrentVersion(uint256 nextVersion) public onlyAdminOrModeratorRoles { require(nextVersion > 0, "Invalid version info"); currentVersion = nextVersion; } function claim( address recipient, uint256 amount, string memory uniqueKey, bytes32[] calldata proof ) external override nonReentrant { require(msg.sender == recipient, "Cannot claim reward of others."); (bool isClaimable, string memory message) = getIsClaimable( currentVersion, recipient, amount, uniqueKey, proof ); require(isClaimable, message); versionToDetailMap[currentVersion].hasClaimed[recipient] = true; require(token.transfer(recipient, amount), "Transfer failed"); emit Claim(recipient, amount, uniqueKey); } function getIsClaimableOnCurrentVersion( address recipient, uint256 amount, string memory uniqueKey, bytes32[] calldata proof ) public view returns (bool, string memory) { return getIsClaimable(currentVersion, recipient, amount, uniqueKey, proof); } function getIsClaimable( uint256 version, address recipient, uint256 amount, string memory uniqueKey, bytes32[] calldata proof ) public view returns (bool, string memory) { if (versionToDetailMap[version].hasClaimed[recipient]) { return (false, "Recipient already claimed"); } bytes32 leaf = keccak256(abi.encodePacked(recipient, amount, uniqueKey)); bool isValidLeaf = MerkleProofUpgradeable.verify( proof, versionToDetailMap[version].merkleRoot, leaf ); if (!isValidLeaf) { return (false, "Not a valid leaf"); } return (true, "Reward is claimable"); } }
default value is 0
uint256 public currentVersion;
13,063,606
[ 1, 4625, 348, 7953, 560, 30, 225, 805, 460, 353, 374, 203, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ 1, 565, 2254, 5034, 1071, 23344, 31, 225, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
/** *Submitted for verification at Etherscan.io on 2021-07-13 */ /** *Submitted for verification at Etherscan.io on 2020-03-13 */ pragma solidity 0.4.24; // File: contracts/generic/Restricted.sol /* Generic contract to authorise calls to certain functions only from a given address. The address authorised must be a contract (multisig or not, depending on the permission), except for local test deployment works as: 1. contract deployer account deploys contracts 2. constructor grants "PermissionGranter" permission to deployer account 3. deployer account executes initial setup (no multiSig) 4. deployer account grants PermissionGranter permission for the MultiSig contract (e.g. StabilityBoardProxy or PreTokenProxy) 5. deployer account revokes its own PermissionGranter permission */ pragma solidity 0.4.24; contract Restricted { // NB: using bytes32 rather than the string type because it's cheaper gas-wise: mapping (address => mapping (bytes32 => bool)) public permissions; event PermissionGranted(address indexed agent, bytes32 grantedPermission); event PermissionRevoked(address indexed agent, bytes32 revokedPermission); modifier restrict(bytes32 requiredPermission) { require(permissions[msg.sender][requiredPermission], "msg.sender must have permission"); _; } constructor(address permissionGranterContract) public { require(permissionGranterContract != address(0), "permissionGranterContract must be set"); permissions[permissionGranterContract]["PermissionGranter"] = true; emit PermissionGranted(permissionGranterContract, "PermissionGranter"); } function grantPermission(address agent, bytes32 requiredPermission) public { require(permissions[msg.sender]["PermissionGranter"], "msg.sender must have PermissionGranter permission"); permissions[agent][requiredPermission] = true; emit PermissionGranted(agent, requiredPermission); } function grantMultiplePermissions(address agent, bytes32[] requiredPermissions) public { require(permissions[msg.sender]["PermissionGranter"], "msg.sender must have PermissionGranter permission"); uint256 length = requiredPermissions.length; for (uint256 i = 0; i < length; i++) { grantPermission(agent, requiredPermissions[i]); } } function revokePermission(address agent, bytes32 requiredPermission) public { require(permissions[msg.sender]["PermissionGranter"], "msg.sender must have PermissionGranter permission"); permissions[agent][requiredPermission] = false; emit PermissionRevoked(agent, requiredPermission); } function revokeMultiplePermissions(address agent, bytes32[] requiredPermissions) public { uint256 length = requiredPermissions.length; for (uint256 i = 0; i < length; i++) { revokePermission(agent, requiredPermissions[i]); } } } // File: contracts/generic/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error TODO: check against ds-math: https://blog.dapphub.com/ds-math/ TODO: move roundedDiv to a sep lib? (eg. Math.sol) TODO: more unit tests! */ pragma solidity 0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; require(a == 0 || c / a == b, "mul overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "div by 0"); // Solidity automatically throws for div by 0 but require to emit reason uint256 c = a / b; // require(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) { require(b <= a, "sub underflow"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "add overflow"); return c; } // Division, round to nearest integer, round half up function roundedDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "div by 0"); // Solidity automatically throws for div by 0 but require to emit reason uint256 halfB = (b % 2 == 0) ? (b / 2) : (b / 2 + 1); return (a % b >= halfB) ? (a / b + 1) : (a / b); } // Division, always rounds up function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "div by 0"); // Solidity automatically throws for div by 0 but require to emit reason return (a % b != 0) ? (a / b + 1) : (a / b); } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? b : a; } } // File: contracts/interfaces/TransferFeeInterface.sol /* * transfer fee calculation interface * */ pragma solidity 0.4.24; interface TransferFeeInterface { function calculateTransferFee(address from, address to, uint amount) external view returns (uint256 fee); } // File: contracts/interfaces/ERC20Interface.sol /* * ERC20 interface * see https://github.com/ethereum/EIPs/issues/20 */ pragma solidity 0.4.24; interface ERC20Interface { event Approval(address indexed _owner, address indexed _spender, uint _value); event Transfer(address indexed from, address indexed to, uint amount); function transfer(address to, uint value) external returns (bool); // solhint-disable-line no-simple-event-func-name function transferFrom(address from, address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function balanceOf(address who) external view returns (uint); function allowance(address _owner, address _spender) external view returns (uint remaining); } // File: contracts/interfaces/TokenReceiver.sol /* * receiver contract interface * see https://github.com/ethereum/EIPs/issues/677 */ pragma solidity 0.4.24; interface TokenReceiver { function transferNotification(address from, uint256 amount, uint data) external; } // File: contracts/interfaces/AugmintTokenInterface.sol /* Augmint Token interface (abstract contract) TODO: overload transfer() & transferFrom() instead of transferWithNarrative() & transferFromWithNarrative() when this fix available in web3& truffle also uses that web3: https://github.com/ethereum/web3.js/pull/1185 TODO: shall we use bytes for narrative? */ pragma solidity 0.4.24; contract AugmintTokenInterface is Restricted, ERC20Interface { using SafeMath for uint256; string public name; string public symbol; bytes32 public peggedSymbol; uint8 public decimals; uint public totalSupply; mapping(address => uint256) public balances; // Balances for each account mapping(address => mapping (address => uint256)) public allowed; // allowances added with approve() TransferFeeInterface public feeAccount; mapping(bytes32 => bool) public delegatedTxHashesUsed; // record txHashes used by delegatedTransfer event TransferFeesChanged(uint transferFeePt, uint transferFeeMin, uint transferFeeMax); event Transfer(address indexed from, address indexed to, uint amount); event AugmintTransfer(address indexed from, address indexed to, uint amount, string narrative, uint fee); event TokenIssued(uint amount); event TokenBurned(uint amount); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function transfer(address to, uint value) external returns (bool); // solhint-disable-line no-simple-event-func-name function transferFrom(address from, address to, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool); function delegatedTransfer(address from, address to, uint amount, string narrative, uint maxExecutorFeeInToken, /* client provided max fee for executing the tx */ bytes32 nonce, /* random nonce generated by client */ /* ^^^^ end of signed data ^^^^ */ bytes signature, uint requestedExecutorFeeInToken /* the executor can decide to request lower fee */ ) external; function delegatedTransferAndNotify(address from, TokenReceiver target, uint amount, uint data, uint maxExecutorFeeInToken, /* client provided max fee for executing the tx */ bytes32 nonce, /* random nonce generated by client */ /* ^^^^ end of signed data ^^^^ */ bytes signature, uint requestedExecutorFeeInToken /* the executor can decide to request lower fee */ ) external; function increaseApproval(address spender, uint addedValue) external; function decreaseApproval(address spender, uint subtractedValue) external; function issueTo(address to, uint amount) external; // restrict it to "MonetarySupervisor" in impl.; function burn(uint amount) external; function transferAndNotify(TokenReceiver target, uint amount, uint data) external; function transferWithNarrative(address to, uint256 amount, string narrative) external; function transferFromWithNarrative(address from, address to, uint256 amount, string narrative) external; function setName(string _name) external; function setSymbol(string _symbol) external; function allowance(address owner, address spender) external view returns (uint256 remaining); function balanceOf(address who) external view returns (uint); } // File: contracts/generic/ECRecovery.sol /** * @title Eliptic curve signature operations * * @dev Based on https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ECRecovery.sol * * TODO Remove this library once solidity supports passing a signature to ecrecover. * See https://github.com/ethereum/solidity/issues/864 * */ library ECRecovery { /** * @dev Recover signer address from a message by using their signature * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param sig bytes signature, the signature is generated using web3.eth.sign() */ function recover(bytes32 hash, bytes sig) internal pure returns (address) { bytes32 r; bytes32 s; uint8 v; // Check the signature length if (sig.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solium-disable-next-line security/no-inline-assembly assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions if (v < 27) { v += 27; } // If the version is correct return the signer address if (v != 27 && v != 28) { return (address(0)); } else { // solium-disable-next-line arg-overflow return ecrecover(hash, v, r, s); } } /** * toEthSignedMessageHash * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * @dev and hash the result */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } // File: contracts/generic/AugmintToken.sol /* Generic Augmint Token implementation (ERC20 token) This contract manages: * Balances of Augmint holders and transactions between them * Issues/burns tokens TODO: - reconsider delegatedTransfer and how to structure it - shall we allow change of txDelegator? - consider generic bytes arg instead of uint for transferAndNotify - consider separate transfer fee params and calculation to separate contract (to feeAccount?) */ pragma solidity 0.4.24; contract AugmintToken is AugmintTokenInterface { event FeeAccountChanged(TransferFeeInterface newFeeAccount); constructor(address permissionGranterContract, string _name, string _symbol, bytes32 _peggedSymbol, uint8 _decimals, TransferFeeInterface _feeAccount) public Restricted(permissionGranterContract) { require(_feeAccount != address(0), "feeAccount must be set"); require(bytes(_name).length > 0, "name must be set"); require(bytes(_symbol).length > 0, "symbol must be set"); name = _name; symbol = _symbol; peggedSymbol = _peggedSymbol; decimals = _decimals; feeAccount = _feeAccount; } function transfer(address to, uint256 amount) external returns (bool) { _transfer(msg.sender, to, amount, ""); return true; } /* Transfers based on an offline signed transfer instruction. */ function delegatedTransfer(address from, address to, uint amount, string narrative, uint maxExecutorFeeInToken, /* client provided max fee for executing the tx */ bytes32 nonce, /* random nonce generated by client */ /* ^^^^ end of signed data ^^^^ */ bytes signature, uint requestedExecutorFeeInToken /* the executor can decide to request lower fee */ ) external { bytes32 txHash = keccak256(abi.encodePacked(this, from, to, amount, narrative, maxExecutorFeeInToken, nonce)); _checkHashAndTransferExecutorFee(txHash, signature, from, maxExecutorFeeInToken, requestedExecutorFeeInToken); _transfer(from, to, amount, narrative); } function approve(address _spender, uint256 amount) external returns (bool) { require(_spender != 0x0, "spender must be set"); allowed[msg.sender][_spender] = amount; emit Approval(msg.sender, _spender, amount); return true; } /** ERC20 transferFrom attack protection: https://github.com/DecentLabs/dcm-poc/issues/57 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) Based on MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) external { require(_spender != 0x0, "spender must be set"); mapping (address => uint256) allowances = allowed[msg.sender]; uint newValue = allowances[_spender].add(_addedValue); allowances[_spender] = newValue; emit Approval(msg.sender, _spender, newValue); } function decreaseApproval(address _spender, uint _subtractedValue) external { require(_spender != 0x0, "spender must be set"); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); } function transferFrom(address from, address to, uint256 amount) external returns (bool) { _transferFrom(from, to, amount, ""); return true; } // Issue tokens. See MonetarySupervisor but as a rule of thumb issueTo is only allowed: // - on new loan (by trusted Lender contracts) // - when converting old tokens using MonetarySupervisor // - strictly to reserve by Stability Board (via MonetarySupervisor) function issueTo(address to, uint amount) external restrict("MonetarySupervisor") { balances[to] = balances[to].add(amount); totalSupply = totalSupply.add(amount); emit Transfer(0x0, to, amount); emit AugmintTransfer(0x0, to, amount, "", 0); } // Burn tokens. Anyone can burn from its own account. YOLO. // Used by to burn from Augmint reserve or by Lender contract after loan repayment function burn(uint amount) external { require(balances[msg.sender] >= amount, "balance must be >= amount"); balances[msg.sender] = balances[msg.sender].sub(amount); totalSupply = totalSupply.sub(amount); emit Transfer(msg.sender, 0x0, amount); emit AugmintTransfer(msg.sender, 0x0, amount, "", 0); } /* to upgrade feeAccount (eg. for fee calculation changes) */ function setFeeAccount(TransferFeeInterface newFeeAccount) external restrict("StabilityBoard") { feeAccount = newFeeAccount; emit FeeAccountChanged(newFeeAccount); } /* transferAndNotify can be used by contracts which require tokens to have only 1 tx (instead of approve + call) Eg. repay loan, lock funds, token sell order on exchange Reverts on failue: - transfer fails - if transferNotification fails (callee must revert on failure) - if targetContract is an account or targetContract doesn't have neither transferNotification or fallback fx TODO: make data param generic bytes (see receiver code attempt in Locker.transferNotification) */ function transferAndNotify(TokenReceiver target, uint amount, uint data) external { _transfer(msg.sender, target, amount, ""); target.transferNotification(msg.sender, amount, data); } /* transferAndNotify based on an instruction signed offline */ function delegatedTransferAndNotify(address from, TokenReceiver target, uint amount, uint data, uint maxExecutorFeeInToken, /* client provided max fee for executing the tx */ bytes32 nonce, /* random nonce generated by client */ /* ^^^^ end of signed data ^^^^ */ bytes signature, uint requestedExecutorFeeInToken /* the executor can decide to request lower fee */ ) external { bytes32 txHash = keccak256(abi.encodePacked(this, from, target, amount, data, maxExecutorFeeInToken, nonce)); _checkHashAndTransferExecutorFee(txHash, signature, from, maxExecutorFeeInToken, requestedExecutorFeeInToken); _transfer(from, target, amount, ""); target.transferNotification(from, amount, data); } function transferWithNarrative(address to, uint256 amount, string narrative) external { _transfer(msg.sender, to, amount, narrative); } function transferFromWithNarrative(address from, address to, uint256 amount, string narrative) external { _transferFrom(from, to, amount, narrative); } /* Allow Stability Board to change the name when a new token contract version is deployed and ready for production use. So that older token contracts are identifiable in 3rd party apps. */ function setName(string _name) external restrict("StabilityBoard") { name = _name; } /* Allow Stability Board to change the symbol when a new token contract version is deployed and ready for production use. So that older token contracts are identifiable in 3rd party apps. */ function setSymbol(string _symbol) external restrict("StabilityBoard") { symbol = _symbol; } function balanceOf(address _owner) external view returns (uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) external view returns (uint256 remaining) { return allowed[_owner][_spender]; } function _checkHashAndTransferExecutorFee(bytes32 txHash, bytes signature, address signer, uint maxExecutorFeeInToken, uint requestedExecutorFeeInToken) private { require(requestedExecutorFeeInToken <= maxExecutorFeeInToken, "requestedExecutorFee must be <= maxExecutorFee"); require(!delegatedTxHashesUsed[txHash], "txHash already used"); delegatedTxHashesUsed[txHash] = true; address recovered = ECRecovery.recover(ECRecovery.toEthSignedMessageHash(txHash), signature); require(recovered == signer, "invalid signature"); _transfer(signer, msg.sender, requestedExecutorFeeInToken, "Delegated transfer fee", 0); } function _transferFrom(address from, address to, uint256 amount, string narrative) private { uint fee = feeAccount.calculateTransferFee(from, to, amount); uint amountWithFee = amount.add(fee); /* NB: fee is deducted from owner, so transferFrom could fail if amount + fee is not available on owner balance, or allowance */ require(balances[from] >= amountWithFee, "balance must be >= amount + fee"); require(allowed[from][msg.sender] >= amountWithFee, "allowance must be >= amount + fee"); _transfer(from, to, amount, narrative, fee); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amountWithFee); } function _transfer(address from, address to, uint transferAmount, string narrative) private { uint fee = feeAccount.calculateTransferFee(from, to, transferAmount); _transfer(from, to, transferAmount, narrative, fee); } function _transfer(address from, address to, uint transferAmount, string narrative, uint fee) private { require(to != 0x0, "to must be set"); uint amountWithFee = transferAmount.add(fee); // to emit proper reason instead of failing on from.sub() require(balances[from] >= amountWithFee, "balance must be >= amount + transfer fee"); balances[from] = balances[from].sub(amountWithFee); balances[to] = balances[to].add(transferAmount); emit Transfer(from, to, transferAmount); if (fee > 0) { balances[feeAccount] = balances[feeAccount].add(fee); emit Transfer(from, feeAccount, fee); } emit AugmintTransfer(from, to, transferAmount, narrative, fee); } } // File: contracts/generic/SystemAccount.sol /* Contract to collect fees from system */ pragma solidity 0.4.24; contract SystemAccount is Restricted { event WithdrawFromSystemAccount(address tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative); constructor(address permissionGranterContract) public Restricted(permissionGranterContract) {} // solhint-disable-line no-empty-blocks function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative) external restrict("StabilityBoard") { tokenAddress.transferWithNarrative(to, tokenAmount, narrative); if (weiAmount > 0) { to.transfer(weiAmount); } emit WithdrawFromSystemAccount(tokenAddress, to, tokenAmount, weiAmount, narrative); } } // File: contracts/AugmintReserves.sol /* Contract to hold Augmint reserves (ETH & Token) - ETH as regular ETH balance of the contract - ERC20 token reserve (stored as regular Token balance under the contract address) NB: reserves are held under the contract address, therefore any transaction on the reserve is limited to the tx-s defined here (i.e. transfer is not allowed even by the contract owner or StabilityBoard or MonetarySupervisor) */ pragma solidity 0.4.24; contract AugmintReserves is Restricted { event ReserveMigration(address to, uint weiAmount); constructor(address permissionGranterContract) public Restricted(permissionGranterContract) {} // solhint-disable-line no-empty-blocks function () external payable { // solhint-disable-line no-empty-blocks // to accept ETH sent into reserve (from defaulted loan's collateral ) } function burn(AugmintTokenInterface augmintToken, uint amount) external restrict("MonetarySupervisor") { augmintToken.burn(amount); } function migrate(address to, uint weiAmount) external restrict("StabilityBoard") { if (weiAmount > 0) { to.transfer(weiAmount); } emit ReserveMigration(to, weiAmount); } } // File: contracts/generic/MultiSig.sol /* Abstract multisig contract to allow multi approval execution of atomic contracts scripts e.g. migrations or settings. * Script added by signing a script address by a signer (NEW state) * Script goes to ALLOWED state once a quorom of signers sign it (quorom fx is defined in each derived contracts) * Script can be signed even in APPROVED state * APPROVED scripts can be executed only once. - if script succeeds then state set to DONE - If script runs out of gas or reverts then script state set to FAILEd and not allowed to run again (To avoid leaving "behind" scripts which fail in a given state but eventually execute in the future) * Scripts can be cancelled by an other multisig script approved and calling cancelScript() * Adding/removing signers is only via multisig approved scripts using addSigners / removeSigners fxs */ pragma solidity 0.4.24; contract MultiSig { using SafeMath for uint256; mapping(address => bool) public isSigner; address[] public allSigners; // all signers, even the disabled ones // NB: it can contain duplicates when a signer is added, removed then readded again // the purpose of this array is to being able to iterate on signers in isSigner uint public activeSignersCount; enum ScriptState {New, Approved, Done, Cancelled, Failed} struct Script { ScriptState state; uint signCount; mapping(address => bool) signedBy; address[] allSigners; } mapping(address => Script) public scripts; address[] public scriptAddresses; event SignerAdded(address signer); event SignerRemoved(address signer); event ScriptSigned(address scriptAddress, address signer); event ScriptApproved(address scriptAddress); event ScriptCancelled(address scriptAddress); event ScriptExecuted(address scriptAddress, bool result); constructor() public { // deployer address is the first signer. Deployer can configure new contracts by itself being the only "signer" // The first script which sets the new contracts live should add signers and revoke deployer's signature right isSigner[msg.sender] = true; allSigners.push(msg.sender); activeSignersCount = 1; emit SignerAdded(msg.sender); } function sign(address scriptAddress) public { require(isSigner[msg.sender], "sender must be signer"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved || script.state == ScriptState.New, "script state must be New or Approved"); require(!script.signedBy[msg.sender], "script must not be signed by signer yet"); if (script.allSigners.length == 0) { // first sign of a new script scriptAddresses.push(scriptAddress); } script.allSigners.push(msg.sender); script.signedBy[msg.sender] = true; script.signCount = script.signCount.add(1); emit ScriptSigned(scriptAddress, msg.sender); if (checkQuorum(script.signCount)) { script.state = ScriptState.Approved; emit ScriptApproved(scriptAddress); } } function execute(address scriptAddress) public returns (bool result) { // only allow execute to signers to avoid someone set an approved script failed by calling it with low gaslimit require(isSigner[msg.sender], "sender must be signer"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved, "script state must be Approved"); result = _execute(scriptAddress); } /* Function to test scripts without signatures - always reverts. It's even possible to test scripts without deployment if script deployed and dry run on a ganache */ function dryExecute(address scriptAddress) public { bool result = _execute(scriptAddress); if(!result) { // if delegatecall failed then revert with the revert returndata // solium-disable-next-line security/no-inline-assembly assembly { let ptr := mload(0x40) // starts from the "free memory pointer" returndatacopy(ptr, 0, returndatasize) // retreive delegatecall revert reason message revert(ptr, returndatasize) // revert with the reason message from delegeatecall } } revert("dryExecute success"); } function cancelScript(address scriptAddress) public { require(msg.sender == address(this), "only callable via MultiSig"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved || script.state == ScriptState.New, "script state must be New or Approved"); script.state = ScriptState.Cancelled; emit ScriptCancelled(scriptAddress); } /* requires quorum so it's callable only via a script executed by this contract */ function addSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i = 0; i < signers.length; i++) { if (!isSigner[signers[i]]) { require(signers[i] != address(0), "new signer must not be 0x0"); activeSignersCount++; allSigners.push(signers[i]); isSigner[signers[i]] = true; emit SignerAdded(signers[i]); } } } /* requires quorum so it's callable only via a script executed by this contract */ function removeSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i = 0; i < signers.length; i++) { if (isSigner[signers[i]]) { require(activeSignersCount > 1, "must not remove last signer"); activeSignersCount--; isSigner[signers[i]] = false; emit SignerRemoved(signers[i]); } } } /* implement it in derived contract */ function checkQuorum(uint signersCount) internal view returns(bool isQuorum); function getAllSignersCount() external view returns (uint allSignersCount) { return allSigners.length; } // UI helper fx - Returns signers from offset as [signer id (index in allSigners), address as uint, isActive 0 or 1] function getSigners(uint offset, uint16 chunkSize) external view returns(uint[3][]) { uint limit = SafeMath.min(offset.add(chunkSize), allSigners.length); uint[3][] memory response = new uint[3][](limit.sub(offset)); for (uint i = offset; i < limit; i++) { address signerAddress = allSigners[i]; response[i - offset] = [i, uint(signerAddress), isSigner[signerAddress] ? 1 : 0]; } return response; } function getScriptsCount() external view returns (uint scriptsCount) { return scriptAddresses.length; } // UI helper fx - Returns scripts from offset as // [scriptId (index in scriptAddresses[]), address as uint, state, signCount] function getScripts(uint offset, uint16 chunkSize) external view returns(uint[4][]) { uint limit = SafeMath.min(offset.add(chunkSize), scriptAddresses.length); uint[4][] memory response = new uint[4][](limit.sub(offset)); for (uint i = offset; i < limit; i++) { address scriptAddress = scriptAddresses[i]; response[i - offset] = [i, uint(scriptAddress), uint(scripts[scriptAddress].state), scripts[scriptAddress].signCount]; } return response; } function _execute(address scriptAddress) private returns (bool result) { Script storage script = scripts[scriptAddress]; // passing scriptAddress to allow called script access its own public fx-s if needed if (scriptAddress.delegatecall.gas(gasleft() - 23000) (abi.encodeWithSignature("execute(address)", scriptAddress))) { script.state = ScriptState.Done; result = true; } else { script.state = ScriptState.Failed; result = false; } emit ScriptExecuted(scriptAddress, result); } } // File: contracts/StabilityBoardProxy.sol /* allows tx to execute if 50% +1 vote of active signers signed */ pragma solidity 0.4.24; contract StabilityBoardProxy is MultiSig { function checkQuorum(uint signersCount) internal view returns(bool isQuorum) { isQuorum = signersCount > activeSignersCount / 2 ; } } // File: contracts/SB_scripts/mainnet/Main0037_reserve_transfer.sol contract Main0037_reserve_transfer { StabilityBoardProxy public constant STABILITY_BOARD_PROXY = StabilityBoardProxy(0xde36a8773531406dCBefFdfd3C7b89fCed7A9F84); AugmintReserves public constant AUGMINT_RESERVES = AugmintReserves(0x65F30f8DD20c707C1938CcAd7416c7381E6eB9C8); address public constant TARGET_ADDRESS = 0xD4019C7D2d8e66A4f353c7Ee5a5fCe734D539B3b; function execute(Main0037_reserve_transfer /* self, not used */) external { // called via StabilityBoardProxy require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy"); AUGMINT_RESERVES.migrate(TARGET_ADDRESS, address(AUGMINT_RESERVES).balance); } }
requires quorum so it's callable only via a script executed by this contract */
function addSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i = 0; i < signers.length; i++) { if (!isSigner[signers[i]]) { require(signers[i] != address(0), "new signer must not be 0x0"); activeSignersCount++; allSigners.push(signers[i]); isSigner[signers[i]] = true; emit SignerAdded(signers[i]); } } for (uint i = 0; i < signers.length; i++) { if (!isSigner[signers[i]]) { require(signers[i] != address(0), "new signer must not be 0x0"); activeSignersCount++; allSigners.push(signers[i]); isSigner[signers[i]] = true; emit SignerAdded(signers[i]); } } }
10,695,796
[ 1, 4625, 348, 7953, 560, 30, 225, 4991, 31854, 1427, 518, 1807, 4140, 1338, 3970, 279, 2728, 7120, 635, 333, 6835, 1195, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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 ]
[ 1, 565, 445, 527, 2766, 414, 12, 2867, 8526, 1573, 414, 13, 1071, 288, 203, 3639, 2583, 12, 3576, 18, 15330, 422, 1758, 12, 2211, 3631, 315, 3700, 4140, 3970, 5991, 8267, 8863, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 1573, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 16051, 291, 15647, 63, 2977, 414, 63, 77, 65, 5717, 288, 203, 7734, 2583, 12, 2977, 414, 63, 77, 65, 480, 1758, 12, 20, 3631, 315, 2704, 10363, 1297, 486, 506, 374, 92, 20, 8863, 203, 7734, 2695, 2766, 414, 1380, 9904, 31, 203, 7734, 777, 2766, 414, 18, 6206, 12, 2977, 414, 63, 77, 19226, 203, 7734, 353, 15647, 63, 2977, 414, 63, 77, 13563, 273, 638, 31, 203, 7734, 3626, 16763, 8602, 12, 2977, 414, 63, 77, 19226, 203, 5411, 289, 203, 3639, 289, 203, 3639, 364, 261, 11890, 277, 273, 374, 31, 277, 411, 1573, 414, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 16051, 291, 15647, 63, 2977, 414, 63, 77, 65, 5717, 288, 203, 7734, 2583, 12, 2977, 414, 63, 77, 65, 480, 1758, 12, 20, 3631, 315, 2704, 10363, 1297, 486, 506, 374, 92, 20, 8863, 203, 7734, 2695, 2766, 414, 1380, 9904, 31, 203, 7734, 777, 2766, 414, 18, 6206, 12, 2977, 414, 63, 77, 19226, 203, 7734, 353, 15647, 63, 2977, 414, 63, 77, 13563, 273, 638, 31, 203, 7734, 3626, 16763, 8602, 12, 2977, 414, 63, 77, 19226, 203, 5411, 289, 203, 3639, 289, 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 ]
pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; library Utils { /* @notice Convert the bytes array to bytes32 type, the bytes array length must be 32 * @param _bs Source bytes array * @return bytes32 */ function bytesToBytes32(bytes memory _bs) internal pure returns (bytes32 value) { require(_bs.length == 32, "bytes length is not 32."); assembly { // load 32 bytes from memory starting from position _bs + 0x20 since the first 0x20 bytes stores _bs length value := mload(add(_bs, 0x20)) } } /* @notice Convert bytes to uint256 * @param _b Source bytes should have length of 32 * @return uint256 */ function bytesToUint256(bytes memory _bs) internal pure returns (uint256 value) { require(_bs.length == 32, "bytes length is not 32."); assembly { // load 32 bytes from memory starting from position _bs + 32 value := mload(add(_bs, 0x20)) } require(value <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds the range"); } /* @notice Convert uint256 to bytes * @param _b uint256 that needs to be converted * @return bytes */ function uint256ToBytes(uint256 _value) internal pure returns (bytes memory bs) { require(_value <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds the range"); assembly { // Get a location of some free memory and store it in result as // Solidity does for memory variables. bs := mload(0x40) // Put 0x20 at the first word, the length of bytes for uint256 value mstore(bs, 0x20) //In the next word, put value in bytes format to the next 32 bytes mstore(add(bs, 0x20), _value) // Update the free-memory pointer by padding our last write location to 32 bytes mstore(0x40, add(bs, 0x40)) } } /* @notice Convert bytes to address * @param _bs Source bytes: bytes length must be 20 * @return Converted address from source bytes */ function bytesToAddress(bytes memory _bs) internal pure returns (address addr) { require(_bs.length == 20, "bytes length does not match address"); assembly { // for _bs, first word store _bs.length, second word store _bs.value // load 32 bytes from mem[_bs+20], convert it into Uint160, meaning we take last 20 bytes as addr (address). addr := mload(add(_bs, 0x14)) } } /* @notice Convert address to bytes * @param _addr Address need to be converted * @return Converted bytes from address */ function addressToBytes(address _addr) internal pure returns (bytes memory bs){ assembly { // Get a location of some free memory and store it in result as // Solidity does for memory variables. bs := mload(0x40) // Put 20 (address byte length) at the first word, the length of bytes for uint256 value mstore(bs, 0x14) // logical shift left _a by 12 bytes, change _a from right-aligned to left-aligned mstore(add(bs, 0x20), shl(96, _addr)) // Update the free-memory pointer by padding our last write location to 32 bytes mstore(0x40, add(bs, 0x40)) } } /* @notice Do hash leaf as the multi-chain does * @param _data Data in bytes format * @return Hashed value in bytes32 format */ function hashLeaf(bytes memory _data) internal pure returns (bytes32 result) { result = sha256(abi.encodePacked(byte(0x0), _data)); } /* @notice Do hash children as the multi-chain does * @param _l Left node * @param _r Right node * @return Hashed value in bytes32 format */ function hashChildren(bytes32 _l, bytes32 _r) internal pure returns (bytes32 result) { result = sha256(abi.encodePacked(bytes1(0x01), _l, _r)); } /* @notice Compare if two bytes are equal, which are in storage and memory, seperately Refer from https://github.com/summa-tx/bitcoin-spv/blob/master/solidity/contracts/BytesLib.sol#L368 * @param _preBytes The bytes stored in storage * @param _postBytes The bytes stored in memory * @return Bool type indicating if they are equal */ 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) // 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) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // fslot can contain both the length and contents of the array // if slength < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage // slength != 0 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; } /* @notice Slice the _bytes from _start index till the result has length of _length Refer from https://github.com/summa-tx/bitcoin-spv/blob/master/solidity/contracts/BytesLib.sol#L246 * @param _bytes The original bytes needs to be sliced * @param _start The index of _bytes for the start of sliced bytes * @param _length The index of _bytes for the end of sliced bytes * @return The sliced bytes */ function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory) { require(_bytes.length >= (_start + _length)); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. // lengthmod <= _length % 32 let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } /* @notice Check if the elements number of _signers within _keepers array is no less than _m * @param _keepers The array consists of serveral address * @param _signers Some specific addresses to be looked into * @param _m The number requirement paramter * @return True means containment, false meansdo do not contain. */ function containMAddresses(address[] memory _keepers, address[] memory _signers, uint _m) internal pure returns (bool){ uint m = 0; for(uint i = 0; i < _signers.length; i++){ for (uint j = 0; j < _keepers.length; j++) { if (_signers[i] == _keepers[j]) { m++; delete _keepers[j]; } } } return m >= _m; } /* @notice TODO * @param key * @return */ function compressMCPubKey(bytes memory key) internal pure returns (bytes memory newkey) { require(key.length >= 67, "key lenggh is too short"); newkey = slice(key, 0, 35); if (uint8(key[66]) % 2 == 0){ newkey[2] = byte(0x02); } else { newkey[2] = byte(0x03); } return newkey; } /** * @dev Returns true if `account` is a contract. * Refer from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L18 * * 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. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } } /** * @dev Wrappers over encoding and serialization operation into bytes from bassic types in Solidity for PolyNetwork cross chain utility. * * Encode basic types in Solidity into bytes easily. It's designed to be used * for PolyNetwork cross chain application, and the encoding rules on Ethereum chain * and the decoding rules on other chains should be consistent. Here we * follow the underlying serialization rule with implementation found here: * https://github.com/polynetwork/poly/blob/master/common/zero_copy_sink.go * * Using this library instead of the unchecked serialization method can help reduce * the risk of serious bugs and handfule, so it's recommended to use it. * * Please note that risk can be minimized, yet not eliminated. */ library ZeroCopySink { /* @notice Convert boolean value into bytes * @param b The boolean value * @return Converted bytes array */ function WriteBool(bool b) internal pure returns (bytes memory) { bytes memory buff; assembly{ buff := mload(0x40) mstore(buff, 1) switch iszero(b) case 1 { mstore(add(buff, 0x20), shl(248, 0x00)) // mstore8(add(buff, 0x20), 0x00) } default { mstore(add(buff, 0x20), shl(248, 0x01)) // mstore8(add(buff, 0x20), 0x01) } mstore(0x40, add(buff, 0x21)) } return buff; } /* @notice Convert byte value into bytes * @param b The byte value * @return Converted bytes array */ function WriteByte(byte b) internal pure returns (bytes memory) { return WriteUint8(uint8(b)); } /* @notice Convert uint8 value into bytes * @param v The uint8 value * @return Converted bytes array */ function WriteUint8(uint8 v) internal pure returns (bytes memory) { bytes memory buff; assembly{ buff := mload(0x40) mstore(buff, 1) mstore(add(buff, 0x20), shl(248, v)) // mstore(add(buff, 0x20), byte(0x1f, v)) mstore(0x40, add(buff, 0x21)) } return buff; } /* @notice Convert uint16 value into bytes * @param v The uint16 value * @return Converted bytes array */ function WriteUint16(uint16 v) internal pure returns (bytes memory) { bytes memory buff; assembly{ buff := mload(0x40) let byteLen := 0x02 mstore(buff, byteLen) for { let mindex := 0x00 let vindex := 0x1f } lt(mindex, byteLen) { mindex := add(mindex, 0x01) vindex := sub(vindex, 0x01) }{ mstore8(add(add(buff, 0x20), mindex), byte(vindex, v)) } mstore(0x40, add(buff, 0x22)) } return buff; } /* @notice Convert uint32 value into bytes * @param v The uint32 value * @return Converted bytes array */ function WriteUint32(uint32 v) internal pure returns(bytes memory) { bytes memory buff; assembly{ buff := mload(0x40) let byteLen := 0x04 mstore(buff, byteLen) for { let mindex := 0x00 let vindex := 0x1f } lt(mindex, byteLen) { mindex := add(mindex, 0x01) vindex := sub(vindex, 0x01) }{ mstore8(add(add(buff, 0x20), mindex), byte(vindex, v)) } mstore(0x40, add(buff, 0x24)) } return buff; } /* @notice Convert uint64 value into bytes * @param v The uint64 value * @return Converted bytes array */ function WriteUint64(uint64 v) internal pure returns(bytes memory) { bytes memory buff; assembly{ buff := mload(0x40) let byteLen := 0x08 mstore(buff, byteLen) for { let mindex := 0x00 let vindex := 0x1f } lt(mindex, byteLen) { mindex := add(mindex, 0x01) vindex := sub(vindex, 0x01) }{ mstore8(add(add(buff, 0x20), mindex), byte(vindex, v)) } mstore(0x40, add(buff, 0x28)) } return buff; } /* @notice Convert limited uint256 value into bytes * @param v The uint256 value * @return Converted bytes array */ function WriteUint255(uint256 v) internal pure returns (bytes memory) { require(v <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds uint255 range"); bytes memory buff; assembly{ buff := mload(0x40) let byteLen := 0x20 mstore(buff, byteLen) for { let mindex := 0x00 let vindex := 0x1f } lt(mindex, byteLen) { mindex := add(mindex, 0x01) vindex := sub(vindex, 0x01) }{ mstore8(add(add(buff, 0x20), mindex), byte(vindex, v)) } mstore(0x40, add(buff, 0x40)) } return buff; } /* @notice Encode bytes format data into bytes * @param data The bytes array data * @return Encoded bytes array */ function WriteVarBytes(bytes memory data) internal pure returns (bytes memory) { uint64 l = uint64(data.length); return abi.encodePacked(WriteVarUint(l), data); } function WriteVarUint(uint64 v) internal pure returns (bytes memory) { if (v < 0xFD){ return WriteUint8(uint8(v)); } else if (v <= 0xFFFF) { return abi.encodePacked(WriteByte(0xFD), WriteUint16(uint16(v))); } else if (v <= 0xFFFFFFFF) { return abi.encodePacked(WriteByte(0xFE), WriteUint32(uint32(v))); } else { return abi.encodePacked(WriteByte(0xFF), WriteUint64(uint64(v))); } } } /** * @dev Wrappers over decoding and deserialization operation from bytes into bassic types in Solidity for PolyNetwork cross chain utility. * * Decode into basic types in Solidity from bytes easily. It's designed to be used * for PolyNetwork cross chain application, and the decoding rules on Ethereum chain * and the encoding rule on other chains should be consistent, and . Here we * follow the underlying deserialization rule with implementation found here: * https://github.com/polynetwork/poly/blob/master/common/zero_copy_source.go * * Using this library instead of the unchecked serialization method can help reduce * the risk of serious bugs and handfule, so it's recommended to use it. * * Please note that risk can be minimized, yet not eliminated. */ library ZeroCopySource { /* @notice Read next byte as boolean type starting at offset from buff * @param buff Source bytes array * @param offset The position from where we read the boolean value * @return The the read boolean value and new offset */ function NextBool(bytes memory buff, uint256 offset) internal pure returns(bool, uint256) { require(offset + 1 <= buff.length && offset < offset + 1, "Offset exceeds limit"); // byte === bytes1 byte v; assembly{ v := mload(add(add(buff, 0x20), offset)) } bool value; if (v == 0x01) { value = true; } else if (v == 0x00) { value = false; } else { revert("NextBool value error"); } return (value, offset + 1); } /* @notice Read next byte starting at offset from buff * @param buff Source bytes array * @param offset The position from where we read the byte value * @return The read byte value and new offset */ function NextByte(bytes memory buff, uint256 offset) internal pure returns (byte, uint256) { require(offset + 1 <= buff.length && offset < offset + 1, "NextByte, Offset exceeds maximum"); byte v; assembly{ v := mload(add(add(buff, 0x20), offset)) } return (v, offset + 1); } /* @notice Read next byte as uint8 starting at offset from buff * @param buff Source bytes array * @param offset The position from where we read the byte value * @return The read uint8 value and new offset */ function NextUint8(bytes memory buff, uint256 offset) internal pure returns (uint8, uint256) { require(offset + 1 <= buff.length && offset < offset + 1, "NextUint8, Offset exceeds maximum"); uint8 v; assembly{ let tmpbytes := mload(0x40) let bvalue := mload(add(add(buff, 0x20), offset)) mstore8(tmpbytes, byte(0, bvalue)) mstore(0x40, add(tmpbytes, 0x01)) v := mload(sub(tmpbytes, 0x1f)) } return (v, offset + 1); } /* @notice Read next two bytes as uint16 type starting from offset * @param buff Source bytes array * @param offset The position from where we read the uint16 value * @return The read uint16 value and updated offset */ function NextUint16(bytes memory buff, uint256 offset) internal pure returns (uint16, uint256) { require(offset + 2 <= buff.length && offset < offset + 2, "NextUint16, offset exceeds maximum"); uint16 v; assembly { let tmpbytes := mload(0x40) let bvalue := mload(add(add(buff, 0x20), offset)) mstore8(tmpbytes, byte(0x01, bvalue)) mstore8(add(tmpbytes, 0x01), byte(0, bvalue)) mstore(0x40, add(tmpbytes, 0x02)) v := mload(sub(tmpbytes, 0x1e)) } return (v, offset + 2); } /* @notice Read next four bytes as uint32 type starting from offset * @param buff Source bytes array * @param offset The position from where we read the uint32 value * @return The read uint32 value and updated offset */ function NextUint32(bytes memory buff, uint256 offset) internal pure returns (uint32, uint256) { require(offset + 4 <= buff.length && offset < offset + 4, "NextUint32, offset exceeds maximum"); uint32 v; assembly { let tmpbytes := mload(0x40) let byteLen := 0x04 for { let tindex := 0x00 let bindex := sub(byteLen, 0x01) let bvalue := mload(add(add(buff, 0x20), offset)) } lt(tindex, byteLen) { tindex := add(tindex, 0x01) bindex := sub(bindex, 0x01) }{ mstore8(add(tmpbytes, tindex), byte(bindex, bvalue)) } mstore(0x40, add(tmpbytes, byteLen)) v := mload(sub(tmpbytes, sub(0x20, byteLen))) } return (v, offset + 4); } /* @notice Read next eight bytes as uint64 type starting from offset * @param buff Source bytes array * @param offset The position from where we read the uint64 value * @return The read uint64 value and updated offset */ function NextUint64(bytes memory buff, uint256 offset) internal pure returns (uint64, uint256) { require(offset + 8 <= buff.length && offset < offset + 8, "NextUint64, offset exceeds maximum"); uint64 v; assembly { let tmpbytes := mload(0x40) let byteLen := 0x08 for { let tindex := 0x00 let bindex := sub(byteLen, 0x01) let bvalue := mload(add(add(buff, 0x20), offset)) } lt(tindex, byteLen) { tindex := add(tindex, 0x01) bindex := sub(bindex, 0x01) }{ mstore8(add(tmpbytes, tindex), byte(bindex, bvalue)) } mstore(0x40, add(tmpbytes, byteLen)) v := mload(sub(tmpbytes, sub(0x20, byteLen))) } return (v, offset + 8); } /* @notice Read next 32 bytes as uint256 type starting from offset, there are limits considering the numerical limits in multi-chain * @param buff Source bytes array * @param offset The position from where we read the uint256 value * @return The read uint256 value and updated offset */ function NextUint255(bytes memory buff, uint256 offset) internal pure returns (uint256, uint256) { require(offset + 32 <= buff.length && offset < offset + 32, "NextUint255, offset exceeds maximum"); uint256 v; assembly { let tmpbytes := mload(0x40) let byteLen := 0x20 for { let tindex := 0x00 let bindex := sub(byteLen, 0x01) let bvalue := mload(add(add(buff, 0x20), offset)) } lt(tindex, byteLen) { tindex := add(tindex, 0x01) bindex := sub(bindex, 0x01) }{ mstore8(add(tmpbytes, tindex), byte(bindex, bvalue)) } mstore(0x40, add(tmpbytes, byteLen)) v := mload(tmpbytes) } require(v <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds the range"); return (v, offset + 32); } /* @notice Read next variable bytes starting from offset, the decoding rule coming from multi-chain * @param buff Source bytes array * @param offset The position from where we read the bytes value * @return The read variable bytes array value and updated offset */ function NextVarBytes(bytes memory buff, uint256 offset) internal pure returns(bytes memory, uint256) { uint len; (len, offset) = NextVarUint(buff, offset); require(offset + len <= buff.length && offset < offset + len, "NextVarBytes, offset exceeds maximum"); bytes memory tempBytes; assembly{ switch iszero(len) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(len, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, len) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(buff, lengthmod), mul(0x20, iszero(lengthmod))), offset) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, len) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) mstore(0x40, add(tempBytes, 0x20)) } } return (tempBytes, offset + len); } /* @notice Read next 32 bytes starting from offset, * @param buff Source bytes array * @param offset The position from where we read the bytes value * @return The read bytes32 value and updated offset */ function NextHash(bytes memory buff, uint256 offset) internal pure returns (bytes32 , uint256) { require(offset + 32 <= buff.length && offset < offset + 32, "NextHash, offset exceeds maximum"); bytes32 v; assembly { v := mload(add(buff, add(offset, 0x20))) } return (v, offset + 32); } /* @notice Read next 20 bytes starting from offset, * @param buff Source bytes array * @param offset The position from where we read the bytes value * @return The read bytes20 value and updated offset */ function NextBytes20(bytes memory buff, uint256 offset) internal pure returns (bytes20 , uint256) { require(offset + 20 <= buff.length && offset < offset + 20, "NextBytes20, offset exceeds maximum"); bytes20 v; assembly { v := mload(add(buff, add(offset, 0x20))) } return (v, offset + 20); } function NextVarUint(bytes memory buff, uint256 offset) internal pure returns(uint, uint256) { byte v; (v, offset) = NextByte(buff, offset); uint value; if (v == 0xFD) { // return NextUint16(buff, offset); (value, offset) = NextUint16(buff, offset); require(value >= 0xFD && value <= 0xFFFF, "NextUint16, value outside range"); return (value, offset); } else if (v == 0xFE) { // return NextUint32(buff, offset); (value, offset) = NextUint32(buff, offset); require(value > 0xFFFF && value <= 0xFFFFFFFF, "NextVarUint, value outside range"); return (value, offset); } else if (v == 0xFF) { // return NextUint64(buff, offset); (value, offset) = NextUint64(buff, offset); require(value > 0xFFFFFFFF, "NextVarUint, value outside range"); return (value, offset); } else{ // return (uint8(v), offset); value = uint8(v); require(value < 0xFD, "NextVarUint, value outside range"); return (value, offset); } } } library ECCUtils { using SafeMath for uint256; struct Header { uint32 version; uint64 chainId; uint32 timestamp; uint32 height; uint64 consensusData; bytes32 prevBlockHash; bytes32 transactionsRoot; bytes32 crossStatesRoot; bytes32 blockRoot; bytes consensusPayload; bytes20 nextBookkeeper; } struct ToMerkleValue { bytes txHash; // cross chain txhash uint64 fromChainID; TxParam makeTxParam; } struct TxParam { bytes txHash; // source chain txhash bytes crossChainId; bytes fromContract; uint64 toChainId; bytes toContract; bytes method; bytes args; } uint constant POLYCHAIN_PUBKEY_LEN = 67; uint constant POLYCHAIN_SIGNATURE_LEN = 65; /* @notice Verify Poly chain transaction whether exist or not * @param _auditPath Poly chain merkle proof * @param _root Poly chain root * @return The verified value included in _auditPath */ function merkleProve(bytes memory _auditPath, bytes32 _root) internal pure returns (bytes memory) { uint256 off = 0; bytes memory value; (value, off) = ZeroCopySource.NextVarBytes(_auditPath, off); bytes32 hash = Utils.hashLeaf(value); uint size = _auditPath.length.sub(off).div(33); bytes32 nodeHash; byte pos; for (uint i = 0; i < size; i++) { (pos, off) = ZeroCopySource.NextByte(_auditPath, off); (nodeHash, off) = ZeroCopySource.NextHash(_auditPath, off); if (pos == 0x00) { hash = Utils.hashChildren(nodeHash, hash); } else if (pos == 0x01) { hash = Utils.hashChildren(hash, nodeHash); } else { revert("merkleProve, NextByte for position info failed"); } } require(hash == _root, "merkleProve, expect root is not equal actual root"); return value; } /* @notice calculate next book keeper according to public key list * @param _keyLen consensus node number * @param _m minimum signature number * @param _pubKeyList consensus node public key list * @return two element: next book keeper, consensus node signer addresses */ function _getBookKeeper(uint _keyLen, uint _m, bytes memory _pubKeyList) internal pure returns (bytes20, address[] memory){ bytes memory buff; buff = ZeroCopySink.WriteUint16(uint16(_keyLen)); address[] memory keepers = new address[](_keyLen); bytes32 hash; bytes memory publicKey; for(uint i = 0; i < _keyLen; i++){ publicKey = Utils.slice(_pubKeyList, i*POLYCHAIN_PUBKEY_LEN, POLYCHAIN_PUBKEY_LEN); buff = abi.encodePacked(buff, ZeroCopySink.WriteVarBytes(Utils.compressMCPubKey(publicKey))); hash = keccak256(Utils.slice(publicKey, 3, 64)); keepers[i] = address(uint160(uint256(hash))); } buff = abi.encodePacked(buff, ZeroCopySink.WriteUint16(uint16(_m))); bytes20 nextBookKeeper = ripemd160(abi.encodePacked(sha256(buff))); return (nextBookKeeper, keepers); } /* @notice Verify public key derived from Poly chain * @param _pubKeyList serialized consensus node public key list * @param _sigList consensus node signature list * @return return two element: next book keeper, consensus node signer addresses */ function verifyPubkey(bytes memory _pubKeyList) internal pure returns (bytes20, address[] memory) { require(_pubKeyList.length % POLYCHAIN_PUBKEY_LEN == 0, "_pubKeyList length illegal!"); uint n = _pubKeyList.length / POLYCHAIN_PUBKEY_LEN; require(n >= 1, "too short _pubKeyList!"); return _getBookKeeper(n, n - (n - 1) / 3, _pubKeyList); } /* @notice Verify Poly chain consensus node signature * @param _rawHeader Poly chain block header raw bytes * @param _sigList consensus node signature list * @param _keepers addresses corresponding with Poly chain book keepers' public keys * @param _m minimum signature number * @return true or false */ function verifySig(bytes memory _rawHeader, bytes memory _sigList, address[] memory _keepers, uint _m) internal pure returns (bool){ bytes32 hash = getHeaderHash(_rawHeader); uint sigCount = _sigList.length.div(POLYCHAIN_SIGNATURE_LEN); address[] memory signers = new address[](sigCount); bytes32 r; bytes32 s; uint8 v; for(uint j = 0; j < sigCount; j++){ r = Utils.bytesToBytes32(Utils.slice(_sigList, j*POLYCHAIN_SIGNATURE_LEN, 32)); s = Utils.bytesToBytes32(Utils.slice(_sigList, j*POLYCHAIN_SIGNATURE_LEN + 32, 32)); v = uint8(_sigList[j*POLYCHAIN_SIGNATURE_LEN + 64]) + 27; signers[j] = ecrecover(sha256(abi.encodePacked(hash)), v, r, s); } return Utils.containMAddresses(_keepers, signers, _m); } /* @notice Serialize Poly chain book keepers' info in Ethereum addresses format into raw bytes * @param keepersBytes The serialized addresses * @return serialized bytes result */ function serializeKeepers(address[] memory keepers) internal pure returns (bytes memory) { uint256 keeperLen = keepers.length; bytes memory keepersBytes = ZeroCopySink.WriteUint64(uint64(keeperLen)); for(uint i = 0; i < keeperLen; i++) { keepersBytes = abi.encodePacked(keepersBytes, ZeroCopySink.WriteVarBytes(Utils.addressToBytes(keepers[i]))); } return keepersBytes; } /* @notice Deserialize bytes into Ethereum addresses * @param keepersBytes The serialized addresses derived from Poly chain book keepers in bytes format * @return addresses */ function deserializeKeepers(bytes memory keepersBytes) internal pure returns (address[] memory) { uint256 off = 0; uint64 keeperLen; (keeperLen, off) = ZeroCopySource.NextUint64(keepersBytes, off); address[] memory keepers = new address[](keeperLen); bytes memory keeperBytes; for(uint i = 0; i < keeperLen; i++) { (keeperBytes, off) = ZeroCopySource.NextVarBytes(keepersBytes, off); keepers[i] = Utils.bytesToAddress(keeperBytes); } return keepers; } /* @notice Deserialize Poly chain transaction raw value * @param _valueBs Poly chain transaction raw bytes * @return ToMerkleValue struct */ function deserializeMerkleValue(bytes memory _valueBs) internal pure returns (ToMerkleValue memory) { ToMerkleValue memory toMerkleValue; uint256 off = 0; (toMerkleValue.txHash, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (toMerkleValue.fromChainID, off) = ZeroCopySource.NextUint64(_valueBs, off); TxParam memory txParam; (txParam.txHash, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (txParam.crossChainId, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (txParam.fromContract, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (txParam.toChainId, off) = ZeroCopySource.NextUint64(_valueBs, off); (txParam.toContract, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (txParam.method, off) = ZeroCopySource.NextVarBytes(_valueBs, off); (txParam.args, off) = ZeroCopySource.NextVarBytes(_valueBs, off); toMerkleValue.makeTxParam = txParam; return toMerkleValue; } /* @notice Deserialize Poly chain block header raw bytes * @param _valueBs Poly chain block header raw bytes * @return Header struct */ function deserializeHeader(bytes memory _headerBs) internal pure returns (Header memory) { Header memory header; uint256 off = 0; (header.version, off) = ZeroCopySource.NextUint32(_headerBs, off); (header.chainId, off) = ZeroCopySource.NextUint64(_headerBs, off); (header.prevBlockHash, off) = ZeroCopySource.NextHash(_headerBs, off); (header.transactionsRoot, off) = ZeroCopySource.NextHash(_headerBs, off); (header.crossStatesRoot, off) = ZeroCopySource.NextHash(_headerBs, off); (header.blockRoot, off) = ZeroCopySource.NextHash(_headerBs, off); (header.timestamp, off) = ZeroCopySource.NextUint32(_headerBs, off); (header.height, off) = ZeroCopySource.NextUint32(_headerBs, off); (header.consensusData, off) = ZeroCopySource.NextUint64(_headerBs, off); (header.consensusPayload, off) = ZeroCopySource.NextVarBytes(_headerBs, off); (header.nextBookkeeper, off) = ZeroCopySource.NextBytes20(_headerBs, off); return header; } /* @notice Deserialize Poly chain block header raw bytes * @param rawHeader Poly chain block header raw bytes * @return header hash same as Poly chain */ function getHeaderHash(bytes memory rawHeader) internal pure returns (bytes32) { return sha256(abi.encodePacked(sha256(rawHeader))); } } /** * @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; } } /** * @dev Interface of the EthCrossChainData contract, the implementation is in EthCrossChainData.sol */ interface IEthCrossChainData { function putCurEpochStartHeight(uint32 curEpochStartHeight) external returns (bool); function getCurEpochStartHeight() external view returns (uint32); function putCurEpochConPubKeyBytes(bytes calldata curEpochPkBytes) external returns (bool); function getCurEpochConPubKeyBytes() external view returns (bytes memory); function markFromChainTxExist(uint64 fromChainId, bytes32 fromChainTx) external returns (bool); function checkIfFromChainTxExist(uint64 fromChainId, bytes32 fromChainTx) external view returns (bool); function getEthTxHashIndex() external view returns (uint256); function putEthTxHash(bytes32 ethTxHash) external returns (bool); function putExtraData(bytes32 key1, bytes32 key2, bytes calldata value) external returns (bool); function getExtraData(bytes32 key1, bytes32 key2) external view returns (bytes memory); function transferOwnership(address newOwner) external; function pause() external returns (bool); function unpause() external returns (bool); function paused() external view returns (bool); // Not used currently by ECCM function getEthTxHash(uint256 ethTxHashIndex) external view returns (bytes32); } pragma solidity ^0.5.0; /** * @dev Interface of the EthCrossChainManager contract for business contract like LockProxy to request cross chain transaction */ interface IEthCrossChainManager { function crossChain(uint64 _toChainId, bytes calldata _toContract, bytes calldata _method, bytes calldata _txData) external returns (bool); } pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. * Refer from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/GSN/Context.sol */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Pausable is Context { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called to pause, triggers stopped state. */ function _pause() internal whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Called to unpause, returns to normal state. */ function _unpause() internal whenPaused { _paused = false; emit Unpaused(_msgSender()); } } pragma solidity ^0.5.0; /** * @dev Interface of upgradableECCM to make ECCM be upgradable, the implementation is in UpgradableECCM.sol */ interface IUpgradableECCM { function pause() external returns (bool); function unpause() external returns (bool); function paused() external view returns (bool); function upgradeToNew(address) external returns (bool); function isOwner() external view returns (bool); function setChainId(uint64 _newChainId) external returns (bool); } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract UpgradableECCM is IUpgradableECCM, Ownable, Pausable { address public EthCrossChainDataAddress; uint64 public chainId; constructor (address ethCrossChainDataAddr, uint64 _chainId) Pausable() Ownable() public { EthCrossChainDataAddress = ethCrossChainDataAddr; chainId = _chainId; } function pause() onlyOwner public returns (bool) { if (!paused()) { _pause(); } IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); if (!eccd.paused()) { require(eccd.pause(), "pause EthCrossChainData contract failed"); } return true; } function unpause() onlyOwner public returns (bool) { if (paused()) { _unpause(); } IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); if (eccd.paused()) { require(eccd.unpause(), "unpause EthCrossChainData contract failed"); } return true; } // if we want to upgrade this contract, we need to invoke this method function upgradeToNew(address newEthCrossChainManagerAddress) whenPaused onlyOwner public returns (bool) { IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); eccd.transferOwnership(newEthCrossChainManagerAddress); return true; } function setChainId(uint64 _newChainId) whenPaused onlyOwner public returns (bool) { chainId = _newChainId; return true; } } contract EthCrossChainManager is IEthCrossChainManager, UpgradableECCM { using SafeMath for uint256; mapping(address => bool) public whiteListFromContract; mapping(address => bool) public whiteListToContract; mapping(bytes => bool) public whiteListMethod; mapping(bytes => bool) public unsetEpochPkBytes; event InitGenesisBlockEvent(uint256 height, bytes rawHeader); event ChangeBookKeeperEvent(uint256 height, bytes rawHeader); event CrossChainEvent(address indexed sender, bytes txId, address proxyOrAssetContract, uint64 toChainId, bytes toContract, bytes rawdata); event VerifyHeaderAndExecuteTxEvent(uint64 fromChainID, bytes toContract, bytes crossChainTxHash, bytes fromChainTxHash); constructor( address _eccd, uint64 _chainId, address[] memory fromContractWhiteList, address[] memory toContractWhiteList, bytes[] memory methodWhiteList, bytes memory curEpochPkBytes ) UpgradableECCM(_eccd,_chainId) public { for (uint i=0;i<fromContractWhiteList.length;i++) { whiteListFromContract[fromContractWhiteList[i]] = true; } for (uint i=0;i<toContractWhiteList.length;i++) { whiteListToContract[toContractWhiteList[i]] = true; } for (uint i=0;i<methodWhiteList.length;i++) { whiteListMethod[methodWhiteList[i]] = true; } unsetEpochPkBytes[curEpochPkBytes] = true; } function recoverEpochPk(bytes memory EpochPkBytes) public { require(unsetEpochPkBytes[EpochPkBytes],"Don't arbitrarily set"); unsetEpochPkBytes[EpochPkBytes] = false; IEthCrossChainData(EthCrossChainDataAddress).putCurEpochConPubKeyBytes(EpochPkBytes); } /* @notice sync Poly chain genesis block header to smart contrat * @dev this function can only be called once, nextbookkeeper of rawHeader can't be empty * @param rawHeader Poly chain genesis block raw header or raw Header including switching consensus peers info * @return true or false */ function initGenesisBlock(bytes memory rawHeader, bytes memory pubKeyList) whenNotPaused public returns(bool) { // Load Ethereum cross chain data contract IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); // Make sure the contract has not been initialized before require(eccd.getCurEpochConPubKeyBytes().length == 0, "EthCrossChainData contract has already been initialized!"); // Parse header and convit the public keys into nextBookKeeper and compare it with header.nextBookKeeper to verify the validity of signature ECCUtils.Header memory header = ECCUtils.deserializeHeader(rawHeader); (bytes20 nextBookKeeper, address[] memory keepers) = ECCUtils.verifyPubkey(pubKeyList); require(header.nextBookkeeper == nextBookKeeper, "NextBookers illegal"); // Record current epoch start height and public keys (by storing them in address format) require(eccd.putCurEpochStartHeight(header.height), "Save Poly chain current epoch start height to Data contract failed!"); require(eccd.putCurEpochConPubKeyBytes(ECCUtils.serializeKeepers(keepers)), "Save Poly chain current epoch book keepers to Data contract failed!"); // Fire the event emit InitGenesisBlockEvent(header.height, rawHeader); return true; } /* @notice change Poly chain consensus book keeper * @param rawHeader Poly chain change book keeper block raw header * @param pubKeyList Poly chain consensus nodes public key list * @param sigList Poly chain consensus nodes signature list * @return true or false */ function changeBookKeeper(bytes memory rawHeader, bytes memory pubKeyList, bytes memory sigList) whenNotPaused public returns(bool) { // Load Ethereum cross chain data contract ECCUtils.Header memory header = ECCUtils.deserializeHeader(rawHeader); IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); // Make sure rawHeader.height is higher than recorded current epoch start height uint64 curEpochStartHeight = eccd.getCurEpochStartHeight(); require(header.height > curEpochStartHeight, "The height of header is lower than current epoch start height!"); // Ensure the rawHeader is the key header including info of switching consensus peers by containing non-empty nextBookKeeper field require(header.nextBookkeeper != bytes20(0), "The nextBookKeeper of header is empty"); // Verify signature of rawHeader comes from pubKeyList address[] memory polyChainBKs = ECCUtils.deserializeKeepers(eccd.getCurEpochConPubKeyBytes()); uint n = polyChainBKs.length; require(ECCUtils.verifySig(rawHeader, sigList, polyChainBKs, n - (n - 1) / 3), "Verify signature failed!"); // Convert pubKeyList into ethereum address format and make sure the compound address from the converted ethereum addresses // equals passed in header.nextBooker (bytes20 nextBookKeeper, address[] memory keepers) = ECCUtils.verifyPubkey(pubKeyList); require(header.nextBookkeeper == nextBookKeeper, "NextBookers illegal"); // update current epoch start height of Poly chain and current epoch consensus peers book keepers addresses require(eccd.putCurEpochStartHeight(header.height), "Save MC LatestHeight to Data contract failed!"); require(eccd.putCurEpochConPubKeyBytes(ECCUtils.serializeKeepers(keepers)), "Save Poly chain book keepers bytes to Data contract failed!"); // Fire the change book keeper event emit ChangeBookKeeperEvent(header.height, rawHeader); return true; } /* @notice ERC20 token cross chain to other blockchain. * this function push tx event to blockchain * @param toChainId Target chain id * @param toContract Target smart contract address in target block chain * @param txData Transaction data for target chain, include to_address, amount * @return true or false */ function crossChain(uint64 toChainId, bytes calldata toContract, bytes calldata method, bytes calldata txData) whenNotPaused external returns (bool) { // Only allow whitelist contract to call require(whiteListFromContract[msg.sender],"Invalid from contract"); // Load Ethereum cross chain data contract IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); // To help differentiate two txs, the ethTxHashIndex is increasing automatically uint256 txHashIndex = eccd.getEthTxHashIndex(); // Convert the uint256 into bytes bytes memory paramTxHash = Utils.uint256ToBytes(txHashIndex); // Construct the makeTxParam, and put the hash info storage, to help provide proof of tx existence bytes memory rawParam = abi.encodePacked(ZeroCopySink.WriteVarBytes(paramTxHash), ZeroCopySink.WriteVarBytes(abi.encodePacked(sha256(abi.encodePacked(address(this), paramTxHash)))), ZeroCopySink.WriteVarBytes(Utils.addressToBytes(msg.sender)), ZeroCopySink.WriteUint64(toChainId), ZeroCopySink.WriteVarBytes(toContract), ZeroCopySink.WriteVarBytes(method), ZeroCopySink.WriteVarBytes(txData) ); // Must save it in the storage to be included in the proof to be verified. require(eccd.putEthTxHash(keccak256(rawParam)), "Save ethTxHash by index to Data contract failed!"); // Fire the cross chain event denoting there is a cross chain request from Ethereum network to other public chains through Poly chain network emit CrossChainEvent(tx.origin, paramTxHash, msg.sender, toChainId, toContract, rawParam); return true; } /* @notice Verify Poly chain header and proof, execute the cross chain tx from Poly chain to Ethereum * @param proof Poly chain tx merkle proof * @param rawHeader The header containing crossStateRoot to verify the above tx merkle proof * @param headerProof The header merkle proof used to verify rawHeader * @param curRawHeader Any header in current epoch consensus of Poly chain * @param headerSig The coverted signature veriable for solidity derived from Poly chain consensus nodes' signature * used to verify the validity of curRawHeader * @return true or false */ function verifyHeaderAndExecuteTx(bytes memory proof, bytes memory rawHeader, bytes memory headerProof, bytes memory curRawHeader,bytes memory headerSig) whenNotPaused public returns (bool){ ECCUtils.Header memory header = ECCUtils.deserializeHeader(rawHeader); // Load ehereum cross chain data contract IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); // Get stored consensus public key bytes of current poly chain epoch and deserialize Poly chain consensus public key bytes to address[] address[] memory polyChainBKs = ECCUtils.deserializeKeepers(eccd.getCurEpochConPubKeyBytes()); uint256 curEpochStartHeight = eccd.getCurEpochStartHeight(); uint n = polyChainBKs.length; if (header.height >= curEpochStartHeight) { // It's enough to verify rawHeader signature require(ECCUtils.verifySig(rawHeader, headerSig, polyChainBKs, n - ( n - 1) / 3), "Verify poly chain header signature failed!"); } else { // We need to verify the signature of curHeader require(ECCUtils.verifySig(curRawHeader, headerSig, polyChainBKs, n - ( n - 1) / 3), "Verify poly chain current epoch header signature failed!"); // Then use curHeader.StateRoot and headerProof to verify rawHeader.CrossStateRoot ECCUtils.Header memory curHeader = ECCUtils.deserializeHeader(curRawHeader); bytes memory proveValue = ECCUtils.merkleProve(headerProof, curHeader.blockRoot); require(ECCUtils.getHeaderHash(rawHeader) == Utils.bytesToBytes32(proveValue), "verify header proof failed!"); } // Through rawHeader.CrossStatesRoot, the toMerkleValue or cross chain msg can be verified and parsed from proof bytes memory toMerkleValueBs = ECCUtils.merkleProve(proof, header.crossStatesRoot); // Parse the toMerkleValue struct and make sure the tx has not been processed, then mark this tx as processed ECCUtils.ToMerkleValue memory toMerkleValue = ECCUtils.deserializeMerkleValue(toMerkleValueBs); require(!eccd.checkIfFromChainTxExist(toMerkleValue.fromChainID, Utils.bytesToBytes32(toMerkleValue.txHash)), "the transaction has been executed!"); require(eccd.markFromChainTxExist(toMerkleValue.fromChainID, Utils.bytesToBytes32(toMerkleValue.txHash)), "Save crosschain tx exist failed!"); // Ethereum ChainId is 2, we need to check the transaction is for Ethereum network require(toMerkleValue.makeTxParam.toChainId == chainId, "This Tx is not aiming at this network!"); // Obtain the targeting contract, so that Ethereum cross chain manager contract can trigger the executation of cross chain tx on Ethereum side address toContract = Utils.bytesToAddress(toMerkleValue.makeTxParam.toContract); // only invoke PreWhiteListed Contract and method For Now require(whiteListToContract[toContract],"Invalid to contract"); require(whiteListMethod[toMerkleValue.makeTxParam.method],"Invalid method"); //TODO: check this part to make sure we commit the next line when doing local net UT test require(_executeCrossChainTx(toContract, toMerkleValue.makeTxParam.method, toMerkleValue.makeTxParam.args, toMerkleValue.makeTxParam.fromContract, toMerkleValue.fromChainID), "Execute CrossChain Tx failed!"); // Fire the cross chain event denoting the executation of cross chain tx is successful, // and this tx is coming from other public chains to current Ethereum network emit VerifyHeaderAndExecuteTxEvent(toMerkleValue.fromChainID, toMerkleValue.makeTxParam.toContract, toMerkleValue.txHash, toMerkleValue.makeTxParam.txHash); return true; } /* @notice Dynamically invoke the targeting contract, and trigger executation of cross chain tx on Ethereum side * @param _toContract The targeting contract that will be invoked by the Ethereum Cross Chain Manager contract * @param _method At which method will be invoked within the targeting contract * @param _args The parameter that will be passed into the targeting contract * @param _fromContractAddr From chain smart contract address * @param _fromChainId Indicate from which chain current cross chain tx comes * @return true or false */ function _executeCrossChainTx(address _toContract, bytes memory _method, bytes memory _args, bytes memory _fromContractAddr, uint64 _fromChainId) internal returns (bool){ // Ensure the targeting contract gonna be invoked is indeed a contract rather than a normal account address require(Utils.isContract(_toContract), "The passed in address is not a contract!"); bytes memory returnData; bool success; // The returnData will be bytes32, the last byte must be 01; (success, returnData) = _toContract.call(abi.encodePacked(bytes4(keccak256(abi.encodePacked(_method, "(bytes,bytes,uint64)"))), abi.encode(_args, _fromContractAddr, _fromChainId))); // Ensure the executation is successful require(success == true, "EthCrossChain call business contract failed"); // Ensure the returned value is true require(returnData.length != 0, "No return value from business contract!"); (bool res,) = ZeroCopySource.NextBool(returnData, 31); require(res == true, "EthCrossChain call business contract return is not true"); return true; } }
@notice ERC20 token cross chain to other blockchain. this function push tx event to blockchain @param toChainId Target chain id @param toContract Target smart contract address in target block chain @param txData Transaction data for target chain, include to_address, amount @return true or false/ Only allow whitelist contract to call Load Ethereum cross chain data contract To help differentiate two txs, the ethTxHashIndex is increasing automatically Convert the uint256 into bytes Construct the makeTxParam, and put the hash info storage, to help provide proof of tx existence Must save it in the storage to be included in the proof to be verified. Fire the cross chain event denoting there is a cross chain request from Ethereum network to other public chains through Poly chain network
function crossChain(uint64 toChainId, bytes calldata toContract, bytes calldata method, bytes calldata txData) whenNotPaused external returns (bool) { require(whiteListFromContract[msg.sender],"Invalid from contract"); IEthCrossChainData eccd = IEthCrossChainData(EthCrossChainDataAddress); uint256 txHashIndex = eccd.getEthTxHashIndex(); bytes memory paramTxHash = Utils.uint256ToBytes(txHashIndex); bytes memory rawParam = abi.encodePacked(ZeroCopySink.WriteVarBytes(paramTxHash), ZeroCopySink.WriteVarBytes(abi.encodePacked(sha256(abi.encodePacked(address(this), paramTxHash)))), ZeroCopySink.WriteVarBytes(Utils.addressToBytes(msg.sender)), ZeroCopySink.WriteUint64(toChainId), ZeroCopySink.WriteVarBytes(toContract), ZeroCopySink.WriteVarBytes(method), ZeroCopySink.WriteVarBytes(txData) ); require(eccd.putEthTxHash(keccak256(rawParam)), "Save ethTxHash by index to Data contract failed!"); emit CrossChainEvent(tx.origin, paramTxHash, msg.sender, toChainId, toContract, rawParam); return true; }
9,941,891
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 2868, 4232, 39, 3462, 1147, 6828, 2687, 358, 1308, 16766, 18, 15604, 333, 445, 1817, 2229, 871, 358, 16766, 225, 632, 891, 358, 3893, 548, 377, 5916, 2687, 612, 225, 632, 891, 358, 8924, 565, 5916, 13706, 6835, 1758, 316, 1018, 1203, 2687, 225, 632, 891, 2229, 751, 3639, 5947, 501, 364, 1018, 2687, 16, 2341, 358, 67, 2867, 16, 3844, 225, 632, 2463, 2868, 638, 578, 629, 19, 5098, 1699, 10734, 6835, 358, 745, 4444, 512, 18664, 379, 6828, 2687, 501, 6835, 2974, 2809, 3775, 3840, 2795, 20599, 16, 326, 13750, 4188, 2310, 1016, 353, 21006, 6635, 4037, 326, 2254, 5034, 1368, 1731, 14291, 326, 1221, 4188, 786, 16, 471, 1378, 326, 1651, 1123, 2502, 16, 358, 2809, 5615, 14601, 434, 2229, 15782, 6753, 1923, 518, 316, 326, 2502, 358, 506, 5849, 316, 326, 14601, 358, 506, 13808, 18, 10151, 326, 6828, 2687, 871, 5545, 17128, 1915, 353, 279, 6828, 2687, 590, 628, 512, 18664, 379, 2483, 358, 1308, 1071, 13070, 3059, 18394, 2687, 2483, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 6828, 3893, 12, 11890, 1105, 358, 3893, 548, 16, 1731, 745, 892, 358, 8924, 16, 1731, 745, 892, 707, 16, 1731, 745, 892, 2229, 751, 13, 1347, 1248, 28590, 3903, 1135, 261, 6430, 13, 288, 203, 3639, 2583, 12, 14739, 682, 1265, 8924, 63, 3576, 18, 15330, 6487, 6, 1941, 628, 6835, 8863, 203, 540, 203, 3639, 10897, 451, 13941, 3893, 751, 18104, 72, 273, 10897, 451, 13941, 3893, 751, 12, 41, 451, 13941, 3893, 751, 1887, 1769, 203, 540, 203, 3639, 2254, 5034, 2229, 2310, 1016, 273, 18104, 72, 18, 588, 41, 451, 4188, 2310, 1016, 5621, 203, 540, 203, 3639, 1731, 3778, 579, 4188, 2310, 273, 6091, 18, 11890, 5034, 21033, 12, 978, 2310, 1016, 1769, 203, 540, 203, 3639, 1731, 3778, 1831, 786, 273, 24126, 18, 3015, 4420, 329, 12, 7170, 2951, 11326, 18, 3067, 1537, 2160, 12, 891, 4188, 2310, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 1537, 2160, 12, 21457, 18, 3015, 4420, 329, 12, 7819, 5034, 12, 21457, 18, 3015, 4420, 329, 12, 2867, 12, 2211, 3631, 579, 4188, 2310, 20349, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 1537, 2160, 12, 1989, 18, 2867, 21033, 12, 3576, 18, 15330, 13, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 5487, 1105, 12, 869, 3893, 548, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 1537, 2160, 12, 869, 8924, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 1537, 2160, 12, 2039, 3631, 203, 5411, 12744, 2951, 11326, 18, 3067, 1537, 2160, 12, 978, 751, 13, 203, 3639, 11272, 203, 540, 203, 3639, 2583, 12, 557, 4315, 18, 458, 41, 451, 4188, 2310, 12, 79, 24410, 581, 5034, 12, 1899, 786, 13, 3631, 315, 4755, 13750, 4188, 2310, 635, 770, 358, 1910, 6835, 2535, 4442, 1769, 203, 540, 203, 3639, 3626, 19742, 3893, 1133, 12, 978, 18, 10012, 16, 579, 4188, 2310, 16, 1234, 18, 15330, 16, 358, 3893, 548, 16, 358, 8924, 16, 1831, 786, 1769, 203, 3639, 327, 638, 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 ]
pragma solidity 0.4.25; import "./Common/Upgradable.sol"; import "./Common/Random.sol"; import "./Core.sol"; import "./Battle.sol"; import "./Treasury.sol"; import "./Getter.sol"; import "./Common/SafeMath8.sol"; import "./Common/SafeMath16.sol"; import "./Common/SafeMath32.sol"; import "./Common/SafeMath256.sol"; /* solium-disable operator-whitespace */ contract BattleController is Upgradable { using SafeMath8 for uint8; using SafeMath16 for uint16; using SafeMath32 for uint32; using SafeMath256 for uint256; Core core; Battle battle; Treasury treasury; Getter getter; Random random; // stores date to which dragon is untouchable as opponent for the battle mapping (uint256 => uint256) lastBattleDate; uint8 constant MAX_PERCENTAGE = 100; uint8 constant MIN_HEALTH_PERCENTAGE = 50; uint8 constant MAX_TACTICS_PERCENTAGE = 80; uint8 constant MIN_TACTICS_PERCENTAGE = 20; uint8 constant PERCENT_MULTIPLIER = 100; uint8 constant DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE = 10; uint32 constant MAX_GOLD_REWARD_MULTIPLIER = 10000000; uint256 constant GOLD_REWARD_MULTIPLIER = 10 ** 18; function _min(uint256 lth, uint256 rth) internal pure returns (uint256) { return lth > rth ? rth : lth; } function _isTouchable(uint256 _id) internal view returns (bool) { uint32 _regenerationTime = core.getDragonFullRegenerationTime(_id); return lastBattleDate[_id].add(_regenerationTime.mul(4)) < now; // solium-disable-line security/no-block-members } function _checkBattlePossibility( address _sender, uint256 _id, uint256 _opponentId, uint8[2] _tactics ) internal view { require(getter.isDragonOwner(_sender, _id), "not an owner"); require(!getter.isDragonOwner(_sender, _opponentId), "can't be owner of opponent dragon"); require(!getter.isDragonOwner(address(0), _opponentId), "opponent dragon has no owner"); require(!getter.isDragonInGladiatorBattle(_id), "your dragon participates in gladiator battle"); require(!getter.isDragonInGladiatorBattle(_opponentId), "opponent dragon participates in gladiator battle"); require(_isTouchable(_opponentId), "opponent dragon is untouchable"); require( _tactics[0] >= MIN_TACTICS_PERCENTAGE && _tactics[0] <= MAX_TACTICS_PERCENTAGE && _tactics[1] >= MIN_TACTICS_PERCENTAGE && _tactics[1] <= MAX_TACTICS_PERCENTAGE, "tactics value must be between 20 and 80" ); uint8 _attackerHealthPercentage; uint8 _attackerManaPercentage; ( , , _attackerHealthPercentage, _attackerManaPercentage) = getter.getDragonCurrentHealthAndMana(_id); require( _attackerHealthPercentage >= MIN_HEALTH_PERCENTAGE, "dragon's health less than 50%" ); uint8 _opponentHealthPercentage; uint8 _opponentManaPercentage; ( , , _opponentHealthPercentage, _opponentManaPercentage) = getter.getDragonCurrentHealthAndMana(_opponentId); require( _opponentHealthPercentage == MAX_PERCENTAGE && _opponentManaPercentage == MAX_PERCENTAGE, "opponent health and/or mana is not full" ); } function startBattle( address _sender, uint256 _id, uint256 _opponentId, uint8[2] _tactics ) external onlyController returns ( uint256 battleId, uint256 seed, uint256[2] winnerLooserIds ) { _checkBattlePossibility(_sender, _id, _opponentId, _tactics); seed = random.random(2**256 - 1); uint32 _winnerHealth; uint32 _winnerMana; uint32 _looserHealth; uint32 _looserMana; ( winnerLooserIds, _winnerHealth, _winnerMana, _looserHealth, _looserMana, battleId ) = battle.start( _id, _opponentId, _tactics, [0, 0], seed, false ); core.setDragonRemainingHealthAndMana(winnerLooserIds[0], _winnerHealth, _winnerMana); core.setDragonRemainingHealthAndMana(winnerLooserIds[1], _looserHealth, _looserMana); core.increaseDragonWins(winnerLooserIds[0]); core.increaseDragonDefeats(winnerLooserIds[1]); lastBattleDate[_opponentId] = now; // solium-disable-line security/no-block-members _payBattleRewards( _sender, _id, _opponentId, winnerLooserIds[0] ); } function _payBattleRewards( address _sender, uint256 _id, uint256 _opponentId, uint256 _winnerId ) internal { uint32 _strength = getter.getDragonStrength(_id); uint32 _opponentStrength = getter.getDragonStrength(_opponentId); bool _isAttackerWinner = _id == _winnerId; uint256 _xpFactor = _calculateExperience(_isAttackerWinner, _strength, _opponentStrength); core.increaseDragonExperience(_winnerId, _xpFactor); if (_isAttackerWinner) { uint256 _factor = _calculateGoldRewardFactor(_strength, _opponentStrength); _payGoldReward(_sender, _id, _factor); } } function _calculateExperience( bool _isAttackerWinner, uint32 _attackerStrength, uint32 _opponentStrength ) internal pure returns (uint256) { uint8 _attackerFactor; uint256 _winnerStrength; uint256 _looserStrength; uint8 _degree; if (_isAttackerWinner) { _attackerFactor = 10; _winnerStrength = _attackerStrength; _looserStrength = _opponentStrength; _degree = _winnerStrength <= _looserStrength ? 2 : 5; } else { _attackerFactor = 5; _winnerStrength = _opponentStrength; _looserStrength = _attackerStrength; _degree = _winnerStrength <= _looserStrength ? 1 : 5; } uint256 _factor = _looserStrength.pow(_degree).mul(_attackerFactor).div(_winnerStrength.pow(_degree)); if (_isAttackerWinner) { return _factor; } return _min(_factor, 10); // 1 } function _calculateGoldRewardFactor( uint256 _winnerStrength, uint256 _looserStrength ) internal pure returns (uint256) { uint8 _degree = _winnerStrength <= _looserStrength ? 1 : 8; return _looserStrength.pow(_degree).mul(GOLD_REWARD_MULTIPLIER).div(_winnerStrength.pow(_degree)); } function _getMaxGoldReward( uint256 _hatchingPrice, uint256 _dragonsAmount ) internal pure returns (uint256) { uint32 _factor; if (_dragonsAmount < 3000) _factor = 2000000; // Hydrogen Eon else if (_dragonsAmount < 6000) _factor = 1000000; // Helium Eon else if (_dragonsAmount < 9000) _factor = 500000; // Carbon Eon else if (_dragonsAmount < 12000) _factor = 250000; // Oxygen Eon else if (_dragonsAmount < 15000) _factor = 125000; // Silicon Eon else if (_dragonsAmount < 18000) _factor = 62500; // Titanium Eon else if (_dragonsAmount < 21000) _factor = 31250; // Silver Eon else _factor = 15625; // Gold Eon return _hatchingPrice.mul(_factor).div(MAX_GOLD_REWARD_MULTIPLIER); } function _payGoldReward( address _sender, uint256 _id, uint256 _factor ) internal { uint256 _goldRemain = treasury.remainingGold(); uint256 _dragonsAmount = getter.getDragonsAmount(); uint32 _coolness; (, , , , , , , _coolness) = getter.getDragonProfile(_id); uint256 _hatchingPrice = treasury.hatchingPrice(); // dragon coolness is multyplied by 100 uint256 _value = _goldRemain.mul(_coolness).mul(10).div(_dragonsAmount.pow(2)).div(100); _value = _value.mul(_factor).div(GOLD_REWARD_MULTIPLIER); uint256 _maxReward = _getMaxGoldReward(_hatchingPrice, _dragonsAmount); if (_value > _maxReward) _value = _maxReward; if (_value > _goldRemain) _value = _goldRemain; treasury.giveGold(_sender, _value); } struct Opponent { uint256 id; uint256 timestamp; uint32 strength; } function _iterateTimestampIndex(uint8 _index) internal pure returns (uint8) { return _index < 5 ? _index.add(1) : 0; } function _getPercentOfValue(uint32 _value, uint8 _percent) internal pure returns (uint32) { return _value.mul(_percent).div(PERCENT_MULTIPLIER); } function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint256 _timestamp; // usually the date of the last battle uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = _opponents[5].timestamp = now; // solium-disable-line security/no-block-members for (uint256 _id = 1; _id <= getter.getDragonsAmount(); _id++) { // no dragon with id = 0 if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; } function resetDragonBuffs(uint256 _id) external onlyController { core.resetDragonBuffs(_id); } // UPDATE CONTRACT function setInternalDependencies(address[] _newDependencies) public onlyOwner { super.setInternalDependencies(_newDependencies); core = Core(_newDependencies[0]); battle = Battle(_newDependencies[1]); treasury = Treasury(_newDependencies[2]); getter = Getter(_newDependencies[3]); random = Random(_newDependencies[4]); } }
stores date to which dragon is untouchable as opponent for the battle
contract BattleController is Upgradable { using SafeMath8 for uint8; using SafeMath16 for uint16; using SafeMath32 for uint32; using SafeMath256 for uint256; Core core; Battle battle; Treasury treasury; Getter getter; Random random; mapping (uint256 => uint256) lastBattleDate; uint8 constant MAX_PERCENTAGE = 100; uint8 constant MIN_HEALTH_PERCENTAGE = 50; uint8 constant MAX_TACTICS_PERCENTAGE = 80; uint8 constant MIN_TACTICS_PERCENTAGE = 20; uint8 constant PERCENT_MULTIPLIER = 100; uint8 constant DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE = 10; uint32 constant MAX_GOLD_REWARD_MULTIPLIER = 10000000; uint256 constant GOLD_REWARD_MULTIPLIER = 10 ** 18; function _min(uint256 lth, uint256 rth) internal pure returns (uint256) { return lth > rth ? rth : lth; } function _isTouchable(uint256 _id) internal view returns (bool) { uint32 _regenerationTime = core.getDragonFullRegenerationTime(_id); } function _checkBattlePossibility( address _sender, uint256 _id, uint256 _opponentId, uint8[2] _tactics ) internal view { require(getter.isDragonOwner(_sender, _id), "not an owner"); require(!getter.isDragonOwner(_sender, _opponentId), "can't be owner of opponent dragon"); require(!getter.isDragonOwner(address(0), _opponentId), "opponent dragon has no owner"); require(!getter.isDragonInGladiatorBattle(_id), "your dragon participates in gladiator battle"); require(!getter.isDragonInGladiatorBattle(_opponentId), "opponent dragon participates in gladiator battle"); require(_isTouchable(_opponentId), "opponent dragon is untouchable"); require( _tactics[0] >= MIN_TACTICS_PERCENTAGE && _tactics[0] <= MAX_TACTICS_PERCENTAGE && _tactics[1] >= MIN_TACTICS_PERCENTAGE && _tactics[1] <= MAX_TACTICS_PERCENTAGE, "tactics value must be between 20 and 80" ); uint8 _attackerHealthPercentage; uint8 _attackerManaPercentage; ( , , _attackerHealthPercentage, _attackerManaPercentage) = getter.getDragonCurrentHealthAndMana(_id); require( _attackerHealthPercentage >= MIN_HEALTH_PERCENTAGE, "dragon's health less than 50%" ); uint8 _opponentHealthPercentage; uint8 _opponentManaPercentage; ( , , _opponentHealthPercentage, _opponentManaPercentage) = getter.getDragonCurrentHealthAndMana(_opponentId); require( _opponentHealthPercentage == MAX_PERCENTAGE && _opponentManaPercentage == MAX_PERCENTAGE, "opponent health and/or mana is not full" ); } function startBattle( address _sender, uint256 _id, uint256 _opponentId, uint8[2] _tactics ) external onlyController returns ( uint256 battleId, uint256 seed, uint256[2] winnerLooserIds ) { _checkBattlePossibility(_sender, _id, _opponentId, _tactics); seed = random.random(2**256 - 1); uint32 _winnerHealth; uint32 _winnerMana; uint32 _looserHealth; uint32 _looserMana; ( winnerLooserIds, _winnerHealth, _winnerMana, _looserHealth, _looserMana, battleId ) = battle.start( _id, _opponentId, _tactics, [0, 0], seed, false ); core.setDragonRemainingHealthAndMana(winnerLooserIds[0], _winnerHealth, _winnerMana); core.setDragonRemainingHealthAndMana(winnerLooserIds[1], _looserHealth, _looserMana); core.increaseDragonWins(winnerLooserIds[0]); core.increaseDragonDefeats(winnerLooserIds[1]); _payBattleRewards( _sender, _id, _opponentId, winnerLooserIds[0] ); } function _payBattleRewards( address _sender, uint256 _id, uint256 _opponentId, uint256 _winnerId ) internal { uint32 _strength = getter.getDragonStrength(_id); uint32 _opponentStrength = getter.getDragonStrength(_opponentId); bool _isAttackerWinner = _id == _winnerId; uint256 _xpFactor = _calculateExperience(_isAttackerWinner, _strength, _opponentStrength); core.increaseDragonExperience(_winnerId, _xpFactor); if (_isAttackerWinner) { uint256 _factor = _calculateGoldRewardFactor(_strength, _opponentStrength); _payGoldReward(_sender, _id, _factor); } } function _payBattleRewards( address _sender, uint256 _id, uint256 _opponentId, uint256 _winnerId ) internal { uint32 _strength = getter.getDragonStrength(_id); uint32 _opponentStrength = getter.getDragonStrength(_opponentId); bool _isAttackerWinner = _id == _winnerId; uint256 _xpFactor = _calculateExperience(_isAttackerWinner, _strength, _opponentStrength); core.increaseDragonExperience(_winnerId, _xpFactor); if (_isAttackerWinner) { uint256 _factor = _calculateGoldRewardFactor(_strength, _opponentStrength); _payGoldReward(_sender, _id, _factor); } } function _calculateExperience( bool _isAttackerWinner, uint32 _attackerStrength, uint32 _opponentStrength ) internal pure returns (uint256) { uint8 _attackerFactor; uint256 _winnerStrength; uint256 _looserStrength; uint8 _degree; if (_isAttackerWinner) { _attackerFactor = 10; _winnerStrength = _attackerStrength; _looserStrength = _opponentStrength; _degree = _winnerStrength <= _looserStrength ? 2 : 5; _attackerFactor = 5; _winnerStrength = _opponentStrength; _looserStrength = _attackerStrength; _degree = _winnerStrength <= _looserStrength ? 1 : 5; } uint256 _factor = _looserStrength.pow(_degree).mul(_attackerFactor).div(_winnerStrength.pow(_degree)); if (_isAttackerWinner) { return _factor; } } function _calculateExperience( bool _isAttackerWinner, uint32 _attackerStrength, uint32 _opponentStrength ) internal pure returns (uint256) { uint8 _attackerFactor; uint256 _winnerStrength; uint256 _looserStrength; uint8 _degree; if (_isAttackerWinner) { _attackerFactor = 10; _winnerStrength = _attackerStrength; _looserStrength = _opponentStrength; _degree = _winnerStrength <= _looserStrength ? 2 : 5; _attackerFactor = 5; _winnerStrength = _opponentStrength; _looserStrength = _attackerStrength; _degree = _winnerStrength <= _looserStrength ? 1 : 5; } uint256 _factor = _looserStrength.pow(_degree).mul(_attackerFactor).div(_winnerStrength.pow(_degree)); if (_isAttackerWinner) { return _factor; } } } else { function _calculateExperience( bool _isAttackerWinner, uint32 _attackerStrength, uint32 _opponentStrength ) internal pure returns (uint256) { uint8 _attackerFactor; uint256 _winnerStrength; uint256 _looserStrength; uint8 _degree; if (_isAttackerWinner) { _attackerFactor = 10; _winnerStrength = _attackerStrength; _looserStrength = _opponentStrength; _degree = _winnerStrength <= _looserStrength ? 2 : 5; _attackerFactor = 5; _winnerStrength = _opponentStrength; _looserStrength = _attackerStrength; _degree = _winnerStrength <= _looserStrength ? 1 : 5; } uint256 _factor = _looserStrength.pow(_degree).mul(_attackerFactor).div(_winnerStrength.pow(_degree)); if (_isAttackerWinner) { return _factor; } } function _calculateGoldRewardFactor( uint256 _winnerStrength, uint256 _looserStrength ) internal pure returns (uint256) { uint8 _degree = _winnerStrength <= _looserStrength ? 1 : 8; return _looserStrength.pow(_degree).mul(GOLD_REWARD_MULTIPLIER).div(_winnerStrength.pow(_degree)); } function _getMaxGoldReward( uint256 _hatchingPrice, uint256 _dragonsAmount ) internal pure returns (uint256) { uint32 _factor; return _hatchingPrice.mul(_factor).div(MAX_GOLD_REWARD_MULTIPLIER); } function _payGoldReward( address _sender, uint256 _id, uint256 _factor ) internal { uint256 _goldRemain = treasury.remainingGold(); uint256 _dragonsAmount = getter.getDragonsAmount(); uint32 _coolness; (, , , , , , , _coolness) = getter.getDragonProfile(_id); uint256 _hatchingPrice = treasury.hatchingPrice(); uint256 _value = _goldRemain.mul(_coolness).mul(10).div(_dragonsAmount.pow(2)).div(100); _value = _value.mul(_factor).div(GOLD_REWARD_MULTIPLIER); uint256 _maxReward = _getMaxGoldReward(_hatchingPrice, _dragonsAmount); if (_value > _maxReward) _value = _maxReward; if (_value > _goldRemain) _value = _goldRemain; treasury.giveGold(_sender, _value); } struct Opponent { uint256 id; uint256 timestamp; uint32 strength; } function _iterateTimestampIndex(uint8 _index) internal pure returns (uint8) { return _index < 5 ? _index.add(1) : 0; } function _getPercentOfValue(uint32 _value, uint8 _percent) internal pure returns (uint32) { return _value.mul(_percent).div(PERCENT_MULTIPLIER); } function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; function matchOpponents(uint256 _attackerId) external view returns (uint256[6]) { uint32 _attackerStrength = getter.getDragonStrength(_attackerId); uint32 _strengthDiff = _getPercentOfValue(_attackerStrength, DRAGON_STRENGTH_DIFFERENCE_PERCENTAGE); uint32 _minStrength = _attackerStrength.sub(_strengthDiff); uint32 _maxStrength = _attackerStrength.add(_strengthDiff); uint32 _strength; uint8 _timestampIndex; uint8 _healthPercentage; uint8 _manaPercentage; address _owner = getter.ownerOfDragon(_attackerId); Opponent[6] memory _opponents; _opponents[0].timestamp = _opponents[1].timestamp = _opponents[2].timestamp = _opponents[3].timestamp = _opponents[4].timestamp = if ( _attackerId != _id && !getter.isDragonOwner(_owner, _id) && !getter.isDragonInGladiatorBattle(_id) && _isTouchable(_id) ) { _strength = getter.getDragonStrength(_id); if (_strength >= _minStrength && _strength <= _maxStrength) { ( , , _healthPercentage, _manaPercentage) = getter.getDragonCurrentHealthAndMana(_id); if (_healthPercentage == MAX_PERCENTAGE && _manaPercentage == MAX_PERCENTAGE) { (_timestamp, , , , ) = getter.getDragonHealthAndMana(_id); if (_timestamp < _opponents[_timestampIndex].timestamp) { _opponents[_timestampIndex] = Opponent(_id, _timestamp, _strength); _timestampIndex = _iterateTimestampIndex(_timestampIndex); } } } } } return [ _opponents[0].id, _opponents[1].id, _opponents[2].id, _opponents[3].id, _opponents[4].id, _opponents[5].id ]; }
13,093,072
[ 1, 4625, 348, 7953, 560, 30, 225, 9064, 1509, 358, 1492, 8823, 265, 353, 640, 14084, 429, 487, 1061, 1029, 364, 326, 324, 4558, 298, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 5034, 31, 203, 203, 565, 4586, 2922, 31, 203, 565, 605, 4558, 298, 324, 4558, 298, 31, 203, 565, 399, 266, 345, 22498, 9787, 345, 22498, 31, 203, 565, 968, 387, 7060, 31, 203, 565, 8072, 2744, 31, 203, 203, 565, 2874, 261, 11890, 5034, 516, 2254, 5034, 13, 1142, 38, 4558, 298, 1626, 31, 203, 203, 565, 2254, 28, 5381, 4552, 67, 3194, 19666, 2833, 273, 2130, 31, 203, 565, 2254, 28, 5381, 6989, 67, 3900, 1013, 2455, 67, 3194, 19666, 2833, 273, 6437, 31, 203, 565, 2254, 28, 5381, 4552, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 273, 8958, 31, 203, 565, 2254, 28, 5381, 6989, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 273, 4200, 31, 203, 565, 2254, 28, 5381, 10950, 19666, 67, 24683, 2053, 654, 273, 2130, 31, 203, 565, 2254, 28, 5381, 16801, 1781, 673, 67, 882, 862, 4960, 2455, 67, 2565, 9303, 7535, 67, 3194, 19666, 2833, 273, 1728, 31, 203, 565, 2254, 1578, 5381, 4552, 67, 43, 11846, 67, 862, 21343, 67, 24683, 2053, 654, 273, 2130, 11706, 31, 203, 203, 565, 2254, 5034, 5381, 611, 11846, 67, 862, 21343, 67, 24683, 2053, 654, 273, 1728, 2826, 6549, 31, 203, 203, 203, 565, 445, 389, 1154, 12, 11890, 5034, 328, 451, 16, 2254, 5034, 436, 451, 13, 2713, 16618, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 328, 451, 405, 436, 451, 692, 436, 451, 294, 328, 451, 31, 203, 565, 289, 203, 203, 565, 445, 389, 291, 10491, 429, 12, 11890, 5034, 389, 350, 13, 2713, 1476, 1135, 261, 6430, 13, 288, 203, 3639, 2254, 1578, 389, 1574, 708, 367, 950, 273, 2922, 18, 588, 11728, 265, 5080, 1617, 708, 367, 950, 24899, 350, 1769, 203, 565, 289, 203, 203, 565, 445, 389, 1893, 38, 4558, 298, 1616, 17349, 12, 203, 3639, 1758, 389, 15330, 16, 203, 3639, 2254, 5034, 389, 350, 16, 203, 3639, 2254, 5034, 389, 556, 1029, 548, 16, 203, 3639, 2254, 28, 63, 22, 65, 389, 88, 621, 2102, 203, 565, 262, 2713, 1476, 288, 203, 3639, 2583, 12, 11990, 18, 291, 11728, 265, 5541, 24899, 15330, 16, 389, 350, 3631, 315, 902, 392, 3410, 8863, 203, 3639, 2583, 12, 5, 11990, 18, 291, 11728, 265, 5541, 24899, 15330, 16, 389, 556, 1029, 548, 3631, 315, 4169, 1404, 506, 3410, 434, 1061, 1029, 8823, 265, 8863, 203, 3639, 2583, 12, 5, 11990, 18, 291, 11728, 265, 5541, 12, 2867, 12, 20, 3631, 389, 556, 1029, 548, 3631, 315, 556, 1029, 8823, 265, 711, 1158, 3410, 8863, 203, 203, 3639, 2583, 12, 5, 11990, 18, 291, 11728, 265, 382, 21308, 361, 10620, 38, 4558, 298, 24899, 350, 3631, 315, 93, 477, 8823, 265, 30891, 815, 316, 5118, 361, 10620, 324, 4558, 298, 8863, 203, 3639, 2583, 12, 5, 11990, 18, 291, 11728, 265, 382, 21308, 361, 10620, 38, 4558, 298, 24899, 556, 1029, 548, 3631, 315, 556, 1029, 8823, 265, 30891, 815, 316, 5118, 361, 10620, 324, 4558, 298, 8863, 203, 203, 3639, 2583, 24899, 291, 10491, 429, 24899, 556, 1029, 548, 3631, 315, 556, 1029, 8823, 265, 353, 640, 14084, 429, 8863, 203, 203, 3639, 2583, 12, 203, 5411, 389, 88, 621, 2102, 63, 20, 65, 1545, 6989, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 597, 203, 5411, 389, 88, 621, 2102, 63, 20, 65, 1648, 4552, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 597, 203, 5411, 389, 88, 621, 2102, 63, 21, 65, 1545, 6989, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 597, 203, 5411, 389, 88, 621, 2102, 63, 21, 65, 1648, 4552, 67, 56, 6526, 28919, 67, 3194, 19666, 2833, 16, 203, 5411, 315, 88, 621, 2102, 460, 1297, 506, 3086, 4200, 471, 8958, 6, 203, 3639, 11272, 203, 203, 3639, 2254, 28, 389, 4558, 484, 264, 7802, 16397, 31, 203, 3639, 2254, 28, 389, 4558, 484, 264, 5669, 69, 16397, 31, 203, 3639, 261, 269, 269, 389, 4558, 484, 264, 7802, 16397, 16, 389, 4558, 484, 264, 5669, 69, 16397, 13, 273, 7060, 18, 588, 11728, 265, 3935, 7802, 1876, 5669, 69, 24899, 350, 1769, 203, 3639, 2583, 12, 203, 5411, 389, 4558, 484, 264, 7802, 16397, 1545, 6989, 67, 3900, 1013, 2455, 67, 3194, 19666, 2833, 16, 203, 5411, 315, 15997, 265, 1807, 8437, 5242, 2353, 6437, 16407, 203, 3639, 11272, 203, 3639, 2254, 28, 389, 556, 1029, 7802, 16397, 31, 203, 3639, 2254, 28, 389, 556, 1029, 5669, 69, 16397, 31, 203, 3639, 261, 269, 269, 389, 556, 1029, 7802, 16397, 16, 389, 556, 1029, 5669, 69, 16397, 13, 273, 7060, 18, 588, 11728, 265, 3935, 7802, 1876, 5669, 69, 24899, 556, 1029, 548, 1769, 203, 3639, 2583, 12, 203, 5411, 389, 556, 1029, 7802, 16397, 422, 4552, 67, 3194, 19666, 2833, 597, 203, 5411, 389, 556, 1029, 5669, 69, 16397, 422, 4552, 67, 3194, 19666, 2833, 16, 203, 5411, 315, 556, 1029, 8437, 471, 19, 280, 3161, 69, 353, 486, 1983, 6, 203, 3639, 11272, 203, 565, 289, 203, 203, 565, 445, 787, 38, 4558, 298, 12, 203, 3639, 1758, 389, 15330, 16, 203, 3639, 2254, 5034, 389, 350, 16, 203, 3639, 2254, 5034, 389, 556, 1029, 548, 16, 203, 3639, 2254, 28, 63, 22, 65, 389, 88, 621, 2102, 203, 565, 262, 3903, 1338, 2933, 1135, 261, 203, 3639, 2254, 5034, 324, 4558, 298, 548, 16, 203, 3639, 2254, 5034, 5009, 16, 203, 3639, 2254, 5034, 63, 22, 65, 5657, 1224, 1504, 13164, 2673, 203, 565, 262, 288, 203, 3639, 389, 1893, 38, 4558, 298, 1616, 17349, 24899, 15330, 16, 389, 350, 16, 389, 556, 1029, 548, 16, 389, 88, 621, 2102, 1769, 203, 203, 3639, 5009, 273, 2744, 18, 9188, 12, 22, 636, 5034, 300, 404, 1769, 203, 203, 3639, 2254, 1578, 389, 91, 7872, 7802, 31, 203, 3639, 2254, 1578, 389, 91, 7872, 5669, 69, 31, 203, 3639, 2254, 1578, 389, 383, 13164, 7802, 31, 203, 2 ]
./full_match/1/0x73217eE72fDedf763BACd83Acf60b4218f6ff8Af/sources/Users/ivannikov/work/snake-jungle/cosmo-farming/contracts/FarmUniswapGenerator.sol
minimum 1000 divisibility per block reward
require(_blockReward > 1000, 'BLOCK REWARD');
4,880,096
[ 1, 4625, 348, 7953, 560, 30, 225, 5224, 4336, 3739, 291, 3628, 1534, 1203, 19890, 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,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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 ]
[ 1, 565, 2583, 24899, 2629, 17631, 1060, 405, 4336, 16, 296, 11403, 2438, 21343, 8284, 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 ]
./full_match/4/0x8542E1ddE76E7725DF3ff3C7829DC07229998333/sources/temp-contracts/DelegateCallProxyManager.sol
* @dev Lock the current implementation for `implementationID` so that it can never be upgraded again./ Read the implementation holder address from storage. Verify that the implementation exists.
function lockImplementationManyToOne(bytes32 implementationID) external override onlyOwner { address implementationHolder = _implementationHolders[implementationID]; require(implementationHolder != address(0), "ERR_IMPLEMENTATION_ID"); _lockedImplementations[implementationHolder] = true; emit ManyToOne_ImplementationLocked(implementationID); }
647,932
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 3488, 326, 783, 4471, 364, 1375, 30810, 734, 68, 1427, 716, 518, 848, 5903, 506, 31049, 3382, 18, 19, 2720, 326, 4471, 10438, 1758, 628, 2502, 18, 8553, 716, 326, 4471, 1704, 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,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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 ]
[ 1, 225, 445, 2176, 13621, 5594, 16027, 12, 3890, 1578, 4471, 734, 13, 3903, 3849, 1338, 5541, 288, 203, 565, 1758, 4471, 6064, 273, 389, 30810, 27003, 63, 30810, 734, 15533, 203, 565, 2583, 12, 30810, 6064, 480, 1758, 12, 20, 3631, 315, 9712, 67, 9883, 7618, 2689, 67, 734, 8863, 203, 565, 389, 15091, 5726, 1012, 63, 30810, 6064, 65, 273, 638, 31, 203, 565, 3626, 19903, 16027, 67, 13621, 8966, 12, 30810, 734, 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 ]
//Address: 0x00fc2e075bc935c7c4283d277b90e6b9c822a105 //Contract name: PoolManager //Balance: 0 Ether //Verification Date: 6/17/2018 //Transacion Count: 7 // CODE STARTS HERE pragma solidity ^0.4.16; //Define the pool contract SmartPool { //Pool info uint currAmount; //Current amount in the pool (=balance) uint ticketPrice; //Price of one ticket uint startDate; //The date of opening uint endDate; //The date of closing (or 0 if still open) //Block infos (better to use block number than dates to trigger the end) uint startBlock; uint endBlock; //End triggers uint duration; //The pool ends when the duration expire uint ticketCount; //Or when the reserve of tickets has been sold bool ended; //Current state (can't buy tickets when ended) bool terminated; //true if a winner has been picked bool moneySent; //true if the winner has picked his money //Min wait duration between ended and terminated states uint constant blockDuration = 15; // we use 15 sec for the block duration uint constant minWaitDuration = 240; // (= 3600 / blockDuration => 60 minutes waiting between 'ended' and 'terminated') //Players address[] players; //List of tickets owners, each ticket gives an entry in the array //Winning info address winner; //The final winner (only available when terminated == true) //Pool manager address (only the manager can call modifiers of this contract, see PoolManager.sol) address poolManager; //Create a pool with a fixed ticket price, a ticket reserve and/or a duration) function SmartPool(uint _ticketPrice, uint _ticketCount, uint _duration) public { //Positive ticket price and either ticketCount or duration must be provided require(_ticketPrice > 0 && (_ticketCount > 0 || _duration > blockDuration)); //Check for overflows require(now + _duration >= now); //Set ticketCount if needed (according to max balance) if (_ticketCount == 0) { _ticketCount = (2 ** 256 - 1) / _ticketPrice; } require(_ticketCount * _ticketPrice >= _ticketPrice); //Store manager poolManager = msg.sender; //Init currAmount = 0; startDate = now; endDate = 0; startBlock = block.number; endBlock = 0; ticketPrice = _ticketPrice; ticketCount = _ticketCount; duration = _duration / blockDuration; // compute duration in blocks ended = false; terminated = false; moneySent = false; winner = 0x0000000000000000000000000000000000000000; } //Accessors function getPlayers() public constant returns (address[]) { return players; } function getStartDate() public constant returns (uint) { return startDate; } function getStartBlock() public constant returns (uint) { return startBlock; } function getCurrAmount() public constant returns (uint) { return currAmount; } function getTicketPrice() public constant returns (uint) { return ticketPrice; } function getTicketCount() public constant returns (uint) { return ticketCount; } function getBoughtTicketCount() public constant returns (uint) { return players.length; } function getAvailableTicketCount() public constant returns (uint) { return ticketCount - players.length; } function getEndDate() public constant returns (uint) { return endDate; } function getEndBlock() public constant returns (uint) { return endBlock; } function getDuration() public constant returns (uint) { return duration; // duration in blocks } function getDurationS() public constant returns (uint) { return duration * blockDuration; // duration in seconds } function isEnded() public constant returns (bool) { return ended; } function isTerminated() public constant returns (bool) { return terminated; } function isMoneySent() public constant returns (bool) { return moneySent; } function getWinner() public constant returns (address) { return winner; } //End trigger function checkEnd() public { if ( (duration > 0 && block.number >= startBlock + duration) || (players.length >= ticketCount) ) { ended = true; endDate = now; endBlock = block.number; } } //Add player with ticketCount to the pool (only poolManager can do this) function addPlayer(address player, uint ticketBoughtCount, uint amount) public { //Only manager can call this require(msg.sender == poolManager); //Revert if pool ended (should not happen because the manager check this too) require (!ended); //Add amount to the pool currAmount += amount; // amount has been checked by the manager //Add player to the ticket owner array, for each bought ticket for (uint i = 0; i < ticketBoughtCount; i++) players.push(player); //Check end checkEnd(); } function canTerminate() public constant returns(bool) { return ended && !terminated && block.number - endBlock >= minWaitDuration; } //Terminate the pool by picking a winner (only poolManager can do this, after the pool is ended and some time has passed so the seed has changed many times) function terminate(uint randSeed) public { //Only manager can call this require(msg.sender == poolManager); //The pool need to be ended, but not terminated require(ended && !terminated); //Min duration between ended and terminated require(block.number - endBlock >= minWaitDuration); //Only one call to this function terminated = true; //Pick a winner if (players.length > 0) winner = players[randSeed % players.length]; } //Update pool state (only poolManager can call this when the money has been sent) function onMoneySent() public { //Only manager can call this require(msg.sender == poolManager); //The pool must be terminated (winner picked) require(terminated); //Update money sent (only one call to this function) require(!moneySent); moneySent = true; } } //Wallet interface contract WalletContract { function payMe() public payable; } contract PoolManager { //Pool owner (address which manage the pool creation) address owner; //Wallet which receive the fees (1% of ticket price) address wallet; //Fees infos (external websites providing access to pools get 1% too) mapping(address => uint) fees; //Fees divider (1% for the wallet, and 1% for external website where player can buy tickets) uint constant feeDivider = 100; //(1/100 of the amount) //The ticket price for pools must be a multiple of 0.010205 ether (to avoid truncating the fees, and having a minimum to send to the winner) uint constant ticketPriceMultiple = 10205000000000000; //(multiple of 0.010205 ether for ticketPrice) //Pools infos (current active pools. When a pool is done, it goes into the poolsDone array bellow and a new pool is created to replace it at the same index) SmartPool[] pools; //Ended pools (cleaned automatically after winners get their prices) SmartPool[] poolsDone; //History (contains all the pools since the deploy) SmartPool[] poolsHistory; //Current rand seed (it changes a lot so it's pretty hard to know its value when the winner is picked) uint randSeed; //Constructor (only owner) function PoolManager(address wal) public { owner = msg.sender; wallet = wal; randSeed = 0; } //Called frequently by other functions to keep the seed moving function updateSeed() private { randSeed += (uint(block.blockhash(block.number - 1))); } //Create a new pool (only owner can do this) function addPool(uint ticketPrice, uint ticketCount, uint duration) public { require(msg.sender == owner); require(ticketPrice >= ticketPriceMultiple && ticketPrice % ticketPriceMultiple == 0); //Deploy a new pool pools.push(new SmartPool(ticketPrice, ticketCount, duration)); } //Accessors (public) //Get Active Pools function getPoolCount() public constant returns(uint) { return pools.length; } function getPool(uint index) public constant returns(address) { require(index < pools.length); return pools[index]; } //Get Ended Pools function getPoolDoneCount() public constant returns(uint) { return poolsDone.length; } function getPoolDone(uint index) public constant returns(address) { require(index < poolsDone.length); return poolsDone[index]; } //Get History function getPoolHistoryCount() public constant returns(uint) { return poolsHistory.length; } function getPoolHistory(uint index) public constant returns(address) { require(index < poolsHistory.length); return poolsHistory[index]; } //Buy tickets for a pool (public) function buyTicket(uint poolIndex, uint ticketCount, address websiteFeeAddr) public payable { require(poolIndex < pools.length); require(ticketCount > 0); //Get pool and check state SmartPool pool = pools[poolIndex]; pool.checkEnd(); require (!pool.isEnded()); //Adjust ticketCount according to available tickets uint availableCount = pool.getAvailableTicketCount(); if (ticketCount > availableCount) ticketCount = availableCount; //Get amount required and check msg.value uint amountRequired = ticketCount * pool.getTicketPrice(); require(msg.value >= amountRequired); //If too much value sent, we send it back to player uint amountLeft = msg.value - amountRequired; //if no websiteFeeAddr given, the wallet get the fee if (websiteFeeAddr == address(0)) websiteFeeAddr = wallet; //Compute fee uint feeAmount = amountRequired / feeDivider; addFee(websiteFeeAddr, feeAmount); addFee(wallet, feeAmount); //Add player to the pool with the amount minus the fees (1% + 1% = 2%) pool.addPlayer(msg.sender, ticketCount, amountRequired - 2 * feeAmount); //Send back amountLeft to player if too much value sent if (amountLeft > 0 && !msg.sender.send(amountLeft)) { addFee(wallet, amountLeft); // if it fails, we take it as a fee.. } updateSeed(); } //Check pools end. (called by our console each 10 minutes, or can be called by anybody) function checkPoolsEnd() public { for (uint i = 0; i < pools.length; i++) { //Check each pool and restart the ended ones checkPoolEnd(i); } } //Check end of a pool and restart it if it's ended (public) function checkPoolEnd(uint i) public { require(i < pools.length); //Check end (if not triggered yet) SmartPool pool = pools[i]; if (!pool.isEnded()) pool.checkEnd(); if (!pool.isEnded()) { return; // not ended yet } updateSeed(); //Store pool done and restart a pool to replace it poolsDone.push(pool); pools[i] = new SmartPool(pool.getTicketPrice(), pool.getTicketCount(), pool.getDurationS()); } //Check pools done. (called by our console, or can be called by anybody) function checkPoolsDone() public { for (uint i = 0; i < poolsDone.length; i++) { checkPoolDone(i); } } //Check end of one pool function checkPoolDone(uint i) public { require(i < poolsDone.length); SmartPool pool = poolsDone[i]; if (pool.isTerminated()) return; // already terminated if (!pool.canTerminate()) return; // we need to wait a bit more before random occurs, so the seed has changed enough (60 minutes before ended and terminated states) updateSeed(); //Terminate (pick a winner) and store pool done pool.terminate(randSeed); } //Send money of the pool to the winner (public) function sendPoolMoney(uint i) public { require(i < poolsDone.length); SmartPool pool = poolsDone[i]; require (pool.isTerminated()); // we need a winner picked require(!pool.isMoneySent()); // money not sent uint amount = pool.getCurrAmount(); address winner = pool.getWinner(); pool.onMoneySent(); if (amount > 0 && !winner.send(amount)) // the winner can't get his money (should not happen) { addFee(wallet, amount); } //Pool goes into history array poolsHistory.push(pool); } //Clear pools done array (called once a week by our console, or can be called by anybody) function clearPoolsDone() public { //Make sure all pools are terminated with no money left for (uint i = 0; i < poolsDone.length; i++) { if (!poolsDone[i].isMoneySent()) return; } //"Clear" poolsDone array (just reset the length, instances will be override) poolsDone.length = 0; } //Get current fee value function getFeeValue(address a) public constant returns (uint) { if (a == address(0)) a = msg.sender; return fees[a]; } //Send fee to address (public, with a min amount required) function getMyFee(address a) public { if (a == address(0)) a = msg.sender; uint amount = fees[a]; require (amount > 0); fees[a] = 0; if (a == wallet) { WalletContract walletContract = WalletContract(a); walletContract.payMe.value(amount)(); } else if (!a.send(amount)) addFee(wallet, amount); // the fee can't be sent (hacking attempt?), so we take it... :-p } //Add fee (private) function addFee(address a, uint fee) private { if (fees[a] == 0) fees[a] = fee; else fees[a] += fee; // we don't check for overflow, if you're billionaire in fees, call getMyFee sometimes :-) } }
Check pools done. (called by our console, or can be called by anybody)
function checkPoolsDone() public { for (uint i = 0; i < poolsDone.length; i++) { checkPoolDone(i); } }
2,527,713
[ 1, 4625, 348, 7953, 560, 30, 2073, 16000, 2731, 18, 261, 11777, 635, 3134, 2983, 16, 578, 848, 506, 2566, 635, 1281, 3432, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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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 ]
[ 1, 202, 915, 866, 16639, 7387, 1435, 1071, 7010, 202, 95, 203, 202, 202, 1884, 261, 11890, 277, 273, 374, 31, 277, 411, 16000, 7387, 18, 2469, 31, 277, 27245, 203, 202, 202, 95, 203, 1082, 202, 1893, 2864, 7387, 12, 77, 1769, 203, 202, 202, 97, 203, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x92990e791fE5445164DA13A64E4AC3387708760c/sources/browser/Untitled.sol
RiveMont_MasterFarmer is the master of RVMT. He can make RVMT and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once RVMT is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. Info of each user.
contract RiveMont_MasterFarmer is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; struct UserInfo { } struct PoolInfo { } uint256 public FINISH_BONUS_AT_BLOCK; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event SendRVMTReward(address indexed user, uint256 indexed pid, uint256 amount, uint256 lockAmount); constructor( RiveMontToken _RVMT, address _devaddr, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _halvingAfterBlock RiveMontToken public RVMT; address public devaddr; uint256 public REWARD_PER_BLOCK; uint256[] public REWARD_MULTIPLIER = [128, 128, 64, 32, 16, 8, 4, 2, 1]; uint256 public START_BLOCK; IMigratorToRVMTSwap public migrator; PoolInfo[] public poolInfo; mapping (uint256 => mapping (address => UserInfo)) public userInfo; uint256 public totalAllocPoint = 0; ) public { RVMT = _RVMT; devaddr = _devaddr; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); } ) public { RVMT = _RVMT; devaddr = _devaddr; REWARD_PER_BLOCK = _rewardPerBlock; START_BLOCK = _startBlock; for (uint256 i = 0; i < REWARD_MULTIPLIER.length - 1; i++) { uint256 halvingAtBlock = _halvingAfterBlock.mul(i + 1).add(_startBlock); HALVING_AT_BLOCK.push(halvingAtBlock); } FINISH_BONUS_AT_BLOCK = _halvingAfterBlock.mul(REWARD_MULTIPLIER.length - 1).add(_startBlock); HALVING_AT_BLOCK.push(uint256(-1)); } function poolLength() external view returns (uint256) { return poolInfo.length; } function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "RiveMont_MasterFarmer::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accRVMTPerShare: 0 })); } function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "RiveMont_MasterFarmer::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accRVMTPerShare: 0 })); } function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { require(poolId1[address(_lpToken)] == 0, "RiveMont_MasterFarmer::add: lp is already in pool"); if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > START_BLOCK ? block.number : START_BLOCK; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolId1[address(_lpToken)] = poolInfo.length + 1; poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accRVMTPerShare: 0 })); } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function setMigrator(IMigratorToRVMTSwap _migrator) public onlyOwner { migrator = _migrator; } function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 RVMTForDev; uint256 RVMTForFarmer; (RVMTForDev, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (RVMTForDev > 0) { RVMT.mint(devaddr, RVMTForDev); } RVMT.mint(address(this), RVMTForFarmer); pool.accRVMTPerShare = pool.accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 RVMTForDev; uint256 RVMTForFarmer; (RVMTForDev, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (RVMTForDev > 0) { RVMT.mint(devaddr, RVMTForDev); } RVMT.mint(address(this), RVMTForFarmer); pool.accRVMTPerShare = pool.accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 RVMTForDev; uint256 RVMTForFarmer; (RVMTForDev, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (RVMTForDev > 0) { RVMT.mint(devaddr, RVMTForDev); } RVMT.mint(address(this), RVMTForFarmer); pool.accRVMTPerShare = pool.accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 RVMTForDev; uint256 RVMTForFarmer; (RVMTForDev, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); if (RVMTForDev > 0) { RVMT.mint(devaddr, RVMTForDev); } RVMT.mint(address(this), RVMTForFarmer); pool.accRVMTPerShare = pool.accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_BLOCK) return 0; for (uint256 i = 0; i < HALVING_AT_BLOCK.length; i++) { uint256 endBlock = HALVING_AT_BLOCK[i]; if (_to <= endBlock) { uint256 m = _to.sub(_from).mul(REWARD_MULTIPLIER[i]); return result.add(m); } if (_from < endBlock) { uint256 m = endBlock.sub(_from).mul(REWARD_MULTIPLIER[i]); _from = endBlock; result = result.add(m); } } return result; } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint256 forDev, uint256 forFarmer) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint); uint256 RVMTCanMint = (RVMT.totalSupply()); if (RVMTCanMint < amount) { forDev = 0; forFarmer = RVMTCanMint; } else { forDev = amount.mul(PERCENT_FOR_DEV).div(100); forFarmer = amount; } } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint256 forDev, uint256 forFarmer) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint); uint256 RVMTCanMint = (RVMT.totalSupply()); if (RVMTCanMint < amount) { forDev = 0; forFarmer = RVMTCanMint; } else { forDev = amount.mul(PERCENT_FOR_DEV).div(100); forFarmer = amount; } } function getPoolReward(uint256 _from, uint256 _to, uint256 _allocPoint) public view returns (uint256 forDev, uint256 forFarmer) { uint256 multiplier = getMultiplier(_from, _to); uint256 amount = multiplier.mul(REWARD_PER_BLOCK).mul(_allocPoint).div(totalAllocPoint); uint256 RVMTCanMint = (RVMT.totalSupply()); if (RVMTCanMint < amount) { forDev = 0; forFarmer = RVMTCanMint; } else { forDev = amount.mul(PERCENT_FOR_DEV).div(100); forFarmer = amount; } } function pendingReward(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accRVMTPerShare = pool.accRVMTPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 RVMTForFarmer; (, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accRVMTPerShare = accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); } return user.amount.mul(accRVMTPerShare).div(1e12).sub(user.rewardDebt); } function pendingReward(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accRVMTPerShare = pool.accRVMTPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply > 0) { uint256 RVMTForFarmer; (, RVMTForFarmer) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint); accRVMTPerShare = accRVMTPerShare.add(RVMTForFarmer.mul(1e12).div(lpSupply)); } return user.amount.mul(accRVMTPerShare).div(1e12).sub(user.rewardDebt); } function claimReward(uint256 _pid) public { updatePool(_pid); _harvest(_pid); } function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRVMTPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = RVMT.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { RVMT.transfer(msg.sender, pending); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); (msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendRVMTReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); } } function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRVMTPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = RVMT.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { RVMT.transfer(msg.sender, pending); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); (msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendRVMTReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); } } function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRVMTPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = RVMT.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { RVMT.transfer(msg.sender, pending); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); (msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendRVMTReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); } } function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRVMTPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = RVMT.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { RVMT.transfer(msg.sender, pending); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); (msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendRVMTReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); } } function _harvest(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRVMTPerShare).div(1e12).sub(user.rewardDebt); uint256 masterBal = RVMT.balanceOf(address(this)); if (pending > masterBal) { pending = masterBal; } if(pending > 0) { RVMT.transfer(msg.sender, pending); uint256 lockAmount = 0; if (user.rewardDebtAtBlock <= FINISH_BONUS_AT_BLOCK) { lockAmount = pending.mul(PERCENT_LOCK_BONUS_REWARD).div(100); (msg.sender, lockAmount); } user.rewardDebtAtBlock = block.number; emit SendRVMTReward(msg.sender, _pid, pending, lockAmount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); } } function deposit(uint256 _pid, uint256 _amount) public { require(_amount > 0, "RiveMont_MasterFarmer::deposit: amount must be greater than 0"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); _harvest(_pid); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0) { user.rewardDebtAtBlock = block.number; } user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } function deposit(uint256 _pid, uint256 _amount) public { require(_amount > 0, "RiveMont_MasterFarmer::deposit: amount must be greater than 0"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); _harvest(_pid); pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); if (user.amount == 0) { user.rewardDebtAtBlock = block.number; } user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "RiveMont_MasterFarmer::withdraw: not good"); updatePool(_pid); _harvest(_pid); if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "RiveMont_MasterFarmer::withdraw: not good"); updatePool(_pid); _harvest(_pid); if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt = user.amount.mul(pool.accRVMTPerShare).div(1e12); emit Withdraw(msg.sender, _pid, _amount); } function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } function safeRVMTTransfer(address _to, uint256 _amount) internal { uint256 RVMTBal = RVMT.balanceOf(address(this)); if (_amount > RVMTBal) { RVMT.transfer(_to, RVMTBal); RVMT.transfer(_to, _amount); } } function safeRVMTTransfer(address _to, uint256 _amount) internal { uint256 RVMTBal = RVMT.balanceOf(address(this)); if (_amount > RVMTBal) { RVMT.transfer(_to, RVMTBal); RVMT.transfer(_to, _amount); } } } else { function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } function getNewRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return multiplier.mul(REWARD_PER_BLOCK); } else { return multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint); } } function getNewRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return multiplier.mul(REWARD_PER_BLOCK); } else { return multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint); } } function getNewRewardPerBlock(uint256 pid1) public view returns (uint256) { uint256 multiplier = getMultiplier(block.number -1, block.number); if (pid1 == 0) { return multiplier.mul(REWARD_PER_BLOCK); } else { return multiplier .mul(REWARD_PER_BLOCK) .mul(poolInfo[pid1 - 1].allocPoint) .div(totalAllocPoint); } } }
8,201,686
[ 1, 4625, 348, 7953, 560, 30, 225, 534, 688, 49, 1580, 67, 7786, 42, 4610, 264, 353, 326, 4171, 434, 534, 58, 6152, 18, 8264, 848, 1221, 534, 58, 6152, 471, 3904, 353, 279, 284, 1826, 3058, 93, 18, 3609, 716, 518, 1807, 4953, 429, 471, 326, 3410, 341, 491, 87, 268, 2764, 409, 1481, 7212, 18, 1021, 23178, 903, 506, 906, 4193, 358, 279, 314, 1643, 82, 1359, 13706, 6835, 3647, 534, 58, 6152, 353, 18662, 715, 16859, 471, 326, 19833, 848, 2405, 358, 314, 1643, 82, 6174, 18, 21940, 9831, 6453, 518, 18, 670, 1306, 4095, 518, 1807, 7934, 17, 9156, 18, 611, 369, 324, 2656, 18, 3807, 434, 1517, 729, 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,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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 ]
[ 1, 16351, 534, 688, 49, 1580, 67, 7786, 42, 4610, 264, 353, 14223, 6914, 288, 203, 565, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 565, 1450, 14060, 654, 39, 3462, 364, 467, 654, 39, 3462, 31, 203, 203, 565, 1958, 25003, 288, 203, 565, 289, 203, 203, 565, 1958, 8828, 966, 288, 203, 565, 289, 203, 203, 565, 2254, 5034, 1071, 25768, 67, 38, 673, 3378, 67, 789, 67, 11403, 31, 203, 203, 203, 203, 203, 203, 565, 871, 4019, 538, 305, 12, 2867, 8808, 729, 16, 2254, 5034, 8808, 4231, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 3423, 9446, 12, 2867, 8808, 729, 16, 2254, 5034, 8808, 4231, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 512, 6592, 75, 2075, 1190, 9446, 12, 2867, 8808, 729, 16, 2254, 5034, 8808, 4231, 16, 2254, 5034, 3844, 1769, 203, 565, 871, 2479, 54, 7397, 4349, 359, 1060, 12, 2867, 8808, 729, 16, 2254, 5034, 8808, 4231, 16, 2254, 5034, 3844, 16, 2254, 5034, 2176, 6275, 1769, 203, 203, 565, 3885, 12, 203, 3639, 534, 688, 49, 1580, 1345, 389, 54, 58, 6152, 16, 203, 3639, 1758, 389, 5206, 4793, 16, 203, 3639, 2254, 5034, 389, 266, 2913, 2173, 1768, 16, 203, 3639, 2254, 5034, 389, 1937, 1768, 16, 203, 3639, 2254, 5034, 389, 22314, 6282, 4436, 1768, 203, 565, 534, 688, 49, 1580, 1345, 1071, 534, 58, 6152, 31, 203, 565, 1758, 1071, 4461, 4793, 31, 203, 565, 2254, 5034, 1071, 2438, 21343, 67, 3194, 67, 11403, 31, 203, 565, 2254, 5034, 8526, 1071, 2438, 21343, 67, 24683, 2053, 654, 273, 306, 10392, 16, 8038, 16, 5178, 16, 3847, 16, 2872, 16, 1725, 16, 1059, 16, 576, 16, 404, 15533, 203, 565, 2254, 5034, 1071, 10485, 67, 11403, 31, 203, 565, 6246, 2757, 639, 774, 54, 58, 6152, 12521, 1071, 30188, 31, 203, 565, 8828, 966, 8526, 1071, 2845, 966, 31, 203, 565, 2874, 261, 11890, 5034, 516, 2874, 261, 2867, 516, 25003, 3719, 1071, 16753, 31, 203, 565, 2254, 5034, 1071, 2078, 8763, 2148, 273, 374, 31, 203, 565, 262, 1071, 288, 203, 3639, 534, 58, 6152, 273, 389, 54, 58, 6152, 31, 203, 3639, 4461, 4793, 273, 389, 5206, 4793, 31, 203, 3639, 2438, 21343, 67, 3194, 67, 11403, 273, 389, 266, 2913, 2173, 1768, 31, 203, 3639, 10485, 67, 11403, 273, 389, 1937, 1768, 31, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 2438, 21343, 67, 24683, 2053, 654, 18, 2469, 300, 404, 31, 277, 27245, 288, 203, 5411, 2254, 5034, 19514, 6282, 861, 1768, 273, 389, 22314, 6282, 4436, 1768, 18, 16411, 12, 77, 397, 404, 2934, 1289, 24899, 1937, 1768, 1769, 203, 5411, 670, 1013, 58, 1360, 67, 789, 67, 11403, 18, 6206, 12, 22314, 6282, 861, 1768, 1769, 203, 3639, 289, 203, 3639, 25768, 67, 38, 673, 3378, 67, 789, 67, 11403, 273, 389, 22314, 6282, 4436, 1768, 18, 16411, 12, 862, 21343, 67, 24683, 2053, 654, 18, 2469, 300, 404, 2934, 1289, 24899, 1937, 1768, 1769, 203, 3639, 670, 1013, 58, 1360, 67, 789, 67, 11403, 18, 6206, 12, 11890, 5034, 19236, 21, 10019, 203, 565, 289, 203, 203, 565, 262, 1071, 288, 203, 3639, 534, 58, 6152, 273, 389, 54, 58, 6152, 31, 203, 3639, 4461, 4793, 273, 389, 5206, 4793, 31, 203, 3639, 2438, 21343, 67, 3194, 67, 11403, 273, 389, 266, 2913, 2173, 1768, 31, 203, 3639, 10485, 67, 11403, 273, 389, 1937, 1768, 31, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 2438, 21343, 67, 24683, 2053, 654, 18, 2469, 300, 404, 31, 277, 27245, 288, 203, 5411, 2254, 5034, 19514, 6282, 861, 1768, 273, 389, 22314, 6282, 4436, 1768, 18, 16411, 12, 77, 397, 404, 2934, 1289, 24899, 1937, 1768, 1769, 203, 5411, 670, 1013, 58, 1360, 67, 789, 67, 11403, 18, 6206, 12, 22314, 6282, 861, 1768, 1769, 203, 3639, 289, 203, 3639, 25768, 67, 38, 673, 3378, 67, 789, 67, 11403, 273, 389, 22314, 6282, 4436, 1768, 18, 16411, 12, 862, 21343, 67, 24683, 2053, 654, 18, 2469, 300, 404, 2934, 1289, 24899, 1937, 1768, 1769, 203, 3639, 670, 1013, 58, 1360, 67, 789, 67, 11403, 18, 6206, 12, 11890, 5034, 19236, 21, 10019, 203, 565, 289, 203, 203, 565, 445, 2845, 1782, 1435, 3903, 1476, 1135, 261, 11890, 5034, 13, 288, 203, 3639, 327, 2845, 966, 18, 2469, 31, 203, 565, 289, 203, 203, 565, 445, 527, 12, 11890, 5034, 389, 9853, 2148, 16, 467, 654, 39, 3462, 389, 9953, 1345, 16, 1426, 389, 1918, 1891, 13, 1071, 1338, 5541, 288, 203, 3639, 2583, 12, 6011, 548, 21, 63, 2867, 24899, 9953, 1345, 25887, 422, 374, 16, 315, 54, 688, 49, 1580, 67, 7786, 42, 4610, 264, 2866, 1289, 30, 12423, 353, 1818, 316, 2845, 8863, 203, 3639, 309, 261, 67, 1918, 1891, 13, 288, 203, 5411, 8039, 1891, 16639, 5621, 203, 3639, 289, 203, 3639, 2254, 5034, 1142, 17631, 1060, 1768, 273, 1203, 18, 2696, 405, 10485, 67, 11403, 692, 1203, 18, 2696, 294, 10485, 67, 11403, 31, 203, 3639, 2078, 8763, 2148, 273, 2078, 8763, 2148, 18, 1289, 24899, 9853, 2148, 1769, 203, 3639, 2845, 548, 21, 63, 2867, 24899, 9953, 1345, 25887, 273, 2845, 966, 18, 2469, 397, 404, 31, 203, 3639, 2845, 966, 18, 6206, 12, 2864, 966, 12590, 203, 5411, 12423, 1345, 30, 389, 9953, 1345, 16, 203, 5411, 4767, 2148, 30, 389, 9853, 2148, 16, 203, 5411, 1142, 17631, 1060, 1768, 30, 1142, 17631, 1060, 1768, 16, 203, 5411, 4078, 54, 58, 6152, 2173, 9535, 30, 374, 203, 3639, 289, 10019, 203, 565, 289, 203, 203, 565, 445, 527, 12, 11890, 5034, 389, 9853, 2148, 16, 467, 654, 39, 3462, 389, 9953, 1345, 16, 1426, 389, 1918, 1891, 13, 1071, 1338, 5541, 288, 203, 3639, 2583, 12, 6011, 548, 21, 63, 2867, 24899, 9953, 1345, 25887, 422, 374, 16, 315, 54, 688, 49, 1580, 67, 7786, 42, 4610, 264, 2866, 1289, 30, 12423, 353, 1818, 316, 2845, 8863, 203, 3639, 309, 261, 67, 1918, 1891, 13, 288, 203, 5411, 8039, 1891, 16639, 5621, 203, 3639, 289, 203, 3639, 2254, 5034, 1142, 17631, 1060, 1768, 273, 1203, 18, 2696, 405, 10485, 67, 11403, 692, 2 ]
pragma solidity ^0.5.4; contract Account { // The implementation of the proxy address public implementation; // Logic manager address public manager; // The enabled static calls mapping (bytes4 => address) public enabled; event EnabledStaticCall(address indexed module, bytes4 indexed method); event Invoked(address indexed module, address indexed target, uint indexed value, bytes data); event Received(uint indexed value, address indexed sender, bytes data); event AccountInit(address indexed account); event ManagerChanged(address indexed mgr); modifier allowAuthorizedLogicContractsCallsOnly { require(LogicManager(manager).isAuthorized(msg.sender), "not an authorized logic"); _; } /** * @dev better to create and init account through AccountCreator.createAccount, which avoids race condition on Account.init */ function init(address _manager, address _accountStorage, address[] calldata _logics, address[] calldata _keys, address[] calldata _backups) external { require(manager == address(0), "Account: account already initialized"); require(_manager != address(0) && _accountStorage != address(0), "Account: address is null"); manager = _manager; for (uint i = 0; i < _logics.length; i++) { address logic = _logics[i]; require(LogicManager(manager).isAuthorized(logic), "must be authorized logic"); BaseLogic(logic).initAccount(this); } AccountStorage(_accountStorage).initAccount(this, _keys, _backups); emit AccountInit(address(this)); } /** * @dev Account calls an external target contract. * @param _target The target contract address. * @param _value ETH value of the call. * @param _data data of the call. */ function invoke(address _target, uint _value, bytes calldata _data) external allowAuthorizedLogicContractsCallsOnly returns (bytes memory _res) { bool success; // solium-disable-next-line security/no-call-value (success, _res) = _target.call.value(_value)(_data); require(success, "call to target failed"); emit Invoked(msg.sender, _target, _value, _data); } /** * @dev Enables a static method by specifying the target module to which the call must be delegated. * @param _module The target module. * @param _method The static method signature. */ function enableStaticCall(address _module, bytes4 _method) external allowAuthorizedLogicContractsCallsOnly { enabled[_method] = _module; emit EnabledStaticCall(_module, _method); } /** * @dev Reserved method to change account's manager. Normally it's unused. * Calling this method requires adding a new authorized logic. * @param _newMgr New logic manager. */ function changeManager(address _newMgr) external allowAuthorizedLogicContractsCallsOnly { require(_newMgr != address(0), "address cannot be null"); require(_newMgr != manager, "already changed"); manager = _newMgr; emit ManagerChanged(_newMgr); } /** * @dev This method makes it possible for the wallet to comply to interfaces expecting the wallet to * implement specific static methods. It delegates the static call to a target contract if the data corresponds * to an enabled method, or logs the call otherwise. */ function() external payable { if(msg.data.length > 0) { address logic = enabled[msg.sig]; if(logic == address(0)) { emit Received(msg.value, msg.sender, msg.data); } else { require(LogicManager(manager).isAuthorized(logic), "must be an authorized logic for static call"); // solium-disable-next-line security/no-inline-assembly assembly { calldatacopy(0, 0, calldatasize()) let result := staticcall(gas, logic, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 {revert(0, returndatasize())} default {return (0, returndatasize())} } } } } } contract Owned { // The owner address public owner; event OwnerChanged(address indexed _newOwner); /** * @dev Throws if the sender is not the owner. */ modifier onlyOwner { require(msg.sender == owner, "Must be owner"); _; } constructor() public { owner = msg.sender; } /** * @dev Lets the owner transfer ownership of the contract to a new owner. * @param _newOwner The new owner. */ function changeOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Address must not be null"); owner = _newOwner; emit OwnerChanged(_newOwner); } } contract LogicManager is Owned { event UpdateLogicSubmitted(address indexed logic, bool value); event UpdateLogicCancelled(address indexed logic); event UpdateLogicDone(address indexed logic, bool value); struct pending { bool value; //True: enable a new logic; False: disable an old logic. uint dueTime; //due time of a pending logic } // The authorized logic modules mapping (address => bool) public authorized; /* array index 0: AccountLogic address 1: TransferLogic address 2: DualsigsLogic address 3: DappLogic address 4: ... */ address[] public authorizedLogics; // updated logics and their due time of becoming effective mapping (address => pending) public pendingLogics; struct pendingTime { uint curPendingTime; //current pending time uint nextPendingTime; //new pending time uint dueTime; //due time of new pending time } pendingTime public pt; // how many authorized logics uint public logicCount; constructor(address[] memory _initialLogics, uint256 _pendingTime) public { for (uint i = 0; i < _initialLogics.length; i++) { address logic = _initialLogics[i]; authorized[logic] = true; logicCount += 1; } authorizedLogics = _initialLogics; pt.curPendingTime = _pendingTime; pt.nextPendingTime = _pendingTime; pt.dueTime = now; } /** * @dev Submit a new pending time. Called only by owner. * @param _pendingTime The new pending time. */ function submitUpdatePendingTime(uint _pendingTime) external onlyOwner { pt.nextPendingTime = _pendingTime; pt.dueTime = pt.curPendingTime + now; } /** * @dev Trigger updating pending time. */ function triggerUpdatePendingTime() external { require(pt.dueTime <= now, "too early to trigger updatePendingTime"); pt.curPendingTime = pt.nextPendingTime; } /** * @dev check if a logic contract is authorized. */ function isAuthorized(address _logic) external view returns (bool) { return authorized[_logic]; } /** * @dev get the authorized logic array. */ function getAuthorizedLogics() external view returns (address[] memory) { return authorizedLogics; } /** * @dev Submit a new logic. Called only by owner. * @param _logic The new logic contract address. * @param _value True: enable a new logic; False: disable an old logic. */ function submitUpdate(address _logic, bool _value) external onlyOwner { pending storage p = pendingLogics[_logic]; p.value = _value; p.dueTime = now + pt.curPendingTime; emit UpdateLogicSubmitted(_logic, _value); } /** * @dev Cancel a logic update. Called only by owner. */ function cancelUpdate(address _logic) external onlyOwner { delete pendingLogics[_logic]; emit UpdateLogicCancelled(_logic); } /** * @dev Trigger updating a new logic. * @param _logic The logic contract address. */ function triggerUpdateLogic(address _logic) external { pending memory p = pendingLogics[_logic]; require(p.dueTime > 0, "pending logic not found"); require(p.dueTime <= now, "too early to trigger updateLogic"); updateLogic(_logic, p.value); delete pendingLogics[_logic]; } /** * @dev To update an existing logic, for example authorizedLogics[1], * first a new logic is added to the array end, then copied to authorizedLogics[1], * then the last logic is dropped, done. */ function updateLogic(address _logic, bool _value) internal { if (authorized[_logic] != _value) { if(_value) { logicCount += 1; authorized[_logic] = true; authorizedLogics.push(_logic); } else { logicCount -= 1; require(logicCount > 0, "must have at least one logic module"); delete authorized[_logic]; removeLogic(_logic); } emit UpdateLogicDone(_logic, _value); } } function removeLogic(address _logic) internal { uint len = authorizedLogics.length; address lastLogic = authorizedLogics[len - 1]; if (_logic != lastLogic) { for (uint i = 0; i < len; i++) { if (_logic == authorizedLogics[i]) { authorizedLogics[i] = lastLogic; break; } } } authorizedLogics.length--; } } contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // /** * @dev Write account data into storage. * @param _account The Account. * @param _keys The initial keys. * @param _backups The initial backups. */ function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } } /* The MIT License (MIT) Copyright (c) 2016 Smart Contract Solutions, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } } contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @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. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * 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. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // 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. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal view { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } } //https://github.com/hamdiallam/Solidity-RLP/blob/master/contracts/RLPReader.sol library RLPReader { uint8 constant STRING_SHORT_START = 0x80; uint8 constant STRING_LONG_START = 0xb8; uint8 constant LIST_SHORT_START = 0xc0; uint8 constant LIST_LONG_START = 0xf8; uint8 constant WORD_SIZE = 32; struct RLPItem { uint len; uint memPtr; } struct Iterator { RLPItem item; // Item that's being iterated over. uint nextPtr; // Position of the next item in the list. } /* * @dev Returns the next element in the iteration. Reverts if it has not next element. * @param self The iterator. * @return The next element in the iteration. */ function next(Iterator memory self) internal pure returns (RLPItem memory) { require(hasNext(self)); uint ptr = self.nextPtr; uint itemLength = _itemLength(ptr); self.nextPtr = ptr + itemLength; return RLPItem(itemLength, ptr); } /* * @dev Returns true if the iteration has more elements. * @param self The iterator. * @return true if the iteration has more elements. */ function hasNext(Iterator memory self) internal pure returns (bool) { RLPItem memory item = self.item; return self.nextPtr < item.memPtr + item.len; } /* * @param item RLP encoded bytes */ function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) { uint memPtr; assembly { memPtr := add(item, 0x20) } return RLPItem(item.length, memPtr); } /* * @dev Create an iterator. Reverts if item is not a list. * @param self The RLP item. * @return An 'Iterator' over the item. */ function iterator(RLPItem memory self) internal pure returns (Iterator memory) { require(isList(self)); uint ptr = self.memPtr + _payloadOffset(self.memPtr); return Iterator(self, ptr); } /* * @param item RLP encoded bytes */ function rlpLen(RLPItem memory item) internal pure returns (uint) { return item.len; } /* * @param item RLP encoded bytes */ function payloadLen(RLPItem memory item) internal pure returns (uint) { return item.len - _payloadOffset(item.memPtr); } /* * @param item RLP encoded list in bytes */ function toList(RLPItem memory item) internal pure returns (RLPItem[] memory) { require(isList(item)); uint items = numItems(item); RLPItem[] memory result = new RLPItem[](items); uint memPtr = item.memPtr + _payloadOffset(item.memPtr); uint dataLen; for (uint i = 0; i < items; i++) { dataLen = _itemLength(memPtr); result[i] = RLPItem(dataLen, memPtr); memPtr = memPtr + dataLen; } return result; } // @return indicator whether encoded payload is a list. negate this function call for isData. function isList(RLPItem memory item) internal pure returns (bool) { if (item.len == 0) return false; uint8 byte0; uint memPtr = item.memPtr; assembly { byte0 := byte(0, mload(memPtr)) } if (byte0 < LIST_SHORT_START) return false; return true; } /** RLPItem conversions into data types **/ // @returns raw rlp encoding in bytes function toRlpBytes(RLPItem memory item) internal pure returns (bytes memory) { bytes memory result = new bytes(item.len); if (result.length == 0) return result; uint ptr; assembly { ptr := add(0x20, result) } copy(item.memPtr, ptr, item.len); return result; } // any non-zero byte is considered true function toBoolean(RLPItem memory item) internal pure returns (bool) { require(item.len == 1); uint result; uint memPtr = item.memPtr; assembly { result := byte(0, mload(memPtr)) } return result == 0 ? false : true; } function toAddress(RLPItem memory item) internal pure returns (address) { // 1 byte for the length prefix require(item.len == 21); return address(toUint(item)); } function toUint(RLPItem memory item) internal pure returns (uint) { require(item.len > 0 && item.len <= 33); uint offset = _payloadOffset(item.memPtr); uint len = item.len - offset; uint result; uint memPtr = item.memPtr + offset; assembly { result := mload(memPtr) // shfit to the correct location if neccesary if lt(len, 32) { result := div(result, exp(256, sub(32, len))) } } return result; } // enforces 32 byte length function toUintStrict(RLPItem memory item) internal pure returns (uint) { // one byte prefix require(item.len == 33); uint result; uint memPtr = item.memPtr + 1; assembly { result := mload(memPtr) } return result; } function toBytes(RLPItem memory item) internal pure returns (bytes memory) { require(item.len > 0); uint offset = _payloadOffset(item.memPtr); uint len = item.len - offset; // data length bytes memory result = new bytes(len); uint destPtr; assembly { destPtr := add(0x20, result) } copy(item.memPtr + offset, destPtr, len); return result; } /* * Private Helpers */ // @return number of payload items inside an encoded list. function numItems(RLPItem memory item) private pure returns (uint) { if (item.len == 0) return 0; uint count = 0; uint currPtr = item.memPtr + _payloadOffset(item.memPtr); uint endPtr = item.memPtr + item.len; while (currPtr < endPtr) { currPtr = currPtr + _itemLength(currPtr); // skip over an item count++; } return count; } // @return entire rlp item byte length function _itemLength(uint memPtr) private pure returns (uint) { uint itemLen; uint byte0; assembly { byte0 := byte(0, mload(memPtr)) } if (byte0 < STRING_SHORT_START) itemLen = 1; else if (byte0 < STRING_LONG_START) itemLen = byte0 - STRING_SHORT_START + 1; else if (byte0 < LIST_SHORT_START) { assembly { let byteLen := sub(byte0, 0xb7) // # of bytes the actual length is memPtr := add(memPtr, 1) // skip over the first byte /* 32 byte word size */ let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to get the len itemLen := add(dataLen, add(byteLen, 1)) } } else if (byte0 < LIST_LONG_START) { itemLen = byte0 - LIST_SHORT_START + 1; } else { assembly { let byteLen := sub(byte0, 0xf7) memPtr := add(memPtr, 1) let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to the correct length itemLen := add(dataLen, add(byteLen, 1)) } } return itemLen; } // @return number of bytes until the data function _payloadOffset(uint memPtr) private pure returns (uint) { uint byte0; assembly { byte0 := byte(0, mload(memPtr)) } if (byte0 < STRING_SHORT_START) return 0; else if (byte0 < STRING_LONG_START || (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)) return 1; else if (byte0 < LIST_SHORT_START) // being explicit return byte0 - (STRING_LONG_START - 1) + 1; else return byte0 - (LIST_LONG_START - 1) + 1; } /* * @param src Pointer to source * @param dest Pointer to destination * @param len Amount of memory to copy from the source */ function copy(uint src, uint dest, uint len) private pure { if (len == 0) return; // copy as many word sizes as possible for (; len >= WORD_SIZE; len -= WORD_SIZE) { assembly { mstore(dest, mload(src)) } src += WORD_SIZE; dest += WORD_SIZE; } // left over bytes. Mask is used to remove unwanted bytes from the word uint mask = 256 ** (WORD_SIZE - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) // zero out src let destpart := and(mload(dest), mask) // retrieve the bytes mstore(dest, or(destpart, srcpart)) } } } contract DappLogic is BaseLogic { using RLPReader for RLPReader.RLPItem; using RLPReader for bytes; /* index 0: admin key 1: asset(transfer) 2: adding 3: reserved(dapp) 4: assist */ uint constant internal DAPP_KEY_INDEX = 3; // *************** Events *************************** // event DappLogicEntered(bytes data, uint256 indexed nonce); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) BaseLogic(_accountStorage) public { } // *************** action entry ********************* // /** * @dev Entry method of DappLogic. * DappLogic has 2 actions called from 'enter': callContract, callMultiContract */ function enter(bytes calldata _data, bytes calldata _signature, uint256 _nonce) external { address account = getSignerAddress(_data); checkKeyStatus(account, DAPP_KEY_INDEX); address dappKey = accountStorage.getKeyData(account, DAPP_KEY_INDEX); checkAndUpdateNonce(dappKey, _nonce); bytes32 signHash = getSignHash(_data, _nonce); verifySig(dappKey, _signature, signHash); // solium-disable-next-line security/no-low-level-calls (bool success,) = address(this).call(_data); require(success, "calling self failed"); emit DappLogicEntered(_data, _nonce); } // *************** call Dapp ********************* // // called from 'enter' // call other contract from base account function callContract(address payable _account, address payable _target, uint256 _value, bytes calldata _methodData) external allowSelfCallsOnly { bool success; // solium-disable-next-line security/no-low-level-calls (success,) = _account.call(abi.encodeWithSignature("invoke(address,uint256,bytes)", _target, _value, _methodData)); require(success, "calling invoke failed"); } // called from 'enter' // call serveral other contracts at a time // 'bytes[]' not supported, therefore an array of _methodData is rlp encoded into rlpBytes function callMultiContract(address payable _account, address[] calldata _targets, uint256[] calldata _values, bytes calldata _rlpBytes) external allowSelfCallsOnly { RLPReader.RLPItem[] memory ls = _rlpBytes.toRlpItem().toList(); uint256 len = _targets.length; require(len == _values.length && len == ls.length, "length mismatch"); for (uint256 i = 0; i < len; i++) { bool success; RLPReader.RLPItem memory item = ls[i]; // solium-disable-next-line security/no-low-level-calls (success,) = _account.call(abi.encodeWithSignature("invoke(address,uint256,bytes)", _targets[i], _values[i], bytes(item.toBytes()))); require(success, "calling invoke failed"); } } }
updated logics and their due time of becoming effective
mapping (address => pending) public pendingLogics;
1,517,174
[ 1, 4625, 348, 7953, 560, 30, 225, 3526, 613, 2102, 471, 3675, 6541, 813, 434, 506, 5522, 11448, 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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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 ]
[ 1, 565, 2874, 261, 2867, 516, 4634, 13, 1071, 4634, 1343, 2102, 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 ]
./full_match/44787/0x279AD96a13998dE7E6511f6F5AB9bD358b1453Ca/sources/NewWill.sol
Array of Fammily wallets
address payable [] famWallets;
13,253,965
[ 1, 4625, 348, 7953, 560, 30, 225, 1510, 434, 478, 301, 81, 3220, 17662, 2413, 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,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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 ]
[ 1, 565, 1758, 8843, 429, 5378, 26688, 26558, 2413, 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 ]
//Compiler version pragma solidity ^0.4.23; //Import cryptohandler library import { CryptoHandler } from "./libraries/CryptoHandler.sol"; //Internal contract expirable to define the live cycle of a channel contract Expirable { uint256 public channelEnd; constructor (uint256 _daysToExpire) internal { channelEnd = now + (_daysToExpire * 1 days); } //Modifiers for the live cycle of a channel modifier hasNotExpired() { require(now <= channelEnd); _; } modifier hasNotSettle() { require(now <= (channelEnd + 1 days)); _; } modifier inSettlementPeriod() { require(now > channelEnd && now <= (channelEnd + 1 days)); _; } modifier hasSettled() { require(now > (channelEnd + 1 days)); _; } } //Internal contract multiownable to define the two owners of a channel contract Multiownable { address[2] public owners; constructor (address[2] _owners) internal { owners = _owners; } //Get the other owner of the channel for verifying operations function getOtherOwner(address _owner) internal view returns (address){ if(_owner == owners[0]) return owners[1]; else if (_owner == owners[1]) return owners[0]; return 0x0; } //Modifiers for the owners of the channel modifier onlyOwners(){ require(msg.sender == owners[0] || msg.sender == owners[1]); _; } modifier onlyFarEnd(){ require(msg.sender == owners[1]); _; } } //Internal contract modifiers to define modifiers and events of the channel related with closed,accepted and disputed situations contract Modifiers { // Channel accepted, close request and close events event channelAccepted(uint256 farEndValue, uint256 totalValue); event closeRequest(address indexed end, bool closeChange); event channelClosed(address indexed NearEnd, uint256 nearEndFinalValue, address indexed FarEnd, uint256 farEndFinalValue, uint256 finalId); bool public closed; bool public accepted; mapping(address => bool) public disputed; //Modifiers related with closed, accepted and disputed situations modifier notClosed() { require(!closed); _; } modifier isAccepted() { require(accepted); _; } modifier notAccepted(){ require(!accepted); _; } modifier notDisputed(){ require(disputed[msg.sender] == false); _; } } //Channel contract inheriting from the previous internal contracts contract ChannelFinal is Multiownable, Expirable, Modifiers { //Channels events for state update, random shown and dispute accepted situations event stateUpdated(address indexed sender, uint256 senderValue, address indexed uploader, uint256 uploaderValue, uint256 currentId); event disputeAccepted(address indexed end, uint256 currentId); event rsShownAndUsed(bytes32[] randomS, bytes32[] random); //Limit number of hash locked transactions on an update or a dispute uint16 constant public limit = 251; struct State { mapping(address=> uint256) values; uint256 id; } State state; uint256 public channelValue; mapping(address => bool) public requestedClose; //Functions relate with token transfers follow the conditions -> effects -> interaction //in order to avoid security leaks and double-spend problems //Create a channel selfexplanatory constructor (address _nearEnd, address _farEnd, uint256 _daysOpen) Multiownable([_nearEnd, _farEnd]) Expirable(_daysOpen) public payable { state.values[_nearEnd] = msg.value; channelValue = msg.value; } //Accept channel, selfexplanatory function acceptChannel() public payable onlyFarEnd notAccepted hasNotExpired { accepted = true; state.values[msg.sender] = msg.value; channelValue += msg.value; emit channelAccepted(msg.value, channelValue); } //Update state of the channel calls handle state and emits and event function updateState( address[2] _end_chann, uint256[2] _values_id, uint8 _v, bytes32[2] _r_s, bytes32[] _rsSigned, bytes32[] _rs, bytes32[] _hs, uint256[] _ttls, uint256[] _rhValues, uint8[] _end ) public onlyOwners isAccepted notClosed hasNotExpired { handleState(_end_chann, _values_id, _v, _r_s, _rsSigned, _rs, _hs, _ttls, _rhValues, _end); emit stateUpdated(msg.sender, state.values[msg.sender], _end_chann[0], state.values[getOtherOwner(msg.sender)], state.id); } //Dispute state of the channel, practically equal to update state but set disputed to true (just in settlement period) function disputeState( address[2] _end_chann, uint256[2] _values_id, uint8 _v, bytes32[2] _r_s, bytes32[] _rsSigned, bytes32[] _rs, bytes32[] _hs, uint256[] _ttls, uint256[] _rhValues, uint8[] _end ) public onlyOwners isAccepted notClosed inSettlementPeriod notDisputed { handleState(_end_chann, _values_id, _v, _r_s, _rsSigned, _rs, _hs, _ttls, _rhValues, _end); disputed[msg.sender] = true; emit disputeAccepted(msg.sender, state.id); } //Handle an state update, requires a well-build update including hash and signature, consistency in the parameters //Updates the parameters and calls checkRHashesInH function handleState( address[2] _end_chann, uint256[2] _values_id, uint8 _v, bytes32[2] _r_s, bytes32[] _rsSigned, bytes32[] _rs, bytes32[] _hs, uint256[] _ttls, uint256[] _rhValues, uint8[] _end ) internal { require( _end_chann[0] == getOtherOwner(msg.sender) && _end_chann[1] == address(this) && _values_id[0] <= channelValue && _values_id[1] > state.id && uint8(_hs.length) < limit ); bytes32 msgHash; if(_rsSigned.length > 0) msgHash = keccak256(_values_id, _end_chann, _rsSigned, _hs, _ttls, _rhValues, _end); else if(_hs.length > 0) msgHash = keccak256(_values_id, _end_chann, _hs, _ttls, _rhValues, _end); else msgHash = keccak256(_values_id, _end_chann); require(CryptoHandler.verifySignature(_end_chann[0], CryptoHandler.prefixSignHash(msgHash), _v, _r_s)); state.id = _values_id[1]; state.values[_end_chann[0]] = _values_id[0]; state.values[msg.sender] = channelValue - _values_id[0]; if(_hs.length > 0) checkRsHashesInHs(_rsSigned, _rs, _hs, _ttls, _rhValues, _end); } //Check for each R in a hash locked transaction if the time to live is still valid and if it hashed in H //Updates the state and emits the R shown function checkRsHashesInHs( bytes32[] _rsSigned, bytes32[] _rs, bytes32[] _hs, uint256[] _ttls, uint256[] _rhValues, uint8[] _end ) internal { uint256 near; uint256 far; uint8 i = 0; for(i; i < _rsSigned.length; i++) { if(_rsSigned[i] != 0x0 && now <= _ttls[i] && CryptoHandler.verifyHash(_rsSigned[i], _hs[i])) { if(_end[i] == 0) near += _rhValues[i]; else far += _rhValues[i]; } } for(uint8 j = i; j < (i + _rs.length); j++) { if(_rs[j-i] != 0x0 && now <= _ttls[j] && CryptoHandler.verifyHash(_rs[j-i], _hs[j])) { if(_end[j] == 0) near += _rhValues[j]; else far += _rhValues[j]; } } uint values; address higherAddrs; if(near >= far) { values = near - far; higherAddrs = owners[0]; } else { values = far - near; higherAddrs = owners[1]; } if(values > 0) { require(uint(values) <= state.values[higherAddrs]); state.values[higherAddrs] -= uint(values); state.values[getOtherOwner(higherAddrs)] += uint(values); emit rsShownAndUsed(_rsSigned, _rs); } } //Request a close of the channel, if both parties agree in the closing then the channel closes and unlocks the funds function closeChannel(bool _close) public onlyOwners isAccepted notClosed hasNotSettle { if(_close && requestedClose[getOtherOwner(msg.sender)]) { closed = true; emit channelClosed(owners[0], state.values[owners[0]], owners[1], state.values[owners[1]], state.id); if (state.values[owners[0]] > 0) { owners[0].transfer(state.values[owners[0]]); state.values[owners[0]] = 0; } if (state.values[owners[1]] > 0) { owners[1].transfer(state.values[owners[1]]); state.values[owners[1]] = 0; } } else { requestedClose[msg.sender] = _close; emit closeRequest(msg.sender, _close); } } //Unlocks the funds once the channel is settled function unlockFunds() public onlyOwners notClosed hasSettled { closed = true; emit channelClosed(owners[0], state.values[owners[0]], owners[1], state.values[owners[1]], state.id); if (state.values[owners[0]] > 0) { owners[0].transfer(state.values[owners[0]]); state.values[owners[0]] = 0; } if (state.values[owners[1]] > 0) { owners[1].transfer(state.values[owners[1]]); state.values[owners[1]] = 0; } } //Public functions to retrieve each owner value and the state id function getStateNear() public view returns (uint256 val) { return state.values[owners[0]]; } function getStateFar() public view returns (uint256 val) { return state.values[owners[1]]; } function getStateId() public view returns (uint256 val) { return state.id; } } //Factory of channels, smart contract deployed in a known address and main component of the Seths Network on the Blockchain contract Factory{ //Factory event for a new channel event channelProcessed(address indexed ContractAddrs, address indexed NearEnd, address indexed FarEnd, uint256 channelVal, uint256 endDate); //Public payable function to create a channel with a _farEnd to remain open for _daysOpen function createChannel(address _farEnd, uint _daysOpen) public payable { ChannelFinal channel = (new ChannelFinal).value(msg.value)(msg.sender, _farEnd, _daysOpen); emit channelProcessed(channel, msg.sender, _farEnd, channel.channelValue(), channel.channelEnd()); } }
Check for each R in a hash locked transaction if the time to live is still valid and if it hashed in HUpdates the state and emits the R shown
function checkRsHashesInHs( bytes32[] _rsSigned, bytes32[] _rs, bytes32[] _hs, uint256[] _ttls, uint256[] _rhValues, uint8[] _end ) internal { uint256 near; uint256 far; uint8 i = 0; for(i; i < _rsSigned.length; i++) { if(_rsSigned[i] != 0x0 && now <= _ttls[i] && CryptoHandler.verifyHash(_rsSigned[i], _hs[i])) { if(_end[i] == 0) near += _rhValues[i]; else far += _rhValues[i]; } } for(uint8 j = i; j < (i + _rs.length); j++) { if(_rs[j-i] != 0x0 && now <= _ttls[j] && CryptoHandler.verifyHash(_rs[j-i], _hs[j])) { if(_end[j] == 0) near += _rhValues[j]; else far += _rhValues[j]; } } uint values; address higherAddrs; if(near >= far) { values = near - far; higherAddrs = owners[0]; values = far - near; higherAddrs = owners[1]; } if(values > 0) { require(uint(values) <= state.values[higherAddrs]); state.values[higherAddrs] -= uint(values); state.values[getOtherOwner(higherAddrs)] += uint(values); emit rsShownAndUsed(_rsSigned, _rs); } }
5,416,510
[ 1, 4625, 348, 7953, 560, 30, 2073, 364, 1517, 534, 316, 279, 1651, 8586, 2492, 309, 326, 813, 358, 8429, 353, 4859, 923, 471, 309, 518, 14242, 316, 670, 5121, 326, 919, 471, 24169, 326, 534, 12188, 2, 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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2254, 28, 8526, 389, 409, 203, 3639, 262, 2713, 288, 203, 540, 203, 3639, 2254, 5034, 13378, 31, 203, 3639, 2254, 5034, 10247, 31, 203, 3639, 2254, 28, 277, 273, 374, 31, 203, 203, 3639, 364, 12, 77, 31, 277, 411, 389, 5453, 12294, 18, 2469, 31, 277, 27245, 288, 203, 5411, 309, 24899, 5453, 12294, 63, 77, 65, 480, 374, 92, 20, 597, 2037, 1648, 389, 748, 3251, 63, 77, 65, 597, 15629, 1503, 18, 8705, 2310, 24899, 5453, 12294, 63, 77, 6487, 389, 4487, 63, 77, 22643, 288, 203, 7734, 309, 24899, 409, 63, 77, 65, 422, 374, 13, 203, 10792, 13378, 1011, 389, 30138, 1972, 63, 77, 15533, 203, 7734, 469, 203, 10792, 10247, 1011, 389, 30138, 1972, 63, 77, 15533, 203, 5411, 289, 203, 3639, 289, 203, 203, 3639, 364, 12, 11890, 28, 525, 273, 277, 31, 525, 411, 261, 77, 397, 389, 5453, 18, 2469, 1769, 525, 27245, 288, 203, 5411, 309, 24899, 5453, 63, 78, 17, 77, 65, 480, 374, 92, 20, 597, 2037, 1648, 389, 748, 3251, 63, 78, 65, 597, 15629, 1503, 18, 8705, 2310, 24899, 5453, 63, 78, 17, 77, 6487, 389, 4487, 63, 78, 22643, 288, 203, 7734, 309, 24899, 409, 63, 78, 65, 422, 374, 13, 203, 10792, 13378, 1011, 389, 30138, 1972, 63, 78, 15533, 203, 7734, 469, 203, 10792, 10247, 1011, 389, 30138, 1972, 63, 78, 15533, 203, 5411, 289, 203, 3639, 289, 203, 203, 3639, 2254, 924, 31, 203, 3639, 1758, 10478, 13811, 31, 203, 203, 3639, 309, 12, 27862, 1545, 10247, 13, 288, 203, 5411, 924, 273, 13378, 300, 10247, 31, 203, 5411, 10478, 13811, 273, 25937, 63, 20, 15533, 203, 5411, 924, 273, 10247, 300, 13378, 31, 203, 5411, 10478, 13811, 273, 25937, 63, 21, 15533, 203, 3639, 289, 203, 203, 3639, 309, 12, 2372, 405, 374, 13, 288, 203, 203, 5411, 2583, 12, 11890, 12, 2372, 13, 1648, 919, 18, 2372, 63, 76, 9421, 13811, 19226, 203, 203, 5411, 919, 18, 2372, 63, 76, 9421, 13811, 65, 3947, 2254, 12, 2372, 1769, 203, 5411, 919, 18, 2372, 63, 588, 8290, 5541, 12, 76, 9421, 13811, 25887, 1011, 2254, 12, 2372, 1769, 203, 203, 5411, 3626, 3597, 27042, 1876, 6668, 24899, 5453, 12294, 16, 389, 5453, 1769, 203, 203, 3639, 289, 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 ]
pragma solidity 0.4.24; import "../lib/AddressArray.sol"; import "../common/ReservedAddrPublic.sol"; /// @title Group contract /// @author ["Cryptape Technologies <[email protected]>"] /// @notice The address: Created by permissionCreator /// The interface can be called: Only query type contract Group is ReservedAddrPublic { bytes32 name; address parent; address[] accounts; address[] children; event GroupNewed( address indexed _parent, bytes32 indexed _name, address[] _accounts ); event AccountsAdded(address[] _accounts); event AccountsDeleted(address[] _accounts); event NameUpdated(bytes32 indexed _oldName, bytes32 indexed _newName); event ChildDeleted(address indexed _child); event ChildAdded(address indexed _child); modifier onlyUserManagement { require(userManagementAddr == msg.sender, "permission denied."); _; } /// @notice Constructor constructor(address _parent, bytes32 _name, address[] _accounts) public { parent = _parent; name = _name; accounts = _accounts; emit GroupNewed(_parent, _name, _accounts); } /// @notice Add accounts /// @param _accounts The accounts to be added /// @return True if successed, otherwise false function addAccounts(address[] _accounts) public onlyUserManagement returns (bool) { for (uint i = 0; i<_accounts.length; i++) { if (!AddressArray.exist(_accounts[i], accounts)) accounts.push(_accounts[i]); } emit AccountsAdded(_accounts); return true; } /// @notice Delete accounts /// @param _accounts The accounts to be deleted /// @return True if successed, otherwise false function deleteAccounts(address[] _accounts) public onlyUserManagement returns (bool) { require(_accounts.length < accounts.length, "deleteAccounts failed."); for (uint i = 0; i < _accounts.length; i++) assert(AddressArray.remove(_accounts[i], accounts)); emit AccountsDeleted(_accounts); return true; } /// @notice Update group name /// @param _name The new name to be updated /// @return True if successed, otherwise false function updateName(bytes32 _name) public onlyUserManagement returns (bool) { emit NameUpdated(name, _name); name = _name; return true; } /// @notice Delete a child group /// @param _child The child group to be deleted /// @return True if successed, otherwise false function deleteChild(address _child) public onlyUserManagement returns (bool) { assert(AddressArray.remove(_child, children)); emit ChildDeleted(_child); return true; } /// @notice Add a child group /// @param _child The child group to be added /// @return True if successed, otherwise false function addChild(address _child) public onlyUserManagement returns (bool) { if (!AddressArray.exist(_child, children)) children.push(_child); emit ChildAdded(_child); return true; } /// @notice Destruct self /// @return True if successed, otherwise false function close() public onlyUserManagement { selfdestruct(msg.sender); } /// @notice Query the information of the group /// @dev TODO Include the children group /// @return Name and accounts of group function queryInfo() public view returns (bytes32, address[]) { return (name, accounts); } /// @notice Query the name of the group /// @return The name of group function queryName() public view returns (bytes32) { return name; } /// @notice Query the accounts of the group /// @return The accounts of group function queryAccounts() public view returns (address[]) { return accounts; } /// @notice Query the child of the group /// @dev TODO Rename queryChildren /// @return The children of group function queryChild() public view returns (address[]) { return children; } /// @notice Query the length of children of the group /// @return The number of the children group function queryChildLength() public view returns (uint) { return children.length; } /// @notice Query the parent of the group /// @return The parent of the group function queryParent() public view returns (address) { return parent; } /// @notice Check the account in the group /// @return Ture if the account in the group, otherwise false function inGroup(address _account) public view returns (bool) { return AddressArray.exist(_account, accounts); } }
@notice Update group name @param _name The new name to be updated @return True if successed, otherwise false
function updateName(bytes32 _name) public onlyUserManagement returns (bool) { emit NameUpdated(name, _name); name = _name; return true; }
12,888,399
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 20392, 2315, 1041, 508, 632, 891, 389, 529, 225, 1021, 394, 508, 358, 506, 3526, 632, 2463, 1053, 309, 8667, 3692, 16, 3541, 629, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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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 ]
[ 1, 565, 445, 1089, 461, 12, 3890, 1578, 389, 529, 13, 203, 3639, 1071, 203, 3639, 1338, 1299, 10998, 203, 3639, 1135, 261, 6430, 13, 203, 565, 288, 203, 3639, 3626, 1770, 7381, 12, 529, 16, 389, 529, 1769, 203, 3639, 508, 273, 389, 529, 31, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.10; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IAmp { function registerCollateralManager() external; } /** * @title Ownable is a contract the provides contract ownership functionality, including a two- * phase transfer. */ contract Ownable { address private _owner; address private _authorizedNewOwner; /** * @notice Emitted when the owner authorizes ownership transfer to a new address * @param authorizedAddress New owner address */ event OwnershipTransferAuthorization(address indexed authorizedAddress); /** * @notice Emitted when the authorized address assumed ownership * @param oldValue Old owner * @param newValue New owner */ event OwnerUpdate(address indexed oldValue, address indexed newValue); /** * @notice Sets the owner to the sender / contract creator */ constructor() internal { _owner = msg.sender; } /** * @notice Retrieves the owner of the contract * @return The contract owner */ function owner() public view returns (address) { return _owner; } /** * @notice Retrieves the authorized new owner of the contract * @return The authorized new contract owner */ function authorizedNewOwner() public view returns (address) { return _authorizedNewOwner; } /** * @notice Authorizes the transfer of ownership from owner to the provided address. * NOTE: No transfer will occur unless authorizedAddress calls assumeOwnership(). * This authorization may be removed by another call to this function authorizing the zero * address. * @param _authorizedAddress The address authorized to become the new owner */ function authorizeOwnershipTransfer(address _authorizedAddress) external { require(msg.sender == _owner, "Invalid sender"); _authorizedNewOwner = _authorizedAddress; emit OwnershipTransferAuthorization(_authorizedNewOwner); } /** * @notice Transfers ownership of this contract to the _authorizedNewOwner * @dev Error invalid sender. */ function assumeOwnership() external { require(msg.sender == _authorizedNewOwner, "Invalid sender"); address oldValue = _owner; _owner = _authorizedNewOwner; _authorizedNewOwner = address(0); emit OwnerUpdate(oldValue, _owner); } } abstract contract ERC1820Registry { function setInterfaceImplementer( address _addr, bytes32 _interfaceHash, address _implementer ) external virtual; function getInterfaceImplementer(address _addr, bytes32 _interfaceHash) external virtual view returns (address); function setManager(address _addr, address _newManager) external virtual; function getManager(address _addr) public virtual view returns (address); } /// Base client to interact with the registry. contract ERC1820Client { ERC1820Registry constant ERC1820REGISTRY = ERC1820Registry( 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 ); function setInterfaceImplementation( string memory _interfaceLabel, address _implementation ) internal { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); ERC1820REGISTRY.setInterfaceImplementer( address(this), interfaceHash, _implementation ); } function interfaceAddr(address addr, string memory _interfaceLabel) internal view returns (address) { bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel)); return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash); } function delegateManagement(address _newManager) internal { ERC1820REGISTRY.setManager(address(this), _newManager); } } /** * @title IAmpTokensRecipient * @dev IAmpTokensRecipient token transfer hook interface */ interface IAmpTokensRecipient { /** * @dev Report if the recipient will successfully receive the tokens */ function canReceive( bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData ) external view returns (bool); /** * @dev Hook executed upon a transfer to the recipient */ function tokensReceived( bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData ) external; } /** * @title IAmpTokensSender * @dev IAmpTokensSender token transfer hook interface */ interface IAmpTokensSender { /** * @dev Report if the transfer will succeed from the pespective of the * token sender */ function canTransfer( bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData ) external view returns (bool); /** * @dev Hook executed upon a transfer on behalf of the sender */ function tokensToTransfer( bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData ) external; } /** * @title PartitionUtils * @notice Partition related helper functions. */ library PartitionUtils { bytes32 public constant CHANGE_PARTITION_FLAG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /** * @notice Retrieve the destination partition from the 'data' field. * A partition change is requested ONLY when 'data' starts with the flag: * * 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff * * When the flag is detected, the destination partition is extracted from the * 32 bytes following the flag. * @param _data Information attached to the transfer. Will contain the * destination partition if a change is requested. * @param _fallbackPartition Partition value to return if a partition change * is not requested in the `_data`. * @return toPartition Destination partition. If the `_data` does not contain * the prefix and bytes32 partition in the first 64 bytes, the method will * return the provided `_fromPartition`. */ function _getDestinationPartition(bytes memory _data, bytes32 _fallbackPartition) internal pure returns (bytes32) { if (_data.length < 64) { return _fallbackPartition; } (bytes32 flag, bytes32 toPartition) = abi.decode(_data, (bytes32, bytes32)); if (flag == CHANGE_PARTITION_FLAG) { return toPartition; } return _fallbackPartition; } /** * @notice Helper to get the strategy identifying prefix from the `_partition`. * @param _partition Partition to get the prefix for. * @return 4 byte partition strategy prefix. */ function _getPartitionPrefix(bytes32 _partition) internal pure returns (bytes4) { return bytes4(_partition); } /** * @notice Helper method to split the partition into the prefix, sub partition * and partition owner components. * @param _partition The partition to split into parts. * @return The 4 byte partition prefix, 8 byte sub partition, and final 20 * bytes representing an address. */ function _splitPartition(bytes32 _partition) internal pure returns ( bytes4, bytes8, address ) { bytes4 prefix = bytes4(_partition); bytes8 subPartition = bytes8(_partition << 32); address addressPart = address(uint160(uint256(_partition))); return (prefix, subPartition, addressPart); } /** * @notice Helper method to get a partition strategy ERC1820 interface name * based on partition prefix. * @param _prefix 4 byte partition prefix. * @dev Each 4 byte prefix has a unique interface name so that an individual * hook implementation can be set for each prefix. */ function _getPartitionStrategyValidatorIName(bytes4 _prefix) internal pure returns (string memory) { return string(abi.encodePacked("AmpPartitionStrategyValidator", _prefix)); } } /** * @title FlexaCollateralManager is an implementation of IAmpTokensSender and IAmpTokensRecipient * which serves as the Amp collateral manager for the Flexa Network. */ contract FlexaCollateralManager is Ownable, IAmpTokensSender, IAmpTokensRecipient, ERC1820Client { /** * @dev AmpTokensSender interface label. */ string internal constant AMP_TOKENS_SENDER = "AmpTokensSender"; /** * @dev AmpTokensRecipient interface label. */ string internal constant AMP_TOKENS_RECIPIENT = "AmpTokensRecipient"; /** * @dev Change Partition Flag used in transfer data parameters to signal which partition * will receive the tokens. */ bytes32 internal constant CHANGE_PARTITION_FLAG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /** * @dev Required prefix for all registered partitions. Used to ensure the Collateral Pool * Partition Validator is used within Amp. */ bytes4 internal constant PARTITION_PREFIX = 0xCCCCCCCC; /********************************************************************************************** * Operator Data Flags *********************************************************************************************/ /** * @dev Flag used in operator data parameters to indicate the transfer is a withdrawal */ bytes32 internal constant WITHDRAWAL_FLAG = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /** * @dev Flag used in operator data parameters to indicate the transfer is a fallback * withdrawal */ bytes32 internal constant FALLBACK_WITHDRAWAL_FLAG = 0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; /** * @dev Flag used in operator data parameters to indicate the transfer is a supply refund */ bytes32 internal constant REFUND_FLAG = 0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc; /** * @dev Flag used in operator data parameters to indicate the transfer is a direct transfer */ bytes32 internal constant DIRECT_TRANSFER_FLAG = 0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd; /********************************************************************************************** * Configuration *********************************************************************************************/ /** * @notice Address of the Amp contract. Immutable. */ address public amp; /** * @notice Permitted partitions */ mapping(bytes32 => bool) public partitions; /********************************************************************************************** * Roles *********************************************************************************************/ /** * @notice Address authorized to publish withdrawal roots */ address public withdrawalPublisher; /** * @notice Address authorized to publish fallback withdrawal roots */ address public fallbackPublisher; /** * @notice Address authorized to adjust the withdrawal limit */ address public withdrawalLimitPublisher; /** * @notice Address authorized to directly transfer tokens */ address public directTransferer; /** * @notice Address authorized to manage permitted partition */ address public partitionManager; /** * @notice Struct used to record received tokens that can be recovered during the fallback * withdrawal period * @param supplier Token supplier * @param partition Partition which received the tokens * @param amount Number of tokens received */ struct Supply { address supplier; bytes32 partition; uint256 amount; } /********************************************************************************************** * Supply State *********************************************************************************************/ /** * @notice Supply nonce used to track incoming token transfers */ uint256 public supplyNonce = 0; /** * @notice Mapping of all incoming token transfers */ mapping(uint256 => Supply) public nonceToSupply; /********************************************************************************************** * Withdrawal State *********************************************************************************************/ /** * @notice Remaining withdrawal limit. Initially set to 100,000 Amp. */ uint256 public withdrawalLimit = 100 * 1000 * (10**18); /** * @notice Withdrawal maximum root nonce */ uint256 public maxWithdrawalRootNonce = 0; /** * @notice Active set of withdrawal roots */ mapping(bytes32 => uint256) public withdrawalRootToNonce; /** * @notice Last invoked withdrawal root for each account, per partition */ mapping(bytes32 => mapping(address => uint256)) public addressToWithdrawalNonce; /** * @notice Total amount withdrawn for each account, per partition */ mapping(bytes32 => mapping(address => uint256)) public addressToCumulativeAmountWithdrawn; /********************************************************************************************** * Fallback Withdrawal State *********************************************************************************************/ /** * @notice Withdrawal fallback delay. Initially set to one week. */ uint256 public fallbackWithdrawalDelaySeconds = 1 weeks; /** * @notice Current fallback withdrawal root */ bytes32 public fallbackRoot; /** * @notice Timestamp of when the last fallback root was published */ uint256 public fallbackSetDate = 2**200; // very far in the future /** * @notice Latest supply reflected in the fallback withdrawal authorization tree */ uint256 public fallbackMaxIncludedSupplyNonce = 0; /********************************************************************************************** * Supplier Events *********************************************************************************************/ /** * @notice Indicates a token supply has been received * @param supplier Token supplier * @param amount Number of tokens transferred * @param nonce Nonce of the supply */ event SupplyReceipt( address indexed supplier, bytes32 indexed partition, uint256 amount, uint256 indexed nonce ); /** * @notice Indicates that a withdrawal was executed * @param supplier Address whose withdrawal authorization was executed * @param partition Partition from which the tokens were transferred * @param amount Amount of tokens transferred * @param rootNonce Nonce of the withdrawal root used for authorization * @param authorizedAccountNonce Maximum previous nonce used by the account */ event Withdrawal( address indexed supplier, bytes32 indexed partition, uint256 amount, uint256 indexed rootNonce, uint256 authorizedAccountNonce ); /** * @notice Indicates a fallback withdrawal was executed * @param supplier Address whose fallback withdrawal authorization was executed * @param partition Partition from which the tokens were transferred * @param amount Amount of tokens transferred */ event FallbackWithdrawal( address indexed supplier, bytes32 indexed partition, uint256 indexed amount ); /** * @notice Indicates a release of supply is requested * @param supplier Token supplier * @param partition Parition from which the tokens should be released * @param amount Number of tokens requested to be released * @param data Metadata provided by the requestor */ event ReleaseRequest( address indexed supplier, bytes32 indexed partition, uint256 indexed amount, bytes data ); /** * @notice Indicates a supply refund was executed * @param supplier Address whose refund authorization was executed * @param partition Partition from which the tokens were transferred * @param amount Amount of tokens transferred * @param nonce Nonce of the original supply */ event SupplyRefund( address indexed supplier, bytes32 indexed partition, uint256 amount, uint256 indexed nonce ); /********************************************************************************************** * Direct Transfer Events *********************************************************************************************/ /** * @notice Emitted when tokens are directly transfered * @param operator Address that executed the direct transfer * @param from_partition Partition from which the tokens were transferred * @param to_address Address to which the tokens were transferred * @param to_partition Partition to which the tokens were transferred * @param value Amount of tokens transferred */ event DirectTransfer( address operator, bytes32 indexed from_partition, address indexed to_address, bytes32 indexed to_partition, uint256 value ); /********************************************************************************************** * Admin Configuration Events *********************************************************************************************/ /** * @notice Emitted when a partition is permitted for supply * @param partition Partition added to the permitted set */ event PartitionAdded(bytes32 indexed partition); /** * @notice Emitted when a partition is removed from the set permitted for supply * @param partition Partition removed from the permitted set */ event PartitionRemoved(bytes32 indexed partition); /********************************************************************************************** * Admin Withdrawal Management Events *********************************************************************************************/ /** * @notice Emitted when a new withdrawal root hash is added to the active set * @param rootHash Merkle root hash. * @param nonce Nonce of the Merkle root hash. */ event WithdrawalRootHashAddition(bytes32 indexed rootHash, uint256 indexed nonce); /** * @notice Emitted when a withdrawal root hash is removed from the active set * @param rootHash Merkle root hash. * @param nonce Nonce of the Merkle root hash. */ event WithdrawalRootHashRemoval(bytes32 indexed rootHash, uint256 indexed nonce); /** * @notice Emitted when the withdrawal limit is updated * @param oldValue Old limit. * @param newValue New limit. */ event WithdrawalLimitUpdate(uint256 indexed oldValue, uint256 indexed newValue); /********************************************************************************************** * Admin Fallback Management Events *********************************************************************************************/ /** * @notice Emitted when a new fallback withdrawal root hash is set * @param rootHash Merkle root hash * @param maxSupplyNonceIncluded Nonce of the last supply reflected in the tree data * @param setDate Timestamp of when the root hash was set */ event FallbackRootHashSet( bytes32 indexed rootHash, uint256 indexed maxSupplyNonceIncluded, uint256 setDate ); /** * @notice Emitted when the fallback root hash set date is reset * @param newDate Timestamp of when the fallback reset date was set */ event FallbackMechanismDateReset(uint256 indexed newDate); /** * @notice Emitted when the fallback delay is updated * @param oldValue Old delay * @param newValue New delay */ event FallbackWithdrawalDelayUpdate(uint256 indexed oldValue, uint256 indexed newValue); /********************************************************************************************** * Role Management Events *********************************************************************************************/ /** * @notice Emitted when the Withdrawal Publisher is updated * @param oldValue Old publisher * @param newValue New publisher */ event WithdrawalPublisherUpdate(address indexed oldValue, address indexed newValue); /** * @notice Emitted when the Fallback Publisher is updated * @param oldValue Old publisher * @param newValue New publisher */ event FallbackPublisherUpdate(address indexed oldValue, address indexed newValue); /** * @notice Emitted when Withdrawal Limit Publisher is updated * @param oldValue Old publisher * @param newValue New publisher */ event WithdrawalLimitPublisherUpdate(address indexed oldValue, address indexed newValue); /** * @notice Emitted when the DirectTransferer address is updated * @param oldValue Old DirectTransferer address * @param newValue New DirectTransferer address */ event DirectTransfererUpdate(address indexed oldValue, address indexed newValue); /** * @notice Emitted when the Partition Manager address is updated * @param oldValue Old Partition Manager address * @param newValue New Partition Manager address */ event PartitionManagerUpdate(address indexed oldValue, address indexed newValue); /********************************************************************************************** * Constructor *********************************************************************************************/ /** * @notice FlexaCollateralManager constructor * @param _amp Address of the Amp token contract */ constructor(address _amp) public { amp = _amp; ERC1820Client.setInterfaceImplementation(AMP_TOKENS_RECIPIENT, address(this)); ERC1820Client.setInterfaceImplementation(AMP_TOKENS_SENDER, address(this)); IAmp(amp).registerCollateralManager(); } /********************************************************************************************** * IAmpTokensRecipient Hooks *********************************************************************************************/ /** * @notice Validates where the supplied parameters are valid for a transfer of tokens to this * contract * @dev Implements IAmpTokensRecipient * @param _partition Partition from which the tokens were transferred * @param _to The destination address of the tokens. Must be this. * @param _data Optional data sent with the transfer. Used to set the destination partition. * @return true if the tokens can be received, otherwise false */ function canReceive( bytes4, /* functionSig */ bytes32 _partition, address, /* operator */ address, /* from */ address _to, uint256, /* value */ bytes calldata _data, bytes calldata /* operatorData */ ) external override view returns (bool) { if (msg.sender != amp || _to != address(this)) { return false; } bytes32 _destinationPartition = PartitionUtils._getDestinationPartition(_data, _partition); return partitions[_destinationPartition]; } /** * @notice Function called by the token contract after executing a transfer. * @dev Implements IAmpTokensRecipient * @param _partition Partition from which the tokens were transferred * @param _operator Address which triggered the transfer. This address will be credited with * the supply. * @param _to The destination address of the tokens. Must be this. * @param _value Number of tokens the token holder balance is decreased by. * @param _data Optional data sent with the transfer. Used to set the destination partition. */ function tokensReceived( bytes4, /* functionSig */ bytes32 _partition, address _operator, address, /* from */ address _to, uint256 _value, bytes calldata _data, bytes calldata /* operatorData */ ) external override { require(msg.sender == amp, "Invalid sender"); require(_to == address(this), "Invalid to address"); bytes32 _destinationPartition = PartitionUtils._getDestinationPartition(_data, _partition); require(partitions[_destinationPartition], "Invalid destination partition"); supplyNonce = SafeMath.add(supplyNonce, 1); nonceToSupply[supplyNonce].supplier = _operator; nonceToSupply[supplyNonce].partition = _destinationPartition; nonceToSupply[supplyNonce].amount = _value; emit SupplyReceipt(_operator, _destinationPartition, _value, supplyNonce); } /********************************************************************************************** * IAmpTokensSender Hooks *********************************************************************************************/ /** * @notice Validates where the supplied parameters are valid for a transfer of tokens from this * contract * @dev Implements IAmpTokensSender * @param _partition Source partition of the tokens * @param _operator Address which triggered the transfer * @param _from The source address of the tokens. Must be this. * @param _value Amount of tokens to be transferred * @param _operatorData Extra information attached by the operator. Must include the transfer * operation flag and additional authorization data custom for each transfer operation type. * @return true if the token transfer would succeed, otherwise false */ function canTransfer( bytes4, /*functionSig*/ bytes32 _partition, address _operator, address _from, address, /* to */ uint256 _value, bytes calldata, /* data */ bytes calldata _operatorData ) external override view returns (bool) { if (msg.sender != amp || _from != address(this)) { return false; } bytes32 flag = _decodeOperatorDataFlag(_operatorData); if (flag == WITHDRAWAL_FLAG) { return _validateWithdrawal(_partition, _operator, _value, _operatorData); } if (flag == FALLBACK_WITHDRAWAL_FLAG) { return _validateFallbackWithdrawal(_partition, _operator, _value, _operatorData); } if (flag == REFUND_FLAG) { return _validateRefund(_partition, _operator, _value, _operatorData); } if (flag == DIRECT_TRANSFER_FLAG) { return _validateDirectTransfer(_operator, _value); } return false; } /** * @notice Function called by the token contract when executing a transfer * @dev Implements IAmpTokensSender * @param _partition Source partition of the tokens * @param _operator Address which triggered the transfer * @param _from The source address of the tokens. Must be this. * @param _to The target address of the tokens. * @param _value Amount of tokens to be transferred * @param _data Data attached to the transfer. Typically includes partition change information. * @param _operatorData Extra information attached by the operator. Must include the transfer * operation flag and additional authorization data custom for each transfer operation type. */ function tokensToTransfer( bytes4, /* functionSig */ bytes32 _partition, address _operator, address _from, address _to, uint256 _value, bytes calldata _data, bytes calldata _operatorData ) external override { require(msg.sender == amp, "Invalid sender"); require(_from == address(this), "Invalid from address"); bytes32 flag = _decodeOperatorDataFlag(_operatorData); if (flag == WITHDRAWAL_FLAG) { _executeWithdrawal(_partition, _operator, _value, _operatorData); } else if (flag == FALLBACK_WITHDRAWAL_FLAG) { _executeFallbackWithdrawal(_partition, _operator, _value, _operatorData); } else if (flag == REFUND_FLAG) { _executeRefund(_partition, _operator, _value, _operatorData); } else if (flag == DIRECT_TRANSFER_FLAG) { _executeDirectTransfer(_partition, _operator, _to, _value, _data); } else { revert("invalid flag"); } } /********************************************************************************************** * Withdrawals *********************************************************************************************/ /** * @notice Validates withdrawal data * @param _partition Source partition of the withdrawal * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the withdrawal authorization data * @return true if the withdrawal data is valid, otherwise false */ function _validateWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal view returns (bool) { ( address supplier, uint256 maxAuthorizedAccountNonce, uint256 withdrawalRootNonce ) = _getWithdrawalData(_partition, _value, _operatorData); return _validateWithdrawalData( _partition, _operator, _value, supplier, maxAuthorizedAccountNonce, withdrawalRootNonce ); } /** * @notice Validates the withdrawal data and updates state to reflect the transfer * @param _partition Source partition of the withdrawal * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the withdrawal authorization data */ function _executeWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal { ( address supplier, uint256 maxAuthorizedAccountNonce, uint256 withdrawalRootNonce ) = _getWithdrawalData(_partition, _value, _operatorData); require( _validateWithdrawalData( _partition, _operator, _value, supplier, maxAuthorizedAccountNonce, withdrawalRootNonce ), "Transfer unauthorized" ); addressToCumulativeAmountWithdrawn[_partition][supplier] = SafeMath.add( _value, addressToCumulativeAmountWithdrawn[_partition][supplier] ); addressToWithdrawalNonce[_partition][supplier] = withdrawalRootNonce; withdrawalLimit = SafeMath.sub(withdrawalLimit, _value); emit Withdrawal( supplier, _partition, _value, withdrawalRootNonce, maxAuthorizedAccountNonce ); } /** * @notice Extracts withdrawal data from the supplied parameters * @param _partition Source partition of the withdrawal * @param _value Number of tokens to be transferred * @param _operatorData Contains the withdrawal authorization data, including the withdrawal * operation flag, supplier, maximum authorized account nonce, and Merkle proof. * @return supplier, the address whose account is authorized * @return maxAuthorizedAccountNonce, the maximum existing used withdrawal nonce for the * supplier and partition * @return withdrawalRootNonce, the active withdrawal root nonce found based on the supplied * data and Merkle proof */ function _getWithdrawalData( bytes32 _partition, uint256 _value, bytes memory _operatorData ) internal view returns ( address, /* supplier */ uint256, /* maxAuthorizedAccountNonce */ uint256 /* withdrawalRootNonce */ ) { ( address supplier, uint256 maxAuthorizedAccountNonce, bytes32[] memory merkleProof ) = _decodeWithdrawalOperatorData(_operatorData); bytes32 leafDataHash = _calculateWithdrawalLeaf( supplier, _partition, _value, maxAuthorizedAccountNonce ); bytes32 calculatedRoot = _calculateMerkleRoot(merkleProof, leafDataHash); uint256 withdrawalRootNonce = withdrawalRootToNonce[calculatedRoot]; return (supplier, maxAuthorizedAccountNonce, withdrawalRootNonce); } /** * @notice Validates that the parameters are valid for the requested withdrawal * @param _partition Source partition of the tokens * @param _operator Address that is executing the withdrawal * @param _value Number of tokens to be transferred * @param _supplier The address whose account is authorized * @param _maxAuthorizedAccountNonce The maximum existing used withdrawal nonce for the * supplier and partition * @param _withdrawalRootNonce The active withdrawal root nonce found based on the supplied * data and Merkle proof * @return true if the withdrawal data is valid, otherwise false */ function _validateWithdrawalData( bytes32 _partition, address _operator, uint256 _value, address _supplier, uint256 _maxAuthorizedAccountNonce, uint256 _withdrawalRootNonce ) internal view returns (bool) { return // Only owner, withdrawal publisher or supplier can invoke withdrawals (_operator == owner() || _operator == withdrawalPublisher || _operator == _supplier) && // Ensure maxAuthorizedAccountNonce has not been exceeded (addressToWithdrawalNonce[_partition][_supplier] <= _maxAuthorizedAccountNonce) && // Ensure we are within the global withdrawal limit (_value <= withdrawalLimit) && // Merkle tree proof is valid (_withdrawalRootNonce > 0) && // Ensure the withdrawal root is more recent than the maxAuthorizedAccountNonce (_withdrawalRootNonce > _maxAuthorizedAccountNonce); } /********************************************************************************************** * Fallback Withdrawals *********************************************************************************************/ /** * @notice Validates fallback withdrawal data * @param _partition Source partition of the withdrawal * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the fallback withdrawal authorization data * @return true if the fallback withdrawal data is valid, otherwise false */ function _validateFallbackWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal view returns (bool) { ( address supplier, uint256 maxCumulativeWithdrawalAmount, uint256 newCumulativeWithdrawalAmount, bytes32 calculatedRoot ) = _getFallbackWithdrawalData(_partition, _value, _operatorData); return _validateFallbackWithdrawalData( _operator, maxCumulativeWithdrawalAmount, newCumulativeWithdrawalAmount, supplier, calculatedRoot ); } /** * @notice Validates the fallback withdrawal data and updates state to reflect the transfer * @param _partition Source partition of the withdrawal * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the fallback withdrawal authorization data */ function _executeFallbackWithdrawal( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal { ( address supplier, uint256 maxCumulativeWithdrawalAmount, uint256 newCumulativeWithdrawalAmount, bytes32 calculatedRoot ) = _getFallbackWithdrawalData(_partition, _value, _operatorData); require( _validateFallbackWithdrawalData( _operator, maxCumulativeWithdrawalAmount, newCumulativeWithdrawalAmount, supplier, calculatedRoot ), "Transfer unauthorized" ); addressToCumulativeAmountWithdrawn[_partition][supplier] = newCumulativeWithdrawalAmount; addressToWithdrawalNonce[_partition][supplier] = maxWithdrawalRootNonce; emit FallbackWithdrawal(supplier, _partition, _value); } /** * @notice Extracts withdrawal data from the supplied parameters * @param _partition Source partition of the withdrawal * @param _value Number of tokens to be transferred * @param _operatorData Contains the fallback withdrawal authorization data, including the * fallback withdrawal operation flag, supplier, max cumulative withdrawal amount, and Merkle * proof. * @return supplier, the address whose account is authorized * @return maxCumulativeWithdrawalAmount, the maximum amount of tokens that can be withdrawn * for the supplier's account, including both withdrawals and fallback withdrawals * @return newCumulativeWithdrawalAmount, the new total of all withdrawals include the * current request * @return calculatedRoot, the Merkle tree root calculated based on the supplied data and proof */ function _getFallbackWithdrawalData( bytes32 _partition, uint256 _value, bytes memory _operatorData ) internal view returns ( address, /* supplier */ uint256, /* maxCumulativeWithdrawalAmount */ uint256, /* newCumulativeWithdrawalAmount */ bytes32 /* calculatedRoot */ ) { ( address supplier, uint256 maxCumulativeWithdrawalAmount, bytes32[] memory merkleProof ) = _decodeWithdrawalOperatorData(_operatorData); uint256 newCumulativeWithdrawalAmount = SafeMath.add( _value, addressToCumulativeAmountWithdrawn[_partition][supplier] ); bytes32 leafDataHash = _calculateFallbackLeaf( supplier, _partition, maxCumulativeWithdrawalAmount ); bytes32 calculatedRoot = _calculateMerkleRoot(merkleProof, leafDataHash); return ( supplier, maxCumulativeWithdrawalAmount, newCumulativeWithdrawalAmount, calculatedRoot ); } /** * @notice Validates that the parameters are valid for the requested fallback withdrawal * @param _operator Address that is executing the withdrawal * @param _maxCumulativeWithdrawalAmount, the maximum amount of tokens that can be withdrawn * for the supplier's account, including both withdrawals and fallback withdrawals * @param _newCumulativeWithdrawalAmount, the new total of all withdrawals include the * current request * @param _supplier The address whose account is authorized * @param _calculatedRoot The Merkle tree root calculated based on the supplied data and proof * @return true if the fallback withdrawal data is valid, otherwise false */ function _validateFallbackWithdrawalData( address _operator, uint256 _maxCumulativeWithdrawalAmount, uint256 _newCumulativeWithdrawalAmount, address _supplier, bytes32 _calculatedRoot ) internal view returns (bool) { return // Only owner or supplier can invoke the fallback withdrawal (_operator == owner() || _operator == _supplier) && // Ensure we have entered fallback mode (SafeMath.add(fallbackSetDate, fallbackWithdrawalDelaySeconds) <= block.timestamp) && // Check that the maximum allowable withdrawal for the supplier has not been exceeded (_newCumulativeWithdrawalAmount <= _maxCumulativeWithdrawalAmount) && // Merkle tree proof is valid (fallbackRoot == _calculatedRoot); } /********************************************************************************************** * Supply Refunds *********************************************************************************************/ /** * @notice Validates refund data * @param _partition Source partition of the refund * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the refund authorization data * @return true if the refund data is valid, otherwise false */ function _validateRefund( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal view returns (bool) { (uint256 _supplyNonce, Supply memory supply) = _getRefundData(_operatorData); return _verifyRefundData(_partition, _operator, _value, _supplyNonce, supply); } /** * @notice Validates the refund data and updates state to reflect the transfer * @param _partition Source partition of the refund * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @param _operatorData Contains the refund authorization data */ function _executeRefund( bytes32 _partition, address _operator, uint256 _value, bytes memory _operatorData ) internal { (uint256 nonce, Supply memory supply) = _getRefundData(_operatorData); require( _verifyRefundData(_partition, _operator, _value, nonce, supply), "Transfer unauthorized" ); delete nonceToSupply[nonce]; emit SupplyRefund(supply.supplier, _partition, supply.amount, nonce); } /** * @notice Extracts refund data from the supplied parameters * @param _operatorData Contains the refund authorization data, including the refund * operation flag and supply nonce. * @return supplyNonce, nonce of the recorded supply * @return supply, The supplier, partition and amount of tokens in the original supply */ function _getRefundData(bytes memory _operatorData) internal view returns (uint256, Supply memory) { uint256 _supplyNonce = _decodeRefundOperatorData(_operatorData); Supply memory supply = nonceToSupply[_supplyNonce]; return (_supplyNonce, supply); } /** * @notice Validates that the parameters are valid for the requested refund * @param _partition Source partition of the tokens * @param _operator Address that is executing the refund * @param _value Number of tokens to be transferred * @param _supplyNonce nonce of the recorded supply * @param _supply The supplier, partition and amount of tokens in the original supply * @return true if the refund data is valid, otherwise false */ function _verifyRefundData( bytes32 _partition, address _operator, uint256 _value, uint256 _supplyNonce, Supply memory _supply ) internal view returns (bool) { return // Supply record exists (_supply.amount > 0) && // Only owner or supplier can invoke the refund (_operator == owner() || _operator == _supply.supplier) && // Requested partition matches the Supply record (_partition == _supply.partition) && // Requested value matches the Supply record (_value == _supply.amount) && // Ensure we have entered fallback mode (SafeMath.add(fallbackSetDate, fallbackWithdrawalDelaySeconds) <= block.timestamp) && // Supply has not already been included in the fallback withdrawal data (_supplyNonce > fallbackMaxIncludedSupplyNonce); } /********************************************************************************************** * Direct Transfers *********************************************************************************************/ /** * @notice Validates direct transfer data * @param _operator Address that is invoking the transfer * @param _value Number of tokens to be transferred * @return true if the direct transfer data is valid, otherwise false */ function _validateDirectTransfer(address _operator, uint256 _value) internal view returns (bool) { return // Only owner and directTransferer can invoke withdrawals (_operator == owner() || _operator == directTransferer) && // Ensure we are within the global withdrawal limit (_value <= withdrawalLimit); } /** * @notice Validates the direct transfer data and updates state to reflect the transfer * @param _partition Source partition of the direct transfer * @param _operator Address that is invoking the transfer * @param _to The target address of the tokens. * @param _value Number of tokens to be transferred * @param _data Data attached to the transfer. Typically includes partition change information. */ function _executeDirectTransfer( bytes32 _partition, address _operator, address _to, uint256 _value, bytes memory _data ) internal { require(_validateDirectTransfer(_operator, _value), "Transfer unauthorized"); withdrawalLimit = SafeMath.sub(withdrawalLimit, _value); bytes32 to_partition = PartitionUtils._getDestinationPartition(_data, _partition); emit DirectTransfer(_operator, _partition, _to, to_partition, _value); } /********************************************************************************************** * Release Request *********************************************************************************************/ /** * @notice Emits a release request event that can be used to trigger the release of tokens * @param _partition Parition from which the tokens should be released * @param _amount Number of tokens requested to be released * @param _data Metadata to include with the release request */ function requestRelease( bytes32 _partition, uint256 _amount, bytes memory _data ) external { emit ReleaseRequest(msg.sender, _partition, _amount, _data); } /********************************************************************************************** * Partition Management *********************************************************************************************/ /** * @notice Adds a partition to the set allowed to receive tokens * @param _partition Parition to be permitted for incoming transfers */ function addPartition(bytes32 _partition) external { require(msg.sender == owner() || msg.sender == partitionManager, "Invalid sender"); require(partitions[_partition] == false, "Partition already permitted"); (bytes4 prefix, , address partitionOwner) = PartitionUtils._splitPartition(_partition); require(prefix == PARTITION_PREFIX, "Invalid partition prefix"); require(partitionOwner == address(this), "Invalid partition owner"); partitions[_partition] = true; emit PartitionAdded(_partition); } /** * @notice Removes a partition from the set allowed to receive tokens * @param _partition Parition to be disallowed from incoming transfers */ function removePartition(bytes32 _partition) external { require(msg.sender == owner() || msg.sender == partitionManager, "Invalid sender"); require(partitions[_partition], "Partition not permitted"); delete partitions[_partition]; emit PartitionRemoved(_partition); } /********************************************************************************************** * Withdrawal Management *********************************************************************************************/ /** * @notice Modifies the withdrawal limit by the provided amount. * @param _amount Limit delta */ function modifyWithdrawalLimit(int256 _amount) external { require(msg.sender == owner() || msg.sender == withdrawalLimitPublisher, "Invalid sender"); uint256 oldLimit = withdrawalLimit; if (_amount < 0) { uint256 unsignedAmount = uint256(-_amount); withdrawalLimit = SafeMath.sub(withdrawalLimit, unsignedAmount); } else { uint256 unsignedAmount = uint256(_amount); withdrawalLimit = SafeMath.add(withdrawalLimit, unsignedAmount); } emit WithdrawalLimitUpdate(oldLimit, withdrawalLimit); } /** * @notice Adds the root hash of a Merkle tree containing authorized token withdrawals to the * active set * @param _root The root hash to be added to the active set * @param _nonce The nonce of the new root hash. Must be exactly one higher than the existing * max nonce. * @param _replacedRoots The root hashes to be removed from the repository. */ function addWithdrawalRoot( bytes32 _root, uint256 _nonce, bytes32[] calldata _replacedRoots ) external { require(msg.sender == owner() || msg.sender == withdrawalPublisher, "Invalid sender"); require(_root != 0, "Invalid root"); require(maxWithdrawalRootNonce + 1 == _nonce, "Nonce not current max plus one"); require(withdrawalRootToNonce[_root] == 0, "Nonce already used"); withdrawalRootToNonce[_root] = _nonce; maxWithdrawalRootNonce = _nonce; emit WithdrawalRootHashAddition(_root, _nonce); for (uint256 i = 0; i < _replacedRoots.length; i++) { deleteWithdrawalRoot(_replacedRoots[i]); } } /** * @notice Removes withdrawal root hashes from active set * @param _roots The root hashes to be removed from the active set */ function removeWithdrawalRoots(bytes32[] calldata _roots) external { require(msg.sender == owner() || msg.sender == withdrawalPublisher, "Invalid sender"); for (uint256 i = 0; i < _roots.length; i++) { deleteWithdrawalRoot(_roots[i]); } } /** * @notice Removes a withdrawal root hash from active set * @param _root The root hash to be removed from the active set */ function deleteWithdrawalRoot(bytes32 _root) private { uint256 nonce = withdrawalRootToNonce[_root]; require(nonce > 0, "Root not found"); delete withdrawalRootToNonce[_root]; emit WithdrawalRootHashRemoval(_root, nonce); } /********************************************************************************************** * Fallback Management *********************************************************************************************/ /** * @notice Sets the root hash of the Merkle tree containing fallback * withdrawal authorizations. * @param _root The root hash of a Merkle tree containing the fallback withdrawal * authorizations * @param _maxSupplyNonce The nonce of the latest supply whose value is reflected in the * fallback withdrawal authorizations. */ function setFallbackRoot(bytes32 _root, uint256 _maxSupplyNonce) external { require(msg.sender == owner() || msg.sender == fallbackPublisher, "Invalid sender"); require(_root != 0, "Invalid root"); require( SafeMath.add(fallbackSetDate, fallbackWithdrawalDelaySeconds) > block.timestamp, "Fallback is active" ); require( _maxSupplyNonce >= fallbackMaxIncludedSupplyNonce, "Included supply nonce decreased" ); require(_maxSupplyNonce <= supplyNonce, "Included supply nonce exceeds latest supply"); fallbackRoot = _root; fallbackMaxIncludedSupplyNonce = _maxSupplyNonce; fallbackSetDate = block.timestamp; emit FallbackRootHashSet(_root, fallbackMaxIncludedSupplyNonce, block.timestamp); } /** * @notice Resets the fallback set date to the current block's timestamp. This can be used to * delay the start of the fallback period without publishing a new root, or to deactivate the * fallback mechanism so a new fallback root may be published. */ function resetFallbackMechanismDate() external { require(msg.sender == owner() || msg.sender == fallbackPublisher, "Invalid sender"); fallbackSetDate = block.timestamp; emit FallbackMechanismDateReset(fallbackSetDate); } /** * @notice Updates the time-lock period before the fallback mechanism is activated after the * last fallback root was published. * @param _newFallbackDelaySeconds The new delay period in seconds */ function setFallbackWithdrawalDelay(uint256 _newFallbackDelaySeconds) external { require(msg.sender == owner(), "Invalid sender"); require(_newFallbackDelaySeconds != 0, "Invalid zero delay seconds"); require(_newFallbackDelaySeconds < 10 * 365 days, "Invalid delay over 10 years"); uint256 oldDelay = fallbackWithdrawalDelaySeconds; fallbackWithdrawalDelaySeconds = _newFallbackDelaySeconds; emit FallbackWithdrawalDelayUpdate(oldDelay, _newFallbackDelaySeconds); } /********************************************************************************************** * Role Management *********************************************************************************************/ /** * @notice Updates the Withdrawal Publisher address, the only address other than the owner that * can publish / remove withdrawal Merkle tree roots. * @param _newWithdrawalPublisher The address of the new Withdrawal Publisher * @dev Error invalid sender. */ function setWithdrawalPublisher(address _newWithdrawalPublisher) external { require(msg.sender == owner(), "Invalid sender"); address oldValue = withdrawalPublisher; withdrawalPublisher = _newWithdrawalPublisher; emit WithdrawalPublisherUpdate(oldValue, withdrawalPublisher); } /** * @notice Updates the Fallback Publisher address, the only address other than the owner that * can publish / remove fallback withdrawal Merkle tree roots. * @param _newFallbackPublisher The address of the new Fallback Publisher * @dev Error invalid sender. */ function setFallbackPublisher(address _newFallbackPublisher) external { require(msg.sender == owner(), "Invalid sender"); address oldValue = fallbackPublisher; fallbackPublisher = _newFallbackPublisher; emit FallbackPublisherUpdate(oldValue, fallbackPublisher); } /** * @notice Updates the Withdrawal Limit Publisher address, the only address other than the * owner that can set the withdrawal limit. * @param _newWithdrawalLimitPublisher The address of the new Withdrawal Limit Publisher * @dev Error invalid sender. */ function setWithdrawalLimitPublisher(address _newWithdrawalLimitPublisher) external { require(msg.sender == owner(), "Invalid sender"); address oldValue = withdrawalLimitPublisher; withdrawalLimitPublisher = _newWithdrawalLimitPublisher; emit WithdrawalLimitPublisherUpdate(oldValue, withdrawalLimitPublisher); } /** * @notice Updates the DirectTransferer address, the only address other than the owner that * can execute direct transfers * @param _newDirectTransferer The address of the new DirectTransferer */ function setDirectTransferer(address _newDirectTransferer) external { require(msg.sender == owner(), "Invalid sender"); address oldValue = directTransferer; directTransferer = _newDirectTransferer; emit DirectTransfererUpdate(oldValue, directTransferer); } /** * @notice Updates the Partition Manager address, the only address other than the owner that * can add and remove permitted partitions * @param _newPartitionManager The address of the new PartitionManager */ function setPartitionManager(address _newPartitionManager) external { require(msg.sender == owner(), "Invalid sender"); address oldValue = partitionManager; partitionManager = _newPartitionManager; emit PartitionManagerUpdate(oldValue, partitionManager); } /********************************************************************************************** * Operator Data Decoders *********************************************************************************************/ /** * @notice Extract flag from operatorData * @param _operatorData The operator data to be decoded * @return flag, the transfer operation type */ function _decodeOperatorDataFlag(bytes memory _operatorData) internal pure returns (bytes32) { return abi.decode(_operatorData, (bytes32)); } /** * @notice Extracts the supplier, max authorized nonce, and Merkle proof from the operator data * @param _operatorData The operator data to be decoded * @return supplier, the address whose account is authorized * @return For withdrawals: max authorized nonce, the last used withdrawal root nonce for the * supplier and partition. For fallback withdrawals: max cumulative withdrawal amount, the * maximum amount of tokens that can be withdrawn for the supplier's account, including both * withdrawals and fallback withdrawals * @return proof, the Merkle proof to be used for the authorization */ function _decodeWithdrawalOperatorData(bytes memory _operatorData) internal pure returns ( address, uint256, bytes32[] memory ) { (, address supplier, uint256 nonce, bytes32[] memory proof) = abi.decode( _operatorData, (bytes32, address, uint256, bytes32[]) ); return (supplier, nonce, proof); } /** * @notice Extracts the supply nonce from the operator data * @param _operatorData The operator data to be decoded * @return nonce, the nonce of the supply to be refunded */ function _decodeRefundOperatorData(bytes memory _operatorData) internal pure returns (uint256) { (, uint256 nonce) = abi.decode(_operatorData, (bytes32, uint256)); return nonce; } /********************************************************************************************** * Merkle Tree Verification *********************************************************************************************/ /** * @notice Hashes the supplied data and returns the hash to be used in conjunction with a proof * to calculate the Merkle tree root * @param _supplier The address whose account is authorized * @param _partition Source partition of the tokens * @param _value Number of tokens to be transferred * @param _maxAuthorizedAccountNonce The maximum existing used withdrawal nonce for the * supplier and partition * @return leaf, the hash of the supplied data */ function _calculateWithdrawalLeaf( address _supplier, bytes32 _partition, uint256 _value, uint256 _maxAuthorizedAccountNonce ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_supplier, _partition, _value, _maxAuthorizedAccountNonce)); } /** * @notice Hashes the supplied data and returns the hash to be used in conjunction with a proof * to calculate the Merkle tree root * @param _supplier The address whose account is authorized * @param _partition Source partition of the tokens * @param _maxCumulativeWithdrawalAmount, the maximum amount of tokens that can be withdrawn * for the supplier's account, including both withdrawals and fallback withdrawals * @return leaf, the hash of the supplied data */ function _calculateFallbackLeaf( address _supplier, bytes32 _partition, uint256 _maxCumulativeWithdrawalAmount ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_supplier, _partition, _maxCumulativeWithdrawalAmount)); } /** * @notice Calculates the Merkle root for the unique Merkle tree described by the provided Merkle proof and leaf hash. * @param _merkleProof The sibling node hashes at each level of the tree. * @param _leafHash The hash of the leaf data for which merkleProof is an inclusion proof. * @return The calculated Merkle root. */ function _calculateMerkleRoot(bytes32[] memory _merkleProof, bytes32 _leafHash) private pure returns (bytes32) { bytes32 computedHash = _leafHash; for (uint256 i = 0; i < _merkleProof.length; i++) { bytes32 proofElement = _merkleProof[i]; if (computedHash < proofElement) { computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } }
* @notice Hashes the supplied data and returns the hash to be used in conjunction with a proof to calculate the Merkle tree root @param _supplier The address whose account is authorized @param _partition Source partition of the tokens @param _value Number of tokens to be transferred @param _maxAuthorizedAccountNonce The maximum existing used withdrawal nonce for the supplier and partition @return leaf, the hash of the supplied data/
function _calculateWithdrawalLeaf( address _supplier, bytes32 _partition, uint256 _value, uint256 _maxAuthorizedAccountNonce ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_supplier, _partition, _value, _maxAuthorizedAccountNonce)); }
6,532,359
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 2474, 281, 326, 4580, 501, 471, 1135, 326, 1651, 358, 506, 1399, 316, 20998, 598, 279, 14601, 358, 4604, 326, 31827, 2151, 1365, 632, 891, 389, 2859, 5742, 1021, 1758, 8272, 2236, 353, 10799, 632, 891, 389, 10534, 4998, 3590, 434, 326, 2430, 632, 891, 389, 1132, 3588, 434, 2430, 358, 506, 906, 4193, 632, 891, 389, 1896, 15341, 3032, 13611, 1021, 4207, 2062, 1399, 598, 9446, 287, 7448, 364, 326, 17402, 471, 3590, 632, 2463, 7839, 16, 326, 1651, 434, 326, 4580, 501, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 389, 11162, 1190, 9446, 287, 9858, 12, 203, 3639, 1758, 389, 2859, 5742, 16, 203, 3639, 1731, 1578, 389, 10534, 16, 203, 3639, 2254, 5034, 389, 1132, 16, 203, 3639, 2254, 5034, 389, 1896, 15341, 3032, 13611, 203, 565, 262, 2713, 16618, 1135, 261, 3890, 1578, 13, 288, 203, 3639, 327, 203, 5411, 417, 24410, 581, 5034, 12, 21457, 18, 3015, 4420, 329, 24899, 2859, 5742, 16, 389, 10534, 16, 389, 1132, 16, 389, 1896, 15341, 3032, 13611, 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 ]
./full_match/137/0x1e3fCa63502a7AaA6841788301Eae4AC67CF691D/sources/scripts/Learning_Projects/CheeseTouch.sol
* @dev Approve `to` to operate on `tokenId` Emits a {Approval} event./
function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(CheeseTouch.ownerOf(tokenId), to, tokenId); }
4,755,549
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 1716, 685, 537, 1375, 869, 68, 358, 20829, 603, 1375, 2316, 548, 68, 7377, 1282, 279, 288, 23461, 97, 871, 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, 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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 ]
[ 1, 565, 445, 389, 12908, 537, 12, 2867, 358, 16, 2254, 5034, 1147, 548, 13, 2713, 5024, 288, 203, 3639, 389, 2316, 12053, 4524, 63, 2316, 548, 65, 273, 358, 31, 203, 3639, 3626, 1716, 685, 1125, 12, 39, 580, 3392, 10491, 18, 8443, 951, 12, 2316, 548, 3631, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x610142Acd45672894bE44fB9C14376101Ec4Dc16/sources/contracts/hedgie_sales.sol
console.log("inside mint_approved_old"); console.log("mint free",info.mint_free); console.log("prices",amount, info.eth_price, number_of_items); console.log("mint ",number_of_items); console.log("max_purchase",info.max_mint); console.log("before split",address(this).balance,amount); console.log("after split",address(this).balance,amount);
function mint_approved_old(bytes calldata userData) external payable { vData memory info; uint256 amount = msg.value; address from = msg.sender; uint256 number_of_items; require(userData.length == 257, "Invalid user data"); info.from = from; uint256 mint_free = uint256(bytes32(userData[160:192])); info.mint_free = mint_free != 0; require(verify(info), "Unauthorised access secret"); require(block.timestamp > info.start, "sale period not started"); require(block.timestamp < info.end, "sale period over"); require( info.eth_price > 0 || info.mint_free, "presale minting not available" ); number_of_items = amount / info.eth_price; require( number_of_items * info.eth_price == amount, "incorrect ETH sent" ); uint256 _presold = presold[from]; require( (_presold < info.max_mint), "You have already minted your allowance" ); require( _presold + number_of_items <= info.max_mint, "you have reached your presale limit" ); _mintCards(number_of_items, from); _split(amount); emit ETHPresale(from, number_of_items, info.eth_price); }
8,416,200
[ 1, 4625, 348, 7953, 560, 30, 225, 2983, 18, 1330, 2932, 28091, 312, 474, 67, 25990, 67, 1673, 8863, 565, 2983, 18, 1330, 2932, 81, 474, 4843, 3113, 1376, 18, 81, 474, 67, 9156, 1769, 377, 2983, 18, 1330, 2932, 683, 1242, 3113, 8949, 16, 1123, 18, 546, 67, 8694, 16, 1300, 67, 792, 67, 3319, 1769, 377, 2983, 18, 1330, 2932, 81, 474, 3104, 2696, 67, 792, 67, 3319, 1769, 377, 2983, 18, 1330, 2932, 1896, 67, 12688, 12104, 3113, 1376, 18, 1896, 67, 81, 474, 1769, 565, 2983, 18, 1330, 2932, 5771, 1416, 3113, 2867, 12, 2211, 2934, 12296, 16, 8949, 1769, 225, 2983, 18, 1330, 2932, 5205, 1416, 3113, 2867, 12, 2211, 2934, 12296, 16, 8949, 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,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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 ]
[ 1, 565, 445, 312, 474, 67, 25990, 67, 1673, 12, 3890, 745, 892, 13530, 13, 3903, 8843, 429, 288, 203, 3639, 331, 751, 3778, 1123, 31, 203, 3639, 2254, 5034, 3844, 273, 1234, 18, 1132, 31, 203, 3639, 1758, 628, 273, 1234, 18, 15330, 31, 203, 3639, 2254, 5034, 1300, 67, 792, 67, 3319, 31, 203, 3639, 2583, 12, 1355, 751, 18, 2469, 422, 6969, 27, 16, 315, 1941, 729, 501, 8863, 203, 3639, 1123, 18, 2080, 273, 628, 31, 203, 3639, 2254, 5034, 312, 474, 67, 9156, 273, 2254, 5034, 12, 3890, 1578, 12, 1355, 751, 63, 16874, 30, 15561, 5717, 1769, 203, 3639, 1123, 18, 81, 474, 67, 9156, 273, 312, 474, 67, 9156, 480, 374, 31, 203, 203, 203, 3639, 2583, 12, 8705, 12, 1376, 3631, 315, 984, 4161, 5918, 2006, 4001, 8863, 203, 3639, 2583, 12, 2629, 18, 5508, 405, 1123, 18, 1937, 16, 315, 87, 5349, 3879, 486, 5746, 8863, 203, 3639, 2583, 12, 2629, 18, 5508, 411, 1123, 18, 409, 16, 315, 87, 5349, 3879, 1879, 8863, 203, 3639, 2583, 12, 203, 5411, 1123, 18, 546, 67, 8694, 405, 374, 747, 1123, 18, 81, 474, 67, 9156, 16, 203, 5411, 315, 12202, 5349, 312, 474, 310, 486, 2319, 6, 203, 3639, 11272, 203, 3639, 1300, 67, 792, 67, 3319, 273, 3844, 342, 1123, 18, 546, 67, 8694, 31, 203, 3639, 2583, 12, 203, 5411, 1300, 67, 792, 67, 3319, 380, 1123, 18, 546, 67, 8694, 422, 3844, 16, 203, 5411, 315, 267, 6746, 512, 2455, 3271, 6, 203, 3639, 11272, 203, 3639, 2254, 5034, 389, 12202, 1673, 273, 4075, 1673, 63, 2080, 15533, 203, 3639, 2583, 12, 203, 5411, 261, 67, 12202, 1673, 411, 1123, 18, 1896, 67, 81, 474, 3631, 203, 5411, 315, 6225, 1240, 1818, 312, 474, 329, 3433, 1699, 1359, 6, 203, 3639, 11272, 203, 3639, 2583, 12, 203, 5411, 389, 12202, 1673, 397, 1300, 67, 792, 67, 3319, 1648, 1123, 18, 1896, 67, 81, 474, 16, 203, 5411, 315, 19940, 1240, 8675, 3433, 4075, 5349, 1800, 6, 203, 3639, 11272, 203, 3639, 389, 81, 474, 30492, 12, 2696, 67, 792, 67, 3319, 16, 628, 1769, 203, 3639, 389, 4939, 12, 8949, 1769, 203, 3639, 3626, 512, 2455, 12236, 5349, 12, 2080, 16, 1300, 67, 792, 67, 3319, 16, 1123, 18, 546, 67, 8694, 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 ]
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/interfaces/IERC165.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "./interfaces/IMintableERC721.sol"; /** * @title Mintable Sale * * @notice Mintable Sale sales fixed amount of NFTs (tokens) for a fixed price in a fixed period of time; * it can be used in a 10k sale campaign and the smart contract is generic and * can sell any type of mintable NFT (see MintableERC721 interface) * * @dev Technically, all the "fixed" parameters can be changed on the go after smart contract is deployed * and operational, but this ability is reserved for quick fix-like adjustments, and to provide * an ability to restart and run a similar sale after the previous one ends * * @dev When buying a token from this smart contract, next token is minted to the recipient * * @dev Supports functionality to limit amount of tokens that can be minted to each address * * @dev Deployment and setup: * 1. Deploy smart contract, specify smart contract address during the deployment: * - Mintable ER721 deployed instance address * 2. Execute `initialize` function and set up the sale parameters; * sale is not active until it's initialized * */ contract MintableSale is Ownable { // ----- SLOT.1 (256/256) /** * @notice Price of a single item (token) minted * When buying several tokens at once the price accumulates accordingly, with no discount * * @dev Maximum item price is ~18.44 ETH */ uint64 public itemPrice; /** * @dev Next token ID to mint; * initially this is the first "free" ID which can be minted; * at any point in time this should point to a free, mintable ID * for the token * * @dev `nextId` cannot be zero, we do not ever mint NFTs with zero IDs */ uint32 public nextId = 1; /** * @dev Last token ID to mint; * once `nextId` exceeds `finalId` the sale pauses */ uint32 public finalId; /** * @notice Sale start unix timestamp; the sale is active after the start (inclusive) */ uint32 public saleStart; /** * @notice Sale end unix timestamp; the sale is active before the end (exclusive) */ uint32 public saleEnd; /** * @notice Once set, limits the amount of tokens one can buy in a single transaction; * When unset (zero) the amount of tokens is limited only by block size and * amount of tokens left for sale */ uint32 public batchLimit; /** * @notice Once set, limits the amount of tokens one address can buy for the duration of the sale; * When unset (zero) the amount of tokens is limited only by the amount of tokens left for sale */ uint32 public mintLimit; // ----- SLOT.2 (32/256) /** * @notice Counter of the tokens sold (minted) by this sale smart contract */ uint32 public soldCounter; // ----- NON-SLOTTED /** * @dev Mintable ERC721 contract address to mint */ address public immutable tokenContract; // ----- NON-SLOTTED /** * @dev Number of mints performed by address */ mapping(address => uint32) mints; /** * @dev Fired in initialize() * * @param _by an address which executed the initialization * @param _itemPrice price of one token created * @param _nextId next ID of the token to mint * @param _finalId final ID of the token to mint * @param _saleStart start of the sale, unix timestamp * @param _saleEnd end of the sale, unix timestamp * @param _batchLimit how many tokens is allowed to buy in a single transaction */ event Initialized( address indexed _by, uint64 _itemPrice, uint32 _nextId, uint32 _finalId, uint32 _saleStart, uint32 _saleEnd, uint32 _batchLimit, uint32 _limit ); /** * @dev Fired in buy(), buyTo(), buySingle(), and buySingleTo() * * @param _by an address which executed and payed the transaction, probably a buyer * @param _to an address which received token(s) minted * @param _amount number of tokens minted * @param _value ETH amount charged */ event Bought(address indexed _by, address indexed _to, uint256 _amount, uint256 _value); /** * @dev Fired in withdraw() and withdrawTo() * * @param _by an address which executed the withdrawal * @param _to an address which received the ETH withdrawn * @param _value ETH amount withdrawn */ event Withdrawn(address indexed _by, address indexed _to, uint256 _value); /** * @dev Creates/deploys MintableSale and binds it to Mintable ERC721 * smart contract on construction * * @param _tokenContract deployed Mintable ERC721 smart contract; sale will mint ERC721 * tokens of that type to the recipient */ constructor(address _tokenContract) { // verify the input is set require(_tokenContract != address(0), "token contract is not set"); // verify input is valid smart contract of the expected interfaces require( IERC165(_tokenContract).supportsInterface(type(IMintableERC721).interfaceId) && IERC165(_tokenContract).supportsInterface(type(IMintableERC721).interfaceId), "unexpected token contract type" ); // assign the addresses tokenContract = _tokenContract; } /** * @notice Number of tokens left on sale * * @dev Doesn't take into account if sale is active or not, * if `nextId - finalId < 1` returns zero * * @return number of tokens left on sale */ function itemsOnSale() public view returns(uint32) { // calculate items left on sale, taking into account that // finalId is on sale (inclusive bound) return finalId > nextId? finalId + 1 - nextId: 0; } /** * @notice Number of tokens available on sale * * @dev Takes into account if sale is active or not, doesn't throw, * returns zero if sale is inactive * * @return number of tokens available on sale */ function itemsAvailable() public view returns(uint32) { // delegate to itemsOnSale() if sale is active, return zero otherwise return isActive()? itemsOnSale(): 0; } /** * @notice Active sale is an operational sale capable of minting and selling tokens * * @dev The sale is active when all the requirements below are met: * 1. Price is set (`itemPrice` is not zero) * 2. `finalId` is not reached (`nextId <= finalId`) * 3. current timestamp is between `saleStart` (inclusive) and `saleEnd` (exclusive) * * @dev Function is marked as virtual to be overridden in the helper test smart contract (mock) * in order to test how it affects the sale process * * @return true if sale is active (operational) and can sell tokens, false otherwise */ function isActive() public view virtual returns(bool) { // evaluate sale state based on the internal state variables and return return itemPrice > 0 && nextId <= finalId && saleStart <= block.timestamp && saleEnd > block.timestamp; } /** * @dev Restricted access function to set up sale parameters, all at once, * or any subset of them * * @dev To skip parameter initialization, set it to `-1`, * that is a maximum value for unsigned integer of the corresponding type; * `_aliSource` and `_aliValue` must both be either set or skipped * * @dev Example: following initialization will update only _itemPrice and _batchLimit, * leaving the rest of the fields unchanged * initialize( * 100000000000000000, * 0xFFFFFFFF, * 0xFFFFFFFF, * 0xFFFFFFFF, * 0xFFFFFFFF, * 10, * 0xFFFFFFFF * ) * * @dev Requires next ID to be greater than zero (strict): `_nextId > 0` * * @dev Requires transaction sender to have `ROLE_SALE_MANAGER` role * * @param _itemPrice price of one token created; * setting the price to zero deactivates the sale * @param _nextId next ID of the token to mint, will be increased * in smart contract storage after every successful buy * @param _finalId final ID of the token to mint; sale is capable of producing * `_finalId - _nextId + 1` tokens * @param _saleStart start of the sale, unix timestamp * @param _saleEnd end of the sale, unix timestamp; sale is active only * when current time is within _saleStart (inclusive) and _saleEnd (exclusive) * @param _batchLimit how many tokens is allowed to buy in a single transaction, * set to zero to disable the limit * @param _mintLimit how many tokens is allowed to buy for the duration of the sale, * set to zero to disable the limit */ function initialize( uint64 _itemPrice, // <<<--- keep type in sync with the body type(uint64).max !!! uint32 _nextId, // <<<--- keep type in sync with the body type(uint32).max !!! uint32 _finalId, // <<<--- keep type in sync with the body type(uint32).max !!! uint32 _saleStart, // <<<--- keep type in sync with the body type(uint32).max !!! uint32 _saleEnd, // <<<--- keep type in sync with the body type(uint32).max !!! uint32 _batchLimit, // <<<--- keep type in sync with the body type(uint32).max !!! uint32 _mintLimit // <<<--- keep type in sync with the body type(uint32).max !!! ) public onlyOwner { // verify the inputs require(_nextId > 0, "zero nextId"); // no need to verify extra parameters - "incorrect" values will deactivate the sale // initialize contract state based on the values supplied // take into account our convention that value `-1` means "do not set" // 0xFFFFFFFFFFFFFFFF, 64 bits if(_itemPrice != type(uint64).max) { itemPrice = _itemPrice; } // 0xFFFFFFFF, 32 bits if(_nextId != type(uint32).max) { nextId = _nextId; } // 0xFFFFFFFF, 32 bits if(_finalId != type(uint32).max) { finalId = _finalId; } // 0xFFFFFFFF, 32 bits if(_saleStart != type(uint32).max) { saleStart = _saleStart; } // 0xFFFFFFFF, 32 bits if(_saleEnd != type(uint32).max) { saleEnd = _saleEnd; } // 0xFFFFFFFF, 32 bits if(_batchLimit != type(uint32).max) { batchLimit = _batchLimit; } // 0xFFFFFFFF, 32 bits if(_mintLimit != type(uint32).max) { mintLimit = _mintLimit; } // emit an event - read values from the storage since not all of them might be set emit Initialized( msg.sender, itemPrice, nextId, finalId, saleStart, saleEnd, batchLimit, mintLimit ); } /** * @notice Buys several (at least two) tokens in a batch. * Accepts ETH as payment and mints a token * * @param _amount amount of tokens to create, two or more */ function buy(uint32 _amount) public payable { // delegate to `buyTo` with the transaction sender set to be a recipient buyTo(msg.sender, _amount); } /** * @notice Buys several (at least two) tokens in a batch to an address specified. * Accepts ETH as payment and mints tokens * * @param _to address to mint tokens to * @param _amount amount of tokens to create, two or more */ function buyTo(address _to, uint32 _amount) public payable { // verify the inputs require(_to != address(0), "recipient not set"); require(_amount > 1 && (batchLimit == 0 || _amount <= batchLimit), "incorrect amount"); // verify mint limit if(mintLimit != 0) { require(mints[msg.sender] + _amount <= mintLimit, "mint limit reached"); } // verify there is enough items available to buy the amount // verifies sale is in active state under the hood require(itemsAvailable() >= _amount, "inactive sale or not enough items available"); // calculate the total price required and validate the transaction value uint256 totalPrice = uint256(itemPrice) * _amount; require(msg.value >= totalPrice, "not enough funds"); // mint token to to the recipient IMintableERC721(tokenContract).mintBatch(_to, nextId, _amount); // increment `nextId` nextId += _amount; // increment `soldCounter` soldCounter += _amount; // increment sender mints mints[msg.sender] += _amount; // if ETH amount supplied exceeds the price if(msg.value > totalPrice) { // send excess amount back to sender payable(msg.sender).transfer(msg.value - totalPrice); } // emit en event emit Bought(msg.sender, _to, _amount, totalPrice); } /** * @notice Buys single token. * Accepts ETH as payment and mints a token */ function buySingle() public payable { // delegate to `buySingleTo` with the transaction sender set to be a recipient buySingleTo(msg.sender); } /** * @notice Buys single token to an address specified. * Accepts ETH as payment and mints a token * * @param _to address to mint token to */ function buySingleTo(address _to) public payable { // verify the inputs and transaction value require(_to != address(0), "recipient not set"); require(msg.value >= itemPrice, "not enough funds"); // verify mint limit if(mintLimit != 0) { require(mints[msg.sender] + 1 <= mintLimit, "mint limit reached"); } // verify sale is in active state require(isActive(), "inactive sale"); // mint token to the recipient IMintableERC721(tokenContract).mint(_to, nextId); // increment `nextId` nextId++; // increment `soldCounter` soldCounter++; // increment sender mints mints[msg.sender]++; // if ETH amount supplied exceeds the price if(msg.value > itemPrice) { // send excess amount back to sender payable(msg.sender).transfer(msg.value - itemPrice); } // emit en event emit Bought(msg.sender, _to, 1, itemPrice); } /** * @dev Restricted access function to withdraw ETH on the contract balance, * sends ETH back to transaction sender */ function withdraw() public { // delegate to `withdrawTo` withdrawTo(msg.sender); } /** * @dev Restricted access function to withdraw ETH on the contract balance, * sends ETH to the address specified * * @param _to an address to send ETH to */ function withdrawTo(address _to) public onlyOwner { // verify withdrawal address is set require(_to != address(0), "address not set"); // ETH value to send uint256 _value = address(this).balance; // verify sale balance is positive (non-zero) require(_value > 0, "zero balance"); // send the entire balance to the transaction sender payable(_to).transfer(_value); // emit en event emit Withdrawn(msg.sender, _to, _value); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol"; // SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IMintableERC721 { /** * @notice Checks if specified token exists * * @dev Returns whether the specified token ID has an ownership * information associated with it * * @param _tokenId ID of the token to query existence for * @return whether the token exists (true - exists, false - doesn't exist) */ function exists(uint256 _tokenId) external view returns(bool); /** * @dev Creates new token with token ID specified * and assigns an ownership `_to` for this token * * @dev Unsafe: doesn't execute `onERC721Received` on the receiver. * Prefer the use of `saveMint` instead of `mint`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint token to * @param _tokenId ID of the token to mint */ function mint(address _to, uint256 _tokenId) external; /** * @dev Creates new tokens starting with token ID specified * and assigns an ownership `_to` for these tokens * * @dev Token IDs to be minted: [_tokenId, _tokenId + n) * * @dev n must be greater or equal 2: `n > 1` * * @dev Unsafe: doesn't execute `onERC721Received` on the receiver. * Prefer the use of `saveMintBatch` instead of `mintBatch`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint tokens to * @param _tokenId ID of the first token to mint * @param n how many tokens to mint, sequentially increasing the _tokenId */ function mintBatch(address _to, uint256 _tokenId, uint256 n) external; /** * @dev Creates new token with token ID specified * and assigns an ownership `_to` for this token * * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint token to * @param _tokenId ID of the token to mint */ function safeMint(address _to, uint256 _tokenId) external; /** * @dev Creates new token with token ID specified * and assigns an ownership `_to` for this token * * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint token to * @param _tokenId ID of the token to mint * @param _data additional data with no specified format, sent in call to `_to` */ function safeMint(address _to, uint256 _tokenId, bytes memory _data) external; /** * @dev Creates new tokens starting with token ID specified * and assigns an ownership `_to` for these tokens * * @dev Token IDs to be minted: [_tokenId, _tokenId + n) * * @dev n must be greater or equal 2: `n > 1` * * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint token to * @param _tokenId ID of the token to mint * @param n how many tokens to mint, sequentially increasing the _tokenId */ function safeMintBatch(address _to, uint256 _tokenId, uint256 n) external; /** * @dev Creates new tokens starting with token ID specified * and assigns an ownership `_to` for these tokens * * @dev Token IDs to be minted: [_tokenId, _tokenId + n) * * @dev n must be greater or equal 2: `n > 1` * * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. * * @dev Should have a restricted access handled by the implementation * * @param _to an address to mint token to * @param _tokenId ID of the token to mint * @param n how many tokens to mint, sequentially increasing the _tokenId * @param _data additional data with no specified format, sent in call to `_to` */ function safeMintBatch(address _to, uint256 _tokenId, uint256 n, bytes memory _data) 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 meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 "../../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; }
* @dev Restricted access function to set up sale parameters, all at once, or any subset of them @dev To skip parameter initialization, set it to `-1`, that is a maximum value for unsigned integer of the corresponding type; `_aliSource` and `_aliValue` must both be either set or skipped @dev Example: following initialization will update only _itemPrice and _batchLimit, leaving the rest of the fields unchanged initialize( 100000000000000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 10, 0xFFFFFFFF ) @dev Requires next ID to be greater than zero (strict): `_nextId > 0` @dev Requires transaction sender to have `ROLE_SALE_MANAGER` role @param _itemPrice price of one token created; setting the price to zero deactivates the sale @param _nextId next ID of the token to mint, will be increased in smart contract storage after every successful buy @param _finalId final ID of the token to mint; sale is capable of producing `_finalId - _nextId + 1` tokens @param _saleStart start of the sale, unix timestamp @param _saleEnd end of the sale, unix timestamp; sale is active only when current time is within _saleStart (inclusive) and _saleEnd (exclusive) @param _batchLimit how many tokens is allowed to buy in a single transaction, set to zero to disable the limit @param _mintLimit how many tokens is allowed to buy for the duration of the sale, set to zero to disable the limit/ verify the inputs no need to verify extra parameters - "incorrect" values will deactivate the sale initialize contract state based on the values supplied take into account our convention that value `-1` means "do not set" 0xFFFFFFFFFFFFFFFF, 64 bits 0xFFFFFFFF, 32 bits 0xFFFFFFFF, 32 bits 0xFFFFFFFF, 32 bits 0xFFFFFFFF, 32 bits 0xFFFFFFFF, 32 bits 0xFFFFFFFF, 32 bits
function initialize( ) public onlyOwner { require(_nextId > 0, "zero nextId"); if(_itemPrice != type(uint64).max) { itemPrice = _itemPrice; } if(_nextId != type(uint32).max) { nextId = _nextId; } if(_finalId != type(uint32).max) { finalId = _finalId; } if(_saleStart != type(uint32).max) { saleStart = _saleStart; } if(_saleEnd != type(uint32).max) { saleEnd = _saleEnd; } if(_batchLimit != type(uint32).max) { batchLimit = _batchLimit; } if(_mintLimit != type(uint32).max) { mintLimit = _mintLimit; } msg.sender, itemPrice, nextId, finalId, saleStart, saleEnd, batchLimit, mintLimit ); }
14,772,954
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 29814, 2006, 445, 358, 444, 731, 272, 5349, 1472, 16, 777, 622, 3647, 16, 1377, 578, 1281, 7931, 434, 2182, 632, 5206, 2974, 2488, 1569, 10313, 16, 444, 518, 358, 1375, 17, 21, 9191, 1377, 716, 353, 279, 4207, 460, 364, 9088, 3571, 434, 326, 4656, 618, 31, 1377, 1375, 67, 18083, 1830, 68, 471, 1375, 67, 18083, 620, 68, 1297, 3937, 506, 3344, 444, 578, 9700, 632, 5206, 5090, 30, 3751, 10313, 903, 1089, 1338, 389, 1726, 5147, 471, 389, 5303, 3039, 16, 1377, 15086, 326, 3127, 434, 326, 1466, 14827, 1377, 4046, 12, 1850, 2130, 12648, 17877, 16, 1850, 374, 28949, 16, 1850, 374, 28949, 16, 1850, 374, 28949, 16, 1850, 374, 28949, 16, 1850, 1728, 16, 1850, 374, 28949, 1377, 262, 632, 5206, 16412, 1024, 1599, 358, 506, 6802, 2353, 3634, 261, 13948, 4672, 1375, 67, 4285, 548, 405, 374, 68, 632, 5206, 16412, 2492, 5793, 358, 1240, 1375, 16256, 67, 5233, 900, 67, 19402, 68, 2478, 632, 891, 389, 1726, 5147, 6205, 434, 1245, 1147, 2522, 31, 1377, 3637, 326, 6205, 358, 3634, 443, 11422, 815, 326, 272, 5349, 632, 891, 389, 4285, 548, 1024, 1599, 434, 326, 1147, 358, 312, 474, 16, 903, 506, 31383, 1377, 316, 13706, 6835, 2502, 1839, 3614, 6873, 30143, 632, 891, 389, 6385, 548, 727, 1599, 434, 326, 1147, 358, 312, 474, 31, 272, 5349, 353, 22863, 434, 4810, 2822, 1377, 1375, 67, 6385, 548, 300, 389, 4285, 548, 397, 404, 68, 2430, 632, 891, 389, 87, 5349, 1685, 787, 434, 326, 272, 5349, 16, 9753, 2858, 632, 891, 389, 87, 5349, 1638, 679, 434, 326, 272, 5349, 16, 9753, 2858, 31, 272, 5349, 353, 2695, 1338, 1377, 1347, 783, 813, 353, 3470, 389, 87, 5349, 1685, 261, 267, 9173, 13, 471, 389, 87, 5349, 1638, 261, 23792, 13, 632, 891, 389, 5303, 3039, 3661, 4906, 2430, 353, 2935, 358, 30143, 316, 279, 2202, 2492, 16, 1377, 444, 358, 3634, 358, 4056, 326, 1800, 632, 891, 389, 81, 474, 3039, 3661, 4906, 2430, 353, 2935, 358, 30143, 364, 326, 3734, 434, 326, 272, 5349, 16, 1377, 444, 358, 3634, 358, 4056, 326, 1800, 19, 3929, 326, 4540, 1158, 1608, 358, 3929, 2870, 1472, 300, 315, 267, 6746, 6, 924, 903, 18790, 326, 272, 5349, 4046, 6835, 919, 2511, 603, 326, 924, 4580, 4862, 1368, 2236, 3134, 15797, 716, 460, 1375, 17, 21, 68, 4696, 315, 2896, 486, 444, 6, 374, 6356, 8998, 8998, 18343, 16, 5178, 4125, 374, 28949, 16, 3847, 4125, 374, 28949, 16, 3847, 4125, 374, 28949, 16, 3847, 4125, 374, 28949, 16, 3847, 4125, 374, 28949, 16, 3847, 4125, 374, 28949, 16, 3847, 4125, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 262, 1071, 1338, 5541, 288, 203, 565, 2583, 24899, 4285, 548, 405, 374, 16, 315, 7124, 1024, 548, 8863, 203, 203, 203, 565, 309, 24899, 1726, 5147, 480, 618, 12, 11890, 1105, 2934, 1896, 13, 288, 203, 1377, 761, 5147, 273, 389, 1726, 5147, 31, 203, 565, 289, 203, 565, 309, 24899, 4285, 548, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 1024, 548, 273, 389, 4285, 548, 31, 203, 565, 289, 203, 565, 309, 24899, 6385, 548, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 727, 548, 273, 389, 6385, 548, 31, 203, 565, 289, 203, 565, 309, 24899, 87, 5349, 1685, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 272, 5349, 1685, 273, 389, 87, 5349, 1685, 31, 203, 565, 289, 203, 565, 309, 24899, 87, 5349, 1638, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 272, 5349, 1638, 273, 389, 87, 5349, 1638, 31, 203, 565, 289, 203, 565, 309, 24899, 5303, 3039, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 2581, 3039, 273, 389, 5303, 3039, 31, 203, 565, 289, 203, 565, 309, 24899, 81, 474, 3039, 480, 618, 12, 11890, 1578, 2934, 1896, 13, 288, 203, 1377, 312, 474, 3039, 273, 389, 81, 474, 3039, 31, 203, 565, 289, 203, 203, 1377, 1234, 18, 15330, 16, 203, 1377, 761, 5147, 16, 203, 1377, 1024, 548, 16, 203, 1377, 727, 548, 16, 203, 1377, 272, 5349, 1685, 16, 203, 1377, 272, 5349, 1638, 16, 203, 1377, 2581, 3039, 16, 203, 1377, 312, 474, 3039, 203, 565, 11272, 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 ]
./partial_match/1/0xD45A727684D25342eA2900cC6E0a157Ead912141/sources/StabilizeStrategyStablecoinArb.sol
Difference is greater than 1%
if(_price.sub(targetPrice) >= 10000000000000000){
3,592,590
[ 1, 4625, 348, 7953, 560, 30, 225, 29474, 353, 6802, 2353, 404, 9, 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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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 ]
[ 1, 10792, 309, 24899, 8694, 18, 1717, 12, 3299, 5147, 13, 1545, 2130, 12648, 9449, 15329, 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 ]
./partial_match/1/0xAa24F195587506C0Fb26C8e1208d6C0353486cEB/sources/MILADY.sol
* @dev Sets the value of the `decimals`. This value is immutable, it can only be set once during construction./
constructor () ERC20('MILADY', 'MI') { _mint(_msgSender(), _totalSupply); }
4,270,587
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 11511, 326, 460, 434, 326, 1375, 31734, 8338, 1220, 460, 353, 11732, 16, 518, 848, 1338, 506, 444, 3647, 4982, 16171, 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, 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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 ]
[ 1, 565, 3885, 1832, 4232, 39, 3462, 2668, 49, 2627, 1880, 61, 2187, 296, 7492, 6134, 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, -100, -100, -100, -100 ]
pragma solidity 0.5.11; import "./whitelist/WhitelistExtension.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol"; /// @dev SeedSwap contract for presale PKF token /// Some notations: /// dAmount - distributed token amount /// uAmount - undistributed token amount /// tAmount - token amount /// eAmount - eth amount contract SeedSwap is WhitelistExtension, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; using SafeMath for uint80; IERC20 public constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); uint256 public constant MAX_UINT_80 = 2**79 - 1; uint256 public constant HARD_CAP = 320 ether; uint256 public constant MIN_INDIVIDUAL_CAP = 1 ether; uint256 public constant MAX_INDIVIDUAL_CAP = 10 ether; // user can call to distribute tokens after WITHDRAWAL_DEADLINE + saleEndTime uint256 public constant WITHDRAWAL_DEADLINE = 180 days; uint256 public constant SAFE_DISTRIBUTE_NUMBER = 150; // safe to distribute to 150 users at once uint256 public constant DISTRIBUTE_PERIOD_UNIT = 1 days; IERC20 public saleToken; uint256 public saleStartTime = 1609693200; // 00:00:00, 4 Jan 2021 GMT+7 uint256 public saleEndTime = 1610384340; // 23:59:00, 11 Jan 2021 GMT+7 uint256 public saleRate = 25000; // 1 eth = 25,000 token // address to receive eth of presale, default owner address payable public ethRecipient; // total eth and token amounts that all users have swapped struct TotalSwappedData { uint128 eAmount; uint128 tAmount; } TotalSwappedData public totalData; uint256 public totalDistributedToken = 0; struct SwapData { address user; uint80 eAmount; // eth amount uint80 tAmount; // token amount uint80 dAmount; // distributed token amount uint16 daysID; } // all swaps that are made by users SwapData[] public listSwaps; // list indices of user's swaps in listSwaps array mapping(address => uint256[]) public userSwapData; mapping(address => address) public userTokenRecipient; event SwappedEthToPkf( address indexed trader, uint256 indexed ethAmount, uint256 indexed teaAmount, uint256 blockTimestamp, uint16 daysID ); event UpdateSaleTimes( uint256 indexed newStartTime, uint256 newEndTime ); event UpdateSaleRate(uint256 indexed newSaleRate); event UpdateEthRecipient(address indexed newRecipient); event Distributed( address indexed user, address indexed recipient, uint256 dAmount, uint256 indexed percentage, uint256 timestamp ); event SelfWithdrawToken( address indexed sender, address indexed recipient, uint256 indexed dAmount, uint256 timestamp ); event EmergencyOwnerWithdraw( address indexed sender, IERC20 indexed token, uint256 amount ); event UpdatedTokenRecipient( address user, address recipient ); modifier whenNotStarted() { require(block.timestamp < saleStartTime, "already started"); _; } modifier whenNotEnded() { require(block.timestamp <= saleEndTime, "already ended"); _; } modifier whenEnded() { require(block.timestamp > saleEndTime, "not ended yet"); _; } modifier onlyValidPercentage(uint256 percentage) { require(0 < percentage && percentage <= 100, "percentage out of range"); _; } /// @dev Conditions: /// 1. sale must be in progress /// 2. hard cap is not reached yet /// 3. user's total swapped eth amount is within individual caps /// 4. user is whitelisted /// 5. if total eth amount after the swap is higher than hard cap, still allow /// Note: _paused is checked independently. modifier onlyCanSwap(uint256 ethAmount) { require(ethAmount > 0, "onlyCanSwap: amount is 0"); // check sale is in progress uint256 timestamp = block.timestamp; require(timestamp >= saleStartTime, "onlyCanSwap: not started yet"); require(timestamp <= saleEndTime, "onlyCanSwap: already ended"); // check hardcap is not reached require(totalData.eAmount < HARD_CAP, "onlyCanSwap: HARD_CAP reached"); address sender = msg.sender; // check whitelisted require(isWhitelisted(sender), "onlyCanSwap: sender is not whitelisted"); // check total user's swap eth amount is within individual cap (uint80 userEthAmount, ,) = _getUserSwappedAmount(sender); uint256 totalEthAmount = ethAmount.add(uint256(userEthAmount)); require( totalEthAmount >= MIN_INDIVIDUAL_CAP, "onlyCanSwap: eth amount is lower than min individual cap" ); require( totalEthAmount <= MAX_INDIVIDUAL_CAP, "onlyCapSwap: max individual cap reached" ); _; } constructor(address payable _owner, IERC20 _token) public { require(_token != IERC20(0), "constructor: invalid token"); // (safe) check timestamp // assert(block.timestamp < saleStartTime); assert(saleStartTime < saleEndTime); saleToken = _token; ethRecipient = _owner; // add owner as whitelisted admin and transfer ownership if needed if (msg.sender != _owner) { _addWhitelistAdmin(_owner); transferOwnership(_owner); } } function () external payable { swapEthToToken(); } /// ================ UPDATE DEFAULT DATA ==================== /// @dev the owner can update start and end times when it is not yet started function updateSaleTimes(uint256 _newStartTime, uint256 _newEndTime) external whenNotStarted onlyOwner { if (_newStartTime != 0) saleStartTime = _newStartTime; if (_newEndTime != 0) saleEndTime = _newEndTime; require(saleStartTime < saleEndTime, "Times: invalid start and end time"); require(block.timestamp < saleStartTime, "Times: invalid start time"); emit UpdateSaleTimes(saleStartTime, saleEndTime); } /// @dev the owner can update the sale rate whenever the sale is not ended yet function updateSaleRate(uint256 _newsaleRate) external whenNotEnded onlyOwner { require( _newsaleRate < MAX_UINT_80 / MAX_INDIVIDUAL_CAP, "Rates: new rate is out of range" ); // safe check rate not different more than 50% than the current rate require(_newsaleRate >= saleRate / 2, "Rates: new rate too low"); require(_newsaleRate <= saleRate * 3 / 2, "Rates: new rate too high"); saleRate = _newsaleRate; emit UpdateSaleRate(_newsaleRate); } /// @dev the owner can update the recipient of eth any time function updateEthRecipientAddress(address payable _newRecipient) external onlyOwner { require(_newRecipient != address(0), "Receipient: invalid eth recipient address"); ethRecipient = _newRecipient; emit UpdateEthRecipient(_newRecipient); } /// ================ SWAP ETH TO PKF TOKEN ==================== /// @dev user can call this function to swap eth to PKF token /// or just deposit eth directly to the contract function swapEthToToken() public payable nonReentrant whenNotPaused onlyCanSwap(msg.value) returns (uint256 tokenAmount) { address sender = msg.sender; uint256 ethAmount = msg.value; tokenAmount = _getTokenAmount(ethAmount); // should pass the check that presale has started, so no underflow here uint256 daysID = (block.timestamp - saleStartTime) / DISTRIBUTE_PERIOD_UNIT; assert(daysID < 2**16); // should have only few days for presale // record new swap SwapData memory _swapData = SwapData({ user: sender, eAmount: uint80(ethAmount), tAmount: uint80(tokenAmount), dAmount: uint80(0), daysID: uint16(daysID) }); listSwaps.push(_swapData); // update user swap data userSwapData[sender].push(listSwaps.length - 1); // update total swap eth and token amounts TotalSwappedData memory swappedData = totalData; totalData = TotalSwappedData({ eAmount: swappedData.eAmount + uint128(ethAmount), tAmount: swappedData.tAmount + uint128(tokenAmount) }); // transfer eth to recipient ethRecipient.transfer(ethAmount); emit SwappedEthToPkf(sender, ethAmount, tokenAmount, block.timestamp, uint16(daysID)); } /// ================ DISTRIBUTE TOKENS ==================== /// @dev admin can call this function to perform distribute to all eligible swaps /// @param percentage percentage of undistributed amount will be distributed /// @param daysID only distribute for swaps that were made at that day from start function distributeAll(uint256 percentage, uint16 daysID) external onlyWhitelistAdmin whenEnded whenNotPaused onlyValidPercentage(percentage) returns (uint256 totalAmount) { for(uint256 i = 0; i < listSwaps.length; i++) { if (listSwaps[i].daysID == daysID) { totalAmount += _distributedToken(i, percentage); } } totalDistributedToken = totalDistributedToken.add(totalAmount); } /// @dev admin can also use this function to distribute by batch, /// in case distributeAll can be out of gas /// @param percentage percentage of undistributed amount will be distributed /// @param ids list of ids in the listSwaps to be distributed function distributeBatch(uint256 percentage, uint256[] calldata ids) external onlyWhitelistAdmin whenEnded whenNotPaused onlyValidPercentage(percentage) returns (uint256 totalAmount) { uint256 len = listSwaps.length; for(uint256 i = 0; i < ids.length; i++) { require(ids[i] < len, "Distribute: invalid id"); // safe prevent duplicated ids in 1 batch if (i > 0) require(ids[i - 1] < ids[i], "Distribute: indices are not in order"); totalAmount += _distributedToken(ids[i], percentage); } totalDistributedToken = totalDistributedToken.add(totalAmount); } /// ================ EMERGENCY FOR USER AND OWNER ==================== /// @dev in case after WITHDRAWAL_DEADLINE from end sale time /// user can call this function to claim all of their tokens /// also update user's swap records function selfWithdrawToken() external returns (uint256 tokenAmount) { require( block.timestamp > WITHDRAWAL_DEADLINE + saleEndTime, "Emergency: not open for emergency withdrawal" ); address sender = msg.sender; (, uint80 tAmount, uint80 dAmount) = _getUserSwappedAmount(sender); tokenAmount = tAmount.sub(dAmount); require(tokenAmount > 0, "Emergency: user has claimed all tokens"); require( tokenAmount <= saleToken.balanceOf(address(this)), "Emergency: not enough token to distribute" ); // update each user's record uint256[] memory ids = userSwapData[sender]; for(uint256 i = 0; i < ids.length; i++) { // safe check assert(listSwaps[ids[i]].user == sender); // update distributed amount for each swap data listSwaps[ids[i]].dAmount = listSwaps[ids[i]].tAmount; } totalDistributedToken = totalDistributedToken.add(tokenAmount); // transfer token to user address recipient = _transferToken(sender, tokenAmount); emit SelfWithdrawToken(sender, recipient, tokenAmount, block.timestamp); } /// @dev emergency to allow owner withdraw eth or tokens inside the contract /// in case anything happens function emergencyOwnerWithdraw(IERC20 token, uint256 amount) external onlyOwner { if (token == ETH_ADDRESS) { // whenever someone transfer eth to this contract // it will either to the swap or revert // so there should be no eth inside the contract msg.sender.transfer(amount); } else { token.safeTransfer(msg.sender, amount); } emit EmergencyOwnerWithdraw(msg.sender, token, amount); } /// @dev only in case user has lost their wallet, or wrongly send eth from third party platforms function updateUserTokenRecipient(address user, address recipient) external onlyOwner { require(recipient != address(0), "invalid recipient"); userTokenRecipient[user] = recipient; emit UpdatedTokenRecipient(user, recipient); } /// ================ GETTERS ==================== function getNumberSwaps() external view returns (uint256) { return listSwaps.length; } function getAllSwaps() external view returns ( address[] memory users, uint80[] memory ethAmounts, uint80[] memory tokenAmounts, uint80[] memory distributedAmounts, uint16[] memory daysIDs ) { uint256 len = listSwaps.length; users = new address[](len); ethAmounts = new uint80[](len); tokenAmounts = new uint80[](len); distributedAmounts = new uint80[](len); daysIDs = new uint16[](len); for(uint256 i = 0; i < len; i++) { SwapData memory data = listSwaps[i]; users[i] = data.user; ethAmounts[i] = data.eAmount; tokenAmounts[i] = data.tAmount; distributedAmounts[i] = data.dAmount; daysIDs[i] = data.daysID; } } /// @dev return full details data of a user function getUserSwapData(address user) external view returns ( address tokenRecipient, uint256 totalEthAmount, uint80 totalTokenAmount, uint80 distributedAmount, uint80 remainingAmount, uint80[] memory ethAmounts, uint80[] memory tokenAmounts, uint80[] memory distributedAmounts, uint16[] memory daysIDs ) { tokenRecipient = _getRecipient(user); (totalEthAmount, totalTokenAmount, distributedAmount) = _getUserSwappedAmount(user); remainingAmount = totalTokenAmount - distributedAmount; // record of all user's swaps uint256[] memory swapDataIDs = userSwapData[user]; ethAmounts = new uint80[](swapDataIDs.length); tokenAmounts = new uint80[](swapDataIDs.length); distributedAmounts = new uint80[](swapDataIDs.length); daysIDs = new uint16[](swapDataIDs.length); for(uint256 i = 0; i < swapDataIDs.length; i++) { ethAmounts[i] = listSwaps[swapDataIDs[i]].eAmount; tokenAmounts[i] = listSwaps[swapDataIDs[i]].tAmount; distributedAmounts[i] = listSwaps[swapDataIDs[i]].dAmount; daysIDs[i] = listSwaps[swapDataIDs[i]].daysID; } } function getData() external view returns( uint256 _startTime, uint256 _endTime, uint256 _rate, address _ethRecipient, uint128 _tAmount, uint128 _eAmount, uint256 _hardcap ) { _startTime = saleStartTime; _endTime = saleEndTime; _rate = saleRate; _ethRecipient = ethRecipient; _tAmount = totalData.tAmount; _eAmount = totalData.eAmount; _hardcap = HARD_CAP; } /// @dev returns list of users and distributed amounts if user calls distributeAll function /// in case anything is wrong, it will fail and not return anything /// @param percentage percentage of undistributed amount will be distributed /// @param daysID only distribute for swaps that were made at daysID from start function estimateDistributedAllData( uint80 percentage, uint16 daysID ) external view whenEnded whenNotPaused onlyValidPercentage(percentage) returns( bool isSafe, uint256 totalUsers, uint256 totalDistributingAmount, uint256[] memory selectedIds, address[] memory users, address[] memory recipients, uint80[] memory distributingAmounts, uint16[] memory daysIDs ) { // count number of data that can be distributed totalUsers = 0; for(uint256 i = 0; i < listSwaps.length; i++) { if (listSwaps[i].daysID == daysID && listSwaps[i].tAmount > listSwaps[i].dAmount) { totalUsers += 1; } } // return data that will be used to distribute selectedIds = new uint256[](totalUsers); users = new address[](totalUsers); recipients = new address[](totalUsers); distributingAmounts = new uint80[](totalUsers); daysIDs = new uint16[](totalUsers); uint256 counter = 0; for(uint256 i = 0; i < listSwaps.length; i++) { SwapData memory data = listSwaps[i]; if (listSwaps[i].daysID == daysID && listSwaps[i].tAmount > listSwaps[i].dAmount) { selectedIds[counter] = i; users[counter] = data.user; recipients[counter] = _getRecipient(data.user); // don't need to use SafeMath here distributingAmounts[counter] = data.tAmount * percentage / 100; require( distributingAmounts[counter] + data.dAmount <= data.tAmount, "Estimate: total distribute more than 100%" ); daysIDs[counter] = listSwaps[i].daysID; totalDistributingAmount += distributingAmounts[counter]; counter += 1; } } require( totalDistributingAmount <= saleToken.balanceOf(address(this)), "Estimate: not enough token balance" ); isSafe = totalUsers <= SAFE_DISTRIBUTE_NUMBER; } /// @dev returns list of users and distributed amounts if user calls distributeBatch function /// in case anything is wrong, it will fail and not return anything /// @param percentage percentage of undistributed amount will be distributed /// @param ids list indices to distribute in listSwaps /// ids must be in asc order function estimateDistributedBatchData( uint80 percentage, uint256[] calldata ids ) external view whenEnded whenNotPaused onlyValidPercentage(percentage) returns( bool isSafe, uint256 totalUsers, uint256 totalDistributingAmount, uint256[] memory selectedIds, address[] memory users, address[] memory recipients, uint80[] memory distributingAmounts, uint16[] memory daysIDs ) { totalUsers = 0; for(uint256 i = 0; i < ids.length; i++) { require(ids[i] < listSwaps.length, "Estimate: id out of range"); if (i > 0) require(ids[i] > ids[i - 1], "Estimate: duplicated ids"); // has undistributed amount if (listSwaps[i].tAmount > listSwaps[i].dAmount) totalUsers += 1; } // return data that will be used to distribute selectedIds = new uint256[](totalUsers); users = new address[](totalUsers); recipients = new address[](totalUsers); distributingAmounts = new uint80[](totalUsers); daysIDs = new uint16[](totalUsers); uint256 counter = 0; for(uint256 i = 0; i < ids.length; i++) { if (listSwaps[i].tAmount <= listSwaps[i].dAmount) continue; SwapData memory data = listSwaps[ids[i]]; selectedIds[counter] = ids[i]; users[counter] = data.user; recipients[counter] = _getRecipient(data.user); // don't need to use SafeMath here distributingAmounts[counter] = data.tAmount * percentage / 100; require( distributingAmounts[counter] + data.dAmount <= data.tAmount, "Estimate: total distribute more than 100%" ); totalDistributingAmount += distributingAmounts[counter]; daysIDs[counter] = listSwaps[i].daysID; counter += 1; } require( totalDistributingAmount <= saleToken.balanceOf(address(this)), "Estimate: not enough token balance" ); isSafe = totalUsers <= SAFE_DISTRIBUTE_NUMBER; } /// @dev calculate amount token to distribute and send to user function _distributedToken(uint256 id, uint256 percentage) internal returns (uint256 distributingAmount) { SwapData memory data = listSwaps[id]; distributingAmount = uint256(data.tAmount).mul(percentage).div(100); require( distributingAmount.add(data.dAmount) <= data.tAmount, "Distribute: total distribute more than 100%" ); // percentage > 0, data.tAmount > 0 assert (distributingAmount > 0); require( distributingAmount <= saleToken.balanceOf(address(this)), "Distribute: not enough token to distribute" ); // no overflow, so don't need to use SafeMath here listSwaps[id].dAmount += uint80(distributingAmount); // send token to user's wallet address recipient = _transferToken(data.user, distributingAmount); emit Distributed(data.user, recipient, distributingAmount, percentage, block.timestamp); } function _transferToken(address user, uint256 amount) internal returns (address recipient) { recipient = _getRecipient(user); // safe check assert(recipient != address(0)); saleToken.safeTransfer(recipient, amount); } function _getRecipient(address user) internal view returns(address recipient) { recipient = userTokenRecipient[user]; if (recipient == address(0)) { recipient = user; } } /// @dev return received tokenAmount given ethAmount /// note that token decimals is 18 function _getTokenAmount(uint256 ethAmount) internal view returns (uint256) { return ethAmount.mul(saleRate); } function _getUserSwappedAmount(address sender) internal view returns( uint80 eAmount, uint80 tAmount, uint80 dAmount ) { uint256[] memory ids = userSwapData[sender]; for(uint256 i = 0; i < ids.length; i++) { SwapData memory data = listSwaps[ids[i]]; eAmount += data.eAmount; tAmount += data.tAmount; dAmount += data.dAmount; } } }
return data that will be used to distribute
selectedIds = new uint256[](totalUsers);
912,827
[ 1, 4625, 348, 7953, 560, 30, 225, 327, 501, 716, 903, 506, 1399, 358, 25722, 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, 0, 0, 0, 0 ]
[ 1, 3639, 3170, 2673, 273, 394, 2254, 5034, 8526, 12, 4963, 6588, 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 ]
./full_match/1/0xF895B67031670F4b2D00a08a67a7A5c80F8E829f/sources/contracts/protocols/LidoIntegration.sol
solhint-disable-next-line reason-string
require(approvedTargets[swapTarget], "FillQuote: Target is not approved");
8,417,184
[ 1, 4625, 348, 7953, 560, 30, 225, 3704, 11317, 17, 8394, 17, 4285, 17, 1369, 3971, 17, 1080, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 12, 25990, 9432, 63, 22270, 2326, 6487, 315, 8026, 10257, 30, 5916, 353, 486, 20412, 8863, 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 ]
./partial_match/1/0x347933f98c6E3beb9A1a1d11415d81a52fF28B9A/sources/Chadium.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 { pragma solidity ^0.8.15; function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
2,746,020
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 28805, 1779, 2973, 326, 783, 4588, 819, 16, 6508, 326, 5793, 434, 326, 2492, 471, 2097, 501, 18, 21572, 4259, 854, 19190, 2319, 3970, 1234, 18, 15330, 471, 1234, 18, 892, 16, 2898, 1410, 486, 506, 15539, 316, 4123, 279, 2657, 21296, 16, 3241, 1347, 21964, 598, 2191, 17, 20376, 326, 2236, 5431, 471, 8843, 310, 364, 4588, 2026, 486, 506, 326, 3214, 5793, 261, 345, 10247, 487, 392, 2521, 353, 356, 2750, 11748, 2934, 1220, 6835, 353, 1338, 1931, 364, 12110, 16, 5313, 17, 5625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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 17801, 6835, 1772, 288, 203, 203, 203, 203, 683, 9454, 18035, 560, 3602, 20, 18, 28, 18, 3600, 31, 203, 203, 203, 565, 445, 389, 3576, 12021, 1435, 2713, 1476, 5024, 1135, 261, 2867, 13, 288, 203, 3639, 327, 1234, 18, 15330, 31, 203, 565, 289, 203, 203, 565, 445, 389, 3576, 751, 1435, 2713, 1476, 5024, 1135, 261, 3890, 745, 892, 13, 288, 203, 3639, 327, 1234, 18, 892, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x2F674500a367583D6Aaef312478a7cC1941a1977/sources/FECORE.sol
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.
struct Set { bytes32[] _values; mapping(bytes32 => uint256) _indexes; }
8,664,311
[ 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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3639, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x6CCdEed27E139C538C9a83ccdAf997De0A51044D/sources/MasterChef.sol
Update referral commission rate by the owner
function setReferralCommissionRate(uint16 _referralCommissionRate) external onlyOwner { require(_referralCommissionRate <= MAXIMUM_REFERRAL_COMMISSION_RATE, "setReferralCommissionRate: invalid referral commission rate basis points"); referralCommissionRate = _referralCommissionRate; emit SetReferralCommissionRate(msg.sender, _referralCommissionRate); }
4,501,597
[ 1, 4625, 348, 7953, 560, 30, 225, 2315, 1278, 29084, 1543, 19710, 4993, 635, 326, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 444, 1957, 29084, 799, 3951, 4727, 12, 11890, 2313, 389, 1734, 29084, 799, 3951, 4727, 13, 3903, 1338, 5541, 288, 203, 3639, 2583, 24899, 1734, 29084, 799, 3951, 4727, 1648, 4552, 18605, 67, 30269, 54, 1013, 67, 4208, 15566, 67, 24062, 16, 315, 542, 1957, 29084, 799, 3951, 4727, 30, 2057, 1278, 29084, 1543, 19710, 4993, 10853, 3143, 8863, 203, 3639, 1278, 29084, 799, 3951, 4727, 273, 389, 1734, 29084, 799, 3951, 4727, 31, 203, 202, 18356, 1000, 1957, 29084, 799, 3951, 4727, 12, 3576, 18, 15330, 16, 389, 1734, 29084, 799, 3951, 4727, 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 ]
./full_match/1/0xC0eaA22Fdff044F38B79624D65F4eB68c7238703/sources/scripts/Campaign.sol
* @dev Allow either Campaign owner or Factory owner to call this @dev to set the flag to enable token claiming. @dev This is useful when 1 project has multiple campaigns that @dev to sync up the timing of token claiming After LP provision. @notice - Access control: External, onlyFactoryOrCampaignOwner/
function banUser(address _user) external onlyFactoryOrCampaignOwner { lottery[_user] = false; }
3,183,400
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 7852, 3344, 17820, 3410, 578, 7822, 3410, 358, 745, 333, 632, 5206, 358, 444, 326, 2982, 358, 4237, 1147, 7516, 310, 18, 632, 5206, 1220, 353, 5301, 1347, 404, 1984, 711, 3229, 8965, 87, 716, 632, 5206, 358, 3792, 731, 326, 15538, 434, 1147, 7516, 310, 7360, 511, 52, 10595, 18, 632, 20392, 300, 5016, 3325, 30, 11352, 16, 225, 1338, 1733, 1162, 13432, 5541, 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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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 ]
[ 1, 565, 445, 25732, 1299, 12, 2867, 389, 1355, 13, 3903, 1338, 1733, 1162, 13432, 5541, 288, 203, 203, 3639, 17417, 387, 93, 63, 67, 1355, 65, 273, 629, 31, 203, 565, 289, 203, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() 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; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract TokenERC20 { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to].add(_value) > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from].add(balanceOf[_to]); // Subtract from the sender balanceOf[_from] = balanceOf[_from].sub(_value); // Add the same to the recipient balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance //allowance[_from][msg.sender] -= _value; allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } } /******************************************/ /* ADVANCED TOKEN STARTS HERE */ /******************************************/ contract CinociCoin is Ownable, TokenERC20 { using SafeMath for uint256; mapping (address => bool) public frozenAccount; mapping (address => uint256) public freezingPeriod; // how many days the account must remain frozen? mapping (address => bool) public exchangesAccounts; address public bountyManagerAddress; address public bountyManagerDistributionContract = 0x0; address public fundAccount; // ballast fund address bool public isSetFund = false; // if ballast fund is set uint256 public creationDate; uint256 public constant frozenDaysForAdvisor = 187; uint256 public constant frozenDaysForBounty = 187; uint256 public constant frozenDaysForEarlyInvestor = 52; uint256 public constant frozenDaysForICO = 66; uint256 public constant frozenDaysForPartner = 370; uint256 public constant frozenDaysForPreICO = 52; uint256 public constant frozenDaysforTestExchange = 0; /** * allowed for a bounty manager account only */ modifier onlyBountyManager(){ require((msg.sender == bountyManagerDistributionContract) || (msg.sender == bountyManagerAddress)); _; } modifier onlyExchangesAccounts(){ require(exchangesAccounts[msg.sender]); _; } /** * allowed for a fund account only */ modifier onlyFund(){ require(msg.sender == fundAccount); _; } /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /** * Initializes contract with initial supply tokens to the creator of the contract * * */ function CinociCoin( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public { /* solium-disable-next-line */ creationDate = now; address advisor = 0x32c5Ec858c52F8635Bd92e44d8797e5d356eBd05; address bountyManager = 0xdDa9bcf30AFDC40a5fFa6e1b6f70ef030A3E32f4; address earlyInvestor = 0x02FF2bA62440c92D2A02D95Df6fc233eA68c2091; address partner = 0x6A45baAEb21D49fD85B309235Ef2920d3A648858; address exchange1 = 0x8Bd10d3383504a12FD27A1Fd5c0E7bCeae3C8997; address exchange2 = 0xce8b8e7113072C5308cec669375E0Ab364b3435C; _initializeAccount(partner, frozenDaysForPartner, 30000000); _initializeAccount(advisor, frozenDaysForAdvisor, 20000000); _initializeAccount(earlyInvestor, frozenDaysForEarlyInvestor, 10000000); _initializeAccount(exchange1, frozenDaysforTestExchange, 1000); _initializeAccount(exchange2, frozenDaysforTestExchange, 1000); _initializeAccount(bountyManager, frozenDaysForBounty, 15000000); bountyManagerAddress = bountyManager; } /** * Only owner function to set ballast fund account address * * @dev it can be set only once * @param _address smart contract address of ballast fund */ function setFundAccount(address _address) onlyOwner public{ require (_address != 0x0); require (!isSetFund); fundAccount = _address; isSetFund = true; } function addExchangeAccounts(address _address) onlyOwner public{ require(_address != 0x0); exchangesAccounts[_address] = true; } function removeExchangeAccounts(address _address) onlyOwner public{ delete exchangesAccounts[_address]; } /** * Initialize accounts when token deploy occurs * * initialize `_address` account, with balance equal `_value` and frozen for `_frozenDays` * * @param _address wallet address to initialize * @param _frozenDays quantity of days to freeze account * @param _value quantity of tokens to send to account */ function _initializeAccount(address _address, uint _frozenDays, uint _value) internal{ _transfer(msg.sender, _address, _value * 10 ** uint256(decimals)); freezingPeriod[_address] = _frozenDays; _freezeAccount(_address, true); } /** * Check if account freezing period expired * * `now` has to be greater or equal than `creationDate` + `freezingPeriod[_address]` * `1 day` * * @param _address account address to check if allowed to transfer tokens * @return bool true if is allowed to transfer and false if not */ function _isTransferAllowed( address _address ) view public returns (bool) { /* solium-disable-next-line */ if( now >= creationDate + freezingPeriod[_address] * 1 days ){ return ( true ); } else { return ( false ); } } /** * Internal function to transfer tokens * * @param _from account to withdraw tokens * @param _to account to receive tokens * @param _value quantity of tokens to transfer */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to].add(_value) > balanceOf[_to]); // Check for overflows // check if the sender is under a freezing period if(_isTransferAllowed(_from)){ _setFreezingPeriod(_from, false, 0); } // check if the recipient is under a freezing period if(_isTransferAllowed(_to)){ _setFreezingPeriod(_to, false, 0); } require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the sender balanceOf[_to] = balanceOf[_to].add(_value); // Add the same to the recipient emit Transfer(_from, _to, _value); } /** * Internal function to deliver tokens for bounty, pre-ICO or ICO with determined freezing periods * * @param _from account address to withdraw tokens * @param _to account address to send tokens * @param _value quantity of tokes to send * @param _frozenDays quantity of days to freeze account */ function _tokenDelivery(address _from, address _to, uint _value, uint _frozenDays) internal { freezingPeriod[_to] = 0; _freezeAccount(_to, false); _transfer(_from, _to, _value); freezingPeriod[_to] = _frozenDays; _freezeAccount(_to, true); } /** * Only owner function to deliver tokens for pre-ICO investors * * @param _to account address who will receive the tokens * @param _value quantity of tokens to deliver */ function preICOTokenDelivery(address _to, uint _value) onlyOwner public { _tokenDelivery(msg.sender, _to, _value, frozenDaysForPreICO); } /** * Only owner function to deliver tokens for ICO investors * * @param _to account address who will receive tokens * @param _value quantity of tokens to deliver */ function ICOTokenDelivery(address _to, uint _value) onlyOwner public { _tokenDelivery(msg.sender, _to, _value, frozenDaysForICO); } function setBountyDistributionContract(address _contractAddress) onlyOwner public { bountyManagerDistributionContract = _contractAddress; } /**onlyBounty * Only bounty manager distribution contract function to deliver tokens for bounty community * * @param _to account addres who will receive tokens * @param _value quantity of tokens to deliver */ function bountyTransfer(address _to, uint _value) onlyBountyManager public { _freezeAccount(bountyManagerAddress, false); _tokenDelivery(bountyManagerAddress, _to, _value, frozenDaysForBounty); _freezeAccount(bountyManagerAddress, true); } /** * Function to get days to unfreeze some account * * @param _address account address to get days * @return result quantity of days to unfreeze `address` */ function daysToUnfreeze(address _address) public view returns (uint256) { require(_address != 0x0); /* solium-disable-next-line */ uint256 _now = now; uint256 result = 0; if( _now <= creationDate + freezingPeriod[_address] * 1 days ) { // still under the freezing period. uint256 finalPeriod = (creationDate + freezingPeriod[_address] * 1 days) / 1 days; uint256 currePeriod = _now / 1 days; result = finalPeriod - currePeriod; } return result; } /** * @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens * @param target Address to be frozen * @param freeze either to freeze it or not */ function _freezeAccount(address target, bool freeze) internal { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /** * Only owner function to call `_freezeAccount` directly * * @param target account address to freeze * @param freeze true to freeze account and false to unfreeze */ function freezeAccount(address target, bool freeze) onlyOwner public { _freezeAccount(target, freeze); } /** * Internal call to set freezing period for some account * * @param _target account address to freeze * @param _freeze true to freeze account and false to unfreeze * @param _days period to keep account frozen */ function _setFreezingPeriod(address _target, bool _freeze, uint256 _days) internal { _freezeAccount(_target, _freeze); freezingPeriod[_target] = _days; } /** * Only owner function to call `_setFreezingPeriod` directly * * @param _target account address to freeze * @param _freeze true to freeze account and false to unfreeze * @param _days period to keep account frozen */ function setFreezingPeriod(address _target, bool _freeze, uint256 _days) onlyOwner public { _setFreezingPeriod(_target, _freeze, _days); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance //allowance[_from][msg.sender] -= _value; allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { // check if the sender is under a freezing period if( _isTransferAllowed(msg.sender) ) { _setFreezingPeriod(msg.sender, false, 0); } allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { // check if the sender is under a freezing period if( _isTransferAllowed(msg.sender) ) { _setFreezingPeriod(msg.sender, false, 0); } tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough return _burn(msg.sender, _value); } /** * */ function _burn(address _from, uint256 _value) internal returns (bool success) { balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(_from, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance return _burn(_from, _value); } /** * Only ballast fund function to burn tokens from account * * Allows `fundAccount` burn tokens to send equivalent ether for account that claimed it * @param _from account address to burn tokens * @param _value quantity of tokens to burn */ function redemptionBurn(address _from, uint256 _value) onlyFund public{ _burn(_from, _value); } }
* Initializes contract with initial supply tokens to the creator of the contract/
function CinociCoin( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public { creationDate = now; address advisor = 0x32c5Ec858c52F8635Bd92e44d8797e5d356eBd05; address bountyManager = 0xdDa9bcf30AFDC40a5fFa6e1b6f70ef030A3E32f4; address earlyInvestor = 0x02FF2bA62440c92D2A02D95Df6fc233eA68c2091; address partner = 0x6A45baAEb21D49fD85B309235Ef2920d3A648858; address exchange1 = 0x8Bd10d3383504a12FD27A1Fd5c0E7bCeae3C8997; address exchange2 = 0xce8b8e7113072C5308cec669375E0Ab364b3435C; _initializeAccount(partner, frozenDaysForPartner, 30000000); _initializeAccount(advisor, frozenDaysForAdvisor, 20000000); _initializeAccount(earlyInvestor, frozenDaysForEarlyInvestor, 10000000); _initializeAccount(exchange1, frozenDaysforTestExchange, 1000); _initializeAccount(exchange2, frozenDaysforTestExchange, 1000); _initializeAccount(bountyManager, frozenDaysForBounty, 15000000); bountyManagerAddress = bountyManager;
202,607
[ 1, 4625, 348, 7953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0 ]
[ 1, 565, 445, 385, 267, 1882, 27055, 12, 203, 3639, 2254, 5034, 2172, 3088, 1283, 16, 203, 3639, 533, 1147, 461, 16, 203, 3639, 533, 1147, 5335, 203, 565, 262, 3155, 654, 39, 3462, 12, 6769, 3088, 1283, 16, 1147, 461, 16, 1147, 5335, 13, 1071, 7010, 565, 288, 203, 3639, 6710, 1626, 273, 2037, 31, 203, 203, 3639, 1758, 1261, 10227, 273, 374, 92, 1578, 71, 25, 23057, 7140, 28, 71, 9401, 42, 28, 4449, 25, 38, 72, 9975, 73, 6334, 72, 28, 7235, 27, 73, 25, 72, 23, 4313, 73, 38, 72, 6260, 31, 203, 3639, 1758, 324, 592, 93, 1318, 273, 374, 7669, 40, 69, 29, 70, 8522, 5082, 6799, 5528, 7132, 69, 25, 74, 29634, 26, 73, 21, 70, 26, 74, 7301, 10241, 4630, 20, 37, 23, 41, 1578, 74, 24, 31, 203, 3639, 1758, 11646, 3605, 395, 280, 273, 374, 92, 3103, 2246, 22, 70, 37, 26, 3247, 7132, 71, 9975, 40, 22, 37, 3103, 40, 8778, 40, 74, 26, 7142, 31026, 73, 37, 9470, 71, 3462, 12416, 31, 203, 3639, 1758, 19170, 273, 374, 92, 26, 37, 7950, 12124, 16985, 70, 5340, 40, 7616, 74, 40, 7140, 38, 5082, 29, 30803, 41, 74, 5540, 3462, 72, 23, 37, 1105, 5482, 8204, 31, 203, 3639, 1758, 7829, 21, 273, 374, 92, 28, 38, 72, 2163, 72, 3707, 28, 4763, 3028, 69, 2138, 16894, 5324, 37, 21, 27263, 25, 71, 20, 41, 27, 70, 39, 73, 8906, 23, 39, 28, 2733, 27, 31, 203, 3639, 1758, 7829, 22, 273, 374, 92, 311, 28, 70, 28, 73, 27, 2499, 5082, 9060, 39, 25, 5082, 28, 27832, 6028, 11180, 5877, 41, 20, 5895, 23, 1105, 70, 5026, 4763, 39, 31, 203, 203, 3639, 389, 11160, 3032, 12, 31993, 16, 12810, 9384, 1290, 1988, 1224, 16, 890, 17877, 1769, 203, 3639, 389, 11160, 3032, 12, 361, 10227, 16, 12810, 9384, 1290, 28087, 16, 576, 17877, 1769, 203, 3639, 389, 11160, 3032, 12, 2091, 715, 3605, 395, 280, 16, 12810, 9384, 1290, 41, 20279, 3605, 395, 280, 16, 2130, 11706, 1769, 21281, 3639, 389, 11160, 3032, 12, 16641, 21, 16, 12810, 9384, 1884, 4709, 11688, 16, 4336, 1769, 203, 3639, 389, 11160, 3032, 12, 16641, 22, 16, 12810, 9384, 1884, 4709, 11688, 16, 4336, 1769, 203, 3639, 389, 11160, 3032, 12, 70, 592, 93, 1318, 16, 12810, 9384, 1290, 38, 592, 93, 16, 4711, 9449, 1769, 203, 3639, 324, 592, 93, 1318, 1887, 273, 324, 592, 93, 1318, 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 ]
/** *Submitted for verification at Etherscan.io on 2020-07-12 */ // File: contracts/lib/Types.sol /* Copyright 2020 DODO ZOO. SPDX-License-Identifier: Apache-2.0 */ pragma solidity 0.6.9; pragma experimental ABIEncoderV2; library Types { enum RStatus {ONE, ABOVE_ONE, BELOW_ONE} enum EnterStatus {ENTERED, NOT_ENTERED} } // File: contracts/intf/IERC20.sol // This is a file copied from 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); function decimals() external view returns (uint8); function name() external view returns (string memory); /** * @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); } // File: contracts/lib/Ownable.sol /* Copyright 2020 DODO ZOO. */ /** * @title Ownable * @author DODO Breeder * * @notice Ownership related functions */ contract Ownable { address public _OWNER_; address public _NEW_OWNER_; // ============ Events ============ event OwnershipTransferPrepared(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // ============ Modifiers ============ modifier onlyOwner() { require(msg.sender == _OWNER_, "NOT_OWNER"); _; } // ============ Functions ============ constructor() internal { _OWNER_ = msg.sender; emit OwnershipTransferred(address(0), _OWNER_); } function transferOwnership(address newOwner) external onlyOwner { require(newOwner != address(0), "INVALID_OWNER"); emit OwnershipTransferPrepared(_OWNER_, newOwner); _NEW_OWNER_ = newOwner; } function claimOwnership() external { require(msg.sender == _NEW_OWNER_, "INVALID_CLAIM"); emit OwnershipTransferred(_OWNER_, _NEW_OWNER_); _OWNER_ = _NEW_OWNER_; _NEW_OWNER_ = address(0); } } // File: contracts/lib/SafeMath.sol /* Copyright 2020 DODO ZOO. */ /** * @title SafeMath * @author DODO Breeder * * @notice Math operations with safety checks that revert on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "MUL_ERROR"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "DIVIDING_ERROR"); return a / b; } function divCeil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 quotient = div(a, b); uint256 remainder = a - quotient * b; if (remainder > 0) { return quotient + 1; } else { return quotient; } } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SUB_ERROR"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "ADD_ERROR"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = x / 2 + 1; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } // File: contracts/lib/DecimalMath.sol /* Copyright 2020 DODO ZOO. */ /** * @title DecimalMath * @author DODO Breeder * * @notice Functions for fixed point number with 18 decimals */ library DecimalMath { using SafeMath for uint256; uint256 constant ONE = 10**18; function mul(uint256 target, uint256 d) internal pure returns (uint256) { return target.mul(d) / ONE; } function divFloor(uint256 target, uint256 d) internal pure returns (uint256) { return target.mul(ONE).div(d); } function divCeil(uint256 target, uint256 d) internal pure returns (uint256) { return target.mul(ONE).divCeil(d); } } // File: contracts/lib/ReentrancyGuard.sol /* Copyright 2020 DODO ZOO. */ /** * @title ReentrancyGuard * @author DODO Breeder * * @notice Protect functions from Reentrancy Attack */ contract ReentrancyGuard { Types.EnterStatus private _ENTER_STATUS_; constructor() internal { _ENTER_STATUS_ = Types.EnterStatus.NOT_ENTERED; } modifier preventReentrant() { require(_ENTER_STATUS_ != Types.EnterStatus.ENTERED, "REENTRANT"); _ENTER_STATUS_ = Types.EnterStatus.ENTERED; _; _ENTER_STATUS_ = Types.EnterStatus.NOT_ENTERED; } } // File: contracts/intf/IOracle.sol /* Copyright 2020 DODO ZOO. */ interface IOracle { function getPrice() external view returns (uint256); } // File: contracts/intf/IDODOLpToken.sol /* Copyright 2020 DODO ZOO. */ interface IDODOLpToken { function mint(address user, uint256 value) external; function burn(address user, uint256 value) external; function balanceOf(address owner) external view returns (uint256); function totalSupply() external view returns (uint256); } // File: contracts/impl/Storage.sol /* Copyright 2020 DODO ZOO. */ /** * @title Storage * @author DODO Breeder * * @notice Local Variables */ contract Storage is Ownable, ReentrancyGuard { using SafeMath for uint256; // ============ Variables for Control ============ bool internal _INITIALIZED_; bool public _CLOSED_; bool public _DEPOSIT_QUOTE_ALLOWED_; bool public _DEPOSIT_BASE_ALLOWED_; bool public _TRADE_ALLOWED_; uint256 public _GAS_PRICE_LIMIT_; // ============ Core Address ============ address public _SUPERVISOR_; // could freeze system in emergency address public _MAINTAINER_; // collect maintainer fee to buy food for DODO address public _BASE_TOKEN_; address public _QUOTE_TOKEN_; address public _ORACLE_; // ============ Variables for PMM Algorithm ============ uint256 public _LP_FEE_RATE_; uint256 public _MT_FEE_RATE_; uint256 public _K_; Types.RStatus public _R_STATUS_; uint256 public _TARGET_BASE_TOKEN_AMOUNT_; uint256 public _TARGET_QUOTE_TOKEN_AMOUNT_; uint256 public _BASE_BALANCE_; uint256 public _QUOTE_BALANCE_; address public _BASE_CAPITAL_TOKEN_; address public _QUOTE_CAPITAL_TOKEN_; // ============ Variables for Final Settlement ============ uint256 public _BASE_CAPITAL_RECEIVE_QUOTE_; uint256 public _QUOTE_CAPITAL_RECEIVE_BASE_; mapping(address => bool) public _CLAIMED_; // ============ Modifiers ============ modifier onlySupervisorOrOwner() { require(msg.sender == _SUPERVISOR_ || msg.sender == _OWNER_, "NOT_SUPERVISOR_OR_OWNER"); _; } modifier notClosed() { require(!_CLOSED_, "DODO_CLOSED"); _; } // ============ Helper Functions ============ function _checkDODOParameters() internal view returns (uint256) { require(_K_ < DecimalMath.ONE, "K>=1"); require(_K_ > 0, "K=0"); require(_LP_FEE_RATE_.add(_MT_FEE_RATE_) < DecimalMath.ONE, "FEE_RATE>=1"); } function getOraclePrice() public view returns (uint256) { return IOracle(_ORACLE_).getPrice(); } function getBaseCapitalBalanceOf(address lp) public view returns (uint256) { return IDODOLpToken(_BASE_CAPITAL_TOKEN_).balanceOf(lp); } function getTotalBaseCapital() public view returns (uint256) { return IDODOLpToken(_BASE_CAPITAL_TOKEN_).totalSupply(); } function getQuoteCapitalBalanceOf(address lp) public view returns (uint256) { return IDODOLpToken(_QUOTE_CAPITAL_TOKEN_).balanceOf(lp); } function getTotalQuoteCapital() public view returns (uint256) { return IDODOLpToken(_QUOTE_CAPITAL_TOKEN_).totalSupply(); } } // File: contracts/lib/DODOMath.sol /* Copyright 2020 DODO ZOO. */ /** * @title DODOMath * @author DODO Breeder * * @notice Functions for complex calculating. Including ONE Integration and TWO Quadratic solutions */ library DODOMath { using SafeMath for uint256; /* Integrate dodo curve fron V1 to V2 require V0>=V1>=V2>0 res = (1-k)i(V1-V2)+ikV0*V0(1/V2-1/V1) let V1-V2=delta res = i*delta*(1-k+k(V0^2/V1/V2)) */ function _GeneralIntegrate( uint256 V0, uint256 V1, uint256 V2, uint256 i, uint256 k ) internal pure returns (uint256) { uint256 fairAmount = DecimalMath.mul(i, V1.sub(V2)); // i*delta uint256 V0V0V1V2 = DecimalMath.divCeil(V0.mul(V0).div(V1), V2); uint256 penalty = DecimalMath.mul(k, V0V0V1V2); // k(V0^2/V1/V2) return DecimalMath.mul(fairAmount, DecimalMath.ONE.sub(k).add(penalty)); } /* The same with integration expression above, we have: i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2) Given Q1 and deltaB, solve Q2 This is a quadratic function and the standard version is aQ2^2 + bQ2 + c = 0, where a=1-k -b=(1-k)Q1-kQ0^2/Q1+i*deltaB c=-kQ0^2 and Q2=(-b+sqrt(b^2+4(1-k)kQ0^2))/2(1-k) note: another root is negative, abondan if deltaBSig=true, then Q2>Q1 if deltaBSig=false, then Q2<Q1 */ function _SolveQuadraticFunctionForTrade( uint256 Q0, uint256 Q1, uint256 ideltaB, bool deltaBSig, uint256 k ) internal pure returns (uint256) { // calculate -b value and sig // -b = (1-k)Q1-kQ0^2/Q1+i*deltaB uint256 kQ02Q1 = DecimalMath.mul(k, Q0).mul(Q0).div(Q1); // kQ0^2/Q1 uint256 b = DecimalMath.mul(DecimalMath.ONE.sub(k), Q1); // (1-k)Q1 bool minusbSig = true; if (deltaBSig) { b = b.add(ideltaB); // (1-k)Q1+i*deltaB } else { kQ02Q1 = kQ02Q1.add(ideltaB); // i*deltaB+kQ0^2/Q1 } if (b >= kQ02Q1) { b = b.sub(kQ02Q1); minusbSig = true; } else { b = kQ02Q1.sub(b); minusbSig = false; } // calculate sqrt uint256 squareRoot = DecimalMath.mul( DecimalMath.ONE.sub(k).mul(4), DecimalMath.mul(k, Q0).mul(Q0) ); // 4(1-k)kQ0^2 squareRoot = b.mul(b).add(squareRoot).sqrt(); // sqrt(b*b+4(1-k)kQ0*Q0) // final res uint256 denominator = DecimalMath.ONE.sub(k).mul(2); // 2(1-k) uint256 numerator; if (minusbSig) { numerator = b.add(squareRoot); } else { numerator = squareRoot.sub(b); } if (deltaBSig) { return DecimalMath.divFloor(numerator, denominator); } else { return DecimalMath.divCeil(numerator, denominator); } } /* Start from the integration function i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2) Assume Q2=Q0, Given Q1 and deltaB, solve Q0 let fairAmount = i*deltaB */ function _SolveQuadraticFunctionForTarget( uint256 V1, uint256 k, uint256 fairAmount ) internal pure returns (uint256 V0) { // V0 = V1+V1*(sqrt-1)/2k uint256 sqrt = DecimalMath.divCeil(DecimalMath.mul(k, fairAmount).mul(4), V1); sqrt = sqrt.add(DecimalMath.ONE).mul(DecimalMath.ONE).sqrt(); uint256 premium = DecimalMath.divCeil(sqrt.sub(DecimalMath.ONE), k.mul(2)); // V0 is greater than or equal to V1 according to the solution return DecimalMath.mul(V1, DecimalMath.ONE.add(premium)); } } // File: contracts/impl/Pricing.sol /* Copyright 2020 DODO ZOO. */ /** * @title Pricing * @author DODO Breeder * * @notice DODO Pricing model */ contract Pricing is Storage { using SafeMath for uint256; // ============ R = 1 cases ============ function _ROneSellBaseToken(uint256 amount, uint256 targetQuoteTokenAmount) internal view returns (uint256 receiveQuoteToken) { uint256 i = getOraclePrice(); uint256 Q2 = DODOMath._SolveQuadraticFunctionForTrade( targetQuoteTokenAmount, targetQuoteTokenAmount, DecimalMath.mul(i, amount), false, _K_ ); // in theory Q2 <= targetQuoteTokenAmount // however when amount is close to 0, precision problems may cause Q2 > targetQuoteTokenAmount return targetQuoteTokenAmount.sub(Q2); } function _ROneBuyBaseToken(uint256 amount, uint256 targetBaseTokenAmount) internal view returns (uint256 payQuoteToken) { require(amount < targetBaseTokenAmount, "DODO_BASE_BALANCE_NOT_ENOUGH"); uint256 B2 = targetBaseTokenAmount.sub(amount); payQuoteToken = _RAboveIntegrate(targetBaseTokenAmount, targetBaseTokenAmount, B2); return payQuoteToken; } // ============ R < 1 cases ============ function _RBelowSellBaseToken( uint256 amount, uint256 quoteBalance, uint256 targetQuoteAmount ) internal view returns (uint256 receieQuoteToken) { uint256 i = getOraclePrice(); uint256 Q2 = DODOMath._SolveQuadraticFunctionForTrade( targetQuoteAmount, quoteBalance, DecimalMath.mul(i, amount), false, _K_ ); return quoteBalance.sub(Q2); } function _RBelowBuyBaseToken( uint256 amount, uint256 quoteBalance, uint256 targetQuoteAmount ) internal view returns (uint256 payQuoteToken) { // Here we don't require amount less than some value // Because it is limited at upper function // See Trader.queryBuyBaseToken uint256 i = getOraclePrice(); uint256 Q2 = DODOMath._SolveQuadraticFunctionForTrade( targetQuoteAmount, quoteBalance, DecimalMath.mul(i, amount), true, _K_ ); return Q2.sub(quoteBalance); } function _RBelowBackToOne() internal view returns (uint256 payQuoteToken) { // important: carefully design the system to make sure spareBase always greater than or equal to 0 uint256 spareBase = _BASE_BALANCE_.sub(_TARGET_BASE_TOKEN_AMOUNT_); uint256 price = getOraclePrice(); uint256 fairAmount = DecimalMath.mul(spareBase, price); uint256 newTargetQuote = DODOMath._SolveQuadraticFunctionForTarget( _QUOTE_BALANCE_, _K_, fairAmount ); return newTargetQuote.sub(_QUOTE_BALANCE_); } // ============ R > 1 cases ============ function _RAboveBuyBaseToken( uint256 amount, uint256 baseBalance, uint256 targetBaseAmount ) internal view returns (uint256 payQuoteToken) { require(amount < baseBalance, "DODO_BASE_BALANCE_NOT_ENOUGH"); uint256 B2 = baseBalance.sub(amount); return _RAboveIntegrate(targetBaseAmount, baseBalance, B2); } function _RAboveSellBaseToken( uint256 amount, uint256 baseBalance, uint256 targetBaseAmount ) internal view returns (uint256 receiveQuoteToken) { // here we don't require B1 <= targetBaseAmount // Because it is limited at upper function // See Trader.querySellBaseToken uint256 B1 = baseBalance.add(amount); return _RAboveIntegrate(targetBaseAmount, B1, baseBalance); } function _RAboveBackToOne() internal view returns (uint256 payBaseToken) { // important: carefully design the system to make sure spareBase always greater than or equal to 0 uint256 spareQuote = _QUOTE_BALANCE_.sub(_TARGET_QUOTE_TOKEN_AMOUNT_); uint256 price = getOraclePrice(); uint256 fairAmount = DecimalMath.divFloor(spareQuote, price); uint256 newTargetBase = DODOMath._SolveQuadraticFunctionForTarget( _BASE_BALANCE_, _K_, fairAmount ); return newTargetBase.sub(_BASE_BALANCE_); } // ============ Helper functions ============ function getExpectedTarget() public view returns (uint256 baseTarget, uint256 quoteTarget) { uint256 Q = _QUOTE_BALANCE_; uint256 B = _BASE_BALANCE_; if (_R_STATUS_ == Types.RStatus.ONE) { return (_TARGET_BASE_TOKEN_AMOUNT_, _TARGET_QUOTE_TOKEN_AMOUNT_); } else if (_R_STATUS_ == Types.RStatus.BELOW_ONE) { uint256 payQuoteToken = _RBelowBackToOne(); return (_TARGET_BASE_TOKEN_AMOUNT_, Q.add(payQuoteToken)); } else if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { uint256 payBaseToken = _RAboveBackToOne(); return (B.add(payBaseToken), _TARGET_QUOTE_TOKEN_AMOUNT_); } } function getMidPrice() public view returns (uint256 midPrice) { (uint256 baseTarget, uint256 quoteTarget) = getExpectedTarget(); if (_R_STATUS_ == Types.RStatus.BELOW_ONE) { uint256 R = DecimalMath.divFloor( quoteTarget.mul(quoteTarget).div(_QUOTE_BALANCE_), _QUOTE_BALANCE_ ); R = DecimalMath.ONE.sub(_K_).add(DecimalMath.mul(_K_, R)); return DecimalMath.divFloor(getOraclePrice(), R); } else { uint256 R = DecimalMath.divFloor( baseTarget.mul(baseTarget).div(_BASE_BALANCE_), _BASE_BALANCE_ ); R = DecimalMath.ONE.sub(_K_).add(DecimalMath.mul(_K_, R)); return DecimalMath.mul(getOraclePrice(), R); } } function _RAboveIntegrate( uint256 B0, uint256 B1, uint256 B2 ) internal view returns (uint256) { uint256 i = getOraclePrice(); return DODOMath._GeneralIntegrate(B0, B1, B2, i, _K_); } // function _RBelowIntegrate( // uint256 Q0, // uint256 Q1, // uint256 Q2 // ) internal view returns (uint256) { // uint256 i = getOraclePrice(); // i = DecimalMath.divFloor(DecimalMath.ONE, i); // 1/i // return DODOMath._GeneralIntegrate(Q0, Q1, Q2, i, _K_); // } } // File: contracts/lib/SafeERC20.sol /* Copyright 2020 DODO ZOO. This is a simplified version of OpenZepplin's SafeERC20 library */ /** * @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; 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 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 // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/impl/Settlement.sol /* Copyright 2020 DODO ZOO. */ /** * @title Settlement * @author DODO Breeder * * @notice Functions for assets settlement */ contract Settlement is Storage { using SafeMath for uint256; using SafeERC20 for IERC20; // ============ Events ============ event Donate(uint256 amount, bool isBaseToken); event Claim(address indexed user, uint256 baseTokenAmount, uint256 quoteTokenAmount); // ============ Assets IN/OUT Functions ============ function _baseTokenTransferIn(address from, uint256 amount) internal { uint256 beforeBalance = IERC20(_BASE_TOKEN_).balanceOf(address(this)); IERC20(_BASE_TOKEN_).safeTransferFrom(from, address(this), amount); uint256 afterBalance = IERC20(_BASE_TOKEN_).balanceOf(address(this)); _BASE_BALANCE_ = _BASE_BALANCE_.add(afterBalance.sub(beforeBalance)); } function _quoteTokenTransferIn(address from, uint256 amount) internal { uint256 beforeBalance = IERC20(_QUOTE_TOKEN_).balanceOf(address(this)); IERC20(_QUOTE_TOKEN_).safeTransferFrom(from, address(this), amount); uint256 afterBalance = IERC20(_QUOTE_TOKEN_).balanceOf(address(this)); _QUOTE_BALANCE_ = _QUOTE_BALANCE_.add(afterBalance.sub(beforeBalance)); } function _baseTokenTransferOut(address to, uint256 amount) internal { uint256 beforeBalance = IERC20(_BASE_TOKEN_).balanceOf(address(this)); IERC20(_BASE_TOKEN_).safeTransfer(to, amount); uint256 afterBalance = IERC20(_BASE_TOKEN_).balanceOf(address(this)); _BASE_BALANCE_ = _BASE_BALANCE_.sub(beforeBalance.sub(afterBalance)); } function _quoteTokenTransferOut(address to, uint256 amount) internal { uint256 beforeBalance = IERC20(_QUOTE_TOKEN_).balanceOf(address(this)); IERC20(_QUOTE_TOKEN_).safeTransfer(to, amount); uint256 afterBalance = IERC20(_QUOTE_TOKEN_).balanceOf(address(this)); _QUOTE_BALANCE_ = _QUOTE_BALANCE_.sub(beforeBalance.sub(afterBalance)); } // ============ Donate to Liquidity Pool Functions ============ function _donateBaseToken(uint256 amount) internal { _TARGET_BASE_TOKEN_AMOUNT_ = _TARGET_BASE_TOKEN_AMOUNT_.add(amount); emit Donate(amount, true); } function _donateQuoteToken(uint256 amount) internal { _TARGET_QUOTE_TOKEN_AMOUNT_ = _TARGET_QUOTE_TOKEN_AMOUNT_.add(amount); emit Donate(amount, false); } function donateBaseToken(uint256 amount) external { _baseTokenTransferIn(msg.sender, amount); _donateBaseToken(amount); } function donateQuoteToken(uint256 amount) external { _quoteTokenTransferIn(msg.sender, amount); _donateQuoteToken(amount); } // ============ Final Settlement Functions ============ // last step to shut down dodo function finalSettlement() external onlyOwner notClosed { _CLOSED_ = true; _DEPOSIT_QUOTE_ALLOWED_ = false; _DEPOSIT_BASE_ALLOWED_ = false; _TRADE_ALLOWED_ = false; uint256 totalBaseCapital = getTotalBaseCapital(); uint256 totalQuoteCapital = getTotalQuoteCapital(); if (_QUOTE_BALANCE_ > _TARGET_QUOTE_TOKEN_AMOUNT_) { uint256 spareQuote = _QUOTE_BALANCE_.sub(_TARGET_QUOTE_TOKEN_AMOUNT_); _BASE_CAPITAL_RECEIVE_QUOTE_ = DecimalMath.divFloor(spareQuote, totalBaseCapital); } else { _TARGET_QUOTE_TOKEN_AMOUNT_ = _QUOTE_BALANCE_; } if (_BASE_BALANCE_ > _TARGET_BASE_TOKEN_AMOUNT_) { uint256 spareBase = _BASE_BALANCE_.sub(_TARGET_BASE_TOKEN_AMOUNT_); _QUOTE_CAPITAL_RECEIVE_BASE_ = DecimalMath.divFloor(spareBase, totalQuoteCapital); } else { _TARGET_BASE_TOKEN_AMOUNT_ = _BASE_BALANCE_; } _R_STATUS_ = Types.RStatus.ONE; } // claim remaining assets after final settlement function claim() external preventReentrant { require(_CLOSED_, "DODO_NOT_CLOSED"); require(!_CLAIMED_[msg.sender], "ALREADY_CLAIMED"); _CLAIMED_[msg.sender] = true; uint256 quoteAmount = DecimalMath.mul( getBaseCapitalBalanceOf(msg.sender), _BASE_CAPITAL_RECEIVE_QUOTE_ ); uint256 baseAmount = DecimalMath.mul( getQuoteCapitalBalanceOf(msg.sender), _QUOTE_CAPITAL_RECEIVE_BASE_ ); _baseTokenTransferOut(msg.sender, baseAmount); _quoteTokenTransferOut(msg.sender, quoteAmount); emit Claim(msg.sender, baseAmount, quoteAmount); return; } // in case someone transfer to contract directly function retrieve(address token, uint256 amount) external onlyOwner { if (token == _BASE_TOKEN_) { require( IERC20(_BASE_TOKEN_).balanceOf(address(this)) >= _BASE_BALANCE_.add(amount), "DODO_BASE_BALANCE_NOT_ENOUGH" ); } if (token == _QUOTE_TOKEN_) { require( IERC20(_QUOTE_TOKEN_).balanceOf(address(this)) >= _QUOTE_BALANCE_.add(amount), "DODO_QUOTE_BALANCE_NOT_ENOUGH" ); } IERC20(token).safeTransfer(msg.sender, amount); } } // File: contracts/impl/Trader.sol /* Copyright 2020 DODO ZOO. */ /** * @title Trader * @author DODO Breeder * * @notice Functions for trader operations */ contract Trader is Storage, Pricing, Settlement { using SafeMath for uint256; // ============ Events ============ event SellBaseToken(address indexed seller, uint256 payBase, uint256 receiveQuote); event BuyBaseToken(address indexed buyer, uint256 receiveBase, uint256 payQuote); event ChargeMaintainerFee(address indexed maintainer, bool isBaseToken, uint256 amount); // ============ Modifiers ============ modifier tradeAllowed() { require(_TRADE_ALLOWED_, "TRADE_NOT_ALLOWED"); _; } modifier gasPriceLimit() { require(tx.gasprice <= _GAS_PRICE_LIMIT_, "GAS_PRICE_EXCEED"); _; } // ============ Trade Functions ============ function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { // query price ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); // settle assets _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); // update TARGET if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { // query price ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); // settle assets _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); // update TARGET if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } // ============ Query Functions ============ function querySellBaseToken(uint256 amount) external view returns (uint256 receiveQuote) { (receiveQuote, , , , , ) = _querySellBaseToken(amount); return receiveQuote; } function queryBuyBaseToken(uint256 amount) external view returns (uint256 payQuote) { (payQuote, , , , , ) = _queryBuyBaseToken(amount); return payQuote; } function _querySellBaseToken(uint256 amount) internal view returns ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); uint256 sellBaseAmount = amount; if (_R_STATUS_ == Types.RStatus.ONE) { // case 1: R=1 // R falls below one receiveQuote = _ROneSellBaseToken(sellBaseAmount, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; } else if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { uint256 backToOnePayBase = newBaseTarget.sub(_BASE_BALANCE_); uint256 backToOneReceiveQuote = _QUOTE_BALANCE_.sub(newQuoteTarget); // case 2: R>1 // complex case, R status depends on trading amount if (sellBaseAmount < backToOnePayBase) { // case 2.1: R status do not change receiveQuote = _RAboveSellBaseToken(sellBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; if (receiveQuote > backToOneReceiveQuote) { // [Important corner case!] may enter this branch when some precision problem happens. And consequently contribute to negative spare quote amount // to make sure spare quote>=0, mannually set receiveQuote=backToOneReceiveQuote receiveQuote = backToOneReceiveQuote; } } else if (sellBaseAmount == backToOnePayBase) { // case 2.2: R status changes to ONE receiveQuote = backToOneReceiveQuote; newRStatus = Types.RStatus.ONE; } else { // case 2.3: R status changes to BELOW_ONE receiveQuote = backToOneReceiveQuote.add( _ROneSellBaseToken(sellBaseAmount.sub(backToOnePayBase), newQuoteTarget) ); newRStatus = Types.RStatus.BELOW_ONE; } } else { // _R_STATUS_ == Types.RStatus.BELOW_ONE // case 3: R<1 receiveQuote = _RBelowSellBaseToken(sellBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; } // count fees lpFeeQuote = DecimalMath.mul(receiveQuote, _LP_FEE_RATE_); mtFeeQuote = DecimalMath.mul(receiveQuote, _MT_FEE_RATE_); receiveQuote = receiveQuote.sub(lpFeeQuote).sub(mtFeeQuote); return (receiveQuote, lpFeeQuote, mtFeeQuote, newRStatus, newQuoteTarget, newBaseTarget); } function _queryBuyBaseToken(uint256 amount) internal view returns ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); // charge fee from user receive amount lpFeeBase = DecimalMath.mul(amount, _LP_FEE_RATE_); mtFeeBase = DecimalMath.mul(amount, _MT_FEE_RATE_); uint256 buyBaseAmount = amount.add(lpFeeBase).add(mtFeeBase); if (_R_STATUS_ == Types.RStatus.ONE) { // case 1: R=1 payQuote = _ROneBuyBaseToken(buyBaseAmount, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; } else if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { // case 2: R>1 payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; } else if (_R_STATUS_ == Types.RStatus.BELOW_ONE) { uint256 backToOnePayQuote = newQuoteTarget.sub(_QUOTE_BALANCE_); uint256 backToOneReceiveBase = _BASE_BALANCE_.sub(newBaseTarget); // case 3: R<1 // complex case, R status may change if (buyBaseAmount < backToOneReceiveBase) { // case 3.1: R status do not change // no need to check payQuote because spare base token must be greater than zero payQuote = _RBelowBuyBaseToken(buyBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; } else if (buyBaseAmount == backToOneReceiveBase) { // case 3.2: R status changes to ONE payQuote = backToOnePayQuote; newRStatus = Types.RStatus.ONE; } else { // case 3.3: R status changes to ABOVE_ONE payQuote = backToOnePayQuote.add( _ROneBuyBaseToken(buyBaseAmount.sub(backToOneReceiveBase), newBaseTarget) ); newRStatus = Types.RStatus.ABOVE_ONE; } } return (payQuote, lpFeeBase, mtFeeBase, newRStatus, newQuoteTarget, newBaseTarget); } } // File: contracts/impl/LiquidityProvider.sol /* Copyright 2020 DODO ZOO. */ /** * @title LiquidityProvider * @author DODO Breeder * * @notice Functions for liquidity provider operations */ contract LiquidityProvider is Storage, Pricing, Settlement { using SafeMath for uint256; // ============ Events ============ event Deposit( address indexed payer, address indexed receiver, bool isBaseToken, uint256 amount, uint256 lpTokenAmount ); event Withdraw( address indexed payer, address indexed receiver, bool isBaseToken, uint256 amount, uint256 lpTokenAmount ); event ChargePenalty(address indexed payer, bool isBaseToken, uint256 amount); // ============ Modifiers ============ modifier depositQuoteAllowed() { require(_DEPOSIT_QUOTE_ALLOWED_, "DEPOSIT_QUOTE_NOT_ALLOWED"); _; } modifier depositBaseAllowed() { require(_DEPOSIT_BASE_ALLOWED_, "DEPOSIT_BASE_NOT_ALLOWED"); _; } // ============ Routine Functions ============ function withdrawBase(uint256 amount) external returns (uint256) { return withdrawBaseTo(msg.sender, amount); } function depositBase(uint256 amount) external { depositBaseTo(msg.sender, amount); } function withdrawQuote(uint256 amount) external returns (uint256) { return withdrawQuoteTo(msg.sender, amount); } function depositQuote(uint256 amount) external { depositQuoteTo(msg.sender, amount); } function withdrawAllBase() external returns (uint256) { return withdrawAllBaseTo(msg.sender); } function withdrawAllQuote() external returns (uint256) { return withdrawAllQuoteTo(msg.sender); } // ============ Deposit Functions ============ function depositQuoteTo(address to, uint256 amount) public preventReentrant depositQuoteAllowed { (, uint256 quoteTarget) = getExpectedTarget(); uint256 totalQuoteCapital = getTotalQuoteCapital(); uint256 capital = amount; if (address(this).balance == 0) { //inject PRESENT ETHER // give remaining quote token to lp as a gift capital = amount.add(quoteTarget); } else if (quoteTarget > 0) { capital = amount.mul(totalQuoteCapital).div(quoteTarget); } // settlement _quoteTokenTransferIn(msg.sender, amount); _mintQuoteCapital(to, capital); _TARGET_QUOTE_TOKEN_AMOUNT_ = _TARGET_QUOTE_TOKEN_AMOUNT_.add(amount); emit Deposit(msg.sender, to, false, amount, capital); } function depositBaseTo(address to, uint256 amount) public preventReentrant depositBaseAllowed { (uint256 baseTarget, ) = getExpectedTarget(); uint256 totalBaseCapital = getTotalBaseCapital(); uint256 capital = amount; if (address(this).balance == 0) { //inject PRESENT ETHER // give remaining base token to lp as a gift capital = amount.add(baseTarget); } else if (baseTarget > 0) { capital = amount.mul(totalBaseCapital).div(baseTarget); } // settlement _baseTokenTransferIn(msg.sender, amount); _mintBaseCapital(to, capital); _TARGET_BASE_TOKEN_AMOUNT_ = _TARGET_BASE_TOKEN_AMOUNT_.add(amount); emit Deposit(msg.sender, to, true, amount, capital); } // ============ Withdraw Functions ============ function withdrawQuoteTo(address to, uint256 amount) public preventReentrant returns (uint256) { // calculate capital (, uint256 quoteTarget) = getExpectedTarget(); uint256 totalQuoteCapital = getTotalQuoteCapital(); require(totalQuoteCapital > 0, "NO_QUOTE_LP"); uint256 requireQuoteCapital = amount.mul(totalQuoteCapital).divCeil(quoteTarget); require( requireQuoteCapital <= getQuoteCapitalBalanceOf(msg.sender), "LP_QUOTE_CAPITAL_BALANCE_NOT_ENOUGH" ); // handle penalty, penalty may exceed amount uint256 penalty = getWithdrawQuotePenalty(amount); require(penalty < amount, "PENALTY_EXCEED"); // settlement _TARGET_QUOTE_TOKEN_AMOUNT_ = _TARGET_QUOTE_TOKEN_AMOUNT_.sub(amount); _burnQuoteCapital(msg.sender, requireQuoteCapital); _quoteTokenTransferOut(to, amount.sub(penalty)); _donateQuoteToken(penalty); emit Withdraw(msg.sender, to, false, amount.sub(penalty), requireQuoteCapital); emit ChargePenalty(msg.sender, false, penalty); return amount.sub(penalty); } function withdrawBaseTo(address to, uint256 amount) public preventReentrant returns (uint256) { // calculate capital (uint256 baseTarget, ) = getExpectedTarget(); uint256 totalBaseCapital = getTotalBaseCapital(); require(totalBaseCapital > 0, "NO_BASE_LP"); uint256 requireBaseCapital = amount.mul(totalBaseCapital).divCeil(baseTarget); require( requireBaseCapital <= getBaseCapitalBalanceOf(msg.sender), "LP_BASE_CAPITAL_BALANCE_NOT_ENOUGH" ); // handle penalty, penalty may exceed amount uint256 penalty = getWithdrawBasePenalty(amount); require(penalty <= amount, "PENALTY_EXCEED"); // settlement _TARGET_BASE_TOKEN_AMOUNT_ = _TARGET_BASE_TOKEN_AMOUNT_.sub(amount); _burnBaseCapital(msg.sender, requireBaseCapital); _baseTokenTransferOut(to, amount.sub(penalty)); _donateBaseToken(penalty); emit Withdraw(msg.sender, to, true, amount.sub(penalty), requireBaseCapital); emit ChargePenalty(msg.sender, true, penalty); return amount.sub(penalty); } // ============ Withdraw all Functions ============ function withdrawAllQuoteTo(address to) public preventReentrant returns (uint256) { uint256 withdrawAmount = getLpQuoteBalance(msg.sender); uint256 capital = getQuoteCapitalBalanceOf(msg.sender); // handle penalty, penalty may exceed amount uint256 penalty = getWithdrawQuotePenalty(withdrawAmount); require(penalty <= withdrawAmount, "PENALTY_EXCEED"); // settlement _TARGET_QUOTE_TOKEN_AMOUNT_ = _TARGET_QUOTE_TOKEN_AMOUNT_.sub(withdrawAmount); _burnQuoteCapital(msg.sender, capital); _quoteTokenTransferOut(to, withdrawAmount.sub(penalty)); _donateQuoteToken(penalty); emit Withdraw(msg.sender, to, false, withdrawAmount, capital); emit ChargePenalty(msg.sender, false, penalty); return withdrawAmount.sub(penalty); } function withdrawAllBaseTo(address to) public preventReentrant returns (uint256) { uint256 withdrawAmount = getLpBaseBalance(msg.sender); uint256 capital = getBaseCapitalBalanceOf(msg.sender); // handle penalty, penalty may exceed amount uint256 penalty = getWithdrawBasePenalty(withdrawAmount); require(penalty <= withdrawAmount, "PENALTY_EXCEED"); // settlement _TARGET_BASE_TOKEN_AMOUNT_ = _TARGET_BASE_TOKEN_AMOUNT_.sub(withdrawAmount); _burnBaseCapital(msg.sender, capital); _baseTokenTransferOut(to, withdrawAmount.sub(penalty)); _donateBaseToken(penalty); emit Withdraw(msg.sender, to, true, withdrawAmount, capital); emit ChargePenalty(msg.sender, true, penalty); return withdrawAmount.sub(penalty); } // ============ Helper Functions ============ function _mintBaseCapital(address user, uint256 amount) internal { IDODOLpToken(_BASE_CAPITAL_TOKEN_).mint(user, amount); } function _mintQuoteCapital(address user, uint256 amount) internal { IDODOLpToken(_QUOTE_CAPITAL_TOKEN_).mint(user, amount); } function _burnBaseCapital(address user, uint256 amount) internal { IDODOLpToken(_BASE_CAPITAL_TOKEN_).burn(user, amount); } function _burnQuoteCapital(address user, uint256 amount) internal { IDODOLpToken(_QUOTE_CAPITAL_TOKEN_).burn(user, amount); } // ============ Getter Functions ============ function getLpBaseBalance(address lp) public view returns (uint256 lpBalance) { uint256 totalBaseCapital = getTotalBaseCapital(); (uint256 baseTarget, ) = getExpectedTarget(); if (address(this).balance == 0) { //inject PRESENT ETHER return 0; } lpBalance = getBaseCapitalBalanceOf(lp).mul(baseTarget).div(totalBaseCapital); return lpBalance; } function getLpQuoteBalance(address lp) public view returns (uint256 lpBalance) { uint256 totalQuoteCapital = getTotalQuoteCapital(); (, uint256 quoteTarget) = getExpectedTarget(); if (address(this).balance == 0) { //inject PRESENT ETHER return 0; } lpBalance = getQuoteCapitalBalanceOf(lp).mul(quoteTarget).div(totalQuoteCapital); return lpBalance; } function getWithdrawQuotePenalty(uint256 amount) public view returns (uint256 penalty) { require(amount <= _QUOTE_BALANCE_, "DODO_QUOTE_BALANCE_NOT_ENOUGH"); if (_R_STATUS_ == Types.RStatus.BELOW_ONE) { uint256 spareBase = _BASE_BALANCE_.sub(_TARGET_BASE_TOKEN_AMOUNT_); uint256 price = getOraclePrice(); uint256 fairAmount = DecimalMath.mul(spareBase, price); uint256 targetQuote = DODOMath._SolveQuadraticFunctionForTarget( _QUOTE_BALANCE_, _K_, fairAmount ); // if amount = _QUOTE_BALANCE_, div error uint256 targetQuoteWithWithdraw = DODOMath._SolveQuadraticFunctionForTarget( _QUOTE_BALANCE_.sub(amount), _K_, fairAmount ); return targetQuote.sub(targetQuoteWithWithdraw.add(amount)); } else { return 0; } } function getWithdrawBasePenalty(uint256 amount) public view returns (uint256 penalty) { require(amount <= _BASE_BALANCE_, "DODO_BASE_BALANCE_NOT_ENOUGH"); if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { uint256 spareQuote = _QUOTE_BALANCE_.sub(_TARGET_QUOTE_TOKEN_AMOUNT_); uint256 price = getOraclePrice(); uint256 fairAmount = DecimalMath.divFloor(spareQuote, price); uint256 targetBase = DODOMath._SolveQuadraticFunctionForTarget( _BASE_BALANCE_, _K_, fairAmount ); // if amount = _BASE_BALANCE_, div error uint256 targetBaseWithWithdraw = DODOMath._SolveQuadraticFunctionForTarget( _BASE_BALANCE_.sub(amount), _K_, fairAmount ); return targetBase.sub(targetBaseWithWithdraw.add(amount)); } else { return 0; } } } // File: contracts/impl/Admin.sol /* Copyright 2020 DODO ZOO. */ /** * @title Admin * @author DODO Breeder * * @notice Functions for admin operations */ contract Admin is Storage { // ============ Events ============ event UpdateGasPriceLimit(uint256 oldGasPriceLimit, uint256 newGasPriceLimit); event UpdateLiquidityProviderFeeRate( uint256 oldLiquidityProviderFeeRate, uint256 newLiquidityProviderFeeRate ); event UpdateMaintainerFeeRate(uint256 oldMaintainerFeeRate, uint256 newMaintainerFeeRate); event UpdateK(uint256 oldK, uint256 newK); // ============ Params Setting Functions ============ function setOracle(address newOracle) external onlyOwner { _ORACLE_ = newOracle; } function setSupervisor(address newSupervisor) external onlyOwner { _SUPERVISOR_ = newSupervisor; } function setMaintainer(address newMaintainer) external onlyOwner { _MAINTAINER_ = newMaintainer; } function setLiquidityProviderFeeRate(uint256 newLiquidityPorviderFeeRate) external onlyOwner { emit UpdateLiquidityProviderFeeRate(_LP_FEE_RATE_, newLiquidityPorviderFeeRate); _LP_FEE_RATE_ = newLiquidityPorviderFeeRate; _checkDODOParameters(); } function setMaintainerFeeRate(uint256 newMaintainerFeeRate) external onlyOwner { emit UpdateMaintainerFeeRate(_MT_FEE_RATE_, newMaintainerFeeRate); _MT_FEE_RATE_ = newMaintainerFeeRate; _checkDODOParameters(); } function setK(uint256 newK) external onlyOwner { emit UpdateK(_K_, newK); _K_ = newK; _checkDODOParameters(); } function setGasPriceLimit(uint256 newGasPriceLimit) external onlySupervisorOrOwner { emit UpdateGasPriceLimit(_GAS_PRICE_LIMIT_, newGasPriceLimit); _GAS_PRICE_LIMIT_ = newGasPriceLimit; } // ============ System Control Functions ============ function disableTrading() external onlySupervisorOrOwner { _TRADE_ALLOWED_ = false; } function enableTrading() external onlyOwner notClosed { _TRADE_ALLOWED_ = true; } function disableQuoteDeposit() external onlySupervisorOrOwner { _DEPOSIT_QUOTE_ALLOWED_ = false; } function enableQuoteDeposit() external onlyOwner notClosed { _DEPOSIT_QUOTE_ALLOWED_ = true; } function disableBaseDeposit() external onlySupervisorOrOwner { _DEPOSIT_BASE_ALLOWED_ = false; } function enableBaseDeposit() external onlyOwner notClosed { _DEPOSIT_BASE_ALLOWED_ = true; } } // File: contracts/impl/DODOLpToken.sol /* Copyright 2020 DODO ZOO. */ /** * @title DODOLpToken * @author DODO Breeder * * @notice Tokenize liquidity pool assets. An ordinary ERC20 contract with mint and burn functions */ contract DODOLpToken is Ownable { using SafeMath for uint256; string public symbol = "DLP"; address public originToken; uint256 public totalSupply; mapping(address => uint256) internal balances; mapping(address => mapping(address => uint256)) internal allowed; // ============ Events ============ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); event Mint(address indexed user, uint256 value); event Burn(address indexed user, uint256 value); // ============ Functions ============ constructor(address _originToken) public { originToken = _originToken; } function name() public view returns (string memory) { string memory lpTokenSuffix = "_DODO_LP_TOKEN_"; return string(abi.encodePacked(IERC20(originToken).name(), lpTokenSuffix)); } function decimals() public view returns (uint8) { return IERC20(originToken).decimals(); } /** * @dev transfer token for a specified address * @param to The address to transfer to. * @param amount The amount to be transferred. */ function transfer(address to, uint256 amount) public returns (bool) { require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH"); balances[msg.sender] = balances[msg.sender].sub(amount); balances[to] = balances[to].add(amount); emit Transfer(msg.sender, to, amount); return true; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the the balance of. * @return balance An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) external view returns (uint256 balance) { return balances[owner]; } /** * @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 amount uint256 the amount of tokens to be transferred */ function transferFrom( address from, address to, uint256 amount ) public returns (bool) { require(amount <= balances[from], "BALANCE_NOT_ENOUGH"); require(amount <= allowed[from][msg.sender], "ALLOWANCE_NOT_ENOUGH"); balances[from] = balances[from].sub(amount); balances[to] = balances[to].add(amount); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); emit Transfer(from, to, amount); return true; } /** * @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) public returns (bool) { allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); 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]; } function mint(address user, uint256 value) external onlyOwner { balances[user] = balances[user].add(value); totalSupply = totalSupply.add(value); emit Mint(address(0), value); emit Transfer(address(0), user, value); } function burn(address user, uint256 value) external onlyOwner { balances[user] = balances[user].sub(value); totalSupply = totalSupply.sub(value); emit Burn(user, value); } } // File: contracts/dodo.sol /* Copyright 2020 DODO ZOO. */ /** * @title DODO * @author DODO Breeder * * @notice Entrance for users */ contract DODO is Admin, Trader, LiquidityProvider { function init( address supervisor, address maintainer, address baseToken, address quoteToken, address oracle, uint256 lpFeeRate, uint256 mtFeeRate, uint256 k, uint256 gasPriceLimit ) external onlyOwner preventReentrant { require(!_INITIALIZED_, "DODO_INITIALIZED"); _INITIALIZED_ = true; _SUPERVISOR_ = supervisor; _MAINTAINER_ = maintainer; _BASE_TOKEN_ = baseToken; _QUOTE_TOKEN_ = quoteToken; _ORACLE_ = oracle; _DEPOSIT_BASE_ALLOWED_ = true; _DEPOSIT_QUOTE_ALLOWED_ = true; _TRADE_ALLOWED_ = true; _GAS_PRICE_LIMIT_ = gasPriceLimit; _LP_FEE_RATE_ = lpFeeRate; _MT_FEE_RATE_ = mtFeeRate; _K_ = k; _R_STATUS_ = Types.RStatus.ONE; _BASE_CAPITAL_TOKEN_ = address(new DODOLpToken(_BASE_TOKEN_)); _QUOTE_CAPITAL_TOKEN_ = address(new DODOLpToken(_QUOTE_TOKEN_)); _checkDODOParameters(); } }
* @title Trader @author DODO Breeder @notice Functions for trader operations/ ============ Events ============ ============ Modifiers ============
contract Trader is Storage, Pricing, Settlement { using SafeMath for uint256; event SellBaseToken(address indexed seller, uint256 payBase, uint256 receiveQuote); event BuyBaseToken(address indexed buyer, uint256 receiveBase, uint256 payQuote); event ChargeMaintainerFee(address indexed maintainer, bool isBaseToken, uint256 amount); modifier tradeAllowed() { require(_TRADE_ALLOWED_, "TRADE_NOT_ALLOWED"); _; } modifier gasPriceLimit() { require(tx.gasprice <= _GAS_PRICE_LIMIT_, "GAS_PRICE_EXCEED"); _; } function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _querySellBaseToken(amount); require(receiveQuote >= minReceiveQuote, "SELL_BASE_RECEIVE_NOT_ENOUGH"); _baseTokenTransferIn(msg.sender, amount); _quoteTokenTransferOut(msg.sender, receiveQuote); _quoteTokenTransferOut(_MAINTAINER_, mtFeeQuote); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateQuoteToken(lpFeeQuote); emit SellBaseToken(msg.sender, amount, receiveQuote); if (mtFeeQuote != 0) { emit ChargeMaintainerFee(_MAINTAINER_, false, mtFeeQuote); } return receiveQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } function buyBaseToken(uint256 amount, uint256 maxPayQuote) external tradeAllowed gasPriceLimit preventReentrant returns (uint256) { ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) = _queryBuyBaseToken(amount); require(payQuote <= maxPayQuote, "BUY_BASE_COST_TOO_MUCH"); _quoteTokenTransferIn(msg.sender, payQuote); _baseTokenTransferOut(msg.sender, amount); _baseTokenTransferOut(_MAINTAINER_, mtFeeBase); if (_TARGET_QUOTE_TOKEN_AMOUNT_ != newQuoteTarget) { _TARGET_QUOTE_TOKEN_AMOUNT_ = newQuoteTarget; } if (_TARGET_BASE_TOKEN_AMOUNT_ != newBaseTarget) { _TARGET_BASE_TOKEN_AMOUNT_ = newBaseTarget; } if (_R_STATUS_ != newRStatus) { _R_STATUS_ = newRStatus; } _donateBaseToken(lpFeeBase); emit BuyBaseToken(msg.sender, amount, payQuote); if (mtFeeBase != 0) { emit ChargeMaintainerFee(_MAINTAINER_, true, mtFeeBase); } return payQuote; } function querySellBaseToken(uint256 amount) external view returns (uint256 receiveQuote) { (receiveQuote, , , , , ) = _querySellBaseToken(amount); return receiveQuote; } function queryBuyBaseToken(uint256 amount) external view returns (uint256 payQuote) { (payQuote, , , , , ) = _queryBuyBaseToken(amount); return payQuote; } function _querySellBaseToken(uint256 amount) internal view returns ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); uint256 sellBaseAmount = amount; if (_R_STATUS_ == Types.RStatus.ONE) { receiveQuote = _ROneSellBaseToken(sellBaseAmount, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; uint256 backToOnePayBase = newBaseTarget.sub(_BASE_BALANCE_); uint256 backToOneReceiveQuote = _QUOTE_BALANCE_.sub(newQuoteTarget); if (sellBaseAmount < backToOnePayBase) { receiveQuote = _RAboveSellBaseToken(sellBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; if (receiveQuote > backToOneReceiveQuote) { receiveQuote = backToOneReceiveQuote; } newRStatus = Types.RStatus.ONE; _ROneSellBaseToken(sellBaseAmount.sub(backToOnePayBase), newQuoteTarget) ); newRStatus = Types.RStatus.BELOW_ONE; } newRStatus = Types.RStatus.BELOW_ONE; } mtFeeQuote = DecimalMath.mul(receiveQuote, _MT_FEE_RATE_); receiveQuote = receiveQuote.sub(lpFeeQuote).sub(mtFeeQuote); return (receiveQuote, lpFeeQuote, mtFeeQuote, newRStatus, newQuoteTarget, newBaseTarget); } function _querySellBaseToken(uint256 amount) internal view returns ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); uint256 sellBaseAmount = amount; if (_R_STATUS_ == Types.RStatus.ONE) { receiveQuote = _ROneSellBaseToken(sellBaseAmount, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; uint256 backToOnePayBase = newBaseTarget.sub(_BASE_BALANCE_); uint256 backToOneReceiveQuote = _QUOTE_BALANCE_.sub(newQuoteTarget); if (sellBaseAmount < backToOnePayBase) { receiveQuote = _RAboveSellBaseToken(sellBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; if (receiveQuote > backToOneReceiveQuote) { receiveQuote = backToOneReceiveQuote; } newRStatus = Types.RStatus.ONE; _ROneSellBaseToken(sellBaseAmount.sub(backToOnePayBase), newQuoteTarget) ); newRStatus = Types.RStatus.BELOW_ONE; } newRStatus = Types.RStatus.BELOW_ONE; } mtFeeQuote = DecimalMath.mul(receiveQuote, _MT_FEE_RATE_); receiveQuote = receiveQuote.sub(lpFeeQuote).sub(mtFeeQuote); return (receiveQuote, lpFeeQuote, mtFeeQuote, newRStatus, newQuoteTarget, newBaseTarget); } } else if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { function _querySellBaseToken(uint256 amount) internal view returns ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); uint256 sellBaseAmount = amount; if (_R_STATUS_ == Types.RStatus.ONE) { receiveQuote = _ROneSellBaseToken(sellBaseAmount, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; uint256 backToOnePayBase = newBaseTarget.sub(_BASE_BALANCE_); uint256 backToOneReceiveQuote = _QUOTE_BALANCE_.sub(newQuoteTarget); if (sellBaseAmount < backToOnePayBase) { receiveQuote = _RAboveSellBaseToken(sellBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; if (receiveQuote > backToOneReceiveQuote) { receiveQuote = backToOneReceiveQuote; } newRStatus = Types.RStatus.ONE; _ROneSellBaseToken(sellBaseAmount.sub(backToOnePayBase), newQuoteTarget) ); newRStatus = Types.RStatus.BELOW_ONE; } newRStatus = Types.RStatus.BELOW_ONE; } mtFeeQuote = DecimalMath.mul(receiveQuote, _MT_FEE_RATE_); receiveQuote = receiveQuote.sub(lpFeeQuote).sub(mtFeeQuote); return (receiveQuote, lpFeeQuote, mtFeeQuote, newRStatus, newQuoteTarget, newBaseTarget); } function _querySellBaseToken(uint256 amount) internal view returns ( uint256 receiveQuote, uint256 lpFeeQuote, uint256 mtFeeQuote, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); uint256 sellBaseAmount = amount; if (_R_STATUS_ == Types.RStatus.ONE) { receiveQuote = _ROneSellBaseToken(sellBaseAmount, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; uint256 backToOnePayBase = newBaseTarget.sub(_BASE_BALANCE_); uint256 backToOneReceiveQuote = _QUOTE_BALANCE_.sub(newQuoteTarget); if (sellBaseAmount < backToOnePayBase) { receiveQuote = _RAboveSellBaseToken(sellBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; if (receiveQuote > backToOneReceiveQuote) { receiveQuote = backToOneReceiveQuote; } newRStatus = Types.RStatus.ONE; _ROneSellBaseToken(sellBaseAmount.sub(backToOnePayBase), newQuoteTarget) ); newRStatus = Types.RStatus.BELOW_ONE; } newRStatus = Types.RStatus.BELOW_ONE; } mtFeeQuote = DecimalMath.mul(receiveQuote, _MT_FEE_RATE_); receiveQuote = receiveQuote.sub(lpFeeQuote).sub(mtFeeQuote); return (receiveQuote, lpFeeQuote, mtFeeQuote, newRStatus, newQuoteTarget, newBaseTarget); } } else if (sellBaseAmount == backToOnePayBase) { receiveQuote = backToOneReceiveQuote; } else { receiveQuote = backToOneReceiveQuote.add( } else { receiveQuote = _RBelowSellBaseToken(sellBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); lpFeeQuote = DecimalMath.mul(receiveQuote, _LP_FEE_RATE_); function _queryBuyBaseToken(uint256 amount) internal view returns ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); lpFeeBase = DecimalMath.mul(amount, _LP_FEE_RATE_); mtFeeBase = DecimalMath.mul(amount, _MT_FEE_RATE_); uint256 buyBaseAmount = amount.add(lpFeeBase).add(mtFeeBase); if (_R_STATUS_ == Types.RStatus.ONE) { payQuote = _ROneBuyBaseToken(buyBaseAmount, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; uint256 backToOnePayQuote = newQuoteTarget.sub(_QUOTE_BALANCE_); uint256 backToOneReceiveBase = _BASE_BALANCE_.sub(newBaseTarget); if (buyBaseAmount < backToOneReceiveBase) { payQuote = _RBelowBuyBaseToken(buyBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; payQuote = backToOnePayQuote; newRStatus = Types.RStatus.ONE; payQuote = backToOnePayQuote.add( _ROneBuyBaseToken(buyBaseAmount.sub(backToOneReceiveBase), newBaseTarget) ); newRStatus = Types.RStatus.ABOVE_ONE; } } return (payQuote, lpFeeBase, mtFeeBase, newRStatus, newQuoteTarget, newBaseTarget); } function _queryBuyBaseToken(uint256 amount) internal view returns ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); lpFeeBase = DecimalMath.mul(amount, _LP_FEE_RATE_); mtFeeBase = DecimalMath.mul(amount, _MT_FEE_RATE_); uint256 buyBaseAmount = amount.add(lpFeeBase).add(mtFeeBase); if (_R_STATUS_ == Types.RStatus.ONE) { payQuote = _ROneBuyBaseToken(buyBaseAmount, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; uint256 backToOnePayQuote = newQuoteTarget.sub(_QUOTE_BALANCE_); uint256 backToOneReceiveBase = _BASE_BALANCE_.sub(newBaseTarget); if (buyBaseAmount < backToOneReceiveBase) { payQuote = _RBelowBuyBaseToken(buyBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; payQuote = backToOnePayQuote; newRStatus = Types.RStatus.ONE; payQuote = backToOnePayQuote.add( _ROneBuyBaseToken(buyBaseAmount.sub(backToOneReceiveBase), newBaseTarget) ); newRStatus = Types.RStatus.ABOVE_ONE; } } return (payQuote, lpFeeBase, mtFeeBase, newRStatus, newQuoteTarget, newBaseTarget); } } else if (_R_STATUS_ == Types.RStatus.ABOVE_ONE) { } else if (_R_STATUS_ == Types.RStatus.BELOW_ONE) { function _queryBuyBaseToken(uint256 amount) internal view returns ( uint256 payQuote, uint256 lpFeeBase, uint256 mtFeeBase, Types.RStatus newRStatus, uint256 newQuoteTarget, uint256 newBaseTarget ) { (newBaseTarget, newQuoteTarget) = getExpectedTarget(); lpFeeBase = DecimalMath.mul(amount, _LP_FEE_RATE_); mtFeeBase = DecimalMath.mul(amount, _MT_FEE_RATE_); uint256 buyBaseAmount = amount.add(lpFeeBase).add(mtFeeBase); if (_R_STATUS_ == Types.RStatus.ONE) { payQuote = _ROneBuyBaseToken(buyBaseAmount, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget); newRStatus = Types.RStatus.ABOVE_ONE; uint256 backToOnePayQuote = newQuoteTarget.sub(_QUOTE_BALANCE_); uint256 backToOneReceiveBase = _BASE_BALANCE_.sub(newBaseTarget); if (buyBaseAmount < backToOneReceiveBase) { payQuote = _RBelowBuyBaseToken(buyBaseAmount, _QUOTE_BALANCE_, newQuoteTarget); newRStatus = Types.RStatus.BELOW_ONE; payQuote = backToOnePayQuote; newRStatus = Types.RStatus.ONE; payQuote = backToOnePayQuote.add( _ROneBuyBaseToken(buyBaseAmount.sub(backToOneReceiveBase), newBaseTarget) ); newRStatus = Types.RStatus.ABOVE_ONE; } } return (payQuote, lpFeeBase, mtFeeBase, newRStatus, newQuoteTarget, newBaseTarget); } } else if (buyBaseAmount == backToOneReceiveBase) { } else { }
6,388,820
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 2197, 765, 632, 4161, 463, 2311, 605, 15656, 264, 632, 20392, 15486, 364, 1284, 765, 5295, 19, 422, 1432, 631, 9043, 422, 1432, 631, 422, 1432, 631, 3431, 3383, 422, 1432, 631, 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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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 ]
[ 1, 16351, 2197, 765, 353, 5235, 16, 453, 1512, 310, 16, 1000, 88, 806, 288, 203, 565, 1450, 14060, 10477, 364, 2254, 5034, 31, 203, 203, 203, 565, 871, 348, 1165, 2171, 1345, 12, 2867, 8808, 29804, 16, 2254, 5034, 8843, 2171, 16, 2254, 5034, 6798, 10257, 1769, 203, 203, 565, 871, 605, 9835, 2171, 1345, 12, 2867, 8808, 27037, 16, 2254, 5034, 6798, 2171, 16, 2254, 5034, 8843, 10257, 1769, 203, 203, 565, 871, 3703, 908, 49, 1598, 1521, 14667, 12, 2867, 8808, 11566, 1521, 16, 1426, 353, 2171, 1345, 16, 2254, 5034, 3844, 1769, 203, 203, 203, 203, 203, 203, 565, 9606, 18542, 5042, 1435, 288, 203, 3639, 2583, 24899, 20060, 1639, 67, 16852, 67, 16, 315, 20060, 1639, 67, 4400, 67, 16852, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 565, 9606, 16189, 5147, 3039, 1435, 288, 203, 3639, 2583, 12, 978, 18, 31604, 8694, 1648, 389, 43, 3033, 67, 7698, 1441, 67, 8283, 67, 16, 315, 43, 3033, 67, 7698, 1441, 67, 2294, 1441, 2056, 8863, 203, 3639, 389, 31, 203, 565, 289, 203, 203, 203, 565, 445, 357, 80, 2171, 1345, 12, 11890, 5034, 3844, 16, 2254, 5034, 1131, 11323, 10257, 13, 203, 3639, 3903, 203, 3639, 18542, 5042, 203, 3639, 16189, 5147, 3039, 203, 3639, 5309, 426, 8230, 970, 203, 3639, 1135, 261, 11890, 5034, 13, 203, 565, 288, 203, 3639, 261, 203, 5411, 2254, 5034, 6798, 10257, 16, 203, 5411, 2254, 5034, 12423, 14667, 10257, 16, 203, 5411, 2254, 5034, 5874, 14667, 10257, 16, 203, 5411, 7658, 18, 54, 1482, 394, 54, 1482, 16, 203, 5411, 2254, 5034, 394, 10257, 2326, 16, 203, 5411, 2254, 5034, 394, 2171, 2326, 203, 3639, 262, 273, 389, 2271, 55, 1165, 2171, 1345, 12, 8949, 1769, 203, 3639, 2583, 12, 18149, 10257, 1545, 1131, 11323, 10257, 16, 315, 1090, 4503, 67, 8369, 67, 27086, 5354, 67, 4400, 67, 1157, 26556, 16715, 8863, 203, 203, 3639, 389, 1969, 1345, 5912, 382, 12, 3576, 18, 15330, 16, 3844, 1769, 203, 3639, 389, 6889, 1345, 5912, 1182, 12, 3576, 18, 15330, 16, 6798, 10257, 1769, 203, 3639, 389, 6889, 1345, 5912, 1182, 24899, 5535, 3217, 16843, 67, 16, 5874, 14667, 10257, 1769, 203, 203, 3639, 309, 261, 67, 16374, 67, 18980, 67, 8412, 67, 2192, 51, 5321, 67, 480, 394, 10257, 2326, 13, 288, 203, 5411, 389, 16374, 67, 18980, 67, 8412, 67, 2192, 51, 5321, 67, 273, 394, 10257, 2326, 31, 203, 3639, 289, 203, 3639, 309, 261, 67, 16374, 67, 8369, 67, 8412, 67, 2192, 51, 5321, 67, 480, 394, 2171, 2326, 13, 288, 203, 5411, 389, 16374, 67, 8369, 67, 8412, 67, 2192, 51, 5321, 67, 273, 394, 2171, 2326, 31, 203, 3639, 289, 203, 3639, 309, 261, 67, 54, 67, 8608, 67, 480, 394, 54, 1482, 13, 288, 203, 5411, 389, 54, 67, 8608, 67, 273, 394, 54, 1482, 31, 203, 3639, 289, 203, 203, 3639, 389, 19752, 340, 10257, 1345, 12, 9953, 14667, 10257, 1769, 203, 3639, 3626, 348, 1165, 2171, 1345, 12, 3576, 18, 15330, 16, 3844, 16, 6798, 10257, 1769, 203, 3639, 309, 261, 1010, 14667, 10257, 480, 374, 13, 288, 203, 5411, 3626, 3703, 908, 49, 1598, 1521, 14667, 24899, 5535, 3217, 16843, 67, 16, 629, 16, 5874, 14667, 10257, 1769, 203, 3639, 289, 203, 203, 3639, 327, 6798, 10257, 31, 203, 565, 289, 203, 203, 565, 445, 357, 80, 2171, 1345, 12, 11890, 5034, 3844, 16, 2254, 5034, 1131, 11323, 10257, 13, 203, 3639, 3903, 203, 3639, 18542, 5042, 203, 3639, 16189, 5147, 3039, 203, 3639, 5309, 426, 8230, 970, 203, 3639, 1135, 261, 11890, 5034, 13, 203, 565, 288, 203, 3639, 261, 203, 5411, 2254, 5034, 6798, 10257, 16, 203, 5411, 2254, 5034, 12423, 14667, 10257, 16, 203, 5411, 2254, 5034, 5874, 14667, 10257, 16, 203, 5411, 7658, 18, 54, 1482, 394, 54, 1482, 16, 203, 5411, 2254, 5034, 394, 10257, 2326, 16, 203, 5411, 2254, 5034, 394, 2171, 2326, 203, 3639, 262, 273, 389, 2271, 55, 1165, 2171, 1345, 12, 8949, 1769, 203, 3639, 2583, 12, 18149, 10257, 1545, 1131, 11323, 10257, 16, 315, 1090, 4503, 67, 8369, 67, 27086, 5354, 67, 4400, 67, 1157, 26556, 16715, 8863, 203, 203, 3639, 389, 1969, 1345, 5912, 382, 12, 3576, 18, 15330, 16, 3844, 1769, 203, 3639, 389, 6889, 1345, 5912, 1182, 12, 3576, 18, 15330, 16, 6798, 10257, 1769, 203, 3639, 389, 6889, 1345, 5912, 1182, 24899, 5535, 3217, 16843, 67, 16, 5874, 14667, 10257, 1769, 203, 203, 3639, 309, 261, 67, 16374, 67, 18980, 67, 8412, 67, 2192, 51, 5321, 67, 480, 394, 10257, 2326, 13, 288, 203, 5411, 389, 16374, 67, 18980, 67, 8412, 67, 2192, 51, 5321, 67, 273, 394, 10257, 2326, 31, 203, 3639, 289, 203, 3639, 309, 261, 67, 16374, 67, 8369, 67, 8412, 67, 2192, 51, 5321, 67, 480, 394, 2171, 2326, 13, 288, 203, 5411, 389, 16374, 67, 8369, 67, 8412, 67, 2192, 51, 5321, 67, 273, 394, 2171, 2326, 31, 203, 3639, 289, 203, 3639, 309, 261, 67, 54, 67, 8608, 67, 480, 394, 54, 1482, 13, 288, 203, 5411, 389, 54, 67, 8608, 67, 273, 394, 54, 1482, 31, 203, 3639, 289, 203, 203, 3639, 389, 19752, 340, 10257, 1345, 12, 9953, 14667, 10257, 1769, 203, 3639, 3626, 348, 1165, 2171, 1345, 12, 3576, 18, 15330, 16, 3844, 16, 6798, 10257, 1769, 203, 3639, 309, 261, 1010, 14667, 10257, 480, 374, 13, 288, 203, 5411, 3626, 3703, 908, 49, 1598, 1521, 14667, 24899, 5535, 3217, 16843, 67, 16, 629, 16, 5874, 14667, 10257, 1769, 203, 3639, 289, 203, 203, 3639, 327, 6798, 10257, 31, 203, 565, 289, 203, 203, 565, 445, 357, 80, 2171, 1345, 12, 11890, 5034, 3844, 16, 2254, 5034, 1131, 11323, 10257, 13, 203, 3639, 3903, 203, 3639, 18542, 5042, 203, 3639, 16189, 5147, 3039, 203, 3639, 5309, 426, 8230, 970, 203, 3639, 1135, 261, 11890, 5034, 13, 203, 565, 288, 203, 3639, 261, 203, 5411, 2254, 5034, 6798, 10257, 16, 203, 5411, 2254, 5034, 12423, 14667, 10257, 16, 203, 5411, 2254, 5034, 5874, 14667, 10257, 16, 203, 5411, 7658, 18, 54, 1482, 394, 54, 1482, 16, 203, 5411, 2254, 5034, 394, 10257, 2326, 16, 203, 5411, 2254, 5034, 2 ]
// SPDX-License-Identifier: Apache-2.0 /* Copyright 2020 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.6; pragma experimental ABIEncoderV2; interface IKyberDmmFactory { function getPoolAtIndex(address token0, address token1, uint256 index) external view returns (address); } interface IKyberDmmRouter { function factory() external view returns (address); function getAmountsOut(uint256 amountIn, address[] calldata pools, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata pools, address[] calldata path) external view returns (uint256[] memory amounts); } contract KyberDmmSampler { /// @dev Gas limit for KyberDmm calls. uint256 constant private KYBER_DMM_CALL_GAS = 150e3; // 150k /// @dev Sample sell quotes from KyberDmm. /// @param router Router to look up tokens and amounts /// @param path Token route. Should be takerToken -> makerToken /// @param takerTokenAmounts Taker token sell amount for each sample. /// @return pools The pool addresses involved in the multi path trade /// @return makerTokenAmounts Maker amounts bought at each taker token /// amount. function sampleSellsFromKyberDmm( address router, address[] memory path, uint256[] memory takerTokenAmounts ) public view returns (address[] memory pools, uint256[] memory makerTokenAmounts) { uint256 numSamples = takerTokenAmounts.length; makerTokenAmounts = new uint256[](numSamples); pools = _getKyberDmmPools(router, path); if (pools.length == 0) { return (pools, makerTokenAmounts); } for (uint256 i = 0; i < numSamples; i++) { try IKyberDmmRouter(router).getAmountsOut {gas: KYBER_DMM_CALL_GAS} (takerTokenAmounts[i], pools, path) returns (uint256[] memory amounts) { makerTokenAmounts[i] = amounts[path.length - 1]; // Break early if there are 0 amounts if (makerTokenAmounts[i] == 0) { break; } } catch (bytes memory) { // Swallow failures, leaving all results as zero. break; } } } /// @dev Sample buy quotes from KyberDmm. /// @param router Router to look up tokens and amounts /// @param path Token route. Should be takerToken -> makerToken. /// @param makerTokenAmounts Maker token buy amount for each sample. /// @return pools The pool addresses involved in the multi path trade /// @return takerTokenAmounts Taker amounts sold at each maker token /// amount. function sampleBuysFromKyberDmm( address router, address[] memory path, uint256[] memory makerTokenAmounts ) public view returns (address[] memory pools, uint256[] memory takerTokenAmounts) { uint256 numSamples = makerTokenAmounts.length; takerTokenAmounts = new uint256[](numSamples); pools = _getKyberDmmPools(router, path); if (pools.length == 0) { return (pools, takerTokenAmounts); } for (uint256 i = 0; i < numSamples; i++) { try IKyberDmmRouter(router).getAmountsIn {gas: KYBER_DMM_CALL_GAS} (makerTokenAmounts[i], pools, path) returns (uint256[] memory amounts) { takerTokenAmounts[i] = amounts[0]; // Break early if there are 0 amounts if (takerTokenAmounts[i] == 0) { break; } } catch (bytes memory) { // Swallow failures, leaving all results as zero. break; } } } function _getKyberDmmPools( address router, address[] memory path ) private view returns (address[] memory pools) { pools = new address[](path.length - 1); IKyberDmmFactory factory = IKyberDmmFactory(IKyberDmmRouter(router).factory()); for (uint256 i = 0; i < pools.length; i++) { // Currently only supporting the first pool found at the index try factory.getPoolAtIndex {gas: KYBER_DMM_CALL_GAS} (path[i], path[i + 1], 0) returns (address pool) { pools[i] = pool; } catch (bytes memory) { return new address[](0); } } } }
@dev Sample buy quotes from KyberDmm. @param router Router to look up tokens and amounts @param path Token route. Should be takerToken -> makerToken. @param makerTokenAmounts Maker token buy amount for each sample. @return pools The pool addresses involved in the multi path trade @return takerTokenAmounts Taker amounts sold at each maker token amount. Break early if there are 0 amounts
function sampleBuysFromKyberDmm( address router, address[] memory path, uint256[] memory makerTokenAmounts ) public view returns (address[] memory pools, uint256[] memory takerTokenAmounts) { uint256 numSamples = makerTokenAmounts.length; takerTokenAmounts = new uint256[](numSamples); pools = _getKyberDmmPools(router, path); if (pools.length == 0) { return (pools, takerTokenAmounts); } for (uint256 i = 0; i < numSamples; i++) { try IKyberDmmRouter(router).getAmountsIn (makerTokenAmounts[i], pools, path) returns (uint256[] memory amounts) { takerTokenAmounts[i] = amounts[0]; if (takerTokenAmounts[i] == 0) { break; } } } }
13,093,905
[ 1, 4625, 348, 7953, 560, 30, 225, 632, 5206, 11474, 30143, 10681, 628, 1475, 93, 744, 40, 7020, 18, 632, 891, 4633, 9703, 358, 2324, 731, 2430, 471, 30980, 632, 891, 589, 3155, 1946, 18, 9363, 506, 268, 6388, 1345, 317, 312, 6388, 1345, 18, 632, 891, 312, 6388, 1345, 6275, 87, 490, 6388, 1147, 30143, 3844, 364, 1517, 3296, 18, 632, 2463, 16000, 1021, 2845, 6138, 24589, 316, 326, 3309, 589, 18542, 632, 2463, 268, 6388, 1345, 6275, 87, 399, 6388, 30980, 272, 1673, 622, 1517, 312, 6388, 1147, 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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, 3296, 38, 89, 1900, 1265, 47, 93, 744, 40, 7020, 12, 203, 3639, 1758, 4633, 16, 203, 3639, 1758, 8526, 3778, 589, 16, 203, 3639, 2254, 5034, 8526, 3778, 312, 6388, 1345, 6275, 87, 203, 565, 262, 203, 3639, 1071, 203, 3639, 1476, 203, 3639, 1135, 261, 2867, 8526, 3778, 16000, 16, 2254, 5034, 8526, 3778, 268, 6388, 1345, 6275, 87, 13, 203, 565, 288, 203, 3639, 2254, 5034, 818, 13239, 273, 312, 6388, 1345, 6275, 87, 18, 2469, 31, 203, 3639, 268, 6388, 1345, 6275, 87, 273, 394, 2254, 5034, 8526, 12, 2107, 13239, 1769, 203, 3639, 16000, 273, 389, 588, 47, 93, 744, 40, 7020, 16639, 12, 10717, 16, 589, 1769, 203, 3639, 309, 261, 27663, 18, 2469, 422, 374, 13, 288, 203, 5411, 327, 261, 27663, 16, 268, 6388, 1345, 6275, 87, 1769, 203, 3639, 289, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 818, 13239, 31, 277, 27245, 288, 203, 5411, 775, 203, 7734, 467, 47, 93, 744, 40, 7020, 8259, 12, 10717, 2934, 588, 6275, 87, 382, 203, 10792, 261, 29261, 1345, 6275, 87, 63, 77, 6487, 16000, 16, 589, 13, 203, 7734, 1135, 261, 11890, 5034, 8526, 3778, 30980, 13, 203, 5411, 288, 203, 7734, 268, 6388, 1345, 6275, 87, 63, 77, 65, 273, 30980, 63, 20, 15533, 203, 7734, 309, 261, 88, 6388, 1345, 6275, 87, 63, 77, 65, 422, 374, 13, 288, 203, 10792, 898, 31, 203, 7734, 289, 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 ]
/** *Submitted for verification at Etherscan.io on 2021-06-20 */ // NeverApe | NeverApe // Telegram: https://t.me/NeverApe // With thanks and major props to the NeverApe team! // Fair Launch, no Dev Tokens. 100% LP. // Snipers will be nuked. // LP Lock immediately on launch. // Ownership will be renounced 30 minutes after launch. // Slippage Recommended: 14%+ // 3% Supply limit per TX for the first 5 minutes. /** 🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌 * ███  ██ ███████ ██  ██ ███████ ██████  █████  ██████  ███████  * ████  ██ ██      ██  ██ ██      ██   ██ ██   ██ ██   ██ ██       * ██ ██  ██ █████  ██  ██ █████  ██████  ███████ ██████  █████  * ██  ██ ██ ██      ██  ██  ██     ██   ██ ██   ██ ██      ██     * ██   ████ ███████   ████   ███████ ██  ██ ██  ██ ██  ███████  *                                                            🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌 */ // SPDX-License-Identifier: Unlicensed pragma solidity 0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(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 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { 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); } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); 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"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { 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); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } 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 getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event 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 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; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract NeverApe is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isSniper; address[] private _confirmedSnipers; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000000000000000; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "NeverApe | t.me/NeverApe"; string private _symbol = "NeverApe"; uint8 private _decimals = 9; uint256 public launchTime; uint256 public _taxFee = 1; uint256 private _previousTaxFee = _taxFee; address payable private teamDevAddress; uint256 public _liquidityFee = 12; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public splitDivisor = 6; uint256 public _maxTxAmount = 30000000000000000000000; uint256 private minimumTokensBeforeSwap = 5000000000000000000; uint256 private buyBackUpperLimit = 1 * 10**21; bool public tradingOpen = false; //once switched on, can never be switched off. IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public buyBackEnabled = true; event RewardLiquidityProviders(uint256 tokenAmount); event BuyBackEnabledUpdated(bool enabled); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function openTrading() external onlyOwner() { swapAndLiquifyEnabled = true; tradingOpen = true; launchTime = block.timestamp; //setSwapAndLiquifyEnabled(true); } function initContract() external onlyOwner() { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // List of front-runner & sniper bots from t.me/FairLaunchCalls _isSniper[address(0x7589319ED0fD750017159fb4E4d96C63966173C1)] = true; _confirmedSnipers.push(address(0x7589319ED0fD750017159fb4E4d96C63966173C1)); _isSniper[address(0x65A67DF75CCbF57828185c7C050e34De64d859d0)] = true; _confirmedSnipers.push(address(0x65A67DF75CCbF57828185c7C050e34De64d859d0)); _isSniper[address(0xE031b36b53E53a292a20c5F08fd1658CDdf74fce)] = true; _confirmedSnipers.push(address(0xE031b36b53E53a292a20c5F08fd1658CDdf74fce)); _isSniper[address(0xE031b36b53E53a292a20c5F08fd1658CDdf74fce)] = true; _confirmedSnipers.push(address(0xE031b36b53E53a292a20c5F08fd1658CDdf74fce)); _isSniper[address(0xe516bDeE55b0b4e9bAcaF6285130De15589B1345)] = true; _confirmedSnipers.push(address(0xe516bDeE55b0b4e9bAcaF6285130De15589B1345)); _isSniper[address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b)] = true; _confirmedSnipers.push(address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b)); _isSniper[address(0xd7d3EE77D35D0a56F91542D4905b1a2b1CD7cF95)] = true; _confirmedSnipers.push(address(0xd7d3EE77D35D0a56F91542D4905b1a2b1CD7cF95)); _isSniper[address(0xFe76f05dc59fEC04184fA0245AD0C3CF9a57b964)] = true; _confirmedSnipers.push(address(0xFe76f05dc59fEC04184fA0245AD0C3CF9a57b964)); _isSniper[address(0xDC81a3450817A58D00f45C86d0368290088db848)] = true; _confirmedSnipers.push(address(0xDC81a3450817A58D00f45C86d0368290088db848)); _isSniper[address(0x45fD07C63e5c316540F14b2002B085aEE78E3881)] = true; _confirmedSnipers.push(address(0x45fD07C63e5c316540F14b2002B085aEE78E3881)); _isSniper[address(0x27F9Adb26D532a41D97e00206114e429ad58c679)] = true; _confirmedSnipers.push(address(0x27F9Adb26D532a41D97e00206114e429ad58c679)); _isSniper[address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)] = true; _confirmedSnipers.push(address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)); _isSniper[address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)] = true; _confirmedSnipers.push(address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)); _isSniper[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true; _confirmedSnipers.push(address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)); _isSniper[address(0x000000000000084e91743124a982076C59f10084)] = true; _confirmedSnipers.push(address(0x000000000000084e91743124a982076C59f10084)); _isSniper[address(0x6dA4bEa09C3aA0761b09b19837D9105a52254303)] = true; _confirmedSnipers.push(address(0x6dA4bEa09C3aA0761b09b19837D9105a52254303)); _isSniper[address(0x323b7F37d382A68B0195b873aF17CeA5B67cd595)] = true; _confirmedSnipers.push(address(0x323b7F37d382A68B0195b873aF17CeA5B67cd595)); _isSniper[address(0x000000005804B22091aa9830E50459A15E7C9241)] = true; _confirmedSnipers.push(address(0x000000005804B22091aa9830E50459A15E7C9241)); _isSniper[address(0xA3b0e79935815730d942A444A84d4Bd14A339553)] = true; _confirmedSnipers.push(address(0xA3b0e79935815730d942A444A84d4Bd14A339553)); _isSniper[address(0xf6da21E95D74767009acCB145b96897aC3630BaD)] = true; _confirmedSnipers.push(address(0xf6da21E95D74767009acCB145b96897aC3630BaD)); _isSniper[address(0x0000000000007673393729D5618DC555FD13f9aA)] = true; _confirmedSnipers.push(address(0x0000000000007673393729D5618DC555FD13f9aA)); _isSniper[address(0x00000000000003441d59DdE9A90BFfb1CD3fABf1)] = true; _confirmedSnipers.push(address(0x00000000000003441d59DdE9A90BFfb1CD3fABf1)); _isSniper[address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6)] = true; _confirmedSnipers.push(address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6)); _isSniper[address(0x000000917de6037d52b1F0a306eeCD208405f7cd)] = true; _confirmedSnipers.push(address(0x000000917de6037d52b1F0a306eeCD208405f7cd)); _isSniper[address(0x7100e690554B1c2FD01E8648db88bE235C1E6514)] = true; _confirmedSnipers.push(address(0x7100e690554B1c2FD01E8648db88bE235C1E6514)); _isSniper[address(0x72b30cDc1583224381132D379A052A6B10725415)] = true; _confirmedSnipers.push(address(0x72b30cDc1583224381132D379A052A6B10725415)); _isSniper[address(0x9eDD647D7d6Eceae6bB61D7785Ef66c5055A9bEE)] = true; _confirmedSnipers.push(address(0x9eDD647D7d6Eceae6bB61D7785Ef66c5055A9bEE)); _isSniper[address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F)] = true; _confirmedSnipers.push(address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F)); _isSniper[address(0x39608b6f20704889C51C0Ae28b1FCA8F36A5239b)] = true; _confirmedSnipers.push(address(0x39608b6f20704889C51C0Ae28b1FCA8F36A5239b)); _isSniper[address(0xc496D84215d5018f6F53E7F6f12E45c9b5e8e8A9)] = true; _confirmedSnipers.push(address(0xc496D84215d5018f6F53E7F6f12E45c9b5e8e8A9)); _isSniper[address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7)] = true; _confirmedSnipers.push(address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7)); _isSniper[address(0xe986d48EfeE9ec1B8F66CD0b0aE8e3D18F091bDF)] = true; _confirmedSnipers.push(address(0xe986d48EfeE9ec1B8F66CD0b0aE8e3D18F091bDF)); _isSniper[address(0x4aEB32e16DcaC00B092596ADc6CD4955EfdEE290)] = true; _confirmedSnipers.push(address(0x4aEB32e16DcaC00B092596ADc6CD4955EfdEE290)); _isSniper[address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5)] = true; _confirmedSnipers.push(address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5)); _isSniper[address(0x39608b6f20704889C51C0Ae28b1FCA8F36A5239b)] = true; _confirmedSnipers.push(address(0x39608b6f20704889C51C0Ae28b1FCA8F36A5239b)); _isSniper[address(0x5B83A351500B631cc2a20a665ee17f0dC66e3dB7)] = true; _confirmedSnipers.push(address(0x5B83A351500B631cc2a20a665ee17f0dC66e3dB7)); _isSniper[address(0xbCb05a3F85d34f0194C70d5914d5C4E28f11Cc02)] = true; _confirmedSnipers.push(address(0xbCb05a3F85d34f0194C70d5914d5C4E28f11Cc02)); _isSniper[address(0x22246F9BCa9921Bfa9A3f8df5baBc5Bc8ee73850)] = true; _confirmedSnipers.push(address(0x22246F9BCa9921Bfa9A3f8df5baBc5Bc8ee73850)); _isSniper[address(0x42d4C197036BD9984cA652303e07dD29fA6bdB37)] = true; _confirmedSnipers.push(address(0x42d4C197036BD9984cA652303e07dD29fA6bdB37)); _isSniper[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true; _confirmedSnipers.push(address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)); _isSniper[address(0x231DC6af3C66741f6Cf618884B953DF0e83C1A2A)] = true; _confirmedSnipers.push(address(0x231DC6af3C66741f6Cf618884B953DF0e83C1A2A)); _isSniper[address(0xC6bF34596f74eb22e066a878848DfB9fC1CF4C65)] = true; _confirmedSnipers.push(address(0xC6bF34596f74eb22e066a878848DfB9fC1CF4C65)); _isSniper[address(0x20f6fCd6B8813c4f98c0fFbD88C87c0255040Aa3)] = true; _confirmedSnipers.push(address(0x20f6fCd6B8813c4f98c0fFbD88C87c0255040Aa3)); _isSniper[address(0xD334C5392eD4863C81576422B968C6FB90EE9f79)] = true; _confirmedSnipers.push(address(0xD334C5392eD4863C81576422B968C6FB90EE9f79)); _isSniper[address(0xFFFFF6E70842330948Ca47254F2bE673B1cb0dB7)] = true; _confirmedSnipers.push(address(0xFFFFF6E70842330948Ca47254F2bE673B1cb0dB7)); _isSniper[address(0xA39C50bf86e15391180240938F469a7bF4fDAe9a)] = true; _confirmedSnipers.push(address(0xA39C50bf86e15391180240938F469a7bF4fDAe9a)); _isSniper[address(0xA39C50bf86e15391180240938F469a7bF4fDAe9a)] = true; _confirmedSnipers.push(address(0xA39C50bf86e15391180240938F469a7bF4fDAe9a)); teamDevAddress = payable(0xA51B67084e8dfdb0f0993F275C6627c6d64E2c30); } 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 isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function buyBackUpperLimitAmount() public view returns (uint256) { return buyBackUpperLimit; } 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 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 isRemovedSniper(address account) public view returns (bool) { return _isSniper[account]; } function includeInReward(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 _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"); require(!_isSniper[recipient], "You have no power here!"); require(!_isSniper[msg.sender], "You have no power here!"); if(sender != owner() && recipient != owner()) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (!tradingOpen) { if (!(sender == address(this) || recipient == address(this) || sender == address(owner()) || recipient == address(owner()))) { require(tradingOpen, "Trading is not enabled"); } } if (block.timestamp < launchTime + 15 seconds) { if (sender != uniswapV2Pair && sender != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) && sender != address(uniswapV2Router)) { _isSniper[sender] = true; _confirmedSnipers.push(sender); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (!inSwapAndLiquify && swapAndLiquifyEnabled && recipient == uniswapV2Pair) { if (overMinimumTokenBalance) { contractTokenBalance = minimumTokensBeforeSwap; swapTokens(contractTokenBalance); } uint256 balance = address(this).balance; if (buyBackEnabled && balance > uint256(1 * 10**18)) { if (balance > buyBackUpperLimit) balance = buyBackUpperLimit; buyBackTokens(balance.div(100)); } } bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; } _tokenTransfer(sender, recipient,amount,takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance); uint256 transferredBalance = address(this).balance.sub(initialBalance); transferToAddressETH(teamDevAddress, transferredBalance.div(_liquidityFee).mul(splitDivisor)); } function buyBackTokens(uint256 amount) private lockTheSwap { if (amount > 0) { swapETHForTokens(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), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function swapETHForTokens(uint256 amount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}( 0, // accept any amount of Tokens path, deadAddress, // Burn address block.timestamp.add(300) ); emit SwapETHForTokens(amount, path); } 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 owner(), block.timestamp ); } 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]) { _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 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _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 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _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 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _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 tLiquidity) = _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); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); 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 _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() { minimumTokensBeforeSwap = _minimumTokensBeforeSwap; } function setBuybackUpperLimit(uint256 buyBackLimit) external onlyOwner() { buyBackUpperLimit = buyBackLimit * 10**18; } function setTeamDevAddress(address _teamDevAddress) external onlyOwner() { teamDevAddress = payable(_teamDevAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setBuyBackEnabled(bool _enabled) public onlyOwner { buyBackEnabled = _enabled; emit BuyBackEnabledUpdated(_enabled); } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } function _removeSniper(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap'); require(!_isSniper[account], "Account is already blacklisted"); _isSniper[account] = true; _confirmedSnipers.push(account); } function _amnestySniper(address account) external onlyOwner() { require(_isSniper[account], "Account is not blacklisted"); for (uint256 i = 0; i < _confirmedSnipers.length; i++) { if (_confirmedSnipers[i] == account) { _confirmedSnipers[i] = _confirmedSnipers[_confirmedSnipers.length - 1]; _isSniper[account] = false; _confirmedSnipers.pop(); break; } } } function _removeTxLimit() external onlyOwner() { _maxTxAmount = 1000000000000000000000000; } //to recieve ETH from uniswapV2Router when swapping receive() external payable {} }
generate the uniswap pair path of token -> weth make the swap
function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, path, block.timestamp ); emit SwapTokensForETH(tokenAmount, path); }
17,885
[ 1, 4625, 348, 7953, 560, 30, 225, 2103, 326, 640, 291, 91, 438, 3082, 589, 434, 1147, 317, 341, 546, 1221, 326, 7720, 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,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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 ]
[ 1, 565, 445, 7720, 5157, 1290, 41, 451, 12, 11890, 5034, 1147, 6275, 13, 3238, 288, 203, 3639, 1758, 8526, 3778, 589, 273, 394, 1758, 8526, 12, 22, 1769, 203, 3639, 589, 63, 20, 65, 273, 1758, 12, 2211, 1769, 203, 3639, 589, 63, 21, 65, 273, 640, 291, 91, 438, 58, 22, 8259, 18, 59, 1584, 44, 5621, 203, 203, 3639, 389, 12908, 537, 12, 2867, 12, 2211, 3631, 1758, 12, 318, 291, 91, 438, 58, 22, 8259, 3631, 1147, 6275, 1769, 203, 203, 3639, 640, 291, 91, 438, 58, 22, 8259, 18, 22270, 14332, 5157, 1290, 1584, 44, 6289, 310, 14667, 1398, 5912, 5157, 12, 203, 5411, 1147, 6275, 16, 203, 5411, 589, 16, 203, 5411, 1203, 18, 5508, 203, 3639, 11272, 203, 203, 3639, 3626, 12738, 5157, 1290, 1584, 44, 12, 2316, 6275, 16, 589, 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 ]
pragma solidity ^0.4.25; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner, "msg.sender == owner"); _; } function transferOwnership(address _newOwner) public onlyOwner { require(address(0) != _newOwner, "address(0) != _newOwner"); newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner, "msg.sender == newOwner"); emit OwnershipTransferred(owner, msg.sender); owner = msg.sender; newOwner = address(0); } } contract Adminable is Ownable { mapping(address => bool) public admins; modifier onlyAdmin() { require(admins[msg.sender] && msg.sender != owner, "admins[msg.sender] && msg.sender != owner"); _; } function setAdmin(address _admin, bool _authorization) public onlyOwner { admins[_admin] = _authorization; } } contract Token { function transfer(address _to, uint256 _value) public returns (bool success); function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); uint8 public decimals; } contract TokedoExchange is Ownable, Adminable { using SafeMath for uint256; mapping (address => uint256) public invalidOrder; function invalidateOrdersBefore(address _user) public onlyAdmin { require(now > invalidOrder[_user], "now > invalidOrder[_user]"); invalidOrder[_user] = now; } mapping (address => mapping (address => uint256)) public tokens; //mapping of token addresses to mapping of account balances mapping (address => uint256) public lastActiveTransaction; // time of last interaction with this contract mapping (bytes32 => uint256) public orderFills; //balanceOf order filled address public feeAccount; uint256 public inactivityReleasePeriod = 2 weeks; mapping (bytes32 => bool) public hashed; //hashes of: order already traded && funds already hashed && accounts updated uint256 public constant maxFeeWithdrawal = 0.05 ether; // max fee rate applied = 5% uint256 public constant maxFeeTrade = 0.10 ether; // max fee rate applied = 10% address public tokedoToken; uint256 public tokedoTokenFeeDiscount; mapping (address => bool) public baseCurrency; constructor(address _feeAccount, address _tokedoToken, uint256 _tokedoTokenFeeDiscount) public { feeAccount = _feeAccount; tokedoToken = _tokedoToken; tokedoTokenFeeDiscount = _tokedoTokenFeeDiscount; } /*************************** * EDITABLE CONFINGURATION * ***************************/ function setInactivityReleasePeriod(uint256 _expiry) public onlyAdmin returns (bool success) { require(_expiry < 26 weeks, "_expiry < 26 weeks"); inactivityReleasePeriod = _expiry; return true; } function setFeeAccount(address _newFeeAccount) public onlyOwner returns (bool success) { feeAccount = _newFeeAccount; success = true; } function setTokedoToken(address _tokedoToken) public onlyOwner returns (bool success) { tokedoToken = _tokedoToken; success = true; } function setTokedoTokenFeeDiscount(uint256 _tokedoTokenFeeDiscount) public onlyOwner returns (bool success) { tokedoTokenFeeDiscount = _tokedoTokenFeeDiscount; success = true; } function setBaseCurrency (address _baseCurrency, bool _boolean) public onlyOwner returns (bool success) { baseCurrency[_baseCurrency] = _boolean; success = true; } /*************************** * UPDATE ACCOUNT ACTIVITY * ***************************/ function updateAccountActivity() public { lastActiveTransaction[msg.sender] = now; } function adminUpdateAccountActivity(address _user, uint256 _expiry, uint8 _v, bytes32 _r, bytes32 _s) public onlyAdmin returns(bool success) { require(now < _expiry, "should be: now < _expiry"); bytes32 hash = keccak256(abi.encodePacked(this, _user, _expiry)); require(!hashed[hash], "!hashed[hash]"); hashed[hash] = true; require(ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), _v, _r, _s) == _user,"invalid update account activity signature"); lastActiveTransaction[_user] = now; success = true; } /***************** * DEPOSIT TOKEN * *****************/ event Deposit(address token, address user, uint256 amount, uint256 balance); function tokenFallback(address _from, uint256 _amount, bytes) public returns(bool) { depositTokenFunction(msg.sender, _amount, _from); return true; } function receiveApproval(address _from, uint256 _amount, bytes) public returns(bool) { transferFromAndDepositTokenFunction(msg.sender, _amount, _from, _from); return true; } function depositToken(address _token, uint256 _amount) public returns(bool) { transferFromAndDepositTokenFunction(_token, _amount, msg.sender, msg.sender); return true; } function depositTokenFor(address _token, uint256 _amount, address _beneficiary) public returns(bool) { transferFromAndDepositTokenFunction(_token, _amount, msg.sender, _beneficiary); return true; } function transferFromAndDepositTokenFunction (address _token, uint256 _amount, address _sender, address _beneficiary) private { require(Token(_token).transferFrom(_sender, this, _amount), "Token(_token).transferFrom(_sender, this, _amount)"); depositTokenFunction(_token, _amount, _beneficiary); } function depositTokenFunction(address _token, uint256 _amount, address _beneficiary) private { tokens[_token][_beneficiary] = tokens[_token][_beneficiary].add(_amount); if(tx.origin == _beneficiary) lastActiveTransaction[tx.origin] = now; emit Deposit(_token, _beneficiary, _amount, tokens[_token][_beneficiary]); } /***************** * DEPOSIT ETHER * *****************/ function depositEther() public payable { depositEtherFor(msg.sender); } function depositEtherFor(address _beneficiary) public payable { tokens[address(0)][_beneficiary] = tokens[address(0)][_beneficiary].add(msg.value); if(msg.sender == _beneficiary) lastActiveTransaction[msg.sender] = now; emit Deposit(address(0), _beneficiary, msg.value, tokens[address(0)][_beneficiary]); } /************ * WITHDRAW * ************/ event EmergencyWithdraw(address token, address user, uint256 amount, uint256 balance); function emergencyWithdraw(address _token, uint256 _amount) public returns (bool success) { require(now.sub(lastActiveTransaction[msg.sender]) > inactivityReleasePeriod, "now.sub(lastActiveTransaction[msg.sender]) > inactivityReleasePeriod"); require(tokens[_token][msg.sender] >= _amount, "not enough balance for withdrawal"); tokens[_token][msg.sender] = tokens[_token][msg.sender].sub(_amount); if (_token == address(0)) { require(msg.sender.send(_amount), "msg.sender.send(_amount)"); } else { require(Token(_token).transfer(msg.sender, _amount), "Token(_token).transfer(msg.sender, _amount)"); } emit EmergencyWithdraw(_token, msg.sender, _amount, tokens[_token][msg.sender]); success = true; } event Withdraw(address token, address user, uint256 amount, uint256 balance); function adminWithdraw(address _token, uint256 _amount, address _user, uint256 _nonce, uint8 _v, bytes32[2] _rs, uint256[2] _fee) public onlyAdmin returns (bool success) { /*_fee [0] _feeWithdrawal [1] _payWithTokedo (yes is 1 - no is 0) _rs [0] _r [1] _s */ bytes32 hash = keccak256(abi.encodePacked(this, _fee[1], _token, _amount, _user, _nonce)); require(!hashed[hash], "!hashed[hash]"); hashed[hash] = true; require(ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), _v, _rs[0], _rs[1]) == _user, "invalid withdraw signature"); require(tokens[_token][_user] >= _amount, "not enough balance for withdrawal"); tokens[_token][_user] = tokens[_token][_user].sub(_amount); uint256 fee; if (_fee[1] == 1) fee = toWei(_amount, _token).mul(_fee[0]) / 1 ether; if (_fee[1] == 1 && tokens[tokedoToken][_user] >= fee) { tokens[tokedoToken][feeAccount] = tokens[tokedoToken][feeAccount].add(fee); tokens[tokedoToken][_user] = tokens[tokedoToken][_user].sub(fee); } else { if (_fee[0] > maxFeeWithdrawal) _fee[0] = maxFeeWithdrawal; fee = _fee[0].mul(_amount) / 1 ether; tokens[_token][feeAccount] = tokens[_token][feeAccount].add(fee); _amount = _amount.sub(fee); } if (_token == address(0)) { require(_user.send(_amount), "_user.send(_amount)"); } else { require(Token(_token).transfer(_user, _amount), "Token(_token).transfer(_user, _amount)"); } lastActiveTransaction[_user] = now; emit Withdraw(_token, _user, _amount, tokens[_token][_user]); success = true; } function balanceOf(address _token, address _user) public view returns (uint256) { return tokens[_token][_user]; } /*************** * ADMIN TRADE * ***************/ function adminTrade(uint256[] _values, address[] _addresses, uint8[] _v, bytes32[] _rs) public onlyAdmin returns (bool success) { /* amountSellTaker is in amountBuyMaker terms _values [0] amountSellTaker [1] tradeNonceTaker [2] feeTake [3] tokedoPrice [4] feePayableTokedoTaker (yes is 1 - no is 0) [5] feeMake [i*5+6] amountBuyMaker [i*5+7] amountSellMaker [i*5+8] expiresMaker [i*5+9] nonceMaker [i*5+10] feePayableTokedoMaker (yes is 1 - no is 0) _addresses [0] tokenBuyAddress [1] tokenSellAddress [2] takerAddress [i+3] makerAddress _v [0] vTaker [i+1] vMaker _rs [0] rTaker [1] sTaker [i*2+2] rMaker [i*2+3] sMaker */ /********************** * FEE SECURITY CHECK * **********************/ //if (feeTake > maxFeeTrade) feeTake = maxFeeTrade; if (_values[2] > maxFeeTrade) _values[2] = maxFeeTrade; // set max fee take // if (feeMake > maxFeeTrade) feeMake = maxFeeTrade; if (_values[5] > maxFeeTrade) _values[5] = maxFeeTrade; // set max fee make /******************************** * TAKER BEFORE SECURITY CHECK * ********************************/ //check if there are sufficient funds for TAKER: require(tokens[_addresses[0]][_addresses[2]] >= _values[0], "tokens[tokenBuyAddress][takerAddress] >= amountSellTaker"); /************** * LOOP LOGIC * **************/ bytes32[2] memory orderHash; uint256[8] memory amount; /* orderHash [0] globalHash [1] makerHash amount [0] totalBuyMakerAmount [1] appliedAmountSellTaker [2] remainingAmountSellTaker * [3] amountFeeMake * [4] amountFeeTake * [5] priceTrade * [6] feeTokedoMaker * [7] feeTokedoTaker */ // remainingAmountSellTaker = amountSellTaker amount[2] = _values[0]; for(uint256 i=0; i < (_values.length - 6) / 5; i++) { /************************ * MAKER SECURITY CHECK * *************************/ //required: nonceMaker is greater or egual makerAddress require(_values[i*5+9] >= invalidOrder[_addresses[i+3]], "nonceMaker >= invalidOrder[makerAddress]" ); // orderHash: ExchangeAddress, tokenBuyAddress, amountBuyMaker, tokenSellAddress, amountSellMaker, expiresMaker, nonceMaker, makerAddress, feePayableTokedoMaker orderHash[1] = keccak256(abi.encodePacked(abi.encodePacked(this, _addresses[0], _values[i*5+6], _addresses[1], _values[i*5+7], _values[i*5+8], _values[i*5+9], _addresses[i+3]), _values[i*5+10])); //globalHash = keccak256(abi.encodePacked(globalHash, makerHash)); orderHash[0] = keccak256(abi.encodePacked(orderHash[0], orderHash[1])); //required: the signer is the same address of makerAddress require(_addresses[i+3] == ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", orderHash[1])), _v[i+1], _rs[i*2+2], _rs[i*2+3]), 'makerAddress == ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", makerHash )), vMaker, rMaker , sMaker )'); /***************** * GLOBAL AMOUNT * *****************/ //appliedAmountSellTaker = amountBuyMaker.sub(orderFilled) amount[1] = _values[i*5+6].sub(orderFills[orderHash[1]]); //if remainingAmountSellTaker < appliedAmountSellTaker if (amount[2] < amount[1]) { //appliedAmountSellTaker = remainingAmountSellTaker amount[1] = amount[2]; } //remainingAmountSellTaker -= appliedAmountSellTaker amount[2] = amount[2].sub(amount[1]); //totalBuyMakerAmount += appliedAmountSellTaker amount[0] = amount[0].add(amount[1]); /****************************** * MAKER SECURITY CHECK FUNDS * ******************************/ //check if there are sufficient funds for MAKER: tokens[tokenSellAddress][makerAddress] >= amountSellMaker * appliedAmountSellTaker / amountBuyMaker require(tokens[_addresses[1]][_addresses[i+3]] >= (_values[i*5+7].mul(amount[1]).div(_values[i*5+6])), "tokens[tokenSellAddress][makerAddress] >= (amountSellMaker.mul(appliedAmountSellTaker).div(amountBuyMaker))"); /******************* * FEE COMPUTATION * *******************/ /* amount * [3] amountFeeMake * [4] amountFeeTake * [5] priceTrade * [6] feeTokedoMaker * [7] feeTokedoTaker */ //appliedAmountSellTaker = toWei(appliedAmountSellTaker, tokenBuyAddress); amount[1] = toWei(amount[1], _addresses[0]); //amountSellMaker = toWei(amountSellMaker, tokenSellAddress); _values[i*5+7] = toWei(_values[i*5+7], _addresses[1]); //amountBuyMaker = toWei(amountBuyMaker, tokenBuyAddress) _values[i*5+6] = toWei(_values[i*5+6], _addresses[0]); //amountFeeMake = appliedAmountSellTaker.mul(feeMake).div(1e18) amount[3] = amount[1].mul(_values[5]).div(1e18); //amountFeeTake = amountSellMaker.mul(feeTake).mul(appliedAmountSellTaker).div(amountBuyMaker) / 1e18; amount[4] = _values[i*5+7].mul(_values[2]).mul(amount[1]).div(_values[i*5+6]) / 1e18; //if (tokenBuyAddress == address(0) || (baseCurrency[tokenBuyAddress] && !(tokenSellAddress == address(0))) { if (_addresses[0] == address(0) || (baseCurrency[_addresses[0]] && !(_addresses[1] == address(0)))) { // maker sell order //amountBuyMaker is ETH or baseCurrency //amountSellMaker is TKN //amountFeeMake is ETH or baseCurrency //amountFeeTake is TKN //if (feePayableTokedoMaker == 1) feeTokedoMaker = amountFeeMake.mul(1e18).div(tokedoPrice).mul(tokedoTokenFeeDiscount).div(1e18); if (_values[i*5+10] == 1) amount[6] = amount[3].mul(1e18).div(_values[3]).mul(tokedoTokenFeeDiscount).div(1e18); //if (feePayableTokedoTaker == 1) if (_values[4] == 1) { // priceTrade = amountBuyMaker.mul(1e18).div(amountSellMaker) amount[5] = _values[i*5+6].mul(1e18).div(_values[i*5+7]); // price is ETH / TKN //feeTokedoTaker = amountFeeTake.mul(priceTrade).div(tokedoPrice).mul(tokedoTokenFeeDiscount).div(1e18); amount[7] = amount[4].mul(amount[5]).div(_values[3]).mul(tokedoTokenFeeDiscount).div(1e18); } //amountFeeTake = fromWei(amountFeeTake, tokenSellAddress); amount[4] = fromWei(amount[4], _addresses[1]); } else { //maker buy order //amountBuyMaker is TKN //amountSellMaker is ETH or baseCurrency //amountFeeMake is TKN //amountFeeTake is ETH or baseCurrency //if (feePayableTokedoTaker == 1) feeTokedoTaker = amountFeeTake.mul(1e18).div(tokedoPrice).mul(tokedoTokenFeeDiscount).div(1e18); if(_values[4] == 1) amount[7] = amount[4].mul(1e18).div(_values[3]).mul(tokedoTokenFeeDiscount).div(1e18); //if (feePayableTokedoMaker == 1) if (_values[i*5+10] == 1) { // priceTrade = amountSellMaker.mul(1e18).div(amountBuyMaker) amount[5] = _values[i*5+7].mul(1e18).div(_values[i*5+6]); // price is ETH / TKN // feeTokedoMaker = amountFeeMake.mul(priceTrade).div(tokedoPrice).mul(tokedoTokenFeeDiscount).div(1e18); amount[6] = amount[3].mul(amount[5]).div(_values[3]).mul(tokedoTokenFeeDiscount).div(1e18); } //amountFeeMake = fromWei(amountFeeMake, tokenBuyAddress); amount[3] = fromWei(amount[3], _addresses[0]); } //appliedAmountSellTaker = fromWei(appliedAmountSellTaker, tokenBuyAddress); amount[1] = fromWei(amount[1], _addresses[0]); //amountSellMaker = fromWei(amountSellMaker, tokenSellAddress); _values[i*5+7] = fromWei(_values[i*5+7], _addresses[1]); //amountBuyMaker = fromWei(amountBuyMaker, tokenBuyAddress) _values[i*5+6] = fromWei(_values[i*5+6], _addresses[0]); /********************** * FEE BALANCE UPDATE * **********************/ //feePayableTokedoTaker == 1 && tokens[tokedoToken][takerAddress] >= feeTokedoTaker if (_values[4] == 1 && tokens[tokedoToken][_addresses[2]] >= amount[7] ) { //tokens[tokedoToken][takerAddress] = tokens[tokedoToken][takerAddress].sub(feeTokedoTaker); tokens[tokedoToken][_addresses[2]] = tokens[tokedoToken][_addresses[2]].sub(amount[7]); //tokens[tokedoToken][feeAccount] = tokens[tokedoToken][feeAccount].add(feeTokedoTaker); tokens[tokedoToken][feeAccount] = tokens[tokedoToken][feeAccount].add(amount[7]); //amountFeeTake = 0; amount[4] = 0; } else { //tokens[tokenSellAddress][feeAccount] = tokens[tokenSellAddress][feeAccount].add(amountFeeTake); tokens[_addresses[1]][feeAccount] = tokens[_addresses[1]][feeAccount].add(amount[4]); } //feePayableTokedoMaker == 1 && tokens[tokedoToken][makerAddress] >= feeTokedoMaker if (_values[i*5+10] == 1 && tokens[tokedoToken][_addresses[i+3]] >= amount[6]) { //tokens[tokedoToken][makerAddress] = tokens[tokedoToken][makerAddress].sub(feeTokedoMaker); tokens[tokedoToken][_addresses[i+3]] = tokens[tokedoToken][_addresses[i+3]].sub(amount[6]); //tokens[tokedoToken][feeAccount] = tokens[tokedoToken][feeAccount].add(feeTokedoMaker); tokens[tokedoToken][feeAccount] = tokens[tokedoToken][feeAccount].add(amount[6]); //amountFeeMake = 0; amount[3] = 0; } else { //tokens[tokenBuyAddress][feeAccount] = tokens[tokenBuyAddress][feeAccount].add(amountFeeMake); tokens[_addresses[0]][feeAccount] = tokens[_addresses[0]][feeAccount].add(amount[3]); } /****************** * BALANCE UPDATE * ******************/ //tokens[tokenBuyAddress][takerAddress] = tokens[tokenBuyAddress][takerAddress].sub(appliedAmountSellTaker); tokens[_addresses[0]][_addresses[2]] = tokens[_addresses[0]][_addresses[2]].sub(amount[1]); //tokens[tokenBuyAddress][makerAddress] = tokens[tokenBuyAddress]][makerAddress].add(appliedAmountSellTaker.sub(amountFeeMake)); tokens[_addresses[0]][_addresses[i+3]] = tokens[_addresses[0]][_addresses[i+3]].add(amount[1].sub(amount[3])); //tokens[tokenSellAddress][makerAddress] = tokens[tokenSellAddress][makerAddress].sub(amountSellMaker.mul(appliedAmountSellTaker).div(amountBuyMaker)); tokens[_addresses[1]][_addresses[i+3]] = tokens[_addresses[1]][_addresses[i+3]].sub(_values[i*5+7].mul(amount[1]).div(_values[i*5+6])); //tokens[tokenSellAddress][takerAddress] = tokens[tokenSellAddress][takerAddress].add(amountSellMaker.mul(appliedAmountSellTaker).div(amountBuyMaker).sub(amountFeeTake)); tokens[_addresses[1]][_addresses[2]] = tokens[_addresses[1]][_addresses[2]].add(_values[i*5+7].mul(amount[1]).div(_values[i*5+6]).sub(amount[4])); /*********************** * UPDATE MAKER STATUS * ***********************/ //orderFills[orderHash[1]] = orderFills[orderHash[1]].add(appliedAmountSellTaker); orderFills[orderHash[1]] = orderFills[orderHash[1]].add(amount[1]); //lastActiveTransaction[makerAddress] = now; lastActiveTransaction[_addresses[i+3]] = now; } /******************************* * TAKER AFTER SECURITY CHECK * *******************************/ // tradeHash: globalHash, amountSellTaker, takerAddress, tradeNonceTaker, feePayableTokedoTaker bytes32 tradeHash = keccak256(abi.encodePacked(orderHash[0], _values[0], _addresses[2], _values[1], _values[4])); //required: the signer is the same address of takerAddress require(_addresses[2] == ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", tradeHash)), _v[0], _rs[0], _rs[1]), 'takerAddress == ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", tradeHash)), vTaker, rTaker, sTaker)'); //required: the same trade is not done require(!hashed[tradeHash], "!hashed[tradeHash] "); hashed[tradeHash] = true; //required: totalBuyMakerAmount == amountSellTaker require(amount[0] == _values[0], "totalBuyMakerAmount == amountSellTaker"); /*********************** * UPDATE TAKER STATUS * ***********************/ //lastActiveTransaction[takerAddress] = now; lastActiveTransaction[_addresses[2]] = now; success = true; } function toWei(uint256 _number, address _token) internal view returns (uint256) { if (_token == address(0)) return _number; return _number.mul(1e18).div(10**uint256(Token(_token).decimals())); } function fromWei(uint256 _number, address _token) internal view returns (uint256) { if (_token == address(0)) return _number; return _number.mul(10**uint256(Token(_token).decimals())).div(1e18); } }
amountSellMaker = fromWei(amountSellMaker, tokenSellAddress);
_values[i*5+7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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 5411, 389, 2372, 63, 77, 14, 25, 15, 27, 65, 273, 628, 3218, 77, 24899, 2372, 63, 77, 14, 25, 15, 27, 6487, 389, 13277, 63, 21, 19226, 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 ]
./full_match/3/0x918A6A0BFC15eCE8EF7666353F7EC62955584358/sources/contracts/Nifty.sol
uses the mapping to create a listingrequires that the msg sender also be the owner of the NFT from a specific project contractrequires that the nft is not listedsets listing status as truesets the price
function listNewExternalNFT(address nftcontract , uint256 nftID, uint256 price) external{ require(_externalNFTLedger[nftcontract][nftID].owner == msg.sender , "NFT is not owned by message sender"); require(_externalNFTLedger[nftcontract][nftID].alreadyListed == true, "NFT is already listed"); _externalNFTLedger[nftcontract][nftID].alreadyListed = true; _externalNFTLedger[nftcontract][nftID].price = price; }
14,230,680
[ 1, 4625, 348, 7953, 560, 30, 4692, 326, 2874, 358, 752, 279, 11591, 18942, 716, 326, 1234, 5793, 2546, 506, 326, 3410, 434, 326, 423, 4464, 628, 279, 2923, 1984, 6835, 18942, 716, 326, 290, 1222, 353, 486, 12889, 4424, 11591, 1267, 487, 433, 3610, 2413, 326, 6205, 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,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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, 666, 1908, 6841, 50, 4464, 12, 2867, 290, 1222, 16351, 269, 2254, 5034, 290, 1222, 734, 16, 2254, 5034, 6205, 13, 3903, 95, 203, 3639, 2583, 24899, 9375, 50, 4464, 28731, 63, 82, 1222, 16351, 6362, 82, 1222, 734, 8009, 8443, 422, 1234, 18, 15330, 269, 315, 50, 4464, 353, 486, 16199, 635, 883, 5793, 8863, 203, 203, 3639, 2583, 24899, 9375, 50, 4464, 28731, 63, 82, 1222, 16351, 6362, 82, 1222, 734, 8009, 17583, 682, 329, 422, 638, 16, 315, 50, 4464, 353, 1818, 12889, 8863, 203, 3639, 389, 9375, 50, 4464, 28731, 63, 82, 1222, 16351, 6362, 82, 1222, 734, 8009, 17583, 682, 329, 273, 638, 31, 203, 3639, 389, 9375, 50, 4464, 28731, 63, 82, 1222, 16351, 6362, 82, 1222, 734, 8009, 8694, 273, 6205, 31, 203, 203, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/4/0xA5D91d5e965EafF0Bc1a7438541E34f88156193a/sources/browser/Untitled.sol
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^BELOW IS FOR TEST ONLY ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^SHOULD BE REMOVED IN PRODUCTION^^^^^^^^^ This function setBirthDate should be commented or removed on production deploy, it is only for testing purpose
function setBirthDate(uint256 _lessSeconds) public returns(bool) { birthDate = birthDate.sub(_lessSeconds); }
12,331,451
[ 1, 4625, 348, 7953, 560, 30, 3602, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 12800, 66, 5948, 4130, 4437, 12108, 22130, 20747, 3602, 20254, 20254, 20254, 20254, 20254, 20254, 20254, 12800, 2664, 31090, 9722, 23769, 12135, 2120, 11770, 1212, 27035, 20254, 20254, 66, 1220, 445, 15268, 10542, 1626, 1410, 506, 31813, 578, 3723, 603, 12449, 7286, 16, 518, 353, 1338, 364, 7769,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 15268, 10542, 1626, 12, 11890, 5034, 389, 2656, 6762, 13, 1071, 1135, 12, 6430, 13, 203, 565, 288, 203, 3639, 17057, 1626, 273, 17057, 1626, 18, 1717, 24899, 2656, 6762, 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 ]
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================FraxFarm_UniV3_veFXS======================== // ==================================================================== // Migratable Farming contract that accounts for veFXS and UniswapV3 NFTs // Only one possible reward token here (usually FXS), to cut gas costs // Also, because of the nonfungible nature, and to reduce gas, unlocked staking was removed // You can lock for as short as 1 day now, which is de-facto an unlocked stake // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Originally inspired by Synthetixio, but heavily modified by the Frax team // (Locked, veFXS, and UniV3 portions are new) // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../Curve/IveFXS.sol"; import "../Curve/IFraxGaugeController.sol"; import "../ERC20/ERC20.sol"; import '../Uniswap/TransferHelper.sol'; import "../ERC20/SafeERC20.sol"; import "../Uniswap_V3/libraries/TickMath.sol"; import "../Uniswap_V3/libraries/LiquidityAmounts.sol"; import "../Uniswap_V3/IUniswapV3PositionsNFT.sol"; import "../Utils/ReentrancyGuard.sol"; import "./Owned.sol"; contract FraxFarm_UniV3_veFXS is Owned, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances IveFXS private veFXS; ERC20 private rewardsToken0; IGaugeController private gauge_controller; IUniswapV3PositionsNFT private stakingTokenNFT; // UniV3 uses an NFT // Admin addresses address public timelock_address; // Constant for various precisions uint256 private constant MULTIPLIER_PRECISION = 1e18; // Reward and period related uint256 private periodFinish; uint256 private lastUpdateTime; uint256 public reward_rate_manual; uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) // Lock time and multiplier settings uint256 public lock_max_multiplier = uint256(3e18); // E18. 1x = 1e18 uint256 public lock_time_for_max_multiplier = 3 * 365 * 86400; // 3 years uint256 public lock_time_min = 86400; // 1 * 86400 (1 day) // veFXS related uint256 public vefxs_per_frax_for_max_boost = uint256(4e18); // E18. 4e18 means 4 veFXS must be held by the staker per 1 FRAX uint256 public vefxs_max_multiplier = uint256(2e18); // E18. 1x = 1e18 mapping(address => uint256) private _vefxsMultiplierStored; // Uniswap V3 related int24 public uni_tick_lower; int24 public uni_tick_upper; uint24 public uni_required_fee = 500; address public uni_token0; address public uni_token1; // Rewards tracking uint256 private rewardPerTokenStored0 = 0; mapping(address => uint256) private userRewardPerTokenPaid0; mapping(address => uint256) public rewards0; uint256 private last_gauge_relative_weight; uint256 private last_gauge_time_total; // Balance, stake, and weight tracking uint256 private _total_liquidity_locked = 0; uint256 private _total_combined_weight = 0; mapping(address => uint256) private _locked_liquidity; mapping(address => uint256) private _combined_weights; mapping(address => LockedNFT[]) private lockedNFTs; // List of valid migrators (set by governance) mapping(address => bool) private valid_migrators; address[] private valid_migrators_array; // Stakers set which migrator(s) they want to use mapping(address => mapping(address => bool)) private staker_allowed_migrators; // Greylists mapping(address => bool) private greylist; // Admin booleans for emergencies, migrations, and overrides bool public migrationsOn = false; // Used for migrations. Prevents new stakes, but allows LP and reward withdrawals bool public stakesUnlocked = false; // Release locked stakes in case of system migration or emergency bool public stakingPaused = false; bool public withdrawalsPaused = false; bool public rewardsCollectionPaused = false; // Struct for the stake struct LockedNFT { uint256 token_id; // for Uniswap V3 LPs uint256 liquidity; uint256 start_timestamp; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 int24 tick_lower; int24 tick_upper; } /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "You are not the owner or the governance timelock"); _; } modifier isMigrating() { require(migrationsOn == true, "Contract is not in migration"); _; } modifier notWithdrawalsPaused() { require(withdrawalsPaused == false, "Withdrawals are paused"); _; } modifier notRewardsCollectionPaused() { require(rewardsCollectionPaused == false,"Rewards collection is paused"); _; } modifier updateRewardAndBalance(address account, bool sync_too) { _updateRewardAndBalance(account, sync_too); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsToken0, address _stakingTokenNFT, address _timelock_address, address _veFXS_address, address _gauge_controller_address, address _uni_token0, address _uni_token1 ) Owned(_owner) { rewardsToken0 = ERC20(_rewardsToken0); stakingTokenNFT = IUniswapV3PositionsNFT(_stakingTokenNFT); gauge_controller = IGaugeController(_gauge_controller_address); veFXS = IveFXS(_veFXS_address); lastUpdateTime = block.timestamp; timelock_address = _timelock_address; // 1 FXS a day reward_rate_manual = 0; // Set the UniV3 addresses uni_token0 = _uni_token0; uni_token1 = _uni_token1; // Tick and Liquidity related uni_tick_lower = -276420; uni_tick_upper = -276230; } /* ========== VIEWS ========== */ // User locked liquidity tokens function totalLiquidityLocked() external view returns (uint256) { return _total_liquidity_locked; } // Total locked liquidity tokens function lockedLiquidityOf(address account) public view returns (uint256) { return _locked_liquidity[account]; } // Total 'balance' used for calculating the percent of the pool the account owns // Takes into account the locked stake time multiplier and veFXS multiplier function combinedWeightOf(address account) external view returns (uint256) { return _combined_weights[account]; } // Total combined weight function totalCombinedWeight() external view returns (uint256) { return _total_combined_weight; } function lockMultiplier(uint256 secs) public view returns (uint256) { uint256 lock_multiplier = uint256(MULTIPLIER_PRECISION).add( secs.mul(lock_max_multiplier.sub(MULTIPLIER_PRECISION)).div( lock_time_for_max_multiplier ) ); if (lock_multiplier > lock_max_multiplier) lock_multiplier = lock_max_multiplier; return lock_multiplier; } function userStakedFrax(address account) public view returns (uint256) { uint256 frax_tally = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { thisNFT = lockedNFTs[account][i]; uint256 this_liq = thisNFT.liquidity; if (this_liq > 0){ uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_lower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_upper); frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, uint128(thisNFT.liquidity))); } } // In order to avoid excessive gas calculations and the input tokens ratios. 50% FRAX is assumed // If this were Uni V2, it would be akin to reserve0 & reserve1 math return frax_tally.div(2); } function minVeFXSForMaxBoost(address account) public view returns (uint256) { return (userStakedFrax(account)).mul(vefxs_per_frax_for_max_boost).div(MULTIPLIER_PRECISION); } function veFXSMultiplier(address account) public view returns (uint256) { // The claimer gets a boost depending on amount of veFXS they have relative to the amount of FRAX 'inside' // of their locked LP tokens uint256 veFXS_needed_for_max_boost = minVeFXSForMaxBoost(account); if (veFXS_needed_for_max_boost > 0){ uint256 user_vefxs_fraction = (veFXS.balanceOf(account)).mul(MULTIPLIER_PRECISION).div(veFXS_needed_for_max_boost); uint256 vefxs_multiplier = ((user_vefxs_fraction).mul(vefxs_max_multiplier)).div(MULTIPLIER_PRECISION); // Cap the boost to the vefxs_max_multiplier if (vefxs_multiplier > vefxs_max_multiplier) vefxs_multiplier = vefxs_max_multiplier; return vefxs_multiplier; } else return 0; // This will happen with the first stake, when user_staked_frax is 0 } function checkUniV3NFT(uint256 token_id, bool fail_if_false) public view returns (bool is_valid, uint256 liquidity, int24 tick_lower, int24 tick_upper) { ( , , address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 _liquidity, , , , ) = stakingTokenNFT.positions(token_id); // Set initially is_valid = false; liquidity = _liquidity; // Do the checks if (fail_if_false) { require(token0 == uni_token0, "Uniswap token0 incorrect"); require(token1 == uni_token1, "Uniswap token1 incorrect"); require(fee == uni_required_fee, "Uniswap fee incorrect"); require(tickLower >= uni_tick_lower,"Uniswap tickLower is too low"); require(tickUpper <= uni_tick_upper,"Uniswap tickUpper is too high"); is_valid = true; } else { if ( (token0 == uni_token0) && (token1 == uni_token1) && (fee == uni_required_fee) && (tickLower >= uni_tick_lower) && (tickUpper <= uni_tick_upper) ) { is_valid = true; } } return (is_valid, liquidity, tickLower, tickUpper); } // Return all of the locked NFT positions function lockedNFTsOf(address account) external view returns (LockedNFT[] memory) { return lockedNFTs[account]; } function calcCurCombinedWeight(address account) public view returns ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) { // Get the old combined weight old_combined_weight = _combined_weights[account]; // Get the veFXS multipliers // For the calculations, use the midpoint (analogous to midpoint Riemann sum) new_vefxs_multiplier = veFXSMultiplier(account); uint256 midpoint_vefxs_multiplier = ((new_vefxs_multiplier).add(_vefxsMultiplierStored[account])).div(2); // Loop through the locked stakes, first by getting the liquidity * lock_multiplier portion new_combined_weight = 0; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { LockedNFT memory thisNFT = lockedNFTs[account][i]; uint256 lock_multiplier = thisNFT.lock_multiplier; // If the lock period is over, drop the lock multiplier down to 1x for the weight calculations if (thisNFT.ending_timestamp <= block.timestamp){ lock_multiplier = MULTIPLIER_PRECISION; } uint256 liquidity = thisNFT.liquidity; uint256 combined_boosted_amount = liquidity.mul(lock_multiplier.add(midpoint_vefxs_multiplier)).div(MULTIPLIER_PRECISION); new_combined_weight = new_combined_weight.add(combined_boosted_amount); } } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_total_liquidity_locked == 0 || _total_combined_weight == 0) { return rewardPerTokenStored0; } else { return ( rewardPerTokenStored0.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate0()) .mul(1e18) .div(_total_combined_weight) ) ); } } function earned(address account) public view returns (uint256) { uint256 earned_reward_0 = rewardPerToken(); return ( _combined_weights[account] .mul(earned_reward_0.sub(userRewardPerTokenPaid0[account])) .div(1e18) .add(rewards0[account]) ); } function rewardRate0() public view returns (uint256 rwd_rate) { if (address(gauge_controller) != address(0)) { rwd_rate = (gauge_controller.global_emission_rate()).mul(last_gauge_relative_weight).div(1e18); } else { rwd_rate = reward_rate_manual; } } function getRewardForDuration() external view returns (uint256) { return rewardRate0().mul(rewardsDuration); } function migratorApprovedForStaker(address staker_address, address migrator_address) public view returns (bool) { // Migrator is not a valid one if (valid_migrators[migrator_address] == false) return false; // Staker has to have approved this particular migrator if (staker_allowed_migrators[staker_address][migrator_address] == true) return true; // Otherwise, return false return false; } // Needed to indicate that this contract is ERC721 compatible function onERC721Received( address, address, uint256, bytes memory ) public pure returns (bytes4) { return this.onERC721Received.selector; } /* ========== MUTATIVE FUNCTIONS ========== */ function _updateRewardAndBalance(address account, bool sync_too) internal { // Need to retro-adjust some things if the period hasn't been renewed, then start a new one if (sync_too){ sync(); } if (account != address(0)) { // To keep the math correct, the user's combined weight must be recomputed to account for their // ever-changing veFXS balance. ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) = calcCurCombinedWeight(account); // Calculate the earnings first _syncEarned(account); // Update the user's stored veFXS multipliers _vefxsMultiplierStored[account] = new_vefxs_multiplier; // Update the user's and the global combined weights if (new_combined_weight >= old_combined_weight) { uint256 weight_diff = new_combined_weight.sub(old_combined_weight); _total_combined_weight = _total_combined_weight.add(weight_diff); _combined_weights[account] = old_combined_weight.add(weight_diff); } else { uint256 weight_diff = old_combined_weight.sub(new_combined_weight); _total_combined_weight = _total_combined_weight.sub(weight_diff); _combined_weights[account] = old_combined_weight.sub(weight_diff); } } } function _syncEarned(address account) internal { if (account != address(0)) { // Calculate the earnings uint256 earned0 = earned(account); rewards0[account] = earned0; userRewardPerTokenPaid0[account] = rewardPerTokenStored0; } } // Staker can allow a migrator function stakerAllowMigrator(address migrator_address) public { require(staker_allowed_migrators[msg.sender][migrator_address] == false, "Address already exists"); require(valid_migrators[migrator_address], "Invalid migrator address"); staker_allowed_migrators[msg.sender][migrator_address] = true; } // Staker can disallow a previously-allowed migrator function stakerDisallowMigrator(address migrator_address) public { require(staker_allowed_migrators[msg.sender][migrator_address] == true,"Address doesn't exist already"); // Redundant // require(valid_migrators[migrator_address], "Invalid migrator address"); // Delete from the mapping delete staker_allowed_migrators[msg.sender][migrator_address]; } // Two different stake functions are needed because of delegateCall and msg.sender issues (important for migration) function stakeLocked(uint256 token_id, uint256 secs) nonReentrant external { _stakeLocked(msg.sender, msg.sender, token_id, secs, block.timestamp); } // If this were not internal, and source_address had an infinite approve, this could be exploitable // (pull funds from source_address and stake for an arbitrary staker_address) function _stakeLocked( address staker_address, address source_address, uint256 token_id, uint256 secs, uint256 start_timestamp ) internal updateRewardAndBalance(staker_address, true) { require((stakingPaused == false && migrationsOn == false) || valid_migrators[msg.sender] == true, "Staking is paused, or migration is happening"); require(greylist[staker_address] == false, "Address has been greylisted"); require(secs >= lock_time_min, "Minimum stake time not met"); require(secs <= lock_time_for_max_multiplier,"You are trying to lock for too long"); (, uint256 liquidity, int24 tick_lower, int24 tick_upper) = checkUniV3NFT(token_id, true); // Should throw if false { uint256 lock_multiplier = lockMultiplier(secs); lockedNFTs[staker_address].push( LockedNFT( token_id, liquidity, start_timestamp, start_timestamp.add(secs), lock_multiplier, tick_lower, tick_upper ) ); } // Pull the tokens from the source_address stakingTokenNFT.safeTransferFrom(source_address, address(this), token_id); // Update liquidities _total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity); // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); emit LockNFT(staker_address, liquidity, token_id, secs, source_address); } // Two different withdrawLocked functions are needed because of delegateCall and msg.sender issues (important for migration) function withdrawLocked(uint256 token_id) nonReentrant notWithdrawalsPaused external { _withdrawLocked(msg.sender, msg.sender, token_id); } // No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper // functions like migrator_withdraw_locked() and withdrawLocked() function _withdrawLocked( address staker_address, address destination_address, uint256 token_id ) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedNFT memory thisNFT; thisNFT.liquidity = 0; uint256 theArrayIndex; for (uint256 i = 0; i < lockedNFTs[staker_address].length; i++) { if (token_id == lockedNFTs[staker_address][i].token_id) { thisNFT = lockedNFTs[staker_address][i]; theArrayIndex = i; break; } } require(thisNFT.token_id == token_id, "Token ID not found"); require(block.timestamp >= thisNFT.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 theLiquidity = thisNFT.liquidity; if (theLiquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(theLiquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(theLiquidity); // Remove the stake from the array delete lockedNFTs[staker_address][theArrayIndex]; // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address stakingTokenNFT.safeTransferFrom(address(this), destination_address, token_id); emit WithdrawLocked(staker_address, theLiquidity, token_id, destination_address); } } // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) function getReward() external nonReentrant notRewardsCollectionPaused returns (uint256) { return _getReward(msg.sender, msg.sender); } // No withdrawer == msg.sender check needed since this is only internally callable // This distinction is important for the migrator // Also collects the LP fees function _getReward(address rewardee, address destination_address) internal updateRewardAndBalance(rewardee, true) returns (uint256 reward_0) { reward_0 = rewards0[rewardee]; if (reward_0 > 0) { rewards0[rewardee] = 0; TransferHelper.safeTransfer(address(rewardsToken0), destination_address, reward_0); // Collect liquidity fees too uint256 accumulated_token0 = 0; uint256 accumulated_token1 = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[rewardee].length; i++) { thisNFT = lockedNFTs[rewardee][i]; // Check for null entries if (thisNFT.token_id != 0){ IUniswapV3PositionsNFT.CollectParams memory collect_params = IUniswapV3PositionsNFT.CollectParams( thisNFT.token_id, destination_address, type(uint128).max, type(uint128).max ); (uint256 tok0_amt, uint256 tok1_amt) = stakingTokenNFT.collect(collect_params); accumulated_token0 = accumulated_token0.add(tok0_amt); accumulated_token1 = accumulated_token1.add(tok1_amt); } } emit RewardPaid(rewardee, reward_0, accumulated_token0, accumulated_token1, address(rewardsToken0), destination_address); } } // If the period expired, renew it function retroCatchUp() internal { // Failsafe check require(block.timestamp > periodFinish, "Period has not expired yet!"); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period uint256 balance0 = rewardsToken0.balanceOf(address(this)); require(rewardRate0().mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance0, "Not enough FXS available for rewards!"); periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingTokenNFT)); } function sync_gauge_weight(bool force_update) public { if (force_update || (block.timestamp > last_gauge_time_total)){ // Update the gauge_relative_weight last_gauge_relative_weight = gauge_controller.gauge_relative_weight_write(address(this), block.timestamp); last_gauge_time_total = gauge_controller.time_total(); } } function sync() public { // Sync the gauge weight, if applicable sync_gauge_weight(true); if (block.timestamp > periodFinish) { retroCatchUp(); } else { uint256 reward_per_token_0 = rewardPerToken(); rewardPerTokenStored0 = reward_per_token_0; lastUpdateTime = lastTimeRewardApplicable(); } } /* ========== RESTRICTED FUNCTIONS ========== */ // Migrator can stake for someone else (they won't be able to withdraw it back though, only staker_address can). function migrator_stakeLocked_for(address staker_address, uint256 token_id, uint256 secs, uint256 start_timestamp) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _stakeLocked(staker_address, msg.sender, token_id, secs, start_timestamp); } // Used for migrations function migrator_withdraw_locked(address staker_address, uint256 token_id) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _withdrawLocked(staker_address, msg.sender, token_id); } // Adds supported migrator address function addMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == false,"address already exists"); valid_migrators[migrator_address] = true; valid_migrators_array.push(migrator_address); } // Remove a migrator address function removeMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == true,"address doesn't exist already"); // Delete from the mapping delete valid_migrators[migrator_address]; // 'Delete' from the array by setting the address to 0x0 for (uint256 i = 0; i < valid_migrators_array.length; i++) { if (valid_migrators_array[i] == migrator_address) { valid_migrators_array[i] = address(0); // This will leave a null in the array and keep the indices the same break; } } } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Cannot withdraw staking tokens unless migration is on"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Cannot withdraw staking tokens unless migration is on"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal // IUniswapV3PositionsNFT inherits IERC721 so the latter does not need to be imported IUniswapV3PositionsNFT(tokenAddress).safeTransferFrom( address(this), owner, token_id); emit RecoveredERC721(tokenAddress, token_id); } function setRewardsDuration(uint256 _rewardsDuration) external onlyByOwnerOrGovernance { require(periodFinish == 0 || block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period"); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } function setMultipliers(uint256 _lock_max_multiplier, uint256 _vefxs_max_multiplier, uint256 _vefxs_per_frax_for_max_boost) external onlyByOwnerOrGovernance { require(_lock_max_multiplier >= uint256(1e18), "Multiplier must be greater than or equal to 1e18"); require(_vefxs_max_multiplier >= 0, "Max veFXS multiplier must be greater than or equal to 0"); require(_vefxs_per_frax_for_max_boost > 0, "veFXS pct max must be greater than 0"); lock_max_multiplier = _lock_max_multiplier; vefxs_max_multiplier = _vefxs_max_multiplier; vefxs_per_frax_for_max_boost = _vefxs_per_frax_for_max_boost; emit MaxVeFXSMultiplier(vefxs_max_multiplier); emit LockedNFTMaxMultiplierUpdated(lock_max_multiplier); emit veFXSPctForMaxBoostUpdated(vefxs_per_frax_for_max_boost); } function setLockedNFTTimeForMinAndMaxMultiplier(uint256 _lock_time_for_max_multiplier, uint256 _lock_time_min) external onlyByOwnerOrGovernance { require(_lock_time_for_max_multiplier >= 1, "Multiplier Max Time must be greater than or equal to 1"); require(_lock_time_min >= 1, "Multiplier Min Time must be greater than or equal to 1"); lock_time_for_max_multiplier = _lock_time_for_max_multiplier; lock_time_min = _lock_time_min; emit LockedNFTTimeForMaxMultiplier(lock_time_for_max_multiplier); emit LockedNFTMinTime(_lock_time_min); } function initializeDefault() external onlyByOwnerOrGovernance { lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); sync_gauge_weight(true); emit DefaultInitialization(); } function greylistAddress(address _address) external onlyByOwnerOrGovernance { greylist[_address] = !(greylist[_address]); } function unlockStakes() external onlyByOwnerOrGovernance { stakesUnlocked = !stakesUnlocked; } function toggleMigrations() external onlyByOwnerOrGovernance { migrationsOn = !migrationsOn; } function setPauses( bool _stakingPaused, bool _withdrawalsPaused, bool _rewardsCollectionPaused ) external onlyByOwnerOrGovernance { stakingPaused = _stakingPaused; withdrawalsPaused = _withdrawalsPaused; rewardsCollectionPaused = _rewardsCollectionPaused; } function setUniParameters( int24 _uni_tick_lower, int24 _uni_tick_upper, uint24 _uni_required_fee ) external onlyByOwnerOrGovernance { uni_tick_lower = _uni_tick_lower; uni_tick_upper = _uni_tick_upper; uni_required_fee = _uni_required_fee; } function setManualRewardRate(uint256 _reward_rate_manual, bool sync_too) external onlyByOwnerOrGovernance { reward_rate_manual = _reward_rate_manual; if (sync_too) { sync(); } } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } // Set to address(0) to fall back to the reward_rate_manual function setGaugeController(address _gauge_controller_address) external onlyByOwnerOrGovernance { gauge_controller = IGaugeController(_gauge_controller_address); } /* ========== EVENTS ========== */ event LockNFT(address indexed user, uint256 liquidity, uint256 token_id, uint256 secs, address source_address); event WithdrawLocked(address indexed user, uint256 liquidity, uint256 token_id, address destination_address); event RewardPaid(address indexed user, uint256 farm_reward, uint256 liq_tok0_reward, uint256 liq_tok1_reward, address token_address, address destination_address); event RewardsDurationUpdated(uint256 newDuration); event RecoveredERC20(address token, uint256 amount); event RecoveredERC721(address token, uint256 token_id); event RewardsPeriodRenewed(address token); event DefaultInitialization(); event LockedNFTMaxMultiplierUpdated(uint256 multiplier); event LockedNFTTimeForMaxMultiplier(uint256 secs); event LockedNFTMinTime(uint256 secs); event MaxVeFXSMultiplier(uint256 multiplier); event veFXSPctForMaxBoostUpdated(uint256 scale_factor); /* ========== A CHICKEN ========== */ // // ,~. // ,-'__ `-, // {,-' `. } ,') // ,( a ) `-.__ ,',')~, // <=.) ( `-.__,==' ' ' '} // ( ) /) // `-'\ , ) // | \ `~. / // \ `._ \ / // \ `._____,' ,' // `-. ,' // `-._ _,-' // 77jj' // //_|| // __//--'/` // ,--'/` ' // // [hjw] https://textart.io/art/vw6Sa3iwqIRGkZsN1BC2vweF/chicken }
No withdrawer == msg.sender check needed since this is only internally callable This distinction is important for the migrator Also collects the LP fees Collect liquidity fees too Check for null entries
function _getReward(address rewardee, address destination_address) internal updateRewardAndBalance(rewardee, true) returns (uint256 reward_0) { reward_0 = rewards0[rewardee]; if (reward_0 > 0) { rewards0[rewardee] = 0; TransferHelper.safeTransfer(address(rewardsToken0), destination_address, reward_0); uint256 accumulated_token0 = 0; uint256 accumulated_token1 = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[rewardee].length; i++) { thisNFT = lockedNFTs[rewardee][i]; if (thisNFT.token_id != 0){ IUniswapV3PositionsNFT.CollectParams memory collect_params = IUniswapV3PositionsNFT.CollectParams( thisNFT.token_id, destination_address, type(uint128).max, type(uint128).max ); (uint256 tok0_amt, uint256 tok1_amt) = stakingTokenNFT.collect(collect_params); accumulated_token0 = accumulated_token0.add(tok0_amt); accumulated_token1 = accumulated_token1.add(tok1_amt); } } emit RewardPaid(rewardee, reward_0, accumulated_token0, accumulated_token1, address(rewardsToken0), destination_address); } }
1,017,157
[ 1, 4625, 348, 7953, 560, 30, 225, 2631, 598, 9446, 264, 422, 1234, 18, 15330, 866, 3577, 3241, 333, 353, 1338, 12963, 4140, 1220, 2411, 267, 349, 353, 10802, 364, 326, 30188, 8080, 30976, 326, 511, 52, 1656, 281, 9302, 4501, 372, 24237, 1656, 281, 4885, 2073, 364, 446, 3222, 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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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, 565, 445, 389, 588, 17631, 1060, 12, 2867, 283, 905, 20953, 16, 1758, 2929, 67, 2867, 13, 2713, 1089, 17631, 1060, 1876, 13937, 12, 266, 905, 20953, 16, 638, 13, 1135, 261, 11890, 5034, 19890, 67, 20, 13, 288, 203, 3639, 19890, 67, 20, 273, 283, 6397, 20, 63, 266, 905, 20953, 15533, 203, 3639, 309, 261, 266, 2913, 67, 20, 405, 374, 13, 288, 203, 5411, 283, 6397, 20, 63, 266, 905, 20953, 65, 273, 374, 31, 203, 5411, 12279, 2276, 18, 4626, 5912, 12, 2867, 12, 266, 6397, 1345, 20, 3631, 2929, 67, 2867, 16, 19890, 67, 20, 1769, 203, 203, 5411, 2254, 5034, 24893, 67, 2316, 20, 273, 374, 31, 203, 5411, 2254, 5034, 24893, 67, 2316, 21, 273, 374, 31, 203, 5411, 3488, 329, 50, 4464, 3778, 333, 50, 4464, 31, 203, 5411, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 8586, 50, 4464, 87, 63, 266, 905, 20953, 8009, 2469, 31, 277, 27245, 288, 203, 7734, 333, 50, 4464, 273, 8586, 50, 4464, 87, 63, 266, 905, 20953, 6362, 77, 15533, 203, 1171, 203, 7734, 309, 261, 2211, 50, 4464, 18, 2316, 67, 350, 480, 374, 15329, 203, 10792, 467, 984, 291, 91, 438, 58, 23, 11024, 50, 4464, 18, 10808, 1370, 3778, 3274, 67, 2010, 273, 467, 984, 291, 91, 438, 58, 23, 11024, 50, 4464, 18, 10808, 1370, 12, 203, 13491, 333, 50, 4464, 18, 2316, 67, 350, 16, 203, 13491, 2929, 67, 2867, 16, 203, 13491, 618, 12, 11890, 10392, 2934, 1896, 16, 203, 13491, 618, 12, 11890, 10392, 2934, 1896, 203, 10792, 11272, 203, 10792, 261, 11890, 5034, 946, 20, 67, 301, 88, 16, 2254, 5034, 946, 21, 67, 301, 88, 13, 273, 384, 6159, 1345, 50, 4464, 18, 14676, 12, 14676, 67, 2010, 1769, 203, 10792, 24893, 67, 2316, 20, 273, 24893, 67, 2316, 20, 18, 1289, 12, 17692, 20, 67, 301, 88, 1769, 203, 10792, 24893, 67, 2316, 21, 273, 24893, 67, 2316, 21, 18, 1289, 12, 17692, 21, 67, 301, 88, 1769, 203, 7734, 289, 203, 5411, 289, 203, 203, 5411, 3626, 534, 359, 1060, 16507, 350, 12, 266, 905, 20953, 16, 19890, 67, 20, 16, 24893, 67, 2316, 20, 16, 24893, 67, 2316, 21, 16, 1758, 12, 266, 6397, 1345, 20, 3631, 2929, 67, 2867, 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 ]
// SPDX-License-Identifier: MIT pragma solidity >=0.8; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./CreepzAggregatorPool.sol"; import "./CreepzInterfaces.sol"; // /$$$$$$ /$$ /$$ // /$$__ $$ | $$ | $$ // | $$ \__/ /$$$$$$ | $$$$$$$ /$$$$$$ | $$ /$$$$$$ // | $$ |____ $$| $$__ $$ |____ $$| $$ |____ $$ // | $$ /$$$$$$$| $$ \ $$ /$$$$$$$| $$ /$$$$$$$ // | $$ $$ /$$__ $$| $$ | $$ /$$__ $$| $$ /$$__ $$ // | $$$$$$/| $$$$$$$| $$$$$$$/| $$$$$$$| $$| $$$$$$$ // \______/ \_______/|_______/ \_______/|__/ \_______/ // /$$$$$$ // /$$__ $$ // | $$ \__/ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ // | $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/ // | $$ | $$ \__/| $$$$$$$$| $$$$$$$$| $$ \ $$ /$$$$/ // | $$ $$| $$ | $$_____/| $$_____/| $$ | $$ /$$__/ // | $$$$$$/| $$ | $$$$$$$| $$$$$$$| $$$$$$$/ /$$$$$$$$ // \______/ |__/ \_______/ \_______/| $$____/ |________/ // | $$ // /$$$$$$ | $$ /$$ // /$$__ $$ |__/ | $$ // | $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ // | $$$$$$$$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |____ $$|_ $$_/ /$$__ $$ /$$__ $$ // | $$__ $$| $$ \ $$| $$ \ $$| $$ \__/| $$$$$$$$| $$ \ $$ /$$$$$$$ | $$ | $$ \ $$| $$ \__/ // | $$ | $$| $$ | $$| $$ | $$| $$ | $$_____/| $$ | $$ /$$__ $$ | $$ /$$| $$ | $$| $$ // | $$ | $$| $$$$$$$| $$$$$$$| $$ | $$$$$$$| $$$$$$$| $$$$$$$ | $$$$/| $$$$$$/| $$ // |__/ |__/ \____ $$ \____ $$|__/ \_______/ \____ $$ \_______/ \___/ \______/ |__/ // /$$ \ $$ /$$ \ $$ /$$ \ $$ // | $$$$$$/| $$$$$$/ | $$$$$$/ // \______/ \______/ \______/ // catch us at https://cabalacreepz.co contract CreepzAggregator is ERC1155, Ownable { using ECDSA for bytes32; using Clones for address; // Trump 0-4; Cuban 5-9; Paris 10-14; Elon 15-19; // Snoop 20-24; Gary 25-29; Bankz 30-34; ICreepz public immutable Creepz; IShapeshifter public immutable Shapeshifter; CreepzAggregatorPool[7] private pools; address public creepzProvider; uint256 public creepzStaked; mapping(address => uint256) public userToUsedNonce; address private signer; uint256 public commissionRate = 9500; // 1 - (n ÷ 1e4) commission cut for owner uint256 public constant CLAIM_INTERVAL = 43200; // tax is accumlated every 12 hours = 43200 seconds address public poolMaster; bool private initialized = false; constructor(address creepz, address shapeshifter) ERC1155("") { Creepz = ICreepz(creepz); Shapeshifter = IShapeshifter(shapeshifter); } function initialize(address _poolMaster, bytes32[7] calldata salts) external onlyOwner { require(!initialized); poolMaster = _poolMaster; // spawn the 7 pools for (uint256 i = 0; i < 7; i++) { poolMaster.cloneDeterministic(salts[i]); pools[i] = CreepzAggregatorPool(poolMaster.predictDeterministicAddress(salts[i])); pools[i].initialize(); } initialized = true; } // transfer ERC1155 token function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public override { pools[id / 5].updateTWAPForTransfer(from, to, amount); super.safeTransferFrom(from, to, id, amount, data); } function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public override { uint256[7] memory poolChanges; for (uint256 i; i < ids.length; i++) { poolChanges[ids[i] / 5] += amounts[i]; } for (uint256 i; i < 7; i++) { if (poolChanges[i] > 0) { pools[i].updateTWAPForTransfer(from, to, poolChanges[i]); } } super.safeBatchTransferFrom(from, to, ids, amounts, data); } // ---- creepz ----- function stakeCreepz(uint256 creepzId) external { require(creepzProvider == address(0) && creepzStaked == 0); Creepz.transferFrom(_msgSender(), address(pools[0]), creepzId); // put in the donald pool creepzProvider = _msgSender(); creepzStaked = creepzId; } function unstakeCreepz() external { require(creepzProvider == _msgSender() && creepzStaked != 0); Creepz.transferFrom(address(pools[0]), _msgSender(), creepzStaked); creepzProvider = address(0); creepzStaked = 0; } // ---- shapeshifter ----- function _verifyShapeshiferSignature( uint256[] calldata shapeIds, uint256[6][7] calldata shapeTypes, uint256[7] calldata taxAmounts, uint256 nonce, bytes calldata signature ) internal view { require(nonce > userToUsedNonce[_msgSender()]); address recoveredAddress = keccak256(abi.encodePacked(shapeIds, shapeTypes, taxAmounts, nonce, _msgSender())).toEthSignedMessageHash().recover(signature); require(recoveredAddress != address(0) && recoveredAddress == signer); } function stakeShapeshifters( uint256[] calldata shapeIds, uint256[6][7] calldata shapeTypes, // an 2d array holding 7 * 6 uint256s, balances & total uint256[7] calldata taxAmounts, uint256[7] calldata creepzNonces, bytes[7] calldata creepzSignatures, uint256 nonce, bytes calldata signature ) external { // verify the signature & nonce _verifyShapeshiferSignature(shapeIds, shapeTypes, taxAmounts, nonce, signature); userToUsedNonce[_msgSender()] = nonce; // keep track of where the creepz is address creepzOrigin = address(pools[0]); for (uint256 i = 0; i < 7; i++) { // identify the interacting pools if (shapeTypes[i][5] != 0) { // claim the loomi from creepz if necessary, i.e. after the interval and the tax amount is not zero if (pools[i].lastClaimedTimestamp() + CLAIM_INTERVAL < block.timestamp && taxAmounts[i] != 0) { // flash stake to the pool if (creepzOrigin != address(pools[i])) { Creepz.transferFrom(creepzOrigin, address(pools[i]), creepzStaked); creepzOrigin = address(pools[i]); } // claim the tax pools[i].claimTaxFromCreepz(creepzStaked, taxAmounts[i], commissionRate, creepzNonces[i], creepzSignatures[i]); } // update the pool pools[i].stakeShapeshifters(_msgSender(), shapeTypes[i]); // mint the corresponding tokens for (uint256 j = 0; j < 5; j++) { if (shapeTypes[i][j] != 0) { super._mint(_msgSender(), i * 5 + j, shapeTypes[i][j], ""); } } } } // flash stake back to the first pool if the origin is not the first pool if (creepzOrigin != address(pools[0])) { Creepz.transferFrom(creepzOrigin, address(pools[0]), creepzStaked); } // transfer the shapeshifters to this contract for (uint256 i = 0; i < shapeIds.length; i++) { Shapeshifter.transferFrom(_msgSender(), address(this), shapeIds[i]); } } function unstakeShapeshifters( uint256[] calldata shapeIds, uint256[6][7] calldata shapeTypes, // an 2d array holding 7 * 6 uint256s, balances & total uint256[7] calldata taxAmounts, uint256[7] calldata creepzNonces, bytes[7] calldata creepzSignatures, uint256 nonce, bytes calldata signature ) external { // verify the signature & nonce _verifyShapeshiferSignature(shapeIds, shapeTypes, taxAmounts, nonce, signature); userToUsedNonce[_msgSender()] = nonce; // keep track of where the creepz is address creepzOrigin = address(pools[0]); for (uint256 i = 0; i < 7; i++) { // identify the interacting pools if (shapeTypes[i][5] != 0) { // claim the loomi from creepz if necessary if (pools[i].lastClaimedTimestamp() + CLAIM_INTERVAL < block.timestamp && taxAmounts[i] != 0) { // flash stake to the pool if (creepzOrigin != address(pools[i])) { Creepz.transferFrom(creepzOrigin, address(pools[i]), creepzStaked); creepzOrigin = address(pools[i]); } // claim the tax pools[i].claimTaxFromCreepz(creepzStaked, taxAmounts[i], commissionRate, creepzNonces[i], creepzSignatures[i]); } // update the pool pools[i].unstakeShapeshifters(_msgSender(), shapeTypes[i]); // burn the corresponding tokens for (uint256 j = 0; j < 5; j++) { if (shapeTypes[i][j] != 0) { super._burn(_msgSender(), i * 5 + j, shapeTypes[i][j]); } } } } // flash stake back to the first pool if the origin is not the first pool if (creepzOrigin != address(pools[0])) { Creepz.transferFrom(creepzOrigin, address(pools[0]), creepzStaked); } // transfer the shapeshifters to the sender for (uint256 i = 0; i < shapeIds.length; i++) { Shapeshifter.transferFrom(address(this), _msgSender(), shapeIds[i]); } } // ---- mega shapeshifter ----- function unstakeMegaShapeshifter( uint256 poolIndex, uint256[5] calldata burnTypes, // tokens to burn uint256 megaId, uint256 taxAmount, uint256 creepzNonce, bytes calldata creepzSignature, uint256 nonce, bytes calldata signature ) external { // verify the signature & nonce require(nonce > userToUsedNonce[_msgSender()]); address recoveredAddress = keccak256(abi.encodePacked(poolIndex, megaId, nonce, _msgSender())).toEthSignedMessageHash().recover(signature); require(recoveredAddress != address(0) && recoveredAddress == signer); userToUsedNonce[_msgSender()] = nonce; // claim the loomi from creepz if necessary if (pools[poolIndex].lastClaimedTimestamp() + CLAIM_INTERVAL < block.timestamp && taxAmount != 0) { // flash stake to the pool if the pool is not donald if (poolIndex != 0) { Creepz.transferFrom(address(pools[0]), address(pools[poolIndex]), creepzStaked); } // claim the tax pools[poolIndex].claimTaxFromCreepz(creepzStaked, taxAmount, commissionRate, creepzNonce, creepzSignature); // flash stake back to the aggregator if the pool is not donald if (poolIndex != 0) { Creepz.transferFrom(address(pools[poolIndex]), address(pools[0]), creepzStaked); } } // burn the tokens uint256 burnedAmount; for (uint256 i = 0; i < 5; i++) { if (burnTypes[i] != 0) { super._burn(_msgSender(), poolIndex * 5 + i, burnTypes[i]); burnedAmount++; } } // must have burnt 5 tokens at the end require(burnedAmount == 5); // unstake the mega shapeshifter from the designated pool pools[poolIndex].unstakeMegashapeshifter(_msgSender(), megaId); } function mutateMegashifter( uint256[] calldata shapeIds, uint256 shapeType, bytes calldata mutateSignature ) external { // transfer the shapeshifters to the pool for (uint256 i = 0; i < 5; i++) { Shapeshifter.transferFrom(address(this), address(pools[shapeType]), shapeIds[i]); } // mutate the mega shapeshifter in the designated pool pools[shapeType].mutateMegaShapeshifter(shapeIds, shapeType, mutateSignature); } // ---- claim tax from pools ----- function claimTaxFromPools( uint256[] calldata poolIndexes, uint256[] calldata taxAmounts, uint256[] calldata creepzNonces, bytes[] calldata creepzSignatures ) external { require(poolIndexes.length == taxAmounts.length && poolIndexes.length == creepzNonces.length); // keep track of where the creepz is address creepzOrigin = address(pools[0]); for (uint256 i = 0; i < poolIndexes.length; i++) { // claim loomi from creepz if necessary if (pools[poolIndexes[i]].lastClaimedTimestamp() + CLAIM_INTERVAL < block.timestamp && taxAmounts[i] != 0) { // flash stake to the pool if (creepzOrigin != address(pools[poolIndexes[i]])) { Creepz.transferFrom(creepzOrigin, address(pools[poolIndexes[i]]), creepzStaked); creepzOrigin = address(pools[poolIndexes[i]]); } // claim the tax pools[poolIndexes[i]].claimTaxFromCreepz(creepzStaked, taxAmounts[i], commissionRate, creepzNonces[i], creepzSignatures[i]); } // claim tax from pool pools[poolIndexes[i]].claimTaxFromPool(_msgSender()); } // flash stake back to the first pool if the origin is not the first pool if (creepzOrigin != address(pools[0])) { Creepz.transferFrom(creepzOrigin, address(pools[0]), creepzStaked); } } // ---- view ---- function getPoolAddress(uint256 poolIndex) external view returns (address) { return address(pools[poolIndex]); } function uri(uint256 tokenId) public view override returns (string memory) { return string(abi.encodePacked(super.uri(tokenId), Strings.toString(tokenId), ".json")); } // ---- owner ---- function withdrawPoolEarnOwner(address withdrawlAddress) external onlyOwner { for (uint256 i; i < 7; i++) { pools[i].withdrawPoolEarnOwner(withdrawlAddress); } } function setSigner(address _signer) external onlyOwner { signer = _signer; } function setURI(string calldata _uri) external onlyOwner { _setURI(_uri); } // toggle the commission taking function setTakingCommissions(bool takingCommissions) external onlyOwner { if (takingCommissions) { commissionRate = 9500; // 1 - (9500 ÷ 1e4) = 5% commission cut for owner } else { commissionRate = 1e4; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); } /** * @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, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // SPDX-License-Identifier: MIT // 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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @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 { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. 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] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // 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 tryRecover(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 tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @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. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} 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.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // 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 (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @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) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @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 Message, created from `s`. 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(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @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)); } } // 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 pragma solidity >=0.8; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "./CreepzInterfaces.sol"; // /$$$$$$ /$$ /$$ // /$$__ $$ | $$ | $$ // | $$ \__/ /$$$$$$ | $$$$$$$ /$$$$$$ | $$ /$$$$$$ // | $$ |____ $$| $$__ $$ |____ $$| $$ |____ $$ // | $$ /$$$$$$$| $$ \ $$ /$$$$$$$| $$ /$$$$$$$ // | $$ $$ /$$__ $$| $$ | $$ /$$__ $$| $$ /$$__ $$ // | $$$$$$/| $$$$$$$| $$$$$$$/| $$$$$$$| $$| $$$$$$$ // \______/ \_______/|_______/ \_______/|__/ \_______/ // /$$$$$$ // /$$__ $$ // | $$ \__/ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ // | $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/ // | $$ | $$ \__/| $$$$$$$$| $$$$$$$$| $$ \ $$ /$$$$/ // | $$ $$| $$ | $$_____/| $$_____/| $$ | $$ /$$__/ // | $$$$$$/| $$ | $$$$$$$| $$$$$$$| $$$$$$$/ /$$$$$$$$ // \______/ |__/ \_______/ \_______/| $$____/ |________/ // /$$$$$$$ /$$ | $$ // | $$__ $$ | $$ | $$ // | $$ \ $$ /$$$$$$ /$$$$$$ | $$ |__/ // | $$$$$$$//$$__ $$ /$$__ $$| $$ // | $$____/| $$ \ $$| $$ \ $$| $$ // | $$ | $$ | $$| $$ | $$| $$ // | $$ | $$$$$$/| $$$$$$/| $$ // |__/ \______/ \______/ |__/ // catch us at https://cabalacreepz.co contract CreepzAggregatorPool is Context, Initializable, IERC721Receiver { struct Stakeholder { uint256 totalStaked; uint256 unclaimed; uint256 TWAP; } uint256 public totalStaked; uint256 public totalTaxReceived; uint256 public totalClaimable; uint256 public lastClaimedTimestamp; uint256 public TWAP; mapping(address => Stakeholder) public stakes; address public immutable allowedOrigin; ILoomi public immutable Loomi; ICreepz public immutable Creepz; IMegaShapeshifter public immutable MegaShapeshifter; modifier onlyFromAllowedOrigin() { require(_msgSender() == allowedOrigin); _; } constructor( address origin, address loomiAddress, address creepzAddress, address megaShapeshifterAddress ) { // set the allowed origin to the aggregator address allowedOrigin = origin; Loomi = ILoomi(loomiAddress); Creepz = ICreepz(creepzAddress); MegaShapeshifter = IMegaShapeshifter(megaShapeshifterAddress); } function initialize() external initializer { // allow the aggregator to flash stake creepz & unstake mega Creepz.setApprovalForAll(allowedOrigin, true); MegaShapeshifter.setApprovalForAll(allowedOrigin, true); } function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external override returns (bytes4) { return this.onERC721Received.selector; } function updateTWAPForTransfer( address from, address to, uint256 changes ) external onlyFromAllowedOrigin { // update the from's stats stakes[from].unclaimed += (TWAP - stakes[from].TWAP) * stakes[from].totalStaked; stakes[from].totalStaked -= changes; stakes[from].TWAP = TWAP; // update the to's stats stakes[to].unclaimed += (TWAP - stakes[to].TWAP) * stakes[to].totalStaked; stakes[to].totalStaked += changes; stakes[to].TWAP = TWAP; } function claimTaxFromCreepz( uint256 creepzId, uint256 reward, uint256 commissionRate, uint256 creepzNonce, bytes calldata creepzSignature ) external onlyFromAllowedOrigin { // need at least one shapeshifter staked to distribute tax require(totalStaked > 0); // claim the tax from creepz MegaShapeshifter.claimTax(reward, creepzNonce, creepzId, creepzSignature); // withdraw the in-game loomi into ERC20 loomi Loomi.withdrawLoomi(reward); // re-calculate the reward with loomi tax and commission reward = (reward * (100 - Loomi.withdrawTaxAmount()) * commissionRate) / (100 * 1e4); // update the pool's stats TWAP += reward / totalStaked; totalTaxReceived += reward; totalClaimable += reward; // update the last claimed timestamp lastClaimedTimestamp = block.timestamp; } function claimTaxFromPool(address stakeholder) external onlyFromAllowedOrigin { // calculate the total reward amount uint256 totalReward = stakes[stakeholder].unclaimed + (TWAP - stakes[stakeholder].TWAP) * stakes[stakeholder].totalStaked; // update the pool's stats totalClaimable -= totalReward; // update the stakeholder's stats stakes[stakeholder].unclaimed = 0; stakes[stakeholder].TWAP = TWAP; // transfer the total reward to the stakeholder Loomi.transfer(stakeholder, totalReward); } function stakeShapeshifters(address stakeholder, uint256[6] calldata shapeTypes) external onlyFromAllowedOrigin { // update the pool's stats totalStaked += shapeTypes[5]; // update the stakeholder's stats stakes[stakeholder].unclaimed += (TWAP - stakes[stakeholder].TWAP) * stakes[stakeholder].totalStaked; stakes[stakeholder].totalStaked += shapeTypes[5]; stakes[stakeholder].TWAP = TWAP; } function unstakeShapeshifters(address stakeholder, uint256[6] calldata shapeTypes) external onlyFromAllowedOrigin { // update the pool's stats totalStaked -= shapeTypes[5]; // update the stakeholder's stats stakes[stakeholder].unclaimed += (TWAP - stakes[stakeholder].TWAP) * stakes[stakeholder].totalStaked; stakes[stakeholder].totalStaked -= shapeTypes[5]; stakes[stakeholder].TWAP = TWAP; } function unstakeMegashapeshifter(address stakeholder, uint256 megaId) external onlyFromAllowedOrigin { // calculate the inefficiency score require(stakes[stakeholder].totalStaked * MegaShapeshifter.balanceOf(address(this)) >= totalStaked); // update the pool's stats totalStaked -= 5; // update the stakeholder's stats stakes[stakeholder].unclaimed += (TWAP - stakes[stakeholder].TWAP) * stakes[stakeholder].totalStaked; stakes[stakeholder].totalStaked -= 5; stakes[stakeholder].TWAP = TWAP; // transfer the mega shapeshifter MegaShapeshifter.transferFrom(address(this), stakeholder, megaId); } function mutateMegaShapeshifter( uint256[] calldata shapeIds, uint256 shapeType, bytes calldata signature ) external { // mutate by calling the MegaShapeshifter contract MegaShapeshifter.mutate(shapeIds, shapeType, signature); } function withdrawPoolEarnOwner(address withdrawAddress) external onlyFromAllowedOrigin { // get the loomi balance of the contract uint256 loomiBalance = Loomi.balanceOf(address(this)); // transfer the commission received to the withdraw address Loomi.transfer(withdrawAddress, loomiBalance - totalClaimable); } } // SPDX-License-Identifier: MIT pragma solidity >=0.8; interface ILoomi { function approve(address spender, uint256 amount) external; function transfer(address to, uint256 amount) external; function balanceOf(address user) external view returns (uint256); function withdrawLoomi(uint256 amount) external; function withdrawTaxAmount() external view returns (uint256); } interface ICreepz { function setApprovalForAll(address to, bool approved) external; function transferFrom( address from, address to, uint256 tokenId ) external; } interface IShapeshifter { function transferFrom( address from, address to, uint256 tokenId ) external; } interface IMegaShapeshifter { function setApprovalForAll(address to, bool approved) external; function claimTax( uint256 amount, uint256 nonce, uint256 creepzId, bytes calldata signature ) external; function mutate( uint256[] memory shapeIds, uint256 shapeType, bytes calldata signature ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT // 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); } } } } // 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/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/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 (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/Address.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] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * 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 !Address.isContract(address(this)); } } // 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); }
verify the signature & nonce keep track of where the creepz is identify the interacting pools claim the loomi from creepz if necessary flash stake to the pool burn the corresponding tokens flash stake back to the first pool if the origin is not the first pool transfer the shapeshifters to the sender
function unstakeShapeshifters( uint256[] calldata shapeIds, uint256[7] calldata taxAmounts, uint256[7] calldata creepzNonces, bytes[7] calldata creepzSignatures, uint256 nonce, bytes calldata signature ) external { _verifyShapeshiferSignature(shapeIds, shapeTypes, taxAmounts, nonce, signature); userToUsedNonce[_msgSender()] = nonce; address creepzOrigin = address(pools[0]); for (uint256 i = 0; i < 7; i++) { if (shapeTypes[i][5] != 0) { if (pools[i].lastClaimedTimestamp() + CLAIM_INTERVAL < block.timestamp && taxAmounts[i] != 0) { if (creepzOrigin != address(pools[i])) { Creepz.transferFrom(creepzOrigin, address(pools[i]), creepzStaked); creepzOrigin = address(pools[i]); } } for (uint256 j = 0; j < 5; j++) { if (shapeTypes[i][j] != 0) { super._burn(_msgSender(), i * 5 + j, shapeTypes[i][j]); } } } } if (creepzOrigin != address(pools[0])) { Creepz.transferFrom(creepzOrigin, address(pools[0]), creepzStaked); } for (uint256 i = 0; i < shapeIds.length; i++) { Shapeshifter.transferFrom(address(this), _msgSender(), shapeIds[i]); } }
5,761,569
[ 1, 4625, 348, 7953, 560, 30, 225, 3929, 326, 3372, 473, 7448, 3455, 3298, 434, 1625, 326, 1519, 881, 94, 353, 9786, 326, 16592, 310, 16000, 7516, 326, 437, 362, 77, 628, 1519, 881, 94, 309, 4573, 9563, 384, 911, 358, 326, 2845, 18305, 326, 4656, 2430, 9563, 384, 911, 1473, 358, 326, 1122, 2845, 309, 326, 4026, 353, 486, 326, 1122, 2845, 7412, 326, 30721, 4607, 430, 5432, 358, 326, 5793, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 225, 445, 640, 334, 911, 1555, 438, 4607, 430, 5432, 12, 203, 565, 2254, 5034, 8526, 745, 892, 2179, 2673, 16, 203, 565, 2254, 5034, 63, 27, 65, 745, 892, 5320, 6275, 87, 16, 203, 565, 2254, 5034, 63, 27, 65, 745, 892, 1519, 881, 94, 3989, 764, 16, 203, 565, 1731, 63, 27, 65, 745, 892, 1519, 881, 94, 23918, 16, 203, 565, 2254, 5034, 7448, 16, 203, 565, 1731, 745, 892, 3372, 203, 225, 262, 3903, 288, 203, 565, 389, 8705, 1555, 438, 4607, 21549, 5374, 12, 4867, 2673, 16, 2179, 2016, 16, 5320, 6275, 87, 16, 7448, 16, 3372, 1769, 203, 565, 729, 774, 6668, 13611, 63, 67, 3576, 12021, 1435, 65, 273, 7448, 31, 203, 203, 565, 1758, 1519, 881, 94, 7571, 273, 1758, 12, 27663, 63, 20, 19226, 203, 203, 565, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 2371, 31, 277, 27245, 288, 203, 1377, 309, 261, 4867, 2016, 63, 77, 6362, 25, 65, 480, 374, 13, 288, 203, 3639, 309, 261, 27663, 63, 77, 8009, 2722, 9762, 329, 4921, 1435, 397, 29859, 3445, 67, 16435, 411, 1203, 18, 5508, 597, 5320, 6275, 87, 63, 77, 65, 480, 374, 13, 288, 203, 1850, 309, 261, 1793, 881, 94, 7571, 480, 1758, 12, 27663, 63, 77, 22643, 288, 203, 5411, 5799, 881, 94, 18, 13866, 1265, 12, 1793, 881, 94, 7571, 16, 1758, 12, 27663, 63, 77, 65, 3631, 1519, 881, 94, 510, 9477, 1769, 203, 5411, 1519, 881, 94, 7571, 273, 1758, 12, 27663, 63, 77, 19226, 203, 1850, 289, 203, 3639, 289, 203, 3639, 364, 261, 11890, 5034, 525, 273, 374, 31, 525, 411, 1381, 31, 525, 27245, 288, 203, 1850, 309, 261, 4867, 2016, 63, 77, 6362, 78, 65, 480, 374, 13, 288, 203, 5411, 2240, 6315, 70, 321, 24899, 3576, 12021, 9334, 277, 380, 1381, 397, 525, 16, 2179, 2016, 63, 77, 6362, 78, 19226, 203, 1850, 289, 203, 3639, 289, 203, 1377, 289, 203, 565, 289, 203, 203, 565, 309, 261, 1793, 881, 94, 7571, 480, 1758, 12, 27663, 63, 20, 22643, 288, 203, 1377, 5799, 881, 94, 18, 13866, 1265, 12, 1793, 881, 94, 7571, 16, 1758, 12, 27663, 63, 20, 65, 3631, 1519, 881, 94, 510, 9477, 1769, 203, 565, 289, 203, 203, 565, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 2179, 2673, 18, 2469, 31, 277, 27245, 288, 203, 1377, 2638, 438, 4607, 430, 387, 18, 13866, 1265, 12, 2867, 12, 2211, 3631, 389, 3576, 12021, 9334, 2179, 2673, 63, 77, 19226, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.19; /* Adapted from strings.sol created by Nick Johnson <[email protected]> * Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol * @title String & slice utility library for Solidity contracts. * @author Nick Johnson <[email protected]> */ library strings { struct slice { uint _len; uint _ptr; } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string self) internal pure returns (slice) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } function memcpy(uint dest, uint src, uint len) private pure { // Copy word-length chunks while possible for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function concat(slice self, slice other) internal returns (string) { var ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice self, slice needle) internal returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) { uint ptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { // Optimized assembly for 68 gas per byte on short strings assembly { let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1)) let needledata := and(mload(needleptr), mask) let end := add(selfptr, sub(selflen, needlelen)) ptr := selfptr loop: jumpi(exit, eq(and(mload(ptr), mask), needledata)) ptr := add(ptr, 1) jumpi(loop, lt(sub(ptr, 1), end)) ptr := add(selfptr, selflen) exit: } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := sha3(needleptr, needlelen) } ptr = selfptr; for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := sha3(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice self, slice needle, slice token) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice self, slice needle) internal returns (slice token) { split(self, needle, token); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice self) internal pure returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } } /* Helper String Functions for Game Manager Contract * @title String Healpers * @author Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) */ contract StringHelpers { using strings for *; function stringToBytes32(string memory source) internal returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function bytes32ToString(bytes32 x) constant internal returns (string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { byte char = byte(bytes32(uint(x) * 2 ** (8 * j))); if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } } /// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens /// @author Dieter Shirley <[email protected]> (https://github.com/dete) contract ERC721 { // Required methods function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _assetId) public view returns (address owner); function approve(address _to, uint256 _assetId) public; function transfer(address _to, uint256 _assetId) public; function transferFrom(address _from, address _to, uint256 _assetId) public; function implementsERC721() public pure returns (bool); function takeOwnership(uint256 _assetId) public; function totalSupply() public view returns (uint256 total); event Transfer(address indexed from, address indexed to, uint256 tokenId); event Approval(address indexed owner, address indexed approved, uint256 tokenId); // Optional // function name() public view returns (string name); // function symbol() public view returns (string symbol); // function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 tokenId); // function tokenMetadata(uint256 _tokenId) public view returns (string infoUrl); // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165) function supportsInterface(bytes4 _interfaceID) external view returns (bool); } /* Controls game play state and access rights for game functions * @title Operational Control * @author Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) * Inspired and adapted from contract created by OpenZeppelin * Ref: https://github.com/OpenZeppelin/zeppelin-solidity/ */ contract OperationalControl { // Facilitates access & control for the game. // Roles: // -The Game Managers (Primary/Secondary): Has universal control of all game elements (No ability to withdraw) // -The Banker: The Bank can withdraw funds and adjust fees / prices. /// @dev Emited when contract is upgraded event ContractUpgrade(address newContract); // The addresses of the accounts (or contracts) that can execute actions within each roles. address public gameManagerPrimary; address public gameManagerSecondary; address public bankManager; // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; // @dev Keeps track whether the contract erroredOut. When that is true, most actions are blocked & refund can be claimed bool public error = false; /// @dev Operation modifiers for limiting access modifier onlyGameManager() { require(msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary); _; } modifier onlyBanker() { require(msg.sender == bankManager); _; } modifier anyOperator() { require( msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary || msg.sender == bankManager ); _; } /// @dev Assigns a new address to act as the GM. function setPrimaryGameManager(address _newGM) external onlyGameManager { require(_newGM != address(0)); gameManagerPrimary = _newGM; } /// @dev Assigns a new address to act as the GM. function setSecondaryGameManager(address _newGM) external onlyGameManager { require(_newGM != address(0)); gameManagerSecondary = _newGM; } /// @dev Assigns a new address to act as the Banker. function setBanker(address _newBK) external onlyGameManager { require(_newBK != address(0)); bankManager = _newBK; } /*** Pausable functionality adapted from OpenZeppelin ***/ /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Modifier to allow actions only when the contract has Error modifier whenError { require(error); _; } /// @dev Called by any Operator role to pause the contract. /// Used only if a bug or exploit is discovered (Here to limit losses / damage) function pause() external onlyGameManager whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. Can only be called by the Game Master /// @notice This is public rather than external so it can be called by derived contracts. function unpause() public onlyGameManager whenPaused { // can't unpause if contract was upgraded paused = false; } /// @dev Unpauses the smart contract. Can only be called by the Game Master /// @notice This is public rather than external so it can be called by derived contracts. function hasError() public onlyGameManager whenPaused { error = true; } /// @dev Unpauses the smart contract. Can only be called by the Game Master /// @notice This is public rather than external so it can be called by derived contracts. function noError() public onlyGameManager whenPaused { error = false; } } contract CSCCollectibleBase is ERC721, OperationalControl, StringHelpers { /*** EVENTS ***/ /// @dev The Created event is fired whenever a new collectible comes into existence. event CollectibleCreated(address owner, uint256 globalId, uint256 collectibleType, uint256 collectibleClass, uint256 sequenceId, bytes32 collectibleName, bool isRedeemed); event Transfer(address from, address to, uint256 shipId); /*** CONSTANTS ***/ /// @notice Name and symbol of the non fungible token, as defined in ERC721. string public constant NAME = "CSCPreSaleShip"; string public constant SYMBOL = "CSC"; bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); bytes4 constant InterfaceSignature_ERC721 = bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('totalSupply()')) ^ bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ^ bytes4(keccak256('transfer(address,uint256)')) ^ bytes4(keccak256('transferFrom(address,address,uint256)')) ^ bytes4(keccak256('tokensOfOwner(address)')) ^ bytes4(keccak256('tokenMetadata(uint256,string)')); /// @dev CSC Pre Sale Struct, having details of the ship struct CSCPreSaleItem { /// @dev asset ID i..e Local Index uint256 assetId; /// @dev name of the collectible stored in bytes bytes32 collectibleName; /// @dev Timestamp when bought uint256 boughtTimestamp; /// @dev Collectible Types (Voucher/Ship) /// can be 0 - Voucher, 1 - Ship uint256 collectibleType; /// @dev Collectible Class (1 - Prometheus, 2 - Crosair, 3 - Intrepid) uint256 collectibleClass; // @dev owner address address owner; // @dev redeeme flag (to help whether it got redeemed or not) bool isRedeemed; } // @dev Mapping containing the reference to all CSC PreSaleItem //mapping (uint256 => CSCPreSaleItem[]) public indexToPreSaleItem; // @dev array of CSCPreSaleItem type holding information on the Ships CSCPreSaleItem[] allPreSaleItems; // Max Count for Voucher(s), Prometheus, Crosair & Intrepid Ships uint256 public constant PROMETHEUS_SHIP_LIMIT = 300; uint256 public constant INTREPID_SHIP_LIMIT = 1500; uint256 public constant CROSAIR_SHIP_LIMIT = 600; uint256 public constant PROMETHEUS_VOUCHER_LIMIT = 100; uint256 public constant INTREPID_VOUCHER_LIMIT = 300; uint256 public constant CROSAIR_VOUCHER_LIMIT = 200; // Variable to keep a count of Prometheus/Intrepid/Crosair Minted uint256 public prometheusShipMinted; uint256 public intrepidShipMinted; uint256 public crosairShipMinted; uint256 public prometheusVouchersMinted; uint256 public intrepidVouchersMinted; uint256 public crosairVouchersMinted; // @dev mapping which holds all the possible addresses which are allowed to interact with the contract mapping (address => bool) approvedAddressList; // @dev mapping holds the preSaleItem -> owner details mapping (uint256 => address) public preSaleItemIndexToOwner; // @dev A mapping from owner address to count of tokens that address owns. // Used internally inside balanceOf() to resolve ownership count. mapping (address => uint256) private ownershipTokenCount; /// @dev A mapping from preSaleItem to an address that has been approved to call /// transferFrom(). Each Ship can only have one approved address for transfer /// at any time. A zero value means no approval is outstanding. mapping (uint256 => address) public preSaleItemIndexToApproved; /// @dev A mapping of preSaleItem Type to Type Sequence Number to Collectible /// 0 - Voucher /// 1 - Prometheus /// 2 - Crosair /// 3 - Intrepid mapping (uint256 => mapping (uint256 => mapping ( uint256 => uint256 ) ) ) public preSaleItemTypeToSequenceIdToCollectible; /// @dev A mapping from Pre Sale Item Type IDs to the Sequqence Number . /// 0 - Voucher /// 1 - Prometheus /// 2 - Crosair /// 3 - Intrepid mapping (uint256 => mapping ( uint256 => uint256 ) ) public preSaleItemTypeToCollectibleCount; /// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165). /// Returns true for any standardized interfaces implemented by this contract. We implement /// ERC-165 (obviously!) and ERC-721. function supportsInterface(bytes4 _interfaceID) external view returns (bool) { // DEBUG ONLY //require((InterfaceSignature_ERC165 == 0x01ffc9a7) && (InterfaceSignature_ERC721 == 0x9a20483d)); return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721)); } function getCollectibleDetails(uint256 _assetId) external view returns(uint256 assetId, uint256 sequenceId, uint256 collectibleType, uint256 collectibleClass, bool isRedeemed, address owner) { CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; assetId = _assetId; sequenceId = _Obj.assetId; collectibleType = _Obj.collectibleType; collectibleClass = _Obj.collectibleClass; owner = _Obj.owner; isRedeemed = _Obj.isRedeemed; } /*** PUBLIC FUNCTIONS ***/ /// @notice Grant another address the right to transfer token via takeOwnership() and transferFrom(). /// @param _to The address to be granted transfer approval. Pass address(0) to /// clear all approvals. /// @param _assetId The ID of the Token that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function approve(address _to, uint256 _assetId) public { // Caller must own token. require(_owns(msg.sender, _assetId)); preSaleItemIndexToApproved[_assetId] = _to; Approval(msg.sender, _to, _assetId); } /// For querying balance of a particular account /// @param _owner The address for balance query /// @dev Required for ERC-721 compliance. function balanceOf(address _owner) public view returns (uint256 balance) { return ownershipTokenCount[_owner]; } function implementsERC721() public pure returns (bool) { return true; } /// For querying owner of token /// @param _assetId The tokenID for owner inquiry /// @dev Required for ERC-721 compliance. function ownerOf(uint256 _assetId) public view returns (address owner) { owner = preSaleItemIndexToOwner[_assetId]; require(owner != address(0)); } /// @dev Required for ERC-721 compliance. function symbol() public pure returns (string) { return SYMBOL; } /// @notice Allow pre-approved user to take ownership of a token /// @param _assetId The ID of the Token that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function takeOwnership(uint256 _assetId) public { address newOwner = msg.sender; address oldOwner = preSaleItemIndexToOwner[_assetId]; // Safety check to prevent against an unexpected 0x0 default. require(_addressNotNull(newOwner)); // Making sure transfer is approved require(_approved(newOwner, _assetId)); _transfer(oldOwner, newOwner, _assetId); } /// @param _owner The owner whose ships tokens we are interested in. /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly /// expensive (it walks the entire CSCShips array looking for emojis belonging to owner), /// but it also returns a dynamic array, which is only supported for web3 calls, and /// not contract-to-contract calls. function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalShips = totalSupply() + 1; uint256 resultIndex = 0; // We count on the fact that all CSC Ship Collectible have IDs starting at 0 and increasing // sequentially up to the total count. uint256 _assetId; for (_assetId = 0; _assetId < totalShips; _assetId++) { if (preSaleItemIndexToOwner[_assetId] == _owner) { result[resultIndex] = _assetId; resultIndex++; } } return result; } } /// For querying totalSupply of token /// @dev Required for ERC-721 compliance. function totalSupply() public view returns (uint256 total) { return allPreSaleItems.length - 1; //Removed 0 index } /// Owner initates the transfer of the token to another account /// @param _to The address for the token to be transferred to. /// @param _assetId The ID of the Token that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function transfer(address _to, uint256 _assetId) public { require(_addressNotNull(_to)); require(_owns(msg.sender, _assetId)); _transfer(msg.sender, _to, _assetId); } /// Third-party initiates transfer of token from address _from to address _to /// @param _from The address for the token to be transferred from. /// @param _to The address for the token to be transferred to. /// @param _assetId The ID of the Token that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function transferFrom(address _from, address _to, uint256 _assetId) public { require(_owns(_from, _assetId)); require(_approved(_to, _assetId)); require(_addressNotNull(_to)); _transfer(_from, _to, _assetId); } /*** PRIVATE FUNCTIONS ***/ /// @dev Safety check on _to address to prevent against an unexpected 0x0 default. function _addressNotNull(address _to) internal pure returns (bool) { return _to != address(0); } /// @dev For checking approval of transfer for address _to function _approved(address _to, uint256 _assetId) internal view returns (bool) { return preSaleItemIndexToApproved[_assetId] == _to; } /// @dev For creating CSC Collectible function _createCollectible(bytes32 _collectibleName, uint256 _collectibleType, uint256 _collectibleClass) internal returns(uint256) { uint256 _sequenceId = uint256(preSaleItemTypeToCollectibleCount[_collectibleType][_collectibleClass]) + 1; // These requires are not strictly necessary, our calling code should make // sure that these conditions are never broken. require(_sequenceId == uint256(uint32(_sequenceId))); CSCPreSaleItem memory _collectibleObj = CSCPreSaleItem( _sequenceId, _collectibleName, 0, _collectibleType, _collectibleClass, address(0), false ); uint256 newCollectibleId = allPreSaleItems.push(_collectibleObj) - 1; preSaleItemTypeToSequenceIdToCollectible[_collectibleType][_collectibleClass][_sequenceId] = newCollectibleId; preSaleItemTypeToCollectibleCount[_collectibleType][_collectibleClass] = _sequenceId; // emit Created event // CollectibleCreated(address owner, uint256 globalId, uint256 collectibleType, uint256 collectibleClass, uint256 sequenceId, bytes32[6] attributes, bool isRedeemed); CollectibleCreated(address(this), newCollectibleId, _collectibleType, _collectibleClass, _sequenceId, _collectibleObj.collectibleName, false); // This will assign ownership, and also emit the Transfer event as // per ERC721 draft _transfer(address(0), address(this), newCollectibleId); return newCollectibleId; } /// Check for token ownership function _owns(address claimant, uint256 _assetId) internal view returns (bool) { return claimant == preSaleItemIndexToOwner[_assetId]; } /// @dev Assigns ownership of a specific Emoji to an address. function _transfer(address _from, address _to, uint256 _assetId) internal { // Updating the owner details of the ship CSCPreSaleItem memory _shipObj = allPreSaleItems[_assetId]; _shipObj.owner = _to; allPreSaleItems[_assetId] = _shipObj; // Since the number of emojis is capped to 2^32 we can't overflow this ownershipTokenCount[_to]++; //transfer ownership preSaleItemIndexToOwner[_assetId] = _to; // When creating new emojis _from is 0x0, but we can't account that address. if (_from != address(0)) { ownershipTokenCount[_from]--; // clear any previously approved ownership exchange delete preSaleItemIndexToApproved[_assetId]; } // Emit the transfer event. Transfer(_from, _to, _assetId); } /// @dev Checks if a given address currently has transferApproval for a particular CSCPreSaleItem. /// 0 is a valid value as it will be the starter function _approvedFor(address _claimant, uint256 _assetId) internal view returns (bool) { return preSaleItemIndexToApproved[_assetId] == _claimant; } function _getCollectibleDetails (uint256 _assetId) internal view returns(CSCPreSaleItem) { CSCPreSaleItem storage _Obj = allPreSaleItems[_assetId]; return _Obj; } /// @dev Helps in fetching the attributes of the ship depending on the ship /// assetId : The actual ERC721 Asset ID /// sequenceId : Index w.r.t Ship type function getShipDetails(uint256 _sequenceId, uint256 _shipClass) external view returns ( uint256 assetId, uint256 sequenceId, string shipName, uint256 collectibleClass, uint256 boughtTimestamp, address owner ) { uint256 _assetId = preSaleItemTypeToSequenceIdToCollectible[1][_shipClass][_sequenceId]; CSCPreSaleItem storage _collectibleObj = allPreSaleItems[_assetId]; require(_collectibleObj.collectibleType == 1); assetId = _assetId; sequenceId = _sequenceId; shipName = bytes32ToString(_collectibleObj.collectibleName); collectibleClass = _collectibleObj.collectibleClass; boughtTimestamp = _collectibleObj.boughtTimestamp; owner = _collectibleObj.owner; } /// @dev Helps in fetching information regarding a Voucher /// assetId : The actual ERC721 Asset ID /// sequenceId : Index w.r.t Voucher Type function getVoucherDetails(uint256 _sequenceId, uint256 _voucherClass) external view returns ( uint256 assetId, uint256 sequenceId, uint256 boughtTimestamp, uint256 voucherClass, address owner ) { uint256 _assetId = preSaleItemTypeToSequenceIdToCollectible[0][_voucherClass][_sequenceId]; CSCPreSaleItem storage _collectibleObj = allPreSaleItems[_assetId]; require(_collectibleObj.collectibleType == 0); assetId = _assetId; sequenceId = _sequenceId; boughtTimestamp = _collectibleObj.boughtTimestamp; voucherClass = _collectibleObj.collectibleClass; owner = _collectibleObj.owner; } function _isActive(uint256 _assetId) internal returns(bool) { CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; return (_Obj.boughtTimestamp == 0); } } /* Lucid Sight, Inc. ERC-721 CSC Collectilbe Sale Contract. * @title CSCCollectibleSale * @author Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) */ contract CSCCollectibleSale is CSCCollectibleBase { event CollectibleBought (uint256 _assetId, address owner); event PriceUpdated (uint256 collectibleClass, uint256 newPrice, uint256 oldPrice); // SHIP DATATYPES & CONSTANTS // @dev ship Prices & price cap uint256 public PROMETHEUS_SHIP_PRICE = 0.25 ether; uint256 public INTREPID_SHIP_PRICE = 0.005 ether; uint256 public CROSAIR_SHIP_PRICE = 0.1 ether; uint256 public constant PROMETHEUS_MAX_PRICE = 0.85 ether; uint256 public constant INTREPID_MAX_PRICE = 0.25 ether; uint256 public constant CROSAIR_MAX_PRICE = 0.5 ether; uint256 public constant PROMETHEUS_PRICE_INCREMENT = 0.05 ether; uint256 public constant INTREPID_PRICE_INCREMENT = 0.002 ether; uint256 public constant CROSAIR_PRICE_INCREMENT = 0.01 ether; uint256 public constant PROMETHEUS_PRICE_THRESHOLD = 0.85 ether; uint256 public constant INTREPID_PRICE_THRESHOLD = 0.25 ether; uint256 public constant CROSAIR_PRICE_THRESHOLD = 0.5 ether; uint256 public prometheusSoldCount; uint256 public intrepidSoldCount; uint256 public crosairSoldCount; // VOUCHER DATATYPES & CONSTANTS uint256 public PROMETHEUS_VOUCHER_PRICE = 0.75 ether; uint256 public INTREPID_VOUCHER_PRICE = 0.2 ether; uint256 public CROSAIR_VOUCHER_PRICE = 0.35 ether; uint256 public prometheusVoucherSoldCount; uint256 public crosairVoucherSoldCount; uint256 public intrepidVoucherSoldCount; /// @dev Mapping created store the amount of value a wallet address used to buy assets mapping(address => uint256) addressToValue; /// @dev Mapping to holde the balance of each address, i.e. addrs -> collectibleType -> collectibleClass -> balance mapping(address => mapping(uint256 => mapping (uint256 => uint256))) addressToCollectibleTypeBalance; function _bid(uint256 _assetId, uint256 _price,uint256 _collectibleType,uint256 _collectibleClass, address _buyer) internal { CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; if(_collectibleType == 1 && _collectibleClass == 1) { require(_price == PROMETHEUS_SHIP_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; prometheusSoldCount++; if(prometheusSoldCount % 10 == 0){ if(PROMETHEUS_SHIP_PRICE < PROMETHEUS_PRICE_THRESHOLD){ PROMETHEUS_SHIP_PRICE += PROMETHEUS_PRICE_INCREMENT; } } } if(_collectibleType == 1 && _collectibleClass == 2) { require(_price == CROSAIR_SHIP_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; crosairSoldCount++; if(crosairSoldCount % 10 == 0){ if(CROSAIR_SHIP_PRICE < CROSAIR_PRICE_THRESHOLD){ CROSAIR_SHIP_PRICE += CROSAIR_PRICE_INCREMENT; } } } if(_collectibleType == 1 && _collectibleClass == 3) { require(_price == INTREPID_SHIP_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; intrepidSoldCount++; if(intrepidSoldCount % 10 == 0){ if(INTREPID_SHIP_PRICE < INTREPID_PRICE_THRESHOLD){ INTREPID_SHIP_PRICE += INTREPID_PRICE_INCREMENT; } } } if(_collectibleType == 0 &&_collectibleClass == 1) { require(_price == PROMETHEUS_VOUCHER_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; prometheusVoucherSoldCount++; } if(_collectibleType == 0 && _collectibleClass == 2) { require(_price == CROSAIR_VOUCHER_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; crosairVoucherSoldCount++; } if(_collectibleType == 0 && _collectibleClass == 3) { require(_price == INTREPID_VOUCHER_PRICE); _Obj.owner = _buyer; _Obj.boughtTimestamp = now; addressToValue[_buyer] += _price; intrepidVoucherSoldCount++; } addressToCollectibleTypeBalance[_buyer][_collectibleType][_collectibleClass]++; CollectibleBought(_assetId, _buyer); } function getCollectibleTypeBalance(address _owner, uint256 _collectibleType, uint256 _collectibleClass) external view returns(uint256) { require(_owner != address(0)); return addressToCollectibleTypeBalance[_owner][_collectibleType][_collectibleClass]; } function getCollectiblePrice(uint256 _collectibleType, uint256 _collectibleClass) external view returns(uint256 _price){ // For Ships if(_collectibleType == 1 && _collectibleClass == 1) { return PROMETHEUS_SHIP_PRICE; } if(_collectibleType == 1 && _collectibleClass == 2) { return CROSAIR_SHIP_PRICE; } if(_collectibleType == 1 && _collectibleClass == 3) { return INTREPID_SHIP_PRICE; } // For Vouchers if(_collectibleType == 0 && _collectibleClass == 1) { return PROMETHEUS_VOUCHER_PRICE; } if(_collectibleType == 0 && _collectibleClass == 2) { return CROSAIR_VOUCHER_PRICE; } if(_collectibleType == 0 && _collectibleClass == 3) { return INTREPID_VOUCHER_PRICE; } } } /* Lucid Sight, Inc. ERC-721 Collectibles. * @title LSNFT - Lucid Sight, Inc. Non-Fungible Token * @author Fazri Zubair & Farhan Khwaja (Lucid Sight, Inc.) */ contract CSCPreSaleManager is CSCCollectibleSale { event RefundClaimed(address owner, uint256 refundValue); // Ship Names string private constant prometheusShipName = "Vulcan Harvester"; string private constant crosairShipName = "Phoenix Cruiser"; string private constant intrepidShipName = "Reaper Interceptor"; bool CSCPreSaleInit = false; /// @dev Constructor creates a reference to the NFT (ERC721) ownership contract function CSCPreSaleManager() public { require(msg.sender != address(0)); paused = true; error = false; gameManagerPrimary = msg.sender; } function addToApprovedAddress (address _newAddr) onlyGameManager { require(_newAddr != address(0)); require(!approvedAddressList[_newAddr]); approvedAddressList[_newAddr] = true; } function removeFromApprovedAddress (address _newAddr) onlyGameManager { require(_newAddr != address(0)); require(approvedAddressList[_newAddr]); approvedAddressList[_newAddr] = false; } function() external payable { } /// @dev Bid Function which call the interncal bid function /// after doing all the pre-checks required to initiate a bid function bid(uint256 _collectibleType, uint256 _collectibleClass) external payable { require(msg.sender != address(0)); require(msg.sender != address(this)); require(_collectibleType >= 0 && _collectibleType <= 1); require(_isActive(_assetId)); bytes32 collectibleName; if(_collectibleType == 0){ collectibleName = bytes32("NoNameForVoucher"); if(_collectibleClass == 1){ require(prometheusVouchersMinted < PROMETHEUS_VOUCHER_LIMIT); collectibleName = stringToBytes32(prometheusShipName); prometheusVouchersMinted++; } if(_collectibleClass == 2){ require(crosairVouchersMinted < CROSAIR_VOUCHER_LIMIT); crosairVouchersMinted++; } if(_collectibleClass == 3){ require(intrepidVoucherSoldCount < INTREPID_VOUCHER_LIMIT); intrepidVouchersMinted++; } } if(_collectibleType == 1){ if(_collectibleClass == 1){ require(prometheusShipMinted < PROMETHEUS_SHIP_LIMIT); collectibleName = stringToBytes32(prometheusShipName); prometheusShipMinted++; } if(_collectibleClass == 2){ require(crosairShipMinted < CROSAIR_VOUCHER_LIMIT); collectibleName = stringToBytes32(crosairShipName); crosairShipMinted++; } if(_collectibleClass == 3){ require(intrepidShipMinted < INTREPID_SHIP_LIMIT); collectibleName = stringToBytes32(intrepidShipName); intrepidShipMinted++; } } uint256 _assetId = _createCollectible(collectibleName, _collectibleType, _collectibleClass); CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; _bid(_assetId, msg.value, _Obj.collectibleType, _Obj.collectibleClass, msg.sender); _transfer(address(this), msg.sender, _assetId); } /// @dev Bid Function which call the interncal bid function /// after doing all the pre-checks required to initiate a bid function createReferralGiveAways(uint256 _collectibleType, uint256 _collectibleClass, address _toAddress) onlyGameManager external { require(msg.sender != address(0)); require(msg.sender != address(this)); require(_collectibleType >= 0 && _collectibleType <= 1); bytes32 collectibleName; if(_collectibleType == 0){ collectibleName = bytes32("ReferralGiveAwayVoucher"); if(_collectibleClass == 1){ collectibleName = stringToBytes32(prometheusShipName); } if(_collectibleClass == 2){ crosairVouchersMinted++; } if(_collectibleClass == 3){ intrepidVouchersMinted++; } } if(_collectibleType == 1){ if(_collectibleClass == 1){ collectibleName = stringToBytes32(prometheusShipName); } if(_collectibleClass == 2){ collectibleName = stringToBytes32(crosairShipName); } if(_collectibleClass == 3){ collectibleName = stringToBytes32(intrepidShipName); } } uint256 _assetId = _createCollectible(collectibleName, _collectibleType, _collectibleClass); CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; _transfer(address(this), _toAddress, _assetId); } /// @dev Override unpause so it requires all external contract addresses /// to be set before contract can be unpaused. Also, we can't have /// newContractAddress set either, because then the contract was upgraded. /// @notice This is public rather than external so we can call super.unpause /// without using an expensive CALL. function unpause() public onlyGameManager whenPaused { // Actually unpause the contract. super.unpause(); } /// @dev Remove all Ether from the contract, which is the owner's cuts /// as well as any Ether sent directly to the contract address. /// Always transfers to the NFT (ERC721) contract, but can be called either by /// the owner or the NFT (ERC721) contract. function withdrawBalance() onlyBanker { // We are using this boolean method to make sure that even if one fails it will still work bankManager.transfer(this.balance); } function claimRefund(address _ownerAddress) whenError { uint256 refundValue = addressToValue[_ownerAddress]; addressToValue[_ownerAddress] = 0; _ownerAddress.transfer(refundValue); RefundClaimed(_ownerAddress, refundValue); } function preSaleInit() onlyGameManager { require(!CSCPreSaleInit); require(allPreSaleItems.length == 0); CSCPreSaleInit = true; //Fill in index 0 to null requests CSCPreSaleItem memory _Obj = CSCPreSaleItem(0, stringToBytes32("DummyAsset"), 0, 0, 0, address(this), true); allPreSaleItems.push(_Obj); } function isRedeemed(uint256 _assetId) { require(approvedAddressList[msg.sender]); CSCPreSaleItem memory _Obj = allPreSaleItems[_assetId]; _Obj.isRedeemed = true; allPreSaleItems[_assetId] = _Obj; } }
** EVENTS ***/ @dev The Created event is fired whenever a new collectible comes into existence.** CONSTANTS ***/ @notice Name and symbol of the non fungible token, as defined in ERC721. @dev CSC Pre Sale Struct, having details of the ship @dev owner address @dev redeeme flag (to help whether it got redeemed or not)
struct CSCPreSaleItem { uint256 assetId; bytes32 collectibleName; uint256 boughtTimestamp; uint256 collectibleType; uint256 collectibleClass; address owner; bool isRedeemed; } uint256 public constant INTREPID_SHIP_LIMIT = 1500; uint256 public constant CROSAIR_SHIP_LIMIT = 600; uint256 public constant PROMETHEUS_VOUCHER_LIMIT = 100; uint256 public constant INTREPID_VOUCHER_LIMIT = 300; uint256 public constant CROSAIR_VOUCHER_LIMIT = 200; uint256 public intrepidShipMinted; uint256 public crosairShipMinted; uint256 public prometheusVouchersMinted; uint256 public intrepidVouchersMinted; uint256 public crosairVouchersMinted;
10,103,025
[ 1, 4625, 348, 7953, 560, 30, 2826, 9964, 55, 18852, 19, 632, 5206, 1021, 12953, 871, 353, 15950, 17334, 279, 394, 3274, 1523, 14535, 1368, 15782, 18, 636, 24023, 55, 18852, 19, 632, 20392, 1770, 471, 3273, 434, 326, 1661, 9831, 75, 1523, 1147, 16, 487, 2553, 316, 4232, 39, 27, 5340, 18, 632, 5206, 385, 2312, 2962, 348, 5349, 7362, 16, 7999, 3189, 434, 326, 24316, 632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 203, 203, 565, 1758, 3410, 31, 203, 203, 565, 1426, 28627, 24903, 329, 31, 203, 225, 289, 203, 21281, 203, 225, 2254, 5034, 1071, 5381, 6137, 862, 16522, 67, 20101, 67, 8283, 273, 4711, 713, 31, 203, 225, 2254, 5034, 1071, 5381, 385, 1457, 5233, 7937, 67, 20101, 67, 8283, 273, 14707, 31, 203, 225, 2254, 5034, 1071, 5381, 4629, 5277, 41, 3378, 67, 16169, 57, 1792, 654, 67, 8283, 273, 2130, 31, 203, 225, 2254, 5034, 1071, 5381, 6137, 862, 16522, 67, 16169, 57, 1792, 654, 67, 8283, 273, 11631, 31, 203, 225, 2254, 5034, 1071, 5381, 385, 1457, 5233, 7937, 67, 16169, 57, 1792, 654, 67, 8283, 273, 4044, 31, 203, 203, 225, 2254, 5034, 1071, 509, 266, 6610, 26358, 49, 474, 329, 31, 203, 225, 2254, 5034, 1071, 30783, 1826, 26358, 49, 474, 329, 31, 203, 225, 2254, 5034, 1071, 12106, 58, 31952, 49, 474, 329, 31, 203, 225, 2254, 5034, 1071, 509, 266, 6610, 58, 31952, 49, 474, 329, 31, 203, 225, 2254, 5034, 1071, 30783, 1826, 58, 31952, 49, 474, 329, 31, 203, 203, 203, 203, 203, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// Sources flattened with hardhat v2.6.6 https://hardhat.org // File contracts/elk-core/interfaces/IElkFactory.sol pragma solidity >=0.5.0; interface IElkFactory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // File contracts/elk-lib/libraries/TransferHelper.sol pragma solidity >=0.6.0; // 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, uint256 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, uint256 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, uint256 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, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } // File contracts/elk-periphery/interfaces/IElkRouter.sol pragma solidity >=0.6.2; interface IElkRouter { 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); function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // File contracts/elk-core/interfaces/IElkPair.sol pragma solidity >=0.5.0; interface IElkPair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File contracts/elk-periphery/libraries/SafeMath.sol 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/elk-periphery/libraries/ElkLibrary.sol pragma solidity >=0.5.0; library ElkLibrary { 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, 'ElkLibrary: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'ElkLibrary: 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'84845e7ccb283dec564acfcd3d9287a491dec6d675705545a2ab8be22ad78f31' // 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,) = IElkPair(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, 'ElkLibrary: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'ElkLibrary: 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, 'ElkLibrary: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'ElkLibrary: 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, 'ElkLibrary: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'ElkLibrary: 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, 'ElkLibrary: 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, 'ElkLibrary: 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); } } } // File contracts/elk-periphery/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/elk-periphery/interfaces/IWETH.sol pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } // File contracts/elk-periphery/ElkRouter.sol pragma solidity =0.6.6; contract ElkRouter is IElkRouter { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'ElkRouter: 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 (IElkFactory(factory).getPair(tokenA, tokenB) == address(0)) { IElkFactory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = ElkLibrary.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = ElkLibrary.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'ElkRouter: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = ElkLibrary.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'ElkRouter: 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 = ElkLibrary.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IElkPair(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 = ElkLibrary.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IElkPair(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 = ElkLibrary.pairFor(factory, tokenA, tokenB); IElkPair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IElkPair(pair).burn(to); (address token0,) = ElkLibrary.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'ElkRouter: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'ElkRouter: 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 = ElkLibrary.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IElkPair(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 = ElkLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IElkPair(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 = ElkLibrary.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IElkPair(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,) = ElkLibrary.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 ? ElkLibrary.pairFor(factory, output, path[i + 2]) : _to; IElkPair(ElkLibrary.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 = ElkLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'ElkRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, ElkLibrary.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 = ElkLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'ElkRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, ElkLibrary.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, 'ElkRouter: INVALID_PATH'); amounts = ElkLibrary.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'ElkRouter: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(ElkLibrary.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, 'ElkRouter: INVALID_PATH'); amounts = ElkLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'ElkRouter: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, ElkLibrary.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, 'ElkRouter: INVALID_PATH'); amounts = ElkLibrary.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'ElkRouter: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, ElkLibrary.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, 'ElkRouter: INVALID_PATH'); amounts = ElkLibrary.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'ElkRouter: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(ElkLibrary.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,) = ElkLibrary.sortTokens(input, output); IElkPair pair = IElkPair(ElkLibrary.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 = ElkLibrary.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? ElkLibrary.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, ElkLibrary.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, 'ElkRouter: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'ElkRouter: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(ElkLibrary.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, 'ElkRouter: 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, 'ElkRouter: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, ElkLibrary.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'ElkRouter: 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 ElkLibrary.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return ElkLibrary.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return ElkLibrary.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return ElkLibrary.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return ElkLibrary.getAmountsIn(factory, amountOut, path); } }
**** ADD LIQUIDITY **** create the pair if it doesn't exist yet
function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { if (IElkFactory(factory).getPair(tokenA, tokenB) == address(0)) { IElkFactory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = ElkLibrary.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); uint amountBOptimal = ElkLibrary.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'ElkRouter: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); uint amountAOptimal = ElkLibrary.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'ElkRouter: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } }
481,259
[ 1, 4625, 348, 7953, 560, 30, 225, 380, 14465, 11689, 8961, 53, 3060, 4107, 380, 14465, 752, 326, 3082, 309, 518, 3302, 1404, 1005, 4671, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1289, 48, 18988, 24237, 12, 203, 3639, 1758, 1147, 37, 16, 203, 3639, 1758, 1147, 38, 16, 203, 3639, 2254, 3844, 1880, 281, 2921, 16, 203, 3639, 2254, 3844, 38, 25683, 16, 203, 3639, 2254, 3844, 2192, 267, 16, 203, 3639, 2254, 3844, 38, 2930, 203, 565, 262, 2713, 5024, 1135, 261, 11890, 3844, 37, 16, 2254, 3844, 38, 13, 288, 203, 3639, 309, 261, 45, 4958, 79, 1733, 12, 6848, 2934, 588, 4154, 12, 2316, 37, 16, 1147, 38, 13, 422, 1758, 12, 20, 3719, 288, 203, 5411, 467, 4958, 79, 1733, 12, 6848, 2934, 2640, 4154, 12, 2316, 37, 16, 1147, 38, 1769, 203, 3639, 289, 203, 3639, 261, 11890, 20501, 37, 16, 2254, 20501, 38, 13, 273, 10426, 79, 9313, 18, 588, 607, 264, 3324, 12, 6848, 16, 1147, 37, 16, 1147, 38, 1769, 203, 3639, 309, 261, 455, 6527, 37, 422, 374, 597, 20501, 38, 422, 374, 13, 288, 203, 5411, 261, 8949, 37, 16, 3844, 38, 13, 273, 261, 8949, 1880, 281, 2921, 16, 3844, 38, 25683, 1769, 203, 5411, 2254, 3844, 5315, 337, 2840, 273, 10426, 79, 9313, 18, 6889, 12, 8949, 1880, 281, 2921, 16, 20501, 37, 16, 20501, 38, 1769, 203, 5411, 309, 261, 8949, 5315, 337, 2840, 1648, 3844, 38, 25683, 13, 288, 203, 7734, 2583, 12, 8949, 5315, 337, 2840, 1545, 3844, 38, 2930, 16, 296, 4958, 79, 8259, 30, 2120, 6639, 42, 1653, 7266, 2222, 67, 38, 67, 2192, 51, 5321, 8284, 203, 7734, 261, 8949, 37, 16, 3844, 38, 13, 273, 261, 8949, 1880, 281, 2921, 16, 3844, 5315, 337, 2840, 1769, 203, 7734, 2254, 3844, 37, 6179, 2840, 273, 10426, 79, 9313, 18, 6889, 12, 8949, 38, 25683, 16, 20501, 38, 16, 20501, 37, 1769, 203, 7734, 1815, 12, 8949, 37, 6179, 2840, 1648, 3844, 1880, 281, 2921, 1769, 203, 7734, 2583, 12, 8949, 37, 6179, 2840, 1545, 3844, 2192, 267, 16, 296, 4958, 79, 8259, 30, 2120, 6639, 42, 1653, 7266, 2222, 67, 37, 67, 2192, 51, 5321, 8284, 203, 7734, 261, 8949, 37, 16, 3844, 38, 13, 273, 261, 8949, 37, 6179, 2840, 16, 3844, 38, 25683, 1769, 203, 5411, 289, 203, 3639, 289, 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 ]
./full_match/1/0xDe0318369550D2588be5C13A7212830795f13e2F/sources/contracts/VNFTxV5.sol
generates a number from 0 to 2^n based on the last n blocks */
function randomNumber(uint256 seed, uint256 max) public view returns (uint256 _randomNumber) { uint256 n = 0; for (uint256 i = 0; i < 5; i++) { n += uint256( keccak256( abi.encodePacked(blockhash(block.number - i - 1), seed) ) ); } return (n * seed) % max; }
3,032,617
[ 1, 4625, 348, 7953, 560, 30, 225, 6026, 279, 1300, 628, 374, 358, 576, 66, 82, 2511, 603, 326, 1142, 290, 4398, 1195, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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 ]
[ 1, 565, 445, 2744, 1854, 12, 11890, 5034, 5009, 16, 2254, 5034, 943, 13, 203, 3639, 1071, 203, 3639, 1476, 203, 3639, 1135, 261, 11890, 5034, 389, 9188, 1854, 13, 203, 565, 288, 203, 3639, 2254, 5034, 290, 273, 374, 31, 203, 3639, 364, 261, 11890, 5034, 277, 273, 374, 31, 277, 411, 1381, 31, 277, 27245, 288, 203, 5411, 290, 1011, 2254, 5034, 12, 203, 7734, 417, 24410, 581, 5034, 12, 203, 10792, 24126, 18, 3015, 4420, 329, 12, 2629, 2816, 12, 2629, 18, 2696, 300, 277, 300, 404, 3631, 5009, 13, 203, 7734, 262, 203, 5411, 11272, 203, 3639, 289, 203, 3639, 327, 261, 82, 380, 5009, 13, 738, 943, 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 ]
./full_match/1/0x9965cCd16803432C6a0842f1D5690f32E427aEDd/sources/contracts/Marketplace.sol
* @dev Changes Presale Sale Discount Amounts (IN BIPS)/
function __ChangeFixedPriceDiscountAmounts(uint SaleIndex, uint[] calldata Discounts) external onlyAdmin { DiscountAmounts[SaleIndex] = Discounts; }
8,471,311
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 17776, 18346, 5349, 348, 5349, 3035, 1883, 16811, 87, 261, 706, 605, 2579, 55, 13176, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 1001, 3043, 7505, 5147, 9866, 6275, 87, 12, 11890, 348, 5349, 1016, 16, 2254, 8526, 745, 892, 3035, 8008, 13, 3903, 1338, 4446, 203, 565, 288, 203, 3639, 3035, 1883, 6275, 87, 63, 30746, 1016, 65, 273, 3035, 8008, 31, 203, 565, 289, 203, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.1; pragma abicoder v2; import {SafeMath} from "../libraries/LibMath.sol"; import {CreateOrderParams, OrderAttributes, AppStorage, LibAppStorage} from "../libraries/LibAppStorage.sol"; import {OrderInterface} from "../interfaces/OrderInterface.sol"; import {Order} from "../Order.sol"; import {LibMeta} from "../libraries/LibMeta.sol"; contract CreateOrderFacet { AppStorage internal s; using SafeMath for uint256; uint256 internal constant bPDivisor = 10000; // 100th of a bip event orderCreated(uint256 _orderID); // ================ Test-net Events ================= // event tnCreateOrder(uint256 _orderID, address _address); // ================================================== // constructor() { } function createOrder(CreateOrderParams calldata params) external { require((params.fromTokenAddress == s.wethAddress) || (params.toTokenAddress == s.wethAddress)); require(params.settlementGratuityRate < bPDivisor.sub(s.platformRate)); //require() // proctect from .mult overflow Order nocturnalOrder = new Order(address(this), s.uniswapV3SwapRouter); s.orderCounter += 1; // AppStorage OrderAttributes storage orderAttributes = s.orders[s.orderCounter]; orderAttributes.owner = LibMeta.msgSender(); orderAttributes.orderAddress = address(nocturnalOrder); orderAttributes.poolAddress = params.poolAddress; orderAttributes.fromTokenAddress = params.fromTokenAddress; orderAttributes.toTokenAddress = params.toTokenAddress; orderAttributes.fromTokenAmount = params.fromTokenAmount; orderAttributes.limitPrice = params.limitPrice; orderAttributes.limitType = params.limitType; orderAttributes.settlementGratuityRate = params.settlementGratuityRate; orderAttributes.swapSlippage = params.swapSlippage; orderAttributes.depositedFlag = false; orderAttributes.settledFlag = false; orderAttributes.closedFlag = false; OrderInterface(address(this)).mint(LibMeta.msgSender(), s.orderCounter); emit orderCreated(s.orderCounter); // ================ Test-net Events ================= // if ((s.testDuration + s.initTimestamp) >= block.timestamp) { emit tnCreateOrder(s.orderCounter, LibMeta.msgSender()); } // ================================================== // } }
require() proctect from .mult overflow AppStorage ================ Test-net Events =================
function createOrder(CreateOrderParams calldata params) external { require((params.fromTokenAddress == s.wethAddress) || (params.toTokenAddress == s.wethAddress)); require(params.settlementGratuityRate < bPDivisor.sub(s.platformRate)); Order nocturnalOrder = new Order(address(this), s.uniswapV3SwapRouter); s.orderCounter += 1; OrderAttributes storage orderAttributes = s.orders[s.orderCounter]; orderAttributes.owner = LibMeta.msgSender(); orderAttributes.orderAddress = address(nocturnalOrder); orderAttributes.poolAddress = params.poolAddress; orderAttributes.fromTokenAddress = params.fromTokenAddress; orderAttributes.toTokenAddress = params.toTokenAddress; orderAttributes.fromTokenAmount = params.fromTokenAmount; orderAttributes.limitPrice = params.limitPrice; orderAttributes.limitType = params.limitType; orderAttributes.settlementGratuityRate = params.settlementGratuityRate; orderAttributes.swapSlippage = params.swapSlippage; orderAttributes.depositedFlag = false; orderAttributes.settledFlag = false; orderAttributes.closedFlag = false; OrderInterface(address(this)).mint(LibMeta.msgSender(), s.orderCounter); emit orderCreated(s.orderCounter); if ((s.testDuration + s.initTimestamp) >= block.timestamp) { emit tnCreateOrder(s.orderCounter, LibMeta.msgSender()); } }
15,841,290
[ 1, 4625, 348, 7953, 560, 30, 2583, 1435, 225, 450, 299, 386, 628, 263, 5421, 9391, 4677, 3245, 422, 26678, 7766, 17, 2758, 9043, 422, 14468, 12275, 225, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 752, 2448, 12, 1684, 2448, 1370, 745, 892, 859, 13, 3903, 288, 203, 3639, 2583, 12443, 2010, 18, 2080, 1345, 1887, 422, 272, 18, 91, 546, 1887, 13, 747, 261, 2010, 18, 869, 1345, 1887, 422, 272, 18, 91, 546, 1887, 10019, 203, 3639, 2583, 12, 2010, 18, 542, 88, 806, 43, 17048, 89, 560, 4727, 411, 324, 52, 7244, 12385, 18, 1717, 12, 87, 18, 9898, 4727, 10019, 203, 1171, 203, 3639, 4347, 1158, 299, 321, 287, 2448, 273, 394, 4347, 12, 2867, 12, 2211, 3631, 272, 18, 318, 291, 91, 438, 58, 23, 12521, 8259, 1769, 203, 3639, 272, 18, 1019, 4789, 1011, 404, 31, 7010, 540, 203, 3639, 4347, 2498, 2502, 1353, 2498, 273, 272, 18, 9972, 63, 87, 18, 1019, 4789, 15533, 203, 540, 203, 3639, 1353, 2498, 18, 8443, 273, 10560, 2781, 18, 3576, 12021, 5621, 203, 3639, 1353, 2498, 18, 1019, 1887, 273, 1758, 12, 2135, 299, 321, 287, 2448, 1769, 203, 3639, 1353, 2498, 18, 6011, 1887, 273, 859, 18, 6011, 1887, 31, 203, 3639, 1353, 2498, 18, 2080, 1345, 1887, 273, 859, 18, 2080, 1345, 1887, 31, 203, 3639, 1353, 2498, 18, 869, 1345, 1887, 273, 859, 18, 869, 1345, 1887, 31, 203, 3639, 1353, 2498, 18, 2080, 1345, 6275, 273, 859, 18, 2080, 1345, 6275, 31, 203, 3639, 1353, 2498, 18, 3595, 5147, 273, 859, 18, 3595, 5147, 31, 203, 3639, 1353, 2498, 18, 3595, 559, 273, 859, 18, 3595, 559, 31, 203, 3639, 1353, 2498, 18, 542, 88, 806, 43, 17048, 89, 560, 4727, 273, 859, 18, 542, 88, 806, 43, 17048, 89, 560, 4727, 31, 203, 3639, 1353, 2498, 18, 22270, 55, 3169, 2433, 273, 859, 18, 22270, 55, 3169, 2433, 31, 203, 3639, 1353, 2498, 18, 323, 1724, 329, 4678, 273, 629, 31, 203, 3639, 1353, 2498, 18, 542, 88, 1259, 4678, 273, 629, 31, 203, 3639, 1353, 2498, 18, 12204, 4678, 273, 629, 31, 203, 540, 203, 3639, 4347, 1358, 12, 2867, 12, 2211, 13, 2934, 81, 474, 12, 5664, 2781, 18, 3576, 12021, 9334, 272, 18, 1019, 4789, 1769, 203, 203, 3639, 3626, 1353, 6119, 12, 87, 18, 1019, 4789, 1769, 1377, 203, 203, 3639, 309, 14015, 87, 18, 3813, 5326, 397, 272, 18, 2738, 4921, 13, 1545, 1203, 18, 5508, 13, 288, 203, 5411, 3626, 16002, 1684, 2448, 12, 87, 18, 1019, 4789, 16, 10560, 2781, 18, 3576, 12021, 10663, 203, 3639, 289, 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 ]
pragma solidity ^0.4.18; // File: contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event 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; } } // File: contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } // File: contracts/token/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: contracts/token/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @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]; } } // File: contracts/token/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts/token/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @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; } } // File: contracts/token/MintableToken.sol /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } // File: contracts/BigToken.sol contract BigToken is MintableToken { string public constant name = "BigToken"; string public constant symbol = "BTK"; uint8 public decimals = 18; bool public tradingStarted = false; /** * @dev modifier that throws if trading has not started yet */ modifier hasStartedTrading() { require(tradingStarted); _; } /** * @dev Allows the owner to enable the trading. */ function startTrading() onlyOwner public { tradingStarted = true; } /** * @dev Allows anyone to transfer the tokens once trading has started * @param _to the recipient address of the tokens. * @param _value number of tokens to be transfered. */ function transfer(address _to, uint _value) hasStartedTrading public returns (bool){ return super.transfer(_to, _value); } /** * @dev Allows anyone to transfer the tokens once trading has started * @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 uint the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) hasStartedTrading public returns (bool){ return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused. * @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 hasStartedTrading returns (bool) { return super.approve(_spender, _value); } /** * Adding whenNotPaused */ function increaseApproval(address _spender, uint _addedValue) public hasStartedTrading returns (bool success) { return super.increaseApproval(_spender, _addedValue); } /** * Adding whenNotPaused */ function decreaseApproval(address _spender, uint _subtractedValue) public hasStartedTrading returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } // File: contracts/crowdsale/Crowdsale.sol /** * @title Crowdsale * @dev Crowdsale is a base contract for managing a token crowdsale. * Crowdsales have a start and end timestamps, where investors can make * token purchases and the crowdsale will assign them tokens based * on a token per ETH rate. Funds collected are forwarded to a wallet * as they arrive. */ contract Crowdsale { using SafeMath for uint256; // The token being sold MintableToken public token; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public wallet; // how many token units a buyer gets per wei uint256 public rate; // amount of raised money in wei uint256 public weiRaised; /** * 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); function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); token = createTokenContract(); startTime = _startTime; endTime = _endTime; rate = _rate; wallet = _wallet; } // creates the token to be sold. // override this method to have crowdsale of a specific mintable token. function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function // overrided to create custom buy function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate); // update state weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet // overrided to create custom fund forwarding mechanisms function forwardFunds() internal { wallet.transfer(msg.value); } // @return true if the transaction can buy tokens function validPurchase() internal view returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return now > endTime; } } // File: contracts/crowdsale/FinalizableCrowdsale.sol /** * @title FinalizableCrowdsale * @dev Extension of Crowdsale where an owner can do extra work * after finishing. */ contract FinalizableCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() onlyOwner public { require(!isFinalized); require(hasEnded()); finalization(); Finalized(); isFinalized = true; } /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal{ } } // File: contracts/modified.crowdsale/RefundVaultWithCommission.sol /** * @title RefundVault * @dev This contract is used for storing funds while a crowdsale * is in progress. Supports refunding the money if crowdsale fails, * and forwarding it if crowdsale is successful. */ contract RefundVaultWithCommission is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; address public wallet; address public walletFees; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); function RefundVaultWithCommission(address _wallet,address _walletFees) public { require(_wallet != address(0)); require(_walletFees != address(0)); wallet = _wallet; walletFees = _walletFees; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; Closed(); uint256 fees = this.balance.mul(25).div(10000); // transfer the fees walletFees.transfer(fees); //transfer the remaining part wallet.transfer(this.balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } } // File: contracts/modified.crowdsale/RefundableCrowdsaleWithCommission.sol /** * @title RefundableCrowdsale * @dev Extension of Crowdsale contract that adds a funding goal, and * the possibility of users getting a refund if goal is not met. * Uses a RefundVault as the crowdsale's vault. */ contract RefundableCrowdsaleWithCommission is FinalizableCrowdsale { using SafeMath for uint256; // minimum amount of funds to be raised in weis uint256 public goal; // refund vault used to hold funds while crowdsale is running RefundVaultWithCommission public vault; function RefundableCrowdsaleWithCommission(uint256 _goal,address _walletFees) public { require(_goal > 0); vault = new RefundVaultWithCommission(wallet,_walletFees); goal = _goal; } // We're overriding the fund forwarding from Crowdsale. // In addition to sending the funds, we want to call // the RefundVault deposit function function forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } // if crowdsale is unsuccessful, investors can claim refunds here function claimRefund() public { require(isFinalized); require(!goalReached()); vault.refund(msg.sender); } // vault finalization task, called when owner calls finalize() function finalization() internal { if (goalReached()) { vault.close(); } else { vault.enableRefunds(); } super.finalization(); } function goalReached() public view returns (bool) { return weiRaised >= goal; } } // File: contracts/BigTokenCrowdSale.sol contract BigTokenCrowdSale is Crowdsale, RefundableCrowdsaleWithCommission { using SafeMath for uint256; // number of participants uint256 public numberOfPurchasers = 0; // maximum tokens that can be minted in this crowd sale - initialised later by the constructor uint256 public maxTokenSupply = 0; // version cache buster string public constant version = "v1.3"; // pending contract owner - initialised later by the constructor address public pendingOwner; // Minimum amount to been able to contribute - initialised later by the constructor uint256 public minimumAmount = 0; // Reserved amount - initialised later by the constructor address public reservedAddr; uint256 public reservedAmount; // white list for KYC mapping (address => bool) public whitelist; // white listing admin - initialised later by the constructor address public whiteListingAdmin; function BigTokenCrowdSale( uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _minimumAmount, uint256 _maxTokenSupply, address _wallet, address _reservedAddr, uint256 _reservedAmount, address _pendingOwner, address _whiteListingAdmin, address _walletFees ) FinalizableCrowdsale() RefundableCrowdsaleWithCommission(_goal,_walletFees) Crowdsale(_startTime, _endTime, _rate, _wallet) public { require(_pendingOwner != address(0)); require(_minimumAmount >= 0); require(_maxTokenSupply > 0); require(_reservedAmount > 0 && _reservedAmount < _maxTokenSupply); // make sure that the refund goal is within the max supply, using the default rate, without the reserved supply require(_goal.mul(rate) <= _maxTokenSupply.sub(_reservedAmount)); pendingOwner = _pendingOwner; minimumAmount = _minimumAmount; maxTokenSupply = _maxTokenSupply; // reserved amount reservedAddr = _reservedAddr; reservedAmount = _reservedAmount; // whitelisting admin setWhiteListingAdmin(_whiteListingAdmin); } /** * * Create the token on the fly, owner is the contract, not the contract owner yet * **/ function createTokenContract() internal returns (MintableToken) { return new BigToken(); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(whitelist[beneficiary] == true); // require(validPurchase()); // buying can only begins as soon as the ownership has been transfer to the pendingOwner require(owner==pendingOwner); uint256 weiAmount = msg.value; // Compute the number of tokens per wei // bonus structure should be used here, if any uint256 tokens = weiAmount.mul(rate); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); // update wei raised and number of purchasers weiRaised = weiRaised.add(weiAmount); numberOfPurchasers = numberOfPurchasers + 1; forwardFunds(); } // overriding Crowdsale#validPurchase to add extra cap logic // @return true if investors can buy at the moment function validPurchase() internal view returns (bool) { // make sure we accept only the minimum contribution bool minAmount = (msg.value >= minimumAmount); // cap crowdsaled to a maxTokenSupply // make sure we can not mint more token than expected bool lessThanMaxSupply = (token.totalSupply() + msg.value.mul(rate)) <= maxTokenSupply; // make sure that the purchase follow each rules to be valid return super.validPurchase() && minAmount && lessThanMaxSupply; } // overriding Crowdsale#hasEnded to add cap logic // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { bool capReached = token.totalSupply() >= maxTokenSupply; return super.hasEnded() || capReached; } /** * * Admin functions only called by owner: * * */ /** * * Called when the admin function finalize is called : * * it mint the remaining amount to have the supply exactly as planned * it transfer the ownership of the token to the owner of the smart contract * */ function finalization() internal { // // send back to the owner the remaining tokens before finishing minting // it ensure that there is only a exact maxTokenSupply token minted ever // uint256 remainingTokens = maxTokenSupply - token.totalSupply(); // mint the remaining amount and assign them to the owner token.mint(owner, remainingTokens); TokenPurchase(owner, owner, 0, remainingTokens); // finalize the refundable inherited contract super.finalization(); // no more minting allowed - immutable token.finishMinting(); // transfer the token owner ship from the contract address to the owner token.transferOwnership(owner); } /** * * Admin functions only executed by owner: * Can change minimum amount * */ function changeMinimumAmount(uint256 _minimumAmount) onlyOwner public { require(_minimumAmount > 0); minimumAmount = _minimumAmount; } /** * * Admin functions only executed by owner: * Can change rate * * We do not use an oracle here as oracle need to be paid each time, and if the oracle is not responding * or hacked the rate could be detrimentally modified from an contributor perspective. * */ function changeRate(uint256 _rate) onlyOwner public { require(_rate > 0); rate = _rate; } /** * * Admin functions only called by owner: * Can change events dates * */ function changeDates(uint256 _startTime, uint256 _endTime) onlyOwner public { require(_startTime >= now); require(_endTime >= _startTime); startTime = _startTime; endTime = _endTime; } /** * * Admin functions only executed by pendingOwner * Change the owner * */ function transferOwnerShipToPendingOwner() public { // only the pending owner can change the ownership require(msg.sender == pendingOwner); // can only be changed one time require(owner != pendingOwner); // raise the event OwnershipTransferred(owner, pendingOwner); // change the ownership owner = pendingOwner; // run the PreMint runPreMint(); } // run the pre minting of the reserved token function runPreMint() onlyOwner private { token.mint(reservedAddr, reservedAmount); TokenPurchase(owner, reservedAddr, 0, reservedAmount); // update state numberOfPurchasers = numberOfPurchasers + 1; } // add a way to change the whitelistadmin user function setWhiteListingAdmin(address _whiteListingAdmin) onlyOwner public { whiteListingAdmin=_whiteListingAdmin; } /** * @dev Populate the whitelist, only executed by whiteListingAdmin * */ function updateWhitelistMapping(address[] _address,bool value) public { require(msg.sender == whiteListingAdmin); // Add an event here to keep track // add the whitelisted addresses to the mapping for (uint i = 0; i < _address.length; i++) { whitelist[_address[i]] = value; } } }
* @title RefundVault @dev This contract is used for storing funds while a crowdsale is in progress. Supports refunding the money if crowdsale fails, and forwarding it if crowdsale is successful./
contract RefundVaultWithCommission is Ownable { using SafeMath for uint256; mapping (address => uint256) public deposited; address public wallet; address public walletFees; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); enum State { Active, Refunding, Closed } function RefundVaultWithCommission(address _wallet,address _walletFees) public { require(_wallet != address(0)); require(_walletFees != address(0)); wallet = _wallet; walletFees = _walletFees; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; Closed(); uint256 fees = this.balance.mul(25).div(10000); walletFees.transfer(fees); wallet.transfer(this.balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } }
5,436,055
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 2649, 3941, 1074, 12003, 632, 5206, 1220, 6835, 353, 1399, 364, 15729, 284, 19156, 1323, 279, 276, 492, 2377, 5349, 353, 316, 4007, 18, 25110, 1278, 14351, 326, 15601, 309, 276, 492, 2377,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5034, 13, 1071, 443, 1724, 329, 31, 203, 225, 1758, 1071, 9230, 31, 203, 225, 1758, 1071, 9230, 2954, 281, 31, 203, 225, 3287, 1071, 919, 31, 203, 203, 225, 871, 25582, 5621, 203, 225, 871, 3941, 19156, 1526, 5621, 203, 225, 871, 3941, 12254, 12, 2867, 8808, 27641, 74, 14463, 814, 16, 2254, 5034, 732, 77, 6275, 1769, 203, 203, 203, 225, 2792, 3287, 288, 8857, 16, 3941, 14351, 16, 25582, 289, 203, 225, 445, 3941, 1074, 12003, 1190, 799, 3951, 12, 2867, 389, 19177, 16, 2867, 389, 19177, 2954, 281, 13, 1071, 288, 203, 565, 2583, 24899, 19177, 480, 1758, 12, 20, 10019, 203, 565, 2583, 24899, 19177, 2954, 281, 480, 1758, 12, 20, 10019, 203, 565, 9230, 273, 389, 19177, 31, 203, 565, 9230, 2954, 281, 273, 389, 19177, 2954, 281, 31, 203, 565, 919, 273, 3287, 18, 3896, 31, 203, 225, 289, 203, 203, 225, 445, 443, 1724, 12, 2867, 2198, 395, 280, 13, 1338, 5541, 1071, 8843, 429, 288, 203, 565, 2583, 12, 2019, 422, 3287, 18, 3896, 1769, 203, 565, 443, 1724, 329, 63, 5768, 395, 280, 65, 273, 443, 1724, 329, 63, 5768, 395, 280, 8009, 1289, 12, 3576, 18, 1132, 1769, 203, 225, 289, 203, 203, 225, 445, 1746, 1435, 1338, 5541, 1071, 288, 203, 565, 2583, 12, 2019, 422, 3287, 18, 3896, 1769, 203, 565, 919, 273, 3287, 18, 7395, 31, 203, 565, 25582, 5621, 203, 203, 565, 2254, 5034, 1656, 281, 273, 333, 18, 12296, 18, 16411, 12, 2947, 2934, 2892, 12, 23899, 1769, 203, 203, 565, 9230, 2954, 281, 18, 13866, 12, 3030, 281, 1769, 203, 203, 565, 9230, 18, 13866, 12, 2211, 18, 12296, 1769, 203, 225, 289, 203, 203, 225, 445, 4237, 1957, 19156, 1435, 1338, 5541, 1071, 288, 203, 565, 2583, 12, 2019, 422, 3287, 18, 3896, 1769, 203, 565, 919, 273, 3287, 18, 1957, 14351, 31, 203, 565, 3941, 19156, 1526, 5621, 203, 225, 289, 203, 203, 225, 445, 16255, 12, 2867, 2198, 395, 280, 13, 1071, 288, 203, 565, 2583, 12, 2019, 422, 3287, 18, 1957, 14351, 1769, 203, 565, 2254, 5034, 443, 1724, 329, 620, 273, 443, 1724, 329, 63, 5768, 395, 280, 15533, 203, 565, 443, 1724, 329, 63, 5768, 395, 280, 65, 273, 374, 31, 203, 565, 2198, 395, 280, 18, 13866, 12, 323, 1724, 329, 620, 1769, 203, 565, 3941, 12254, 12, 5768, 395, 280, 16, 443, 1724, 329, 620, 1769, 203, 225, 289, 203, 97, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./open-zeppelin/ERC20.sol"; import "./open-zeppelin/AccessControl.sol"; import "./open-zeppelin/utils/Math.sol"; import "./open-zeppelin/utils/ECDSA.sol"; /** @title Paladin Token contract */ /// @author Paladin contract PaladinToken is ERC20, AccessControl { /** @notice The identifier for admin role */ bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); /** @notice The identifier for transfer-allwoed role */ bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER"); bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); struct Checkpoint { uint32 fromBlock; uint224 votes; } struct DelegateCheckpoint { uint32 fromBlock; address delegate; } // Storage : /** @notice boolean allowing transfer for all users */ bool public transfersAllowed = false; mapping(address => address) public delegates; mapping(address => Checkpoint[]) public checkpoints; mapping(address => DelegateCheckpoint[]) public delegateCheckpoints; mapping(address => uint256) public nonces; // Events : /** @notice Emitted when transfer toggle is switched */ event TransfersAllowed(bool transfersAllowed); event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); // Modifiers : /** @dev Allows only ADMIN role to call the function */ modifier onlyAdmin() { require( hasRole(ADMIN_ROLE, msg.sender), "PaladinToken: caller not admin" ); _; } /** @dev Allows only caller with the TRANSFER role to execute transfer */ modifier onlyTransferer(address from) { require( transfersAllowed || hasRole(TRANSFER_ROLE, msg.sender), "PaladinToken: caller cannot transfer" ); _; } constructor( uint256 initialSupply, address admin, address recipient ) ERC20("Paladin Token", "PAL") { _setupRole(TRANSFER_ROLE, admin); _setupRole(TRANSFER_ROLE, msg.sender); _setupRole(ADMIN_ROLE, admin); _setRoleAdmin(TRANSFER_ROLE, ADMIN_ROLE); _mint(recipient, initialSupply); } /** @dev Hook called before any transfer */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override onlyTransferer(from) {} function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { _moveDelegates(delegates[from], delegates[to], amount); } function delegate(address delegatee) external virtual { return _delegate(_msgSender(), delegatee); } function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external virtual { require(block.timestamp <= expiry, "PaladinToken: signature expired"); bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signer = ecrecover(digest, v, r, s); require(signer != address(0), "PaladinToken: invalid signature"); require(nonce == nonces[signer], "PaladinToken: invalid nonce"); nonces[signer]++; return _delegate(signer, delegatee); } function numCheckpoints(address account) external view virtual returns (uint256) { return checkpoints[account].length; } function getCurrentVotes(address account) external view returns (uint256) { uint256 nbCheckpoints = checkpoints[account].length; return nbCheckpoints == 0 ? 0 : checkpoints[account][nbCheckpoints - 1].votes; } function getPastVotes(address account, uint256 blockNumber) external view returns (uint256) { require( blockNumber < block.number, "PaladinToken: invalid blockNumber" ); // no checkpoints written uint256 nbCheckpoints = checkpoints[account].length; if (nbCheckpoints == 0) return 0; // last checkpoint check if (checkpoints[account][nbCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nbCheckpoints - 1].votes; } // no checkpoint old enough if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint256 high = nbCheckpoints - 1; // last checkpoint already checked uint256 low = 0; uint256 mid; while (low < high) { mid = Math.average(low, high); if (checkpoints[account][mid].fromBlock == blockNumber) { return checkpoints[account][mid].votes; } if (checkpoints[account][mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? 0 : checkpoints[account][high - 1].votes; } function getPastDelegate(address account, uint256 blockNumber) external view returns (address) { require( blockNumber < block.number, "PaladinToken: invalid blockNumber" ); // no checkpoints written uint256 nbCheckpoints = delegateCheckpoints[account].length; if (nbCheckpoints == 0) return address(0); // last checkpoint check if (delegateCheckpoints[account][nbCheckpoints - 1].fromBlock <= blockNumber) { return delegateCheckpoints[account][nbCheckpoints - 1].delegate; } // no checkpoint old enough if (delegateCheckpoints[account][0].fromBlock > blockNumber) { return address(0); } uint256 high = nbCheckpoints - 1; // last checkpoint already checked uint256 low = 0; uint256 mid; while (low < high) { mid = Math.average(low, high); if (delegateCheckpoints[account][mid].fromBlock == blockNumber) { return delegateCheckpoints[account][mid].delegate; } if (delegateCheckpoints[account][mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? address(0) : delegateCheckpoints[account][high - 1].delegate; } function _delegate(address delegator, address delegatee) internal { address oldDelegatee = delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); delegates[delegator] = delegatee; delegateCheckpoints[delegator].push(DelegateCheckpoint(safe32(block.number), delegatee)); emit DelegateChanged(delegator, oldDelegatee, delegatee); _moveDelegates(oldDelegatee, delegatee, delegatorBalance); } function _moveDelegates( address from, address to, uint256 amount ) internal { if (from != to && amount > 0) { if (from != address(0)) { uint256 nbCheckpoints = checkpoints[from].length; uint256 oldVotes = nbCheckpoints == 0 ? 0 : checkpoints[from][nbCheckpoints - 1].votes; uint256 newVotes = oldVotes - amount; _writeCheckpoint(from, newVotes); emit DelegateVotesChanged(from, oldVotes, newVotes); } if (to != address(0)) { uint256 nbCheckpoints = checkpoints[to].length; uint256 oldVotes = nbCheckpoints == 0 ? 0 : checkpoints[to][nbCheckpoints - 1].votes; uint256 newVotes = oldVotes + amount; _writeCheckpoint(to, newVotes); emit DelegateVotesChanged(to, oldVotes, newVotes); } } } function _writeCheckpoint( address delegatee, uint256 newVotes ) internal { uint pos = checkpoints[delegatee].length; if (pos > 0 && checkpoints[delegatee][pos - 1].fromBlock == block.number) { checkpoints[delegatee][pos - 1].votes = safe224(newVotes); } else { uint32 blockNumber = safe32(block.number); checkpoints[delegatee].push(Checkpoint(blockNumber, safe224(newVotes))); } } function safe32(uint n) internal pure returns (uint32) { require(n <= type(uint32).max, "PaladinToken : block number exceed 32 bits"); return uint32(n); } function safe224(uint n) internal pure returns (uint224) { require(n <= type(uint224).max, "PaladinToken : amount exceed 224 bits"); return uint224(n); } function getChainId() internal view returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } // Admin methods : /** * @notice Allow/Block transfer for all users * @dev Change transfersAllowed flag * @param _transfersAllowed bool : true to allow Transfer, false to block */ function setTransfersAllowed(bool _transfersAllowed) external onlyAdmin { transfersAllowed = _transfersAllowed; emit TransfersAllowed(transfersAllowed); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IERC20.sol"; import "./interfaces/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 pragma solidity ^0.8.0; import "./interfaces/IAccessControl.sol"; import "./utils/Context.sol"; import "./utils/Strings.sol"; import "./utils/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. 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] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // 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 tryRecover(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 tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @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. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} 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.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // 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 (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @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) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @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)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../interfaces/IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
* @notice Allow/Block transfer for all users @dev Change transfersAllowed flag @param _transfersAllowed bool : true to allow Transfer, false to block/
function setTransfersAllowed(bool _transfersAllowed) external onlyAdmin { transfersAllowed = _transfersAllowed; emit TransfersAllowed(transfersAllowed); }
96,361
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 20392, 7852, 19, 1768, 7412, 364, 777, 3677, 632, 5206, 7576, 29375, 5042, 2982, 632, 891, 389, 2338, 18881, 5042, 1426, 294, 638, 358, 1699, 12279, 16, 629, 358, 1203, 19, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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 ]
[ 1, 565, 445, 444, 1429, 18881, 5042, 12, 6430, 389, 2338, 18881, 5042, 13, 3903, 1338, 4446, 288, 203, 3639, 29375, 5042, 273, 389, 2338, 18881, 5042, 31, 203, 3639, 3626, 2604, 18881, 5042, 12, 2338, 18881, 5042, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/56/0x5B99e0893225178dBf4Ffe9FfD2142a21E8d1087/sources/src/strategies/BaseStrategy.sol
Check the gas cost againts the profit and available credit. There is no sense to call the "work" function, if we don't have decent amount of funds to move.
return _checkGasPriceAgainstProfit(profit);
3,226,502
[ 1, 4625, 348, 7953, 560, 30, 225, 2073, 326, 16189, 6991, 1737, 1598, 87, 326, 450, 7216, 471, 2319, 12896, 18, 6149, 353, 1158, 12764, 358, 745, 326, 315, 1252, 6, 445, 16, 309, 732, 2727, 1404, 1240, 2109, 319, 3844, 434, 284, 19156, 358, 3635, 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,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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 ]
[ 1, 3639, 327, 389, 1893, 27998, 5147, 23530, 334, 626, 7216, 12, 685, 7216, 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 ]
./full_match/80001/0xF60bF646EF62B19859e00a3fC4d4d488b84ff74F/sources/DigitalaxIndex.sol
* @dev Funtion for removal of set @param _sid Id of auction set/
function removeCollectionGroup(uint256 _sid) external { require(accessControls.hasAdminRole(_msgSender()), "DigitalaxIndex.removeAuctionSet: Sender must be admin"); CollectionGroup storage set = collectionGroupSet[_sid]; delete set.digiBundleCollection; delete set.auctions.value; delete set.collections.value; emit CollectionGroupRemoved(_sid); }
852,825
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 478, 10032, 285, 364, 14817, 434, 444, 632, 891, 389, 7453, 3124, 434, 279, 4062, 444, 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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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 ]
[ 1, 565, 445, 1206, 2532, 1114, 12, 11890, 5034, 389, 7453, 13, 3903, 288, 203, 3639, 2583, 12, 3860, 16795, 18, 5332, 4446, 2996, 24899, 3576, 12021, 1435, 3631, 315, 4907, 7053, 651, 1016, 18, 4479, 37, 4062, 694, 30, 15044, 1297, 506, 3981, 8863, 203, 203, 3639, 2200, 1114, 2502, 444, 273, 1849, 1114, 694, 63, 67, 7453, 15533, 203, 3639, 1430, 444, 18, 5606, 77, 3405, 2532, 31, 203, 3639, 1430, 444, 18, 69, 4062, 87, 18, 1132, 31, 203, 3639, 1430, 444, 18, 19246, 18, 1132, 31, 203, 3639, 3626, 2200, 1114, 10026, 24899, 7453, 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 ]
pragma solidity ^0.4.23; import "zeppelin-solidity/contracts/ownership/Ownable.sol"; import "zeppelin-solidity/contracts/lifecycle/Pausable.sol"; import "./SNM.sol"; import "./Blacklist.sol"; import "./OracleUSD.sol"; import "./ProfileRegistry.sol"; contract Market is Ownable, Pausable { using SafeMath for uint256; // DECLARATIONS enum DealStatus{ STATUS_UNKNOWN, STATUS_ACCEPTED, STATUS_CLOSED } enum OrderType { ORDER_UNKNOWN, ORDER_BID, ORDER_ASK } enum OrderStatus { UNKNOWN, ORDER_INACTIVE, ORDER_ACTIVE } enum RequestStatus { REQUEST_UNKNOWN, REQUEST_CREATED, REQUEST_CANCELED, REQUEST_REJECTED, REQUEST_ACCEPTED } enum BlacklistPerson { BLACKLIST_NOBODY, BLACKLIST_WORKER, BLACKLIST_MASTER } struct Deal { uint64[] benchmarks; address supplierID; address consumerID; address masterID; uint askID; uint bidID; uint duration; uint price; //usd * 10^-18 uint startTime; uint endTime; DealStatus status; uint blockedBalance; uint totalPayout; uint lastBillTS; } struct Order { OrderType orderType; OrderStatus orderStatus; address author; address counterparty; uint duration; uint256 price; bool[] netflags; ProfileRegistry.IdentityLevel identityLevel; address blacklist; bytes32 tag; uint64[] benchmarks; uint frozenSum; uint dealID; } struct ChangeRequest { uint dealID; OrderType requestType; uint price; uint duration; RequestStatus status; } // EVENTS event OrderPlaced(uint indexed orderID); event OrderUpdated(uint indexed orderID); event DealOpened(uint indexed dealID); event DealUpdated(uint indexed dealID); event Billed(uint indexed dealID, uint indexed paidAmount); event DealChangeRequestSet(uint indexed changeRequestID); event DealChangeRequestUpdated(uint indexed changeRequestID); event WorkerAnnounced(address indexed worker, address indexed master); event WorkerConfirmed(address indexed worker, address indexed master); event WorkerRemoved(address indexed worker, address indexed master); event NumBenchmarksUpdated(uint indexed newNum); event NumNetflagsUpdated(uint indexed newNum); // VARS uint constant MAX_BENCHMARKS_VALUE = 2 ** 63; SNM token; Blacklist bl; OracleUSD oracle; ProfileRegistry pr; uint ordersAmount = 0; uint dealAmount = 0; uint requestsAmount = 0; // current length of benchmarks uint benchmarksQuantity; // current length of netflags uint netflagsQuantity; mapping(uint => Order) public orders; mapping(uint => Deal) public deals; mapping(address => uint[]) dealsID; mapping(uint => ChangeRequest) requests; mapping(uint => uint[2]) actualRequests; mapping(address => address) masterOf; mapping(address => bool) isMaster; mapping(address => mapping(address => bool)) masterRequest; // INIT constructor(address _token, address _blacklist, address _oracle, address _profileRegistry, uint _benchmarksQuantity, uint _netflagsQuantity) public { token = SNM(_token); bl = Blacklist(_blacklist); oracle = OracleUSD(_oracle); pr = ProfileRegistry(_profileRegistry); benchmarksQuantity = _benchmarksQuantity; netflagsQuantity = _netflagsQuantity; } // EXTERNAL // Order functions function PlaceOrder( OrderType _orderType, address _id_counterparty, uint _duration, uint _price, bool[] _netflags, ProfileRegistry.IdentityLevel _identityLevel, address _blacklist, bytes32 _tag, uint64[] _benchmarks ) whenNotPaused public returns (uint){ require(_identityLevel >= ProfileRegistry.IdentityLevel.ANONYMOUS); require(_netflags.length <= netflagsQuantity); require(_benchmarks.length <= benchmarksQuantity); for (uint i = 0; i < _benchmarks.length; i++) { require(_benchmarks[i] < MAX_BENCHMARKS_VALUE); } uint lockedSum = 0; if (_orderType == OrderType.ORDER_BID) { if (_duration == 0) { lockedSum = CalculatePayment(_price, 1 hours); } else if (_duration < 1 days) { lockedSum = CalculatePayment(_price, _duration); } else { lockedSum = CalculatePayment(_price, 1 days); } // this line contains err. require(token.transferFrom(msg.sender, this, lockedSum)); } ordersAmount = ordersAmount.add(1); uint256 orderId = ordersAmount; orders[orderId] = Order( _orderType, OrderStatus.ORDER_ACTIVE, msg.sender, _id_counterparty, _duration, _price, _netflags, _identityLevel, _blacklist, _tag, _benchmarks, lockedSum, 0 ); emit OrderPlaced(orderId); return orderId; } function CancelOrder(uint orderID) public returns (bool){ require(orderID <= ordersAmount); require(orders[orderID].orderStatus == OrderStatus.ORDER_ACTIVE); require(orders[orderID].author == msg.sender); require(token.transfer(msg.sender, orders[orderID].frozenSum)); orders[orderID].orderStatus = OrderStatus.ORDER_INACTIVE; emit OrderUpdated(orderID); return true; } function QuickBuy(uint askID, uint buyoutDuration) public whenNotPaused { Order memory ask = orders[askID]; require(ask.orderType == OrderType.ORDER_ASK); require(ask.orderStatus == OrderStatus.ORDER_ACTIVE); require(ask.duration >= buyoutDuration); require(pr.GetProfileLevel(msg.sender) >= ask.identityLevel); require(bl.Check(msg.sender, GetMaster(ask.author)) == false && bl.Check(ask.author, msg.sender) == false); require(bl.Check(ask.blacklist, msg.sender) == false); PlaceOrder( OrderType.ORDER_BID, GetMaster(ask.author), buyoutDuration, ask.price, ask.netflags, ProfileRegistry.IdentityLevel.ANONYMOUS, address(0), bytes32(0), ask.benchmarks); OpenDeal(askID, GetOrdersAmount()); } // Deal functions function OpenDeal(uint _askID, uint _bidID) whenNotPaused public { Order memory ask = orders[_askID]; Order memory bid = orders[_bidID]; require(ask.orderStatus == OrderStatus.ORDER_ACTIVE && bid.orderStatus == OrderStatus.ORDER_ACTIVE); require((ask.counterparty == 0x0 || ask.counterparty == GetMaster(bid.author)) && (bid.counterparty == 0x0 || bid.counterparty == GetMaster(ask.author))); require(ask.orderType == OrderType.ORDER_ASK); require(bid.orderType == OrderType.ORDER_BID); require( bl.Check(bid.blacklist, GetMaster(ask.author)) == false && bl.Check(bid.blacklist, ask.author) == false && bl.Check(bid.author, GetMaster(ask.author)) == false && bl.Check(bid.author, ask.author) == false && bl.Check(ask.blacklist, bid.author) == false && bl.Check(GetMaster(ask.author), bid.author) == false && bl.Check(ask.author, bid.author) == false); require(ask.price <= bid.price); require(ask.duration >= bid.duration); // profile level check require(pr.GetProfileLevel(bid.author) >= ask.identityLevel); require(pr.GetProfileLevel(ask.author) >= bid.identityLevel); if (ask.netflags.length < netflagsQuantity) { ask.netflags = ResizeNetflags(ask.netflags); } if (bid.netflags.length < netflagsQuantity) { bid.netflags = ResizeNetflags(ask.netflags); } for (uint i = 0; i < ask.netflags.length; i++) { // implementation: when bid contains requirement, ask necessary needs to have this // if ask have this one - pass require(!bid.netflags[i] || ask.netflags[i]); } if (ask.benchmarks.length < benchmarksQuantity) { ask.benchmarks = ResizeBenchmarks(ask.benchmarks); } if (bid.benchmarks.length < benchmarksQuantity) { bid.benchmarks = ResizeBenchmarks(bid.benchmarks); } for (i = 0; i < ask.benchmarks.length; i++) { require(ask.benchmarks[i] >= bid.benchmarks[i]); } dealAmount = dealAmount.add(1); address master = GetMaster(ask.author); orders[_askID].orderStatus = OrderStatus.ORDER_INACTIVE; orders[_bidID].orderStatus = OrderStatus.ORDER_INACTIVE; orders[_askID].dealID = dealAmount; orders[_bidID].dealID = dealAmount; emit OrderUpdated(_askID); emit OrderUpdated(_bidID); uint startTime = block.timestamp; uint endTime = 0; // `0` - for spot deal // if deal is normal if (ask.duration != 0) { endTime = startTime.add(bid.duration); } uint blockedBalance = bid.frozenSum; deals[dealAmount] = Deal(ask.benchmarks, ask.author, bid.author, master, _askID, _bidID, bid.duration, ask.price, startTime, endTime, DealStatus.STATUS_ACCEPTED, blockedBalance, 0, block.timestamp); emit DealOpened(dealAmount); } function CloseDeal(uint dealID, BlacklistPerson blacklisted) public returns (bool){ require((deals[dealID].status == DealStatus.STATUS_ACCEPTED)); require(msg.sender == deals[dealID].supplierID || msg.sender == deals[dealID].consumerID || msg.sender == deals[dealID].masterID); if (block.timestamp <= deals[dealID].startTime.add(deals[dealID].duration)) { // after endTime require(deals[dealID].consumerID == msg.sender); } AddToBlacklist(dealID, blacklisted); InternalBill(dealID); InternalCloseDeal(dealID); RefundRemainingFunds(dealID); return true; } function Bill(uint dealID) public returns (bool){ InternalBill(dealID); ReserveNextPeriodFunds(dealID); return true; } function CreateChangeRequest(uint dealID, uint newPrice, uint newDuration) public returns (uint changeRequestID) { require(msg.sender == deals[dealID].consumerID || msg.sender == deals[dealID].masterID || msg.sender == deals[dealID].supplierID); require(deals[dealID].status == DealStatus.STATUS_ACCEPTED); if (IsSpot(dealID)) { require(newDuration == 0); } requestsAmount = requestsAmount.add(1); OrderType requestType; if (msg.sender == deals[dealID].consumerID) { requestType = OrderType.ORDER_BID; } else { requestType = OrderType.ORDER_ASK; } requests[requestsAmount] = ChangeRequest(dealID, requestType, newPrice, newDuration, RequestStatus.REQUEST_CREATED); emit DealChangeRequestSet(requestsAmount); if (requestType == OrderType.ORDER_BID) { emit DealChangeRequestUpdated(actualRequests[dealID][1]); requests[actualRequests[dealID][1]].status = RequestStatus.REQUEST_CANCELED; actualRequests[dealID][1] = requestsAmount; ChangeRequest memory matchingRequest = requests[actualRequests[dealID][0]]; if (newDuration == deals[dealID].duration && newPrice > deals[dealID].price) { requests[requestsAmount].status = RequestStatus.REQUEST_ACCEPTED; Bill(dealID); deals[dealID].price = newPrice; actualRequests[dealID][1] = 0; emit DealChangeRequestUpdated(requestsAmount); } else if (matchingRequest.status == RequestStatus.REQUEST_CREATED && matchingRequest.duration >= newDuration && matchingRequest.price <= newPrice) { requests[requestsAmount].status = RequestStatus.REQUEST_ACCEPTED; requests[actualRequests[dealID][0]].status = RequestStatus.REQUEST_ACCEPTED; emit DealChangeRequestUpdated(actualRequests[dealID][0]); actualRequests[dealID][0] = 0; actualRequests[dealID][1] = 0; Bill(dealID); deals[dealID].price = matchingRequest.price; deals[dealID].duration = newDuration; emit DealChangeRequestUpdated(requestsAmount); } else { return requestsAmount; } requests[actualRequests[dealID][1]].status = RequestStatus.REQUEST_CANCELED; emit DealChangeRequestUpdated(actualRequests[dealID][1]); actualRequests[dealID][1] = requestsAmount; } if (requestType == OrderType.ORDER_ASK) { emit DealChangeRequestUpdated(actualRequests[dealID][0]); requests[actualRequests[dealID][0]].status = RequestStatus.REQUEST_CANCELED; actualRequests[dealID][0] = requestsAmount; matchingRequest = requests[actualRequests[dealID][1]]; if (newDuration == deals[dealID].duration && newPrice < deals[dealID].price) { requests[requestsAmount].status = RequestStatus.REQUEST_ACCEPTED; Bill(dealID); deals[dealID].price = newPrice; actualRequests[dealID][0] = 0; emit DealChangeRequestUpdated(requestsAmount); } else if (matchingRequest.status == RequestStatus.REQUEST_CREATED && matchingRequest.duration <= newDuration && matchingRequest.price >= newPrice) { requests[requestsAmount].status = RequestStatus.REQUEST_ACCEPTED; emit DealChangeRequestUpdated(actualRequests[dealID][1]); actualRequests[dealID][0] = 0; actualRequests[dealID][1] = 0; Bill(dealID); deals[dealID].price = newPrice; deals[dealID].duration = matchingRequest.duration; emit DealChangeRequestUpdated(requestsAmount); } else { return requestsAmount; } } deals[dealID].endTime = deals[dealID].startTime.add(deals[dealID].duration); return requestsAmount; } function CancelChangeRequest(uint changeRequestID) public returns (bool) { ChangeRequest memory request = requests[changeRequestID]; require(msg.sender == deals[request.dealID].supplierID || msg.sender == deals[request.dealID].masterID || msg.sender == deals[request.dealID].consumerID); require(request.status != RequestStatus.REQUEST_ACCEPTED); if (request.requestType == OrderType.ORDER_ASK) { if (msg.sender == deals[request.dealID].consumerID) { requests[changeRequestID].status = RequestStatus.REQUEST_REJECTED; } else { requests[changeRequestID].status = RequestStatus.REQUEST_CANCELED; } actualRequests[request.dealID][0] = 0; emit DealChangeRequestUpdated(changeRequestID); } if (request.requestType == OrderType.ORDER_BID) { if (msg.sender == deals[request.dealID].consumerID) { requests[changeRequestID].status = RequestStatus.REQUEST_CANCELED; } else { requests[changeRequestID].status = RequestStatus.REQUEST_REJECTED; } actualRequests[request.dealID][1] = 0; emit DealChangeRequestUpdated(changeRequestID); } return true; } // Master-worker functions function RegisterWorker(address _master) public whenNotPaused returns (bool) { require(GetMaster(msg.sender) == msg.sender); require(isMaster[msg.sender] == false); require(GetMaster(_master) == _master); masterRequest[_master][msg.sender] = true; emit WorkerAnnounced(msg.sender, _master); return true; } function ConfirmWorker(address _worker) public whenNotPaused returns (bool) { require(masterRequest[msg.sender][_worker] == true); masterOf[_worker] = msg.sender; isMaster[msg.sender] = true; delete masterRequest[msg.sender][_worker]; emit WorkerConfirmed(_worker, msg.sender); return true; } function RemoveWorker(address _worker, address _master) public whenNotPaused returns (bool) { require(GetMaster(_worker) == _master && (msg.sender == _worker || msg.sender == _master)); delete masterOf[_worker]; emit WorkerRemoved(_worker, _master); return true; } // GETTERS function GetOrderInfo(uint orderID) view public returns ( OrderType orderType, address author, address counterparty, uint duration, uint price, bool[] netflags, ProfileRegistry.IdentityLevel identityLevel, address blacklist, bytes32 tag, uint64[] benchmarks, uint frozenSum ){ Order memory order = orders[orderID]; return ( order.orderType, order.author, order.counterparty, order.duration, order.price, order.netflags, order.identityLevel, order.blacklist, order.tag, order.benchmarks, order.frozenSum ); } function GetOrderParams(uint orderID) view public returns ( OrderStatus orderStatus, uint dealID ){ Order memory order = orders[orderID]; return ( order.orderStatus, order.dealID ); } function GetDealInfo(uint dealID) view public returns ( uint64[] benchmarks, address supplierID, address consumerID, address masterID, uint askID, uint bidID, uint startTime ){ return ( deals[dealID].benchmarks, deals[dealID].supplierID, deals[dealID].consumerID, deals[dealID].masterID, deals[dealID].askID, deals[dealID].bidID, deals[dealID].startTime ); } function GetDealParams(uint dealID) view public returns ( uint duration, uint price, uint endTime, DealStatus status, uint blockedBalance, uint totalPayout, uint lastBillTS ){ return ( deals[dealID].duration, deals[dealID].price, deals[dealID].endTime, deals[dealID].status, deals[dealID].blockedBalance, deals[dealID].totalPayout, deals[dealID].lastBillTS ); } function GetMaster(address _worker) view public returns (address master) { if (masterOf[_worker] == 0x0 || masterOf[_worker] == _worker) { master = _worker; } else { master = masterOf[_worker]; } } function GetChangeRequestInfo(uint changeRequestID) view public returns ( uint dealID, OrderType requestType, uint price, uint duration, RequestStatus status ){ return ( requests[changeRequestID].dealID, requests[changeRequestID].requestType, requests[changeRequestID].price, requests[changeRequestID].duration, requests[changeRequestID].status ); } function GetDealsAmount() public view returns (uint){ return dealAmount; } function GetOrdersAmount() public view returns (uint){ return ordersAmount; } function GetChangeRequestsAmount() public view returns (uint){ return requestsAmount; } function GetBenchmarksQuantity() public view returns (uint) { return benchmarksQuantity; } function GetNetflagsQuantity() public view returns (uint) { return netflagsQuantity; } // INTERNAL function InternalBill(uint dealID) internal returns (bool){ require(deals[dealID].status == DealStatus.STATUS_ACCEPTED); require(msg.sender == deals[dealID].supplierID || msg.sender == deals[dealID].consumerID || msg.sender == deals[dealID].masterID); Deal memory deal = deals[dealID]; uint paidAmount; if (!IsSpot(dealID) && deal.lastBillTS >= deal.endTime) { // means we already billed deal after endTime return true; } else if (!IsSpot(dealID) && block.timestamp > deal.endTime && deal.lastBillTS < deal.endTime) { paidAmount = CalculatePayment(deal.price, deal.endTime.sub(deal.lastBillTS)); } else { paidAmount = CalculatePayment(deal.price, block.timestamp.sub(deal.lastBillTS)); } if (paidAmount > deal.blockedBalance) { if (token.balanceOf(deal.consumerID) >= paidAmount.sub(deal.blockedBalance)) { require(token.transferFrom(deal.consumerID, this, paidAmount.sub(deal.blockedBalance))); deals[dealID].blockedBalance = deals[dealID].blockedBalance.add(paidAmount.sub(deal.blockedBalance)); } else { emit Billed(dealID, deals[dealID].blockedBalance); InternalCloseDeal(dealID); require(token.transfer(deal.masterID, deal.blockedBalance)); deals[dealID].lastBillTS = block.timestamp; deals[dealID].totalPayout = deals[dealID].totalPayout.add(deal.blockedBalance); deals[dealID].blockedBalance = 0; return true; } } require(token.transfer(deal.masterID, paidAmount)); deals[dealID].blockedBalance = deals[dealID].blockedBalance.sub(paidAmount); deals[dealID].totalPayout = deals[dealID].totalPayout.add(paidAmount); deals[dealID].lastBillTS = block.timestamp; emit Billed(dealID, paidAmount); return true; } function ReserveNextPeriodFunds(uint dealID) internal returns (bool) { uint nextPeriod; Deal memory deal = deals[dealID]; if (IsSpot(dealID)) { if (deal.status == DealStatus.STATUS_CLOSED) { return true; } nextPeriod = 1 hours; } else { if (block.timestamp > deal.endTime) { // we don't reserve funds for next period return true; } if (deal.endTime.sub(block.timestamp) < 1 days) { nextPeriod = deal.endTime.sub(block.timestamp); } else { nextPeriod = 1 days; } } if (CalculatePayment(deal.price, nextPeriod) > deals[dealID].blockedBalance) { uint nextPeriodSum = CalculatePayment(deal.price, nextPeriod).sub(deals[dealID].blockedBalance); if (token.balanceOf(deal.consumerID) >= nextPeriodSum) { require(token.transferFrom(deal.consumerID, this, nextPeriodSum)); deals[dealID].blockedBalance = deals[dealID].blockedBalance.add(nextPeriodSum); } else { emit Billed(dealID, deals[dealID].blockedBalance); InternalCloseDeal(dealID); RefundRemainingFunds(dealID); return true; } } return true; } function RefundRemainingFunds(uint dealID) internal returns (bool){ if (deals[dealID].blockedBalance != 0) { token.transfer(deals[dealID].consumerID, deals[dealID].blockedBalance); deals[dealID].blockedBalance = 0; } return true; } function IsSpot(uint dealID) internal view returns (bool){ return deals[dealID].duration == 0; } function CalculatePayment(uint _price, uint _period) internal view returns (uint) { uint rate = oracle.getCurrentPrice(); return rate.mul(_price).mul(_period).div(1e18); } function AddToBlacklist(uint dealID, BlacklistPerson role) internal { // only consumer can blacklist require(msg.sender == deals[dealID].consumerID || role == BlacklistPerson.BLACKLIST_NOBODY); if (role == BlacklistPerson.BLACKLIST_WORKER) { bl.Add(deals[dealID].consumerID, deals[dealID].supplierID); } else if (role == BlacklistPerson.BLACKLIST_MASTER) { bl.Add(deals[dealID].consumerID, deals[dealID].masterID); } } function InternalCloseDeal(uint dealID) internal { if (deals[dealID].status == DealStatus.STATUS_CLOSED) { return; } require((deals[dealID].status == DealStatus.STATUS_ACCEPTED)); require(msg.sender == deals[dealID].consumerID || msg.sender == deals[dealID].supplierID || msg.sender == deals[dealID].masterID); deals[dealID].status = DealStatus.STATUS_CLOSED; deals[dealID].endTime = block.timestamp; emit DealUpdated(dealID); } function ResizeBenchmarks(uint64[] _benchmarks) internal view returns (uint64[]) { uint64[] memory benchmarks = new uint64[](benchmarksQuantity); for (uint i = 0; i < _benchmarks.length; i++) { benchmarks[i] = _benchmarks[i]; } return benchmarks; } function ResizeNetflags(bool[] _netflags) internal view returns (bool[]) { bool[] memory netflags = new bool[](netflagsQuantity); for (uint i = 0; i < _netflags.length; i++) { netflags[i] = _netflags[i]; } return netflags; } // SETTERS function SetProfileRegistryAddress(address _newPR) onlyOwner public returns (bool) { pr = ProfileRegistry(_newPR); return true; } function SetBlacklistAddress(address _newBL) onlyOwner public returns (bool) { bl = Blacklist(_newBL); return true; } function SetOracleAddress(address _newOracle) onlyOwner public returns (bool) { require(OracleUSD(_newOracle).getCurrentPrice() != 0); oracle = OracleUSD(_newOracle); return true; } function SetBenchmarksQuantity(uint _newQuantity) onlyOwner public returns (bool) { require(_newQuantity > benchmarksQuantity); emit NumBenchmarksUpdated(_newQuantity); benchmarksQuantity = _newQuantity; return true; } function SetNetflagsQuantity(uint _newQuantity) onlyOwner public returns (bool) { require(_newQuantity > netflagsQuantity); emit NumNetflagsUpdated(_newQuantity); netflagsQuantity = _newQuantity; return true; } function KillMarket() onlyOwner public { token.transfer(owner, token.balanceOf(address(this))); selfdestruct(owner); } }
current length of netflags
uint netflagsQuantity;
2,521,085
[ 1, 4625, 348, 7953, 560, 30, 225, 783, 769, 434, 2901, 7133, 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, 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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 ]
[ 1, 565, 2254, 2901, 7133, 12035, 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, -100 ]
/* Copyright 2019-2020 eMobilify GmbH Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.15; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; contract Registry is Ownable { // message prefix included in any signed data string private constant prefix = "\u0019Ethereum Signed Message:\n32"; /** * Events */ event OperatorUpdate(address indexed operator, string domain); event PartyUpdate( bytes2 countryCode, bytes3 partyId, address indexed partyAddress, Role[] roles, Module[] modulesSender, Module[] modulesReceiver, address indexed operatorAddress ); event DebugPacked(bytes packed); event DebugHash(bytes32 hash); /** * Admin methods */ // allow S&C to delete operator (e.g. if operator's private key is lost) function adminDeleteOperator(address operator) public onlyOwner { deleteNode(operator); } // allows owner of contract to overwrite an entry in the registry function adminDeleteParty(bytes2 countryCode, bytes3 partyId) public onlyOwner { address party = uniqueParties[countryCode][partyId]; deleteParty(party); } /** * OCN Node Operator Listings */ // address => domain name/url mapping(address => string) private nodeOf; // domain name/url => true/false mapping(string => bool) private uniqueDomains; // address => true/false mapping(address => bool) private uniqueOperators; // store operators to get list address[] private operators; /** * Create/Update the domain linked to a given operator (internal). */ function setNode(address operator, string memory domain) private { require(bytes(domain).length != 0, "Cannot set empty domain name. Use deleteNode method instead."); // check for domain uniqueness require(uniqueDomains[domain] == false, "Domain name already registered."); uniqueDomains[domain] = true; // store operator if new if (uniqueOperators[operator] == false) { operators.push(operator); } // store and log new node info uniqueOperators[operator] = true; nodeOf[operator] = domain; emit OperatorUpdate(operator, domain); } /** * Direct transaction by signer to create/update their linked domain. */ function setNode(string memory domain) public { setNode(msg.sender, domain); } /** * Raw transaction by signer to create/update another wallet's linked domain. * Requires the other wallet to have signed the same data provided. */ function setNodeRaw(address operator, string memory domain, uint8 v, bytes32 r, bytes32 s) public { bytes32 paramHash = keccak256(abi.encodePacked(operator, domain)); address signer = ecrecover(keccak256(abi.encodePacked(prefix, paramHash)), v, r, s); setNode(signer, domain); } /** * Removes a domain linked to a given node operator (internal). */ function deleteNode(address operator) private { string memory domain = nodeOf[operator]; require(bytes(domain).length > 0, "Cannot delete node that does not exist."); // delete node and log uniqueDomains[domain] = false; delete nodeOf[operator]; emit OperatorUpdate(operator, ""); } /** * Direct transaction allowing node operater to unlink their domain */ function deleteNode() public { deleteNode(msg.sender); } /** * Raw transaction by signer allowing them to delete another wallet's linked domain. * Requires the other wallet to have signed the same data provided. */ function deleteNodeRaw(address operator, uint8 v, bytes32 r, bytes32 s) public { bytes32 paramHash = keccak256(abi.encodePacked(operator)); address signer = ecrecover(keccak256(abi.encodePacked(prefix, paramHash)), v, r, s); deleteNode(signer); } /** * Get the domain name of a given operator. */ function getNode(address operator) public view returns (string memory) { return nodeOf[operator]; } /** * Get list of node operators. */ function getNodeOperators() public view returns (address[] memory) { return operators; } /** * OCPI Party Listings */ enum Role { CPO, EMSP, HUB, NAP, NSP, OTHER, SCSP } enum Module { cdrs, chargingprofiles, commands, locations, sessions, tariffs, tokens } struct PartyDetails { bytes2 countryCode; bytes3 partyId; Role[] roles; PartyModules modules; } struct PartyModules { Module[] sender; Module[] receiver; } // country_code => party_id => ocpi party address mapping(bytes2 => mapping(bytes3 => address)) private uniqueParties; // ocpi party => true/false mapping(address => bool) private uniquePartyAddresses; // ocpi party => party details mapping(address => PartyDetails) private partyOf; // ocpi party => node operator mapping(address => address) private operatorOf; // store parties to get list address[] private parties; /** * Create/update OCPI party details and node (internal). */ function setParty(address party, bytes2 countryCode, bytes3 partyId, Role[] memory roles, address operator) private { require(countryCode != bytes2(0), "Cannot set empty country_code. Use deleteParty method instead."); require(partyId != bytes3(0), "Cannot set empty party_id. Use deleteParty method instead."); require(roles.length > 0, "No roles provided."); require(operator != address(0), "Cannot set empty operator. Use deleteParty method instead."); // check for unique country_code and party_id combination address registeredParty = uniqueParties[countryCode][partyId]; require( registeredParty == address(0) || registeredParty == party, "Party with country_code/party_id already registered under different address." ); uniqueParties[countryCode][partyId] = party; require(bytes(nodeOf[operator]).length != 0, "Provided operator not registered."); if (uniquePartyAddresses[party] == false) { parties.push(party); } uniquePartyAddresses[party] = true; PartyModules memory modules; partyOf[party] = PartyDetails(countryCode, partyId, roles, modules); operatorOf[party] = operator; emit PartyUpdate(countryCode, partyId, party, roles, modules.sender, modules.receiver, operator); } /** * Direct transaction by signer to create/update OCPI party details. */ function setParty(bytes2 countryCode, bytes3 partyId, Role[] memory roles, address operator) public { setParty(msg.sender, countryCode, partyId, roles, operator); } /** * Raw transaction by signer to create/update another wallet's OCPI party details. * Requires the other wallet to have signed the same data provided. */ function setPartyRaw( address party, bytes2 countryCode, bytes3 partyId, Role[] memory roles, address operator, uint8 v, bytes32 r, bytes32 s ) public { bytes32 paramHash = keccak256(abi.encodePacked(party, countryCode, partyId, roles, operator)); address signer = ecrecover(keccak256(abi.encodePacked(prefix, paramHash)), v, r, s); require(signer == party, "Signer and provided party address different."); setParty(signer, countryCode, partyId, roles, operator); } /** * Set optional party module implementations (internal). */ function setPartyModules(address party, Module[] memory sender, Module[] memory receiver) private { address operator = operatorOf[party]; require(operator != address(0), "Party not registered. Use setParty method first."); partyOf[party].modules.sender = sender; partyOf[party].modules.receiver = receiver; PartyDetails memory details = partyOf[party]; emit PartyUpdate(details.countryCode, details.partyId, party, details.roles, sender, receiver, operator); } /** * Direct transaction by signer to set their module implementations */ function setPartyModules(Module[] memory sender, Module[] memory receiver) public { setPartyModules(msg.sender, sender, receiver); } /** * Raw transaction by signer to set another wallet's module implementations. * Requires the other wallet to have signed the same data provided. */ function setPartyModulesRaw(address party, Module[] memory sender, Module[] memory receiver, uint8 v, bytes32 r, bytes32 s) public { bytes32 paramHash = keccak256(abi.encodePacked(party, sender, receiver)); address signer = ecrecover(keccak256(abi.encodePacked(prefix, paramHash)), v, r, s); require(signer == party, "Signer and provided party address different."); setPartyModules(signer, sender, receiver); } /** * Delete OCPI party details and node (internal). */ function deleteParty(address party) private { require(operatorOf[party] != address(0), "Cannot delete party that does not exist. No operator found for given party."); delete operatorOf[party]; PartyDetails memory details = partyOf[party]; delete uniqueParties[details.countryCode][details.partyId]; delete partyOf[party]; Role[] memory emptyRoles; Module[] memory emptyModules; emit PartyUpdate(details.countryCode, details.partyId, party, emptyRoles, emptyModules, emptyModules, address(0)); } /** * Direct transaction by signer to delete OCPI party details. */ function deleteParty() public { deleteParty(msg.sender); } /** * Raw transaction by signer to delete another wallet's OCPI party details. * Requires the other wallet to have signed the same data provided. */ function deletePartyRaw(address party, uint8 v, bytes32 r, bytes32 s) public { bytes32 paramHash = keccak256(abi.encodePacked(party)); address signer = ecrecover(keccak256(abi.encodePacked(prefix, paramHash)), v, r, s); require(signer == party, "Signer and provided party address different."); deleteParty(signer); } /** * Gets operator iformation for a given OCPI party (address). */ function getOperatorByAddress(address party) public view returns (address operator, string memory domain) { operator = operatorOf[party]; domain = nodeOf[operator]; } /** * Gets operator information for a given OCPI party (country_code and party_id combination). */ function getOperatorByOcpi(bytes2 countryCode, bytes3 partyId) public view returns (address operator, string memory domain) { address party = uniqueParties[countryCode][partyId]; operator = operatorOf[party]; domain = nodeOf[operator]; } /** * Gets the party details, roles and node by the address of the party */ function getPartyDetailsByAddress(address partyAddress) public view returns ( bytes2 countryCode, bytes3 partyId, Module[] memory modulesSender, Module[] memory modulesReceiver, Role[] memory roles, address operatorAddress, string memory operatorDomain ) { PartyDetails memory details = partyOf[partyAddress]; countryCode = details.countryCode; partyId = details.partyId; roles = details.roles; modulesSender = details.modules.sender; modulesReceiver = details.modules.receiver; operatorAddress = operatorOf[partyAddress]; operatorDomain = nodeOf[operatorAddress]; } /** * Gets the party details, roles and node by the country_code/party_id of the party */ function getPartyDetailsByOcpi(bytes2 countryCode, bytes3 partyId) public view returns ( address partyAddress, Role[] memory roles, Module[] memory modulesSender, Module[] memory modulesReceiver, address operatorAddress, string memory operatorDomain ) { partyAddress = uniqueParties[countryCode][partyId]; PartyDetails memory details = partyOf[partyAddress]; roles = details.roles; modulesSender = details.modules.sender; modulesReceiver = details.modules.receiver; operatorAddress = operatorOf[partyAddress]; operatorDomain = nodeOf[operatorAddress]; } /** * Get the list of parties registered */ function getParties() public view returns (address[] memory) { return parties; } }
allows owner of contract to overwrite an entry in the registry
function adminDeleteParty(bytes2 countryCode, bytes3 partyId) public onlyOwner { address party = uniqueParties[countryCode][partyId]; deleteParty(party); }
7,220,262
[ 1, 4625, 348, 7953, 560, 30, 225, 5360, 3410, 434, 6835, 358, 6156, 392, 1241, 316, 326, 4023, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 1, 565, 445, 3981, 2613, 17619, 12, 3890, 22, 20622, 16, 1731, 23, 18285, 548, 13, 1071, 1338, 5541, 288, 203, 3639, 1758, 18285, 273, 3089, 1988, 606, 63, 9082, 1085, 6362, 21214, 548, 15533, 203, 3639, 1430, 17619, 12, 21214, 1769, 203, 565, 289, 203, 203, 203, 203, 203, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x9Ae4Ed3bF7a3a529Afbc126b4541c0D636D455f6/sources/EasyTrade.sol
EtherDelta contract address
address constant public ETHERDELTA_ADDR = 0x8d12a197cb00d4747a1fe03395095ce2a5cc6819;
3,889,423
[ 1, 4625, 348, 7953, 560, 30, 225, 512, 1136, 9242, 6835, 1758, 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, 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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 ]
[ 1, 225, 1758, 5381, 1071, 512, 19905, 24733, 9833, 67, 14142, 273, 374, 92, 28, 72, 2138, 69, 31728, 7358, 713, 72, 24, 5608, 27, 69, 21, 3030, 15265, 29, 5995, 25, 311, 22, 69, 25, 952, 9470, 3657, 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 ]
pragma solidity ^0.5.16; // Inheritance import "./Owned.sol"; import "./PerpsV2SettingsMixin.sol"; // Internal references import "./interfaces/IPerpsV2Settings.sol"; import "./interfaces/IPerpsV2Market.sol"; // market manager is still the V1 one import "./interfaces/IFuturesMarketManager.sol"; contract PerpsV2Settings is Owned, PerpsV2SettingsMixin, IPerpsV2Settings { /* ========== CONSTANTS ========== */ /* ---------- Address Resolver Configuration ---------- */ bytes32 internal constant CONTRACT_FUTURES_MARKET_MANAGER = "FuturesMarketManager"; bytes32 public constant CONTRACT_NAME = "PerpsV2Settings"; /* ========== CONSTRUCTOR ========== */ constructor(address _owner, address _resolver) public Owned(_owner) PerpsV2SettingsMixin(_resolver) {} /* ========== VIEWS ========== */ function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = PerpsV2SettingsMixin.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](1); newAddresses[0] = CONTRACT_FUTURES_MARKET_MANAGER; addresses = combineArrays(existingAddresses, newAddresses); } function _futuresMarketManager() internal view returns (IFuturesMarketManager) { return IFuturesMarketManager(requireAndGetAddress(CONTRACT_FUTURES_MARKET_MANAGER)); } /* ---------- Getters ---------- */ /* * The fee charged when opening a position on the heavy side of a market. */ function baseFee(bytes32 _marketKey) external view returns (uint) { return _baseFee(_marketKey); } /* * The fee charged when opening a position on the heavy side of a market using next price mechanism. */ function baseFeeNextPrice(bytes32 _marketKey) external view returns (uint) { return _baseFeeNextPrice(_marketKey); } /* * The number of price update rounds during which confirming next-price is allowed */ function nextPriceConfirmWindow(bytes32 _marketKey) public view returns (uint) { return _nextPriceConfirmWindow(_marketKey); } /* * The maximum allowable leverage in a market. */ function maxLeverage(bytes32 _marketKey) public view returns (uint) { return _maxLeverage(_marketKey); } /* * The maximum allowable notional value on each side of a market. */ function maxSingleSideValueUSD(bytes32 _marketKey) public view returns (uint) { return _maxSingleSideValueUSD(_marketKey); } /* * The maximum theoretical funding rate per day charged by a market. */ function maxFundingRate(bytes32 _marketKey) public view returns (uint) { return _maxFundingRate(_marketKey); } /* * The skew level at which the max funding rate will be charged. */ function skewScaleUSD(bytes32 _marketKey) public view returns (uint) { return _skewScaleUSD(_marketKey); } function parameters(bytes32 _marketKey) external view returns ( uint baseFee, uint baseFeeNextPrice, uint nextPriceConfirmWindow, uint maxLeverage, uint maxSingleSideValueUSD, uint maxFundingRate, uint skewScaleUSD ) { baseFee = _baseFee(_marketKey); baseFeeNextPrice = _baseFeeNextPrice(_marketKey); nextPriceConfirmWindow = _nextPriceConfirmWindow(_marketKey); maxLeverage = _maxLeverage(_marketKey); maxSingleSideValueUSD = _maxSingleSideValueUSD(_marketKey); maxFundingRate = _maxFundingRate(_marketKey); skewScaleUSD = _skewScaleUSD(_marketKey); } /* * The minimum amount of sUSD paid to a liquidator when they successfully liquidate a position. * This quantity must be no greater than `minInitialMargin`. */ function minKeeperFee() external view returns (uint) { return _minKeeperFee(); } /* * Liquidation fee basis points paid to liquidator. * Use together with minKeeperFee() to calculate the actual fee paid. */ function liquidationFeeRatio() external view returns (uint) { return _liquidationFeeRatio(); } /* * Liquidation price buffer in basis points to prevent negative margin on liquidation. */ function liquidationBufferRatio() external view returns (uint) { return _liquidationBufferRatio(); } /* * The minimum margin required to open a position. * This quantity must be no less than `minKeeperFee`. */ function minInitialMargin() external view returns (uint) { return _minInitialMargin(); } /* ========== MUTATIVE FUNCTIONS ========== */ /* ---------- Setters --------- */ function _setParameter( bytes32 _marketKey, bytes32 key, uint value ) internal { _flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, keccak256(abi.encodePacked(_marketKey, key)), value); emit ParameterUpdated(_marketKey, key, value); } function setBaseFee(bytes32 _marketKey, uint _baseFee) public onlyOwner { require(_baseFee <= 1e18, "taker fee greater than 1"); _setParameter(_marketKey, PARAMETER_BASE_FEE, _baseFee); } function setBaseFeeNextPrice(bytes32 _marketKey, uint _baseFeeNextPrice) public onlyOwner { require(_baseFeeNextPrice <= 1e18, "taker fee greater than 1"); _setParameter(_marketKey, PARAMETER_BASE_FEE_NEXT_PRICE, _baseFeeNextPrice); } function setNextPriceConfirmWindow(bytes32 _marketKey, uint _nextPriceConfirmWindow) public onlyOwner { _setParameter(_marketKey, PARAMETER_NEXT_PRICE_CONFIRM_WINDOW, _nextPriceConfirmWindow); } function setMaxLeverage(bytes32 _marketKey, uint _maxLeverage) public onlyOwner { _setParameter(_marketKey, PARAMETER_MAX_LEVERAGE, _maxLeverage); } function setMaxSingleSideValueUSD(bytes32 _marketKey, uint _maxSingleSideValueUSD) public onlyOwner { _setParameter(_marketKey, PARAMETER_MAX_SINGLE_SIDE_VALUE, _maxSingleSideValueUSD); } // Before altering parameters relevant to funding rates, outstanding funding on the underlying market // must be recomputed, otherwise already-accrued but unrealised funding in the market can change. function _recomputeFunding(bytes32 _marketKey) internal { IPerpsV2Market market = IPerpsV2Market(_futuresMarketManager().marketForKey(_marketKey)); if (market.marketSize() > 0) { // only recompute funding when market has positions, this check is important for initial setup market.recomputeFunding(); } } function setMaxFundingRate(bytes32 _marketKey, uint _maxFundingRate) public onlyOwner { _recomputeFunding(_marketKey); _setParameter(_marketKey, PARAMETER_MAX_FUNDING_RATE, _maxFundingRate); } function setSkewScaleUSD(bytes32 _marketKey, uint _skewScaleUSD) public onlyOwner { require(_skewScaleUSD > 0, "cannot set skew scale 0"); _recomputeFunding(_marketKey); _setParameter(_marketKey, PARAMETER_MIN_SKEW_SCALE, _skewScaleUSD); } function setParameters( bytes32 _marketKey, uint _baseFee, uint _baseFeeNextPrice, uint _nextPriceConfirmWindow, uint _maxLeverage, uint _maxSingleSideValueUSD, uint _maxFundingRate, uint _skewScaleUSD ) external onlyOwner { _recomputeFunding(_marketKey); setBaseFee(_marketKey, _baseFee); setBaseFeeNextPrice(_marketKey, _baseFeeNextPrice); setNextPriceConfirmWindow(_marketKey, _nextPriceConfirmWindow); setMaxLeverage(_marketKey, _maxLeverage); setMaxSingleSideValueUSD(_marketKey, _maxSingleSideValueUSD); setMaxFundingRate(_marketKey, _maxFundingRate); setSkewScaleUSD(_marketKey, _skewScaleUSD); } function setMinKeeperFee(uint _sUSD) external onlyOwner { require(_sUSD <= _minInitialMargin(), "min margin < liquidation fee"); _flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_MIN_KEEPER_FEE, _sUSD); emit MinKeeperFeeUpdated(_sUSD); } function setLiquidationFeeRatio(uint _ratio) external onlyOwner { _flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_FEE_RATIO, _ratio); emit LiquidationFeeRatioUpdated(_ratio); } function setLiquidationBufferRatio(uint _ratio) external onlyOwner { _flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_BUFFER_RATIO, _ratio); emit LiquidationBufferRatioUpdated(_ratio); } function setMinInitialMargin(uint _minMargin) external onlyOwner { require(_minKeeperFee() <= _minMargin, "min margin < liquidation fee"); _flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_MIN_INITIAL_MARGIN, _minMargin); emit MinInitialMarginUpdated(_minMargin); } /* ========== EVENTS ========== */ event ParameterUpdated(bytes32 indexed marketKey, bytes32 indexed parameter, uint value); event MinKeeperFeeUpdated(uint sUSD); event LiquidationFeeRatioUpdated(uint bps); event LiquidationBufferRatioUpdated(uint bps); event MinInitialMarginUpdated(uint minMargin); }
The minimum amount of sUSD paid to a liquidator when they successfully liquidate a position. This quantity must be no greater than `minInitialMargin`./
function minKeeperFee() external view returns (uint) { return _minKeeperFee(); }
5,353,416
[ 1, 4625, 348, 7953, 560, 30, 225, 1021, 5224, 3844, 434, 272, 3378, 40, 30591, 358, 279, 4501, 26595, 639, 1347, 2898, 4985, 4501, 26595, 340, 279, 1754, 18, 1220, 10457, 1297, 506, 1158, 6802, 2353, 1375, 1154, 4435, 9524, 8338, 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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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, 1131, 17891, 14667, 1435, 3903, 1476, 1135, 261, 11890, 13, 288, 203, 3639, 327, 389, 1154, 17891, 14667, 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, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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.8; 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); } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender == owner) _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) owner = newOwner; } } contract TokenSpender { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } 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; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract PullPayment { mapping(address => uint) public payments; event RefundETH(address to, uint value); // store sent amount as credit to be pulled, called by payer function asyncSend(address dest, uint amount) internal { payments[dest] += amount; } // withdraw accumulated balance, called by payee function withdrawPayments() { address payee = msg.sender; uint payment = payments[payee]; if (payment == 0) { throw; } if (this.balance < payment) { throw; } payments[payee] = 0; if (!payee.send(payment)) { throw; } RefundETH(payee,payment); } } contract Pausable is Ownable { bool public stopped; modifier stopInEmergency { if (stopped) { throw; } _; } modifier onlyInEmergency { if (!stopped) { throw; } _; } // called by the owner on emergency, triggers stopped state function emergencyStop() external onlyOwner { stopped = true; } // called by the owner on end of emergency, returns to normal state function release() external onlyOwner onlyInEmergency { stopped = false; } } contract RLC is ERC20, SafeMath, Ownable { /* Public variables of the token */ string public name; //fancy name string public symbol; uint8 public decimals; //How many decimals to show. string public version = 'v0.1'; uint public initialSupply; uint public totalSupply; bool public locked; //uint public unlockBlock; mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; // lock transfer during the ICO modifier onlyUnlocked() { if (msg.sender != owner && locked) throw; _; } /* * The RLC Token created with the time at which the crowdsale end */ function RLC() { // lock the transfer function during the crowdsale locked = true; //unlockBlock= now + 45 days; // (testnet) - for mainnet put the block number initialSupply = 87000000000000000; totalSupply = initialSupply; balances[msg.sender] = initialSupply;// Give the creator all initial tokens name = 'iEx.ec Network Token'; // Set the name for display purposes symbol = 'RLC'; // Set the symbol for display purposes decimals = 9; // Amount of decimals for display purposes } function unlock() onlyOwner { locked = false; } function burn(uint256 _value) returns (bool){ balances[msg.sender] = safeSub(balances[msg.sender], _value) ; totalSupply = safeSub(totalSupply, _value); Transfer(msg.sender, 0x0, _value); return true; } function transfer(address _to, uint _value) onlyUnlocked returns (bool) { 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) onlyUnlocked returns (bool) { var _allowance = allowed[_from][msg.sender]; 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) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /* Approve and then comunicate the approved contract in a single tx */ function approveAndCall(address _spender, uint256 _value, bytes _extraData){ TokenSpender spender = TokenSpender(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); } } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract Crowdsale is SafeMath, PullPayment, Pausable { struct Backer { uint weiReceived; // Amount of ETH given string btc_address; //store the btc address for full traceability uint satoshiReceived; // Amount of BTC given uint rlcSent; } RLC public rlc; // RLC contract reference address public owner; // Contract owner (iEx.ec team) address public multisigETH; // Multisig contract that will receive the ETH address public BTCproxy; // address of the BTC Proxy uint public RLCPerETH; // Number of RLC per ETH uint public RLCPerSATOSHI; // Number of RLC per SATOSHI uint public ETHReceived; // Number of ETH received uint public BTCReceived; // Number of BTC received uint public RLCSentToETH; // Number of RLC sent to ETH contributors uint public RLCSentToBTC; // Number of RLC sent to BTC contributors uint public startBlock; // Crowdsale start block uint public endBlock; // Crowdsale end block uint public minCap; // Minimum number of RLC to sell uint public maxCap; // Maximum number of RLC to sell bool public maxCapReached; // Max cap has been reached uint public minInvestETH; // Minimum amount to invest uint public minInvestBTC; // Minimum amount to invest bool public crowdsaleClosed;// Is crowdsale still on going address public bounty; // address at which the bounty RLC will be sent address public reserve; // address at which the contingency reserve will be sent address public team; // address at which the team RLC will be sent uint public rlc_bounty; // amount of bounties RLC uint public rlc_reserve; // amount of the contingency reserve uint public rlc_team; // amount of the team RLC mapping(address => Backer) public backers; //backersETH indexed by their ETH address modifier onlyBy(address a){ if (msg.sender != a) throw; _; } modifier minCapNotReached() { if ((now<endBlock) || RLCSentToETH + RLCSentToBTC >= minCap ) throw; _; } modifier respectTimeFrame() { if ((now < startBlock) || (now > endBlock )) throw; _; } /* * Event */ event ReceivedETH(address addr, uint value); event ReceivedBTC(address addr, string from, uint value, string txid); event RefundBTC(string to, uint value); event Logs(address indexed from, uint amount, string value); /* * Constructor */ //function Crowdsale() { function Crowdsale() { owner = msg.sender; BTCproxy = 0x75c6cceb1a33f177369053f8a0e840de96b4ed0e; rlc = RLC(0x607f4c5bb672230e8672085532f7e901544a7375); multisigETH = 0xAe307e3871E5A321c0559FBf0233A38c937B826A; team = 0xd65380D773208a6Aa49472Bf55186b855B393298; reserve = 0x24F6b37770C6067D05ACc2aD2C42d1Bafde95d48; bounty = 0x8226a24dA0870Fb8A128E4Fc15228a9c4a5baC29; RLCSentToETH = 0; RLCSentToBTC = 0; minInvestETH = 1 ether; minInvestBTC = 5000000; // approx 50 USD or 0.05000000 BTC startBlock = 0 ; // should wait for the call of the function start endBlock = 0; // should wait for the call of the function start RLCPerETH = 200000000000; // will be update every 10min based on the kraken ETHBTC RLCPerSATOSHI = 50000; // 5000 RLC par BTC == 50,000 RLC per satoshi minCap=12000000000000000; maxCap=60000000000000000; rlc_bounty=1700000000000000; // max 6000000 RLC rlc_reserve=1700000000000000; // max 6000000 RLC rlc_team=12000000000000000; } /* * The fallback function corresponds to a donation in ETH */ function() payable { if (now > endBlock) throw; receiveETH(msg.sender); } /* * To call to start the crowdsale */ function start() onlyBy(owner) { startBlock = now ; endBlock = now + 30 days; } /* * Receives a donation in ETH */ function receiveETH(address beneficiary) internal stopInEmergency respectTimeFrame { if (msg.value < minInvestETH) throw; //don't accept funding under a predefined threshold uint rlcToSend = bonus(safeMul(msg.value,RLCPerETH)/(1 ether)); //compute the number of RLC to send if (safeAdd(rlcToSend, safeAdd(RLCSentToETH, RLCSentToBTC)) > maxCap) throw; Backer backer = backers[beneficiary]; if (!rlc.transfer(beneficiary, rlcToSend)) throw; // Do the RLC transfer right now backer.rlcSent = safeAdd(backer.rlcSent, rlcToSend); backer.weiReceived = safeAdd(backer.weiReceived, msg.value); // Update the total wei collected during the crowdfunding for this backer ETHReceived = safeAdd(ETHReceived, msg.value); // Update the total wei collected during the crowdfunding RLCSentToETH = safeAdd(RLCSentToETH, rlcToSend); emitRLC(rlcToSend); // compute the variable part ReceivedETH(beneficiary,ETHReceived); // send the corresponding contribution event } /* * receives a donation in BTC */ function receiveBTC(address beneficiary, string btc_address, uint value, string txid) stopInEmergency respectTimeFrame onlyBy(BTCproxy) returns (bool res){ if (value < minInvestBTC) throw; // this verif is also made on the btcproxy uint rlcToSend = bonus(safeMul(value,RLCPerSATOSHI)); //compute the number of RLC to send if (safeAdd(rlcToSend, safeAdd(RLCSentToETH, RLCSentToBTC)) > maxCap) { // check if we are not reaching the maxCap by accepting this donation RefundBTC(btc_address , value); return false; } Backer backer = backers[beneficiary]; if (!rlc.transfer(beneficiary, rlcToSend)) throw; // Do the transfer right now backer.rlcSent = safeAdd(backer.rlcSent , rlcToSend); backer.btc_address = btc_address; backer.satoshiReceived = safeAdd(backer.satoshiReceived, value); BTCReceived = safeAdd(BTCReceived, value); // Update the total satoshi collected during the crowdfunding for this backer RLCSentToBTC = safeAdd(RLCSentToBTC, rlcToSend); // Update the total satoshi collected during the crowdfunding emitRLC(rlcToSend); ReceivedBTC(beneficiary, btc_address, BTCReceived, txid); return true; } /* *Compute the variable part */ function emitRLC(uint amount) internal { rlc_bounty = safeAdd(rlc_bounty, amount/10); rlc_team = safeAdd(rlc_team, amount/20); rlc_reserve = safeAdd(rlc_reserve, amount/10); Logs(msg.sender ,amount, "emitRLC"); } /* *Compute the RLC bonus according to the investment period */ function bonus(uint amount) internal constant returns (uint) { if (now < safeAdd(startBlock, 10 days)) return (safeAdd(amount, amount/5)); // bonus 20% if (now < safeAdd(startBlock, 20 days)) return (safeAdd(amount, amount/10)); // bonus 10% return amount; } /* * When mincap is not reach backer can call the approveAndCall function of the RLC token contract * with this crowdsale contract on parameter with all the RLC they get in order to be refund */ function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) minCapNotReached public { if (msg.sender != address(rlc)) throw; if (_extraData.length != 0) throw; // no extradata needed if (_value != backers[_from].rlcSent) throw; // compare value from backer balance if (!rlc.transferFrom(_from, address(this), _value)) throw ; // get the token back to the crowdsale contract if (!rlc.burn(_value)) throw ; // token sent for refund are burnt uint ETHToSend = backers[_from].weiReceived; backers[_from].weiReceived=0; uint BTCToSend = backers[_from].satoshiReceived; backers[_from].satoshiReceived = 0; if (ETHToSend > 0) { asyncSend(_from,ETHToSend); // pull payment to get refund in ETH } if (BTCToSend > 0) RefundBTC(backers[_from].btc_address ,BTCToSend); // event message to manually refund BTC } /* * Update the rate RLC per ETH, computed externally by using the ETHBTC index on kraken every 10min */ function setRLCPerETH(uint rate) onlyBy(BTCproxy) { RLCPerETH=rate; } /* * Finalize the crowdsale, should be called after the refund period */ function finalize() onlyBy(owner) { // check if (RLCSentToETH + RLCSentToBTC < maxCap - 5000000000000 && now < endBlock) throw; // cannot finalise before 30 day until maxcap is reached minus 1BTC if (RLCSentToETH + RLCSentToBTC < minCap && now < endBlock + 15 days) throw ; // if mincap is not reached donors have 15days to get refund before we can finalise if (!multisigETH.send(this.balance)) throw; // moves the remaining ETH to the multisig address if (rlc_reserve > 6000000000000000){ // moves RLC to the team, reserve and bounty address if(!rlc.transfer(reserve,6000000000000000)) throw; // max cap 6000000RLC rlc_reserve = 6000000000000000; } else { if(!rlc.transfer(reserve,rlc_reserve)) throw; } if (rlc_bounty > 6000000000000000){ if(!rlc.transfer(bounty,6000000000000000)) throw; // max cap 6000000RLC rlc_bounty = 6000000000000000; } else { if(!rlc.transfer(bounty,rlc_bounty)) throw; } if (!rlc.transfer(team,rlc_team)) throw; uint RLCEmitted = rlc_reserve + rlc_bounty + rlc_team + RLCSentToBTC + RLCSentToETH; if (RLCEmitted < rlc.totalSupply()) // burn the rest of RLC rlc.burn(rlc.totalSupply() - RLCEmitted); rlc.unlock(); crowdsaleClosed = true; } /* * Failsafe drain */ function drain() onlyBy(owner) { if (!owner.send(this.balance)) throw; } }
Number of ETH received
uint public ETHReceived;
13,074,974
[ 1, 4625, 348, 7953, 560, 30, 225, 3588, 434, 512, 2455, 5079, 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,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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 ]
[ 1, 202, 11890, 1071, 512, 2455, 8872, 31, 377, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -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/0x132468CE9B1b3b0609A7ef0EbC3655586C30809D/sources/ShibaMob.sol
* @dev transfers ownership - grant owner role for newOwner/
function transferOwnership(address newOwner) external onlyRole(DEFAULT_OWNER) { require(newOwner != address(0), "ERC20 :: transferOwnership : newOwner != address(0)"); require(!hasRole(DEFAULT_OWNER, newOwner), "ERC20 :: transferOwnership : newOwner has owner role"); _revokeRole(DEFAULT_OWNER,_msgSender()); _setupRole(DEFAULT_OWNER,newOwner); ownedBy = newOwner; }
15,492,237
[ 1, 4625, 348, 7953, 560, 30, 380, 632, 5206, 29375, 23178, 300, 7936, 3410, 2478, 364, 394, 5541, 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,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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, 565, 445, 7412, 5460, 12565, 12, 2867, 394, 5541, 13, 3903, 1338, 2996, 12, 5280, 67, 29602, 13, 288, 203, 3639, 2583, 12, 2704, 5541, 480, 1758, 12, 20, 3631, 315, 654, 39, 3462, 493, 7412, 5460, 12565, 294, 394, 5541, 480, 1758, 12, 20, 2225, 1769, 203, 3639, 2583, 12, 5, 5332, 2996, 12, 5280, 67, 29602, 16, 394, 5541, 3631, 315, 654, 39, 3462, 493, 7412, 5460, 12565, 294, 394, 5541, 711, 3410, 2478, 8863, 203, 3639, 389, 9083, 3056, 2996, 12, 5280, 67, 29602, 16, 67, 3576, 12021, 10663, 203, 3639, 389, 8401, 2996, 12, 5280, 67, 29602, 16, 2704, 5541, 1769, 203, 3639, 16199, 858, 273, 394, 5541, 31, 203, 565, 289, 203, 203, 2, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 ]
./full_match/42161/0x0DAfeC47290C8D7A485b24B9163a525f2Fbd39c1/sources/OmenPerpetua.sol
update the state before sending the ether
claimedProfits[actualPeriod-1][id] += redeemable;
16,304,158
[ 1, 4625, 348, 7953, 560, 30, 225, 1089, 326, 919, 1865, 5431, 326, 225, 2437, 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 ]
[ 1, 5411, 7516, 329, 626, 18352, 63, 18672, 5027, 17, 21, 6362, 350, 65, 1011, 283, 24903, 429, 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 ]
pragma solidity >=0.4.22 <0.6.0; import './common/Ownable.sol'; import './libs/SafeMath.sol'; contract DDNSService is Ownable { /** USINGS */ using SafeMath for uint256; /** STRUCTS */ struct DomainDetails { bytes name; bytes12 topLevel; address owner; bytes15 ip; uint256 expires; } struct Receipt { uint256 amountPaidWei; uint256 timestamp; uint256 expires; } /** CONSTANTS */ uint256 public constant DOMAIN_NAME_COST = 1 ether; uint256 public constant DOMAIN_NAME_COST_SHORT_ADDITION = 1 ether; uint256 public constant DOMAIN_EXPIRATION_DATE = 365 days; uint8 public constant DOMAIN_NAME_MIN_LENGTH = 5; uint8 public constant DOMAIN_NAME_EXPENSIVE_LENGTH = 8; uint8 public constant TOP_LEVEL_DOMAIN_MIN_LENGTH = 1; bytes1 public constant BYTES_DEFAULT_VALUE = bytes1(0x00); /** STATE VARIABLES */ mapping(bytes32 => DomainDetails) public domainNames; mapping(address => bytes32[]) public paymentReceipts; mapping(bytes32 => Receipt) public receiptDetails; /** * MODIFIERS */ modifier isAvailable(bytes memory domain, bytes12 topLevel) { bytes32 domainHash = getDomainHash(domain, topLevel); require( domainNames[domainHash].expires < block.timestamp, 'Domain name is not available.' ); _; } modifier collectDomainNamePayment(bytes memory domain) { uint256 domainPrice = getPrice(domain); require(msg.value >= domainPrice, 'Insufficient amount.'); _; } modifier isDomainOwner(bytes memory domain, bytes12 topLevel) { bytes32 domainHash = getDomainHash(domain, topLevel); require( domainNames[domainHash].owner == msg.sender, 'You are not the owner of this domain.' ); _; } modifier isDomainNameLengthAllowed(bytes memory domain) { require( domain.length >= DOMAIN_NAME_MIN_LENGTH, 'Domain name is too short.' ); _; } modifier isTopLevelLengthAllowed(bytes12 topLevel) { require( topLevel.length >= TOP_LEVEL_DOMAIN_MIN_LENGTH, 'The provided TLD is too short.' ); _; } /** * EVENTS */ event LogDomainNameRegistered( uint256 indexed timestamp, bytes domainName, bytes12 topLevel ); event LogDomainNameRenewed( uint256 indexed timestamp, bytes domainName, bytes12 topLevel, address indexed owner ); event LogDomainNameEdited( uint256 indexed timestamp, bytes domainName, bytes12 topLevel, bytes15 newIp ); event LogDomainNameTransferred( uint256 indexed timestamp, bytes domainName, bytes12 topLevel, address indexed owner, address newOwner ); event LogPurchaseChangeReturned( uint256 indexed timestamp, address indexed _owner, uint256 amount ); event LogReceipt( uint256 indexed timestamp, bytes domainName, uint256 amountInWei, uint256 expires ); /** * @dev - Constructor of the contract */ constructor() public {} /* * @dev - function to register domain name * @param domain - domain name to be registered * @param topLevel - domain top level (TLD) * @param ip - the ip of the host */ function register( bytes memory domain, bytes12 topLevel, bytes15 ip ) public payable isDomainNameLengthAllowed(domain) isTopLevelLengthAllowed(topLevel) isAvailable(domain, topLevel) collectDomainNamePayment(domain) { // calculate the domain hash bytes32 domainHash = getDomainHash(domain, topLevel); // create a new domain entry with the provided fn parameters DomainDetails memory newDomain = DomainDetails({ name: domain, topLevel: topLevel, owner: msg.sender, ip: ip, expires: block.timestamp + DOMAIN_EXPIRATION_DATE }); // save the domain to the storage domainNames[domainHash] = newDomain; // create an receipt entry for this domain purchase Receipt memory newReceipt = Receipt({ amountPaidWei: DOMAIN_NAME_COST, timestamp: block.timestamp, expires: block.timestamp + DOMAIN_EXPIRATION_DATE }); // calculate the receipt hash/key bytes32 receiptKey = getReceiptKey(domain, topLevel); // save the receipt key for this `msg.sender` in storage paymentReceipts[msg.sender].push(receiptKey); // save the receipt entry/details in storage receiptDetails[receiptKey] = newReceipt; // log receipt issuance emit LogReceipt( block.timestamp, domain, DOMAIN_NAME_COST, block.timestamp + DOMAIN_EXPIRATION_DATE ); // log domain name registered emit LogDomainNameRegistered(block.timestamp, domain, topLevel); } /* * @dev - function to extend domain expiration date * @param domain - domain name to be registered * @param topLevel - top level */ function renewDomainName(bytes memory domain, bytes12 topLevel) public payable isDomainOwner(domain, topLevel) collectDomainNamePayment(domain) { // calculate the domain hash bytes32 domainHash = getDomainHash(domain, topLevel); // add 365 days (1 year) to the domain expiration date domainNames[domainHash].expires += 365 days; // create a receipt entity Receipt memory newReceipt = Receipt({ amountPaidWei: DOMAIN_NAME_COST, timestamp: block.timestamp, expires: block.timestamp + DOMAIN_EXPIRATION_DATE }); // calculate the receipt key for this domain bytes32 receiptKey = getReceiptKey(domain, topLevel); // save the receipt id for this msg.sender paymentReceipts[msg.sender].push(receiptKey); // store the receipt details in storage receiptDetails[receiptKey] = newReceipt; // log domain name Renewed emit LogDomainNameRenewed(block.timestamp, domain, topLevel, msg.sender); // log receipt issuance emit LogReceipt( block.timestamp, domain, DOMAIN_NAME_COST, block.timestamp + DOMAIN_EXPIRATION_DATE ); } /* * @dev - function to edit domain name * @param domain - the domain name to be editted * @param topLevel - tld of the domain * @param newIp - the new ip for the domain */ function edit( bytes memory domain, bytes12 topLevel, bytes15 newIp ) public isDomainOwner(domain, topLevel) { // calculate the domain hash - unique id bytes32 domainHash = getDomainHash(domain, topLevel); // update the new ip domainNames[domainHash].ip = newIp; // log change emit LogDomainNameEdited(block.timestamp, domain, topLevel, newIp); } /* * @dev - Transfer domain ownership * @param domain - name of the domain * @param topLevel - tld of the domain * @param newOwner - address of the new owner */ function transferDomain( bytes memory domain, bytes12 topLevel, address newOwner ) public isDomainOwner(domain, topLevel) { // prevent assigning domain ownership to the 0x0 address require(newOwner != address(0)); // calculate the hash of the current domain bytes32 domainHash = getDomainHash(domain, topLevel); // assign the new owner of the domain domainNames[domainHash].owner = newOwner; // log the transfer of ownership emit LogDomainNameTransferred( block.timestamp, domain, topLevel, msg.sender, newOwner ); } /* * @dev - Get ip of domain * @param domain * @param topLevel */ function getIP(bytes memory domain, bytes12 topLevel) public view returns (bytes15) { // calculate the hash of the domain bytes32 domainHash = getDomainHash(domain, topLevel); // return the ip property of the domain from storage return domainNames[domainHash].ip; } /* * @dev - Get price of domain * @param domain */ function getPrice(bytes memory domain) public pure returns (uint256) { // check if the domain name fits in the expensive or cheap categroy if (domain.length < DOMAIN_NAME_EXPENSIVE_LENGTH) { // if the domain is too short - its more expensive return DOMAIN_NAME_COST + DOMAIN_NAME_COST_SHORT_ADDITION; } // otherwise return the regular price return DOMAIN_NAME_COST; } /** * @dev - Get receipt list for the msg.sender */ function getReceiptList() public view returns (bytes32[] memory) { return paymentReceipts[msg.sender]; } /* * @dev - Get single receipt * @param receiptKey */ function getReceipt(bytes32 receiptKey) public view returns ( uint256, uint256, uint256 ) { return ( receiptDetails[receiptKey].amountPaidWei, receiptDetails[receiptKey].timestamp, receiptDetails[receiptKey].expires ); } /* * @dev - Get (domain name + top level) hash used for unique identifier * @param domain * @param topLevel * @return domainHash */ function getDomainHash(bytes memory domain, bytes12 topLevel) public pure returns (bytes32) { // @dev - tightly pack parameters in struct for keccak256 return keccak256(abi.encodePacked(domain, topLevel)); } /* * @dev - Get recepit key hash - unique identifier * @param domain * @param topLevel * @return receiptKey */ function getReceiptKey(bytes memory domain, bytes12 topLevel) public view returns (bytes32) { // @dev - tightly pack parameters in struct for keccak256 return keccak256( abi.encodePacked(domain, topLevel, msg.sender, block.timestamp) ); } /** * @dev - Withdraw function */ function withdraw() public onlyOwner { msg.sender.transfer(address(this).balance); } }
otherwise return the regular price
return DOMAIN_NAME_COST;
5,454,049
[ 1, 4625, 348, 7953, 560, 30, 225, 3541, 327, 326, 6736, 6205, 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,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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, 565, 327, 27025, 67, 1985, 67, 28343, 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 ]
// SPDX-License-Identifier: AGPL-3.0 // MgvOracle.sol // Copyright (C) 2021 Giry SAS. // // 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.8.10; pragma abicoder v2; import "../MgvLib.sol"; /* The purpose of the Oracle contract is to act as a gas price and density * oracle for the Mangrove. It bridges to an external oracle, and allows * a given sender to update the gas price and density which the oracle * reports to Mangrove. */ contract MgvOracle is IMgvMonitor { address governance; address mutator; uint lastReceivedGasPrice; uint lastReceivedDensity; constructor(address _governance, address _initialMutator) { governance = _governance; mutator = _initialMutator; //NOTE: Hardwiring density for now /* Mangrove will reject densities from the Monitor that don't fit in 32 bits and use its internal density instead, so setting this contract's density to `type(uint).max` is a way to let Mangrove deal with density on its own. */ lastReceivedDensity = type(uint).max; } /* ## `authOnly` check */ // NOTE: Should use standard auth method, instead of this copy from MgvGovernable function authOnly() internal view { require( msg.sender == governance || msg.sender == address(this) || governance == address(0), "MgvOracle/unauthorized" ); } function notifySuccess(MgvLib.SingleOrder calldata sor, address taker) external override { // Do nothing } function notifyFail(MgvLib.SingleOrder calldata sor, address taker) external override { // Do nothing } function setMutator(address _mutator) external { authOnly(); mutator = _mutator; } function setGasPrice(uint gasPrice) external { // governance or mutator are allowed to update the gasprice require( msg.sender == governance || msg.sender == mutator, "MgvOracle/unauthorized" ); lastReceivedGasPrice = gasPrice; } function setDensity(uint /*density*/) private view { // governance or mutator are allowed to update the density require( msg.sender == governance || msg.sender == mutator, "MgvOracle/unauthorized" ); //NOTE: Not implemented, so not made external yet } function read(address /*outbound_tkn*/, address /*inbound_tkn*/) external view override returns (uint gasprice, uint density) { return (lastReceivedGasPrice, lastReceivedDensity); } }
governance or mutator are allowed to update the gasprice
function setGasPrice(uint gasPrice) external { require( msg.sender == governance || msg.sender == mutator, "MgvOracle/unauthorized" ); lastReceivedGasPrice = gasPrice; }
6,414,662
[ 1, 4625, 348, 7953, 560, 30, 225, 314, 1643, 82, 1359, 578, 29156, 854, 2935, 358, 1089, 326, 16189, 8694, 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, 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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 ]
[ 1, 225, 445, 26770, 345, 5147, 12, 11890, 16189, 5147, 13, 3903, 288, 203, 565, 2583, 12, 203, 1377, 1234, 18, 15330, 422, 314, 1643, 82, 1359, 747, 1234, 18, 15330, 422, 29156, 16, 203, 1377, 315, 49, 75, 90, 23601, 19, 318, 8434, 6, 203, 565, 11272, 203, 203, 565, 1142, 8872, 27998, 5147, 273, 16189, 5147, 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 ]