Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xFC5AC8E7B71813D69FEACc28c50852d750b87f37
Balance 0 ETH
Nonce 9
Code Size 24396 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

24396 bytes
0x60806040523480156200001157600080fd5b5060043610620000b75760003560e01c8063a217fddf116200007a578063a217fddf1462000182578063a2a69390146200018b578063ae83013a14620001b3578063d539139314620001db578063d964478b1462000203578063e63ab1e9146200022b57600080fd5b8063179871ff14620000bc5780631d2e2cc414620000f75780637d40b676146200013857806389dc56b314620001515780639820d21b146200015a575b600080fd5b620000e47fc94352a6a0f0a14883ec0645ad40af6fe59175917307c63612fb8a19fe81d80581565b6040519081526020015b60405180910390f35b6200011f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e81565b6040516001600160a01b039091168152602001620000ee565b6200014f620001493660046200141b565b62000253565b005b620000e4606481565b6200011f7f0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba4181565b620000e4600081565b6200011f7f000000000000000000000000111baa4c1b1526951cc7de8c3e26a3d4dbcae87c81565b6200011f7f000000000000000000000000bc9a52a09145a4010c5babadc01626116f9f81e281565b620000e47f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6200011f7f000000000000000000000000d9b70872845750c0ec20843beeb234ad63b3e25b81565b620000e47f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b604051633493944960e11b81523360048201527f000000000000000000000000d9b70872845750c0ec20843beeb234ad63b3e25b6001600160a01b03169063692728929060240160206040518083038186803b158015620002b357600080fd5b505afa158015620002c8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002ee9190620013e0565b6200034c5760405162461bcd60e51b815260206004820152602360248201527f53656e646572206e6f7420616c6c6f77656420746f2063726561746520616c62604482015262756d2160e81b60648201526084015b60405180910390fd5b858414620003b65760405162461bcd60e51b815260206004820152603060248201527f4e4654206164647265737320616e6420494420617272617973206d757374206860448201526f6176652073616d65206c656e6774687360801b606482015260840162000343565b68056bc75e2d63100000896020015110156200042b5760405162461bcd60e51b815260206004820152602d60248201527f546f74616c20746f6b656e73206d757374206265206174206c6561737420313060448201526c302066756c6c20746f6b656e7360981b606482015260840162000343565b606489602001516200043e91906200183d565b88606001518a602001516200045491906200185e565b1015620004d45760405162461bcd60e51b815260206004820152604160248201527f456e6f75676820746f6b656e7320666f722074686520737a6e732064616f207260448201527f616b65206d757374206265206c656674206f7574206f6620746865202873616c6064820152606560f81b608482015260a40162000343565b60008060008c604051602001620004ec9190620015ea565b60405160208183030381529060405280519060200120905060007fc94352a6a0f0a14883ec0645ad40af6fe59175917307c63612fb8a19fe81d8058260405160200162000543929190918252602082015260400190565b60408051808303601f190181529082905280516020909101206302571be360e01b82526004820181905291506000906001600160a01b037f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e16906302571be39060240160206040518083038186803b158015620005bf57600080fd5b505afa158015620005d4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005fa9190620012b3565b6001600160a01b031614620006525760405162461bcd60e51b815260206004820152601c60248201527f454e53207375626e616d6520697320616c7265616479206f776e656400000000604482015260640162000343565b604051633d15ee5360e11b8152600481018290527f000000000000000000000000111baa4c1b1526951cc7de8c3e26a3d4dbcae87c6001600160a01b031690637a2bdca6906024016040805180830381600087803b158015620006b457600080fd5b505af1158015620006c9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006ef9190620012d2565b6040516306ab592360e01b81527fc94352a6a0f0a14883ec0645ad40af6fe59175917307c63612fb8a19fe81d80560048201526024810185905230604482015291955093507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e6001600160a01b0316906306ab592390606401602060405180830381600087803b1580156200078357600080fd5b505af115801562000798573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007be919062001402565b50604051630c4b7b8560e11b8152600481018290526001600160a01b037f0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41811660248301527f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e1690631896f70a90604401600060405180830381600087803b1580156200084a57600080fd5b505af11580156200085f573d6000803e3d6000fd5b5050604051631592ca1b60e31b81526001600160a01b037f0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba4116925063ac9650d89150620008b3908a908a90600401620016c6565b600060405180830381600087803b158015620008ce57600080fd5b505af1158015620008e3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200090d919081019062001310565b50604051635b0fc9c360e01b8152600481018290526001600160a01b0385811660248301527f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e1690635b0fc9c390604401600060405180830381600087803b1580156200097957600080fd5b505af11580156200098e573d6000803e3d6000fd5b5050505050506000620009a78d8d600001518562000a26565b90506000620009bd84838e8e8e8e8e8c62000be1565b9050620009d5828e602001518e606001518462000d8e565b7f176979ece66177db4bcf0e3266bafc9bd2ff75bb2e0eb5c45d523952e916f7858e8286868660405162000a0e95949392919062001765565b60405180910390a15050505050505050505050505050565b6000806000858560405162000a3b90620010ac565b62000a48929190620017ac565b8190604051809103906000f590508015801562000a69573d6000803e3d6000fd5b50604051632f2ff15d60e01b8152600060048201526001600160a01b03858116602483015291925090821690632f2ff15d90604401600060405180830381600087803b15801562000ab957600080fd5b505af115801562000ace573d6000803e3d6000fd5b5050604051632f2ff15d60e01b81527f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a660048201526001600160a01b03868116602483015284169250632f2ff15d9150604401600060405180830381600087803b15801562000b3c57600080fd5b505af115801562000b51573d6000803e3d6000fd5b5050604051632f2ff15d60e01b81527f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a60048201526001600160a01b03868116602483015284169250632f2ff15d9150604401600060405180830381600087803b15801562000bbf57600080fd5b505af115801562000bd4573d6000803e3d6000fd5b5092979650505050505050565b6000806040518060200162000bf690620010ba565b601f1982820381018352601f90910116604081905262000c2b908c908c9033908d908d908d908d908d908d9060200162001608565b60408051601f198184030181529082905262000c4b9291602001620015b7565b6040516020818303038152906040529050600062000c726000838051906020012062000f3d565b905060005b8781101562000d705788888281811062000ca157634e487b7160e01b600052603260045260246000fd5b905060200201602081019062000cb8919062001294565b6001600160a01b03166342842e0e33848a8a8681811062000ce957634e487b7160e01b600052603260045260246000fd5b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b15801562000d4157600080fd5b505af115801562000d56573d6000803e3d6000fd5b50505050808062000d6790620018ab565b91505062000c77565b5062000d7f6000808462000f9c565b9b9a5050505050505050505050565b8183101562000d9c57600080fd5b6000831162000daa57600080fd5b6040516340c10f1960e01b81526001600160a01b038281166004830152602482018490528591908216906340c10f1990604401600060405180830381600087803b15801562000df857600080fd5b505af115801562000e0d573d6000803e3d6000fd5b50505050600060648562000e2291906200183d565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000bc9a52a09145a4010c5babadc01626116f9f81e28116600483015260248201839052919250908316906340c10f1990604401600060405180830381600087803b15801562000e9157600080fd5b505af115801562000ea6573d6000803e3d6000fd5b50505050816001600160a01b03166340c10f193383878962000ec991906200185e565b62000ed591906200185e565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801562000f1c57600080fd5b505af115801562000f31573d6000803e3d6000fd5b50505050505050505050565b604080516001600160f81b03196020808301919091526bffffffffffffffffffffffff193060601b16602183015260358201859052605580830185905283518084039091018152607590920190925280519101206000905b9392505050565b6000808447101562000ff15760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015260640162000343565b8251620010415760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015260640162000343565b8383516020850187f590506001600160a01b038116620010a45760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015260640162000343565b949350505050565b611e38806200190f83390190565b6127d0806200374783390190565b60008083601f840112620010da578182fd5b50813567ffffffffffffffff811115620010f2578182fd5b6020830191508360208260051b85010111156200110e57600080fd5b9250929050565b600082601f83011262001126578081fd5b81516200113d620011378262001812565b620017de565b81815284602083860101111562001152578283fd5b620010a482602083016020870162001878565b600082601f83011262001176578081fd5b813562001187620011378262001812565b8181528460208386010111156200119c578283fd5b816020850160208301379081016020019190915292915050565b600060408284031215620011c8578081fd5b6040516040810167ffffffffffffffff8282108183111715620011ef57620011ef620018df565b8160405282935084359150808211156200120857600080fd5b50620012178582860162001165565b825250602083013560208201525092915050565b6000608082840312156200123d578081fd5b6040516080810181811067ffffffffffffffff82111715620012635762001263620018df565b8060405250809150823581526020830135602082015260408301356040820152606083013560608201525092915050565b600060208284031215620012a6578081fd5b813562000f9581620018f5565b600060208284031215620012c5578081fd5b815162000f9581620018f5565b60008060408385031215620012e5578081fd5b8251620012f281620018f5565b60208401519092506200130581620018f5565b809150509250929050565b6000602080838503121562001323578182fd5b825167ffffffffffffffff808211156200133b578384fd5b818501915085601f8301126200134f578384fd5b815181811115620013645762001364620018df565b8060051b62001375858201620017de565b8281528581019085870183870188018b101562001390578889fd5b8893505b84841015620013d257805186811115620013ac57898afd5b620013bc8c8a838b010162001115565b8452506001939093019291870191870162001394565b509998505050505050505050565b600060208284031215620013f2578081fd5b8151801515811462000f95578182fd5b60006020828403121562001414578081fd5b5051919050565b6000806000806000806000806000806101408b8d0312156200143b578586fd5b8a3567ffffffffffffffff8082111562001453578788fd5b620014618e838f0162001165565b9b5060208d013591508082111562001477578788fd5b620014858e838f01620011b6565b9a50620014968e60408f016200122b565b995060c08d0135915080821115620014ac578788fd5b620014ba8e838f01620010c8565b909950975060e08d0135915080821115620014d3578687fd5b620014e18e838f01620010c8565b90975095506101008d0135915080821115620014fb578485fd5b506200150a8d828e01620010c8565b915080945050809250506101208b013590509295989b9194979a5092959850565b81835260006001600160fb1b0383111562001544578081fd5b8260051b80836020870137939093016020019283525090919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008151808452620015a381602086016020860162001878565b601f01601f19169290920160200192915050565b60008351620015cb81846020880162001878565b835190830190620015e181836020880162001878565b01949350505050565b60008251620015fe81846020870162001878565b9190910192915050565b600061014080830160018060a01b03808e1685526020818e1681870152818d1660408701528b516060870152808c0151608087015260408c015160a087015260608c015160c08701528360e0870152829350898352610160860193508a9250845b8a811015620016945783356200167f81620018f5565b83168552938101939281019260010162001669565b50505050828103610100840152620016ae8186886200152b565b915050826101208301529a9950505050505050505050565b60208082528181018390526000906040600585901b8401810190840186845b878110156200175857868403603f190183528135368a9003601e190181126200170c578687fd5b8901803567ffffffffffffffff81111562001725578788fd5b8036038b131562001734578788fd5b62001743868289850162001560565b955050509184019190840190600101620016e5565b5091979650505050505050565b60a0815260006200177a60a083018862001589565b6001600160a01b0396871660208401529486166040830152509184166060830152909216608090920191909152919050565b604081526000620017c1604083018562001589565b8281036020840152620017d5818562001589565b95945050505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156200180a576200180a620018df565b604052919050565b600067ffffffffffffffff8211156200182f576200182f620018df565b50601f01601f191660200190565b6000826200185957634e487b7160e01b81526012600452602481fd5b500490565b600082821015620018735762001873620018c9565b500390565b60005b83811015620018955781810151838201526020016200187b565b83811115620018a5576000848401525b50505050565b6000600019821415620018c257620018c2620018c9565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146200190b57600080fd5b5056fe60806040523480156200001157600080fd5b5060405162001e3838038062001e3883398101604081905262000034916200039b565b8151829082906200004d90600590602085019062000242565b5080516200006390600690602084019062000242565b50506007805460ff19169055506200007d600033620000dd565b620000a97f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633620000dd565b620000d57f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33620000dd565b505062000455565b620000f482826200012060201b620009e91760201c565b60008281526001602090815260409091206200011b918390620009f362000130821b17901c565b505050565b6200012c828262000150565b5050565b600062000147836001600160a01b038416620001f0565b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200012c576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001ac3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205462000239575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200014a565b5060006200014a565b828054620002509062000402565b90600052602060002090601f016020900481019282620002745760008555620002bf565b82601f106200028f57805160ff1916838001178555620002bf565b82800160010185558215620002bf579182015b82811115620002bf578251825591602001919060010190620002a2565b50620002cd929150620002d1565b5090565b5b80821115620002cd5760008155600101620002d2565b600082601f830112620002f9578081fd5b81516001600160401b03808211156200031657620003166200043f565b604051601f8301601f19908116603f011681019082821181831017156200034157620003416200043f565b816040528381526020925086838588010111156200035d578485fd5b8491505b8382101562000380578582018301518183018401529082019062000361565b838211156200039157848385830101525b9695505050505050565b60008060408385031215620003ae578182fd5b82516001600160401b0380821115620003c5578384fd5b620003d386838701620002e8565b93506020850151915080821115620003e9578283fd5b50620003f885828601620002e8565b9150509250929050565b600181811c908216806200041757607f821691505b602082108114156200043957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6119d380620004656000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c806370a08231116100f9578063a457c2d711610097578063d539139311610071578063d5391393146103af578063d547741f146103d6578063dd62ed3e146103e9578063e63ab1e91461042257600080fd5b8063a457c2d714610376578063a9059cbb14610389578063ca15c8731461039c57600080fd5b80639010d07c116100d35780639010d07c1461032857806391d148541461035357806395d89b4114610366578063a217fddf1461036e57600080fd5b806370a08231146102e457806379cc67901461030d5780638456cb591461032057600080fd5b8063313ce567116101665780633f4ba83a116101405780633f4ba83a146102ab57806340c10f19146102b357806342966c68146102c65780635c975abb146102d957600080fd5b8063313ce5671461027657806336568abe14610285578063395093511461029857600080fd5b806318160ddd116101a257806318160ddd1461021957806323b872dd1461022b578063248a9ca31461023e5780632f2ff15d1461026157600080fd5b806301ffc9a7146101c957806306fdde03146101f1578063095ea7b314610206575b600080fd5b6101dc6101d73660046117eb565b610449565b60405190151581526020015b60405180910390f35b6101f9610474565b6040516101e89190611888565b6101dc610214366004611767565b610506565b6004545b6040519081526020016101e8565b6101dc61023936600461172c565b61051c565b61021d61024c366004611790565b60009081526020819052604090206001015490565b61027461026f3660046117a8565b6105cb565b005b604051601281526020016101e8565b6102746102933660046117a8565b6105f2565b6101dc6102a6366004611767565b610614565b610274610650565b6102746102c1366004611767565b6106f6565b6102746102d4366004611790565b610799565b60075460ff166101dc565b61021d6102f23660046116e0565b6001600160a01b031660009081526002602052604090205490565b61027461031b366004611767565b6107a6565b610274610827565b61033b6103363660046117ca565b6108cb565b6040516001600160a01b0390911681526020016101e8565b6101dc6103613660046117a8565b6108ea565b6101f9610913565b61021d600081565b6101dc610384366004611767565b610922565b6101dc610397366004611767565b6109bb565b61021d6103aa366004611790565b6109c8565b61021d7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6102746103e43660046117a8565b6109df565b61021d6103f73660046116fa565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b61021d7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b60006001600160e01b03198216635a05180f60e01b148061046e575061046e82610a08565b92915050565b6060600580546104839061194c565b80601f01602080910402602001604051908101604052809291908181526020018280546104af9061194c565b80156104fc5780601f106104d1576101008083540402835291602001916104fc565b820191906000526020600020905b8154815290600101906020018083116104df57829003601f168201915b5050505050905090565b6000610513338484610a3d565b50600192915050565b6000610529848484610b61565b6001600160a01b0384166000908152600360209081526040808320338452909152902054828110156105b35760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6105c08533858403610a3d565b506001949350505050565b6105d58282610d3c565b60008281526001602052604090206105ed90826109f3565b505050565b6105fc8282610d62565b60008281526001602052604090206105ed9082610ddc565b3360008181526003602090815260408083206001600160a01b0387168452909152812054909161051391859061064b9086906118bb565b610a3d565b61067a7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a336108ea565b6106ec5760405162461bcd60e51b815260206004820152603960248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20756e70617573650000000000000060648201526084016105aa565b6106f4610df1565b565b6107207f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6336108ea565b61078b5760405162461bcd60e51b815260206004820152603660248201527f45524332305072657365744d696e7465725061757365723a206d7573742068616044820152751d99481b5a5b9d195c881c9bdb19481d1bc81b5a5b9d60521b60648201526084016105aa565b6107958282610e84565b5050565b6107a33382610f6f565b50565b60006107b283336103f7565b9050818110156108105760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b60648201526084016105aa565b61081d8333848403610a3d565b6105ed8383610f6f565b6108517f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a336108ea565b6108c35760405162461bcd60e51b815260206004820152603760248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20706175736500000000000000000060648201526084016105aa565b6106f46110c9565b60008281526001602052604081206108e39083611144565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600680546104839061194c565b3360009081526003602090815260408083206001600160a01b0386168452909152812054828110156109a45760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016105aa565b6109b13385858403610a3d565b5060019392505050565b6000610513338484610b61565b600081815260016020526040812061046e90611150565b6105fc828261115a565b6107958282611180565b60006108e3836001600160a01b038416611204565b60006001600160e01b03198216637965db0b60e01b148061046e57506301ffc9a760e01b6001600160e01b031983161461046e565b6001600160a01b038316610a9f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105aa565b6001600160a01b038216610b005760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105aa565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610bc55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105aa565b6001600160a01b038216610c275760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105aa565b610c32838383611253565b6001600160a01b03831660009081526002602052604090205481811015610caa5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016105aa565b6001600160a01b03808516600090815260026020526040808220858503905591851681529081208054849290610ce19084906118bb565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d2d91815260200190565b60405180910390a35b50505050565b600082815260208190526040902060010154610d58813361125e565b6105ed8383611180565b6001600160a01b0381163314610dd25760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016105aa565b61079582826112c2565b60006108e3836001600160a01b038416611327565b60075460ff16610e3a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105aa565b6007805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b038216610eda5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105aa565b610ee660008383611253565b8060046000828254610ef891906118bb565b90915550506001600160a01b03821660009081526002602052604081208054839290610f259084906118bb565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610fcf5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016105aa565b610fdb82600083611253565b6001600160a01b0382166000908152600260205260409020548181101561104f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016105aa565b6001600160a01b038316600090815260026020526040812083830390556004805484929061107e9084906118f2565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b60075460ff161561110f5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016105aa565b6007805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610e673390565b60006108e38383611444565b600061046e825490565b600082815260208190526040902060010154611176813361125e565b6105ed83836112c2565b61118a82826108ea565b610795576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556111c03390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205461124b5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561046e565b50600061046e565b6105ed83838361147c565b61126882826108ea565b61079557611280816001600160a01b031660146114e2565b61128b8360206114e2565b60405160200161129c929190611813565b60408051601f198184030181529082905262461bcd60e51b82526105aa91600401611888565b6112cc82826108ea565b15610795576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000818152600183016020526040812054801561143a57600061134b6001836118f2565b855490915060009061135f906001906118f2565b90508181146113e057600086600001828154811061138d57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106113be57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b85548690806113ff57634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061046e565b600091505061046e565b600082600001828154811061146957634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60075460ff16156105ed5760405162461bcd60e51b815260206004820152602a60248201527f45524332305061757361626c653a20746f6b656e207472616e736665722077686044820152691a5b19481c185d5cd95960b21b60648201526084016105aa565b606060006114f18360026118d3565b6114fc9060026118bb565b67ffffffffffffffff81111561152257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561154c576020820181803683370190505b509050600360fc1b8160008151811061157557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106115b257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006115d68460026118d3565b6115e19060016118bb565b90505b6001811115611675576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061162357634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061164757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361166e81611935565b90506115e4565b5083156108e35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105aa565b80356001600160a01b03811681146116db57600080fd5b919050565b6000602082840312156116f1578081fd5b6108e3826116c4565b6000806040838503121561170c578081fd5b611715836116c4565b9150611723602084016116c4565b90509250929050565b600080600060608486031215611740578081fd5b611749846116c4565b9250611757602085016116c4565b9150604084013590509250925092565b60008060408385031215611779578182fd5b611782836116c4565b946020939093013593505050565b6000602082840312156117a1578081fd5b5035919050565b600080604083850312156117ba578182fd5b82359150611723602084016116c4565b600080604083850312156117dc578182fd5b50508035926020909101359150565b6000602082840312156117fc578081fd5b81356001600160e01b0319811681146108e3578182fd5b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161184b816017850160208801611909565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161187c816028840160208801611909565b01602801949350505050565b60208152600082518060208401526118a7816040850160208701611909565b601f01601f19169190910160400192915050565b600082198211156118ce576118ce611987565b500190565b60008160001904831182151516156118ed576118ed611987565b500290565b60008282101561190457611904611987565b500390565b60005b8381101561192457818101518382015260200161190c565b83811115610d365750506000910152565b60008161194457611944611987565b506000190190565b600181811c9082168061196057607f821691505b6020821081141561198157634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220ff555a869290b610dfe1de2cfd5752f53884ace7362126e14cbaf1658e9c78fc64736f6c6343000804003361010060405262093a806006553480156200001957600080fd5b50604051620027d0380380620027d08339810160408190526200003c916200069b565b848462000049336200013d565b80604001518160200151106200005e57600080fd5b606082811b6001600160601b0319166080908152825160a09081526020808501805160c0526040808701805160e05287870151600b81905588519351915183516001600160a01b038c168152958601949094529184015294820152918201929092527f85e156721fbb7d011ed4fae21ec61e7c6f6995fbe67bfc3d7734c4da5a0a9733910160405180910390a150620000f99050876200018d565b600c8054610100600160a81b0319166101006001600160a01b0389160217905562000125838362000262565b62000130816200053b565b50505050505050620008cb565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000546001600160a01b03163314620001ed5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b038116620002545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401620001e4565b6200025f816200013d565b50565b8051825114620002b55760405162461bcd60e51b815260206004820181905260248201527f496e707574206172726179206c656e6768747320646f6e2774206d617463682e6044820152606401620001e4565b60005b8251811015620004fb576000838281518110620002e557634e487b7160e01b600052603260045260246000fd5b60200260200101519050600081905060008484815181106200031757634e487b7160e01b600052603260045260246000fd5b602002602001015190506000826001600160a01b0316636352211e836040518263ffffffff1660e01b81526004016200035291815260200190565b60206040518083038186803b1580156200036b57600080fd5b505afa15801562000380573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003a6919062000677565b90506001600160a01b03811630146200042457604051632142170760e11b81526001600160a01b038281166004830152306024830152604482018490528416906342842e0e90606401600060405180830381600087803b1580156200040a57600080fd5b505af11580156200041f573d6000803e3d6000fd5b505050505b506007805460018082019092557fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180546001600160a01b0319166001600160a01b039590951694909417909355600880548085019091557ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155506009805491820181556000527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af60208204018054601f9092166101000a60ff0219909116905580620004f2816200088d565b915050620002b8565b507fdaa83305df99008c5e651b6276ac1d3278f596842d6cd5f8a92d97eb3a3bcf4482826040516200052f9291906200078f565b60405180910390a15050565b60058190556040518181527fe843b3ec3b7d5c75d587692fe07d930e310983100b25808444ed339b778485ee9060200160405180910390a150565b80516001600160a01b03811681146200058e57600080fd5b919050565b600082601f830112620005a4578081fd5b81516020620005bd620005b78362000867565b62000834565b80838252828201915082860187848660051b8901011115620005dd578586fd5b855b858110156200060657620005f38262000576565b84529284019290840190600101620005df565b5090979650505050505050565b600082601f83011262000624578081fd5b8151602062000637620005b78362000867565b80838252828201915082860187848660051b890101111562000657578586fd5b855b85811015620006065781518452928401929084019060010162000659565b60006020828403121562000689578081fd5b620006948262000576565b9392505050565b6000806000806000806000878903610140811215620006b8578384fd5b620006c38962000576565b9750620006d360208a0162000576565b9650620006e360408a0162000576565b95506080605f1982011215620006f7578384fd5b506200070262000809565b606089810151825260808a0151602083015260a08a0151604083015260c08a01519082015260e08901519094506001600160401b038082111562000744578485fd5b620007528b838c0162000593565b94506101008a015191508082111562000769578384fd5b50620007788a828b0162000613565b925050610120880151905092959891949750929550565b604080825283519082018190526000906020906060840190828701845b82811015620007d35781516001600160a01b031684529284019290840190600101620007ac565b50505083810382850152845180825285830191830190845b818110156200060657835183529284019291840191600101620007eb565b604051608081016001600160401b03811182821017156200082e576200082e620008b5565b60405290565b604051601f8201601f191681016001600160401b03811182821017156200085f576200085f620008b5565b604052919050565b60006001600160401b03821115620008835762000883620008b5565b5060051b60200190565b6000600019821415620008ae57634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fd5b60805160601c60a05160c05160e051611e826200094e600039600081816103df01528181610497015281816106f40152610c2401526000818161027c0152818161046f0152610c660152600081816101ab015281816104490152610cdb015260008181610425015281816105790152818161079501526108080152611e826000f3fe6080604052600436106101665760003560e01c8063715018a6116100d1578063c58a34cc1161008a578063e4d20c1d11610064578063e4d20c1d14610547578063e4fbb60914610567578063f2fde38b1461059b578063fc0c546a146105bb57600080fd5b8063c58a34cc146104fd578063d0febe4c1461051d578063d8cb55e31461052557600080fd5b8063715018a61461037a578063855f44d21461038f5780638da5cb5b146103af5780639aa0ff7b146103cd578063b916ea1a14610401578063c15bf672146104dd57600080fd5b8063229d5a4611610123578063229d5a461461029e5780632b105663146102c057806332f4e11c146102e2578063379607f5146102f757806357b97c7e146103175780635c4bfa101461037257600080fd5b80630c6f47061461016b57806313aaa39314610199578063150b7a02146101cd5780631a7dd12d1461021157806321df0da714610233578063226730301461026a575b600080fd5b34801561017757600080fd5b5061018666038d7ea4c6800081565b6040519081526020015b60405180910390f35b3480156101a557600080fd5b506101867f000000000000000000000000000000000000000000000000000000000000000081565b3480156101d957600080fd5b506101f86101e8366004611919565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610190565b34801561021d57600080fd5b5061023161022c366004611a23565b6105e0565b005b34801561023f57600080fd5b50600c5461010090046001600160a01b03165b6040516001600160a01b039091168152602001610190565b34801561027657600080fd5b506101867f000000000000000000000000000000000000000000000000000000000000000081565b3480156102aa57600080fd5b506102b3610621565b6040516101909190611c5a565b3480156102cc57600080fd5b506102d5610699565b6040516101909190611ca0565b3480156102ee57600080fd5b506102316106f0565b34801561030357600080fd5b50610231610312366004611b27565b6108df565b34801561032357600080fd5b50600154600254600354600454600654600554604080516001600160a01b03909716875260208701959095529385019290925260ff1615156060840152608083015260a082015260c001610190565b61023161099f565b34801561038657600080fd5b50610231610b4c565b34801561039b57600080fd5b506102316103aa3660046119d5565b610b82565b3480156103bb57600080fd5b506000546001600160a01b0316610252565b3480156103d957600080fd5b506101867f000000000000000000000000000000000000000000000000000000000000000081565b34801561040d57600080fd5b50600a54600b54600c54604080516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681527f000000000000000000000000000000000000000000000000000000000000000060208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f00000000000000000000000000000000000000000000000000000000000000006060820152608081019390935260a083019190915260ff16151560c082015260e001610190565b3480156104e957600080fd5b506102316104f8366004611a4e565b610bb6565b34801561050957600080fd5b50610231610518366004611b27565b610bea565b610231610c20565b34801561053157600080fd5b5061053a610e6e565b6040516101909190611c19565b34801561055357600080fd5b50610231610562366004611b27565b610ecf565b34801561057357600080fd5b506102527f000000000000000000000000000000000000000000000000000000000000000081565b3480156105a757600080fd5b506102316105b63660046118e1565b610f02565b3480156105c757600080fd5b50600c546102529061010090046001600160a01b031681565b6000546001600160a01b031633146106135760405162461bcd60e51b815260040161060a90611cb3565b60405180910390fd5b61061d8282610f9a565b5050565b6060600980548060200260200160405190810160405280929190818152602001828054801561068f57602002820191906000526020600020906000905b825461010083900a900460ff16151581526020600192830181810494850194909303909202910180841161065e5790505b5050505050905090565b6060600880548060200260200160405190810160405280929190818152602001828054801561068f57602002820191906000526020600020905b8154815260200190600101908083116106d3575050505050905090565b60017f00000000000000000000000000000000000000000000000000000000000000004210158082146107355760405162461bcd60e51b815260040161060a90611ce8565b600c5460ff16156107785760405162461bcd60e51b815260206004820152600d60248201526c105b1c9958591e481cddd95c1d609a1b604482015260640161060a565b600c805460ff19166001179055600a546040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169180156108fc02916000818181858888f193505050501580156107dc573d6000803e3d6000fd5b50600c5461010090046001600160a01b0316600b5460405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482019290925291169063a9059cbb90604401602060405180830381600087803b15801561085c57600080fd5b505af1158015610870573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108949190611b07565b507f993934f55ac7d2e69b3ccbf2ec86a5914266cf10029628879d2dcdb8fd1f2f6e600a54600b546040516108d3929190918252602082015260400190565b60405180910390a15050565b60045460ff166109225760405162461bcd60e51b815260206004820152600e60248201526d273790313abcb7baba103cb2ba1760911b604482015260640161060a565b60006109308260025461114c565b604051909150339082156108fc029083906000818181858888f19350505050158015610960573d6000803e3d6000fd5b5060408051338152602081018490529081018290527fe8b9a97a7259cc520260b6c379e702b1ae5349b162fab7f7ba298fcc1d859340906060016108d3565b60045460ff16156109fc5760405162461bcd60e51b815260206004820152602160248201527f416c62756d2068617320616c7265616479206265656e20626f75676874206f756044820152601d60fa1b606482015260840161060a565b6001546001600160a01b03163314610a565760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74207468652062757965722e0000000000000000604482015260640161060a565b6002543414610a995760405162461bcd60e51b815260206004820152600f60248201526e2737ba1032b737bab3b41022aa241760891b604482015260640161060a565b6003544210610aea5760405162461bcd60e51b815260206004820152601e60248201527f4275796f75742074696d656f757420616c7265616479207061737365642e0000604482015260640161060a565b610af261127a565b6004805460ff1916600190811790915554600254604080516001600160a01b03909316835260208301919091527f63e547ec8630574e3f3d7c91efd6420a969b8d4b668474f22e442944d9cd7a13910160405180910390a1565b6000546001600160a01b03163314610b765760405162461bcd60e51b815260040161060a90611cb3565b610b80600061139f565b565b6000546001600160a01b03163314610bac5760405162461bcd60e51b815260040161060a90611cb3565b61061d82826113ef565b6000546001600160a01b03163314610be05760405162461bcd60e51b815260040161060a90611cb3565b61061d8282611582565b6000546001600160a01b03163314610c145760405162461bcd60e51b815260040161060a90611cb3565b610c1d81600655565b50565b60007f00000000000000000000000000000000000000000000000000000000000000004210801590610c645760405162461bcd60e51b815260040161060a90611ce8565b7f0000000000000000000000000000000000000000000000000000000000000000421015610cd45760405162461bcd60e51b815260206004820152601860248201527f53616c6520686173206e6f742073746172746564207965740000000000000000604482015260640161060a565b6000610d007f000000000000000000000000000000000000000000000000000000000000000034611dba565b905080600b541015610d635760405162461bcd60e51b815260206004820152602660248201527f417474656d7074656420746f20707572636861736520746f6f206d616e7920746044820152656f6b656e732160d01b606482015260840161060a565b80600b6000828254610d759190611dd9565b9091555050600c5461010090046001600160a01b031660405163a9059cbb60e01b8152336004820152602481018390526001600160a01b03919091169063a9059cbb90604401602060405180830381600087803b158015610dd557600080fd5b505af1158015610de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0d9190611b07565b5034600a6000828254610e209190611d82565b9091555050604080513381526020810183905234918101919091527f7ceac0b8ee1aa05d6bffe30efcb415d68896c61a7fc61e16d6ec0a7056e93ab0906060015b60405180910390a1505050565b6060600780548060200260200160405190810160405280929190818152602001828054801561068f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ea8575050505050905090565b6000546001600160a01b03163314610ef95760405162461bcd60e51b815260040161060a90611cb3565b610c1d81611837565b6000546001600160a01b03163314610f2c5760405162461bcd60e51b815260040161060a90611cb3565b6001600160a01b038116610f915760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161060a565b610c1d8161139f565b60045460ff1615610fed5760405162461bcd60e51b815260206004820152601e60248201527f41206275796f75742077617320616c726561647920636f6d706c657465640000604482015260640161060a565b6003544210158061100757506001546001600160a01b0316155b6110535760405162461bcd60e51b815260206004820152601760248201527f41206275796f757420697320696e2070726f6772657373000000000000000000604482015260640161060a565b6005548110156110cb5760405162461bcd60e51b815260206004820152603f60248201527f416c62756d2063616e277420626520626f75676874206f757420666f7220616d60448201527f6f756e74206c657373207468616e206d696e5265736572766550726963652100606482015260840161060a565b600180546001600160a01b0319166001600160a01b03841617905560028190556006546110f89042611d82565b6003819055600154600254604080516001600160a01b03909316835260208301919091528101919091527f5cf900a52f5bf9cf30acfefb6ef844f5592718546c60bce2c8002b4b5caea7a0906060016108d3565b600c546040516323b872dd60e01b815260009161010090046001600160a01b0316906323b872dd9061118690339030908890600401611bc9565b602060405180830381600087803b1580156111a057600080fd5b505af11580156111b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d89190611b07565b50600c60019054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561122757600080fd5b505afa15801561123b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125f9190611b3f565b6112698385611dba565b6112739190611d9a565b9392505050565b6000611284610e6e565b90506000611290610699565b9050600061129c610621565b905060005b8351811015611399578181815181106112ca57634e487b7160e01b600052603260045260246000fd5b6020026020010151611387578381815181106112f657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166342842e0e303386858151811061132e57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518463ffffffff1660e01b815260040161135493929190611bc9565b600060405180830381600087803b15801561136e57600080fd5b505af1158015611382573d6000803e3d6000fd5b505050505b8061139181611df0565b9150506112a1565b50505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000805b82518110156115505782818151811061141c57634e487b7160e01b600052603260045260246000fd5b602002602001015191506007828154811061144757634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166342842e0e30866008868154811061149657634e487b7160e01b600052603260045260246000fd5b90600052602060002001546040518463ffffffff1660e01b81526004016114bf93929190611bc9565b600060405180830381600087803b1580156114d957600080fd5b505af11580156114ed573d6000803e3d6000fd5b5050505060016009838154811061151457634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190066101000a81548160ff021916908315150217905550808061154890611df0565b9150506113f3565b507f3083e061477a304cc5b66494752ab2b37bb94537cbb9e49d328f44498ca7932b8383604051610e61929190611bed565b80518251146115d35760405162461bcd60e51b815260206004820181905260248201527f496e707574206172726179206c656e6768747320646f6e2774206d617463682e604482015260640161060a565b60005b825181101561180557600083828151811061160157634e487b7160e01b600052603260045260246000fd5b602002602001015190506000819050600084848151811061163257634e487b7160e01b600052603260045260246000fd5b602002602001015190506000826001600160a01b0316636352211e836040518263ffffffff1660e01b815260040161166c91815260200190565b60206040518083038186803b15801561168457600080fd5b505afa158015611698573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116bc91906118fd565b90506001600160a01b038116301461173157604051632142170760e11b81526001600160a01b038416906342842e0e906116fe90849030908790600401611bc9565b600060405180830381600087803b15801561171857600080fd5b505af115801561172c573d6000803e3d6000fd5b505050505b506007805460018082019092557fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180546001600160a01b0319166001600160a01b039590951694909417909355600880548085019091557ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155506009805491820181556000527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af60208204018054601f9092166101000a60ff02199091169055806117fd81611df0565b9150506115d6565b507fdaa83305df99008c5e651b6276ac1d3278f596842d6cd5f8a92d97eb3a3bcf4482826040516108d3929190611c2c565b60058190556040518181527fe843b3ec3b7d5c75d587692fe07d930e310983100b25808444ed339b778485ee9060200160405180910390a150565b600082601f830112611882578081fd5b8135602061189761189283611d5e565b611d2d565b80838252828201915082860187848660051b89010111156118b6578586fd5b855b858110156118d4578135845292840192908401906001016118b8565b5090979650505050505050565b6000602082840312156118f2578081fd5b813561127381611e37565b60006020828403121561190e578081fd5b815161127381611e37565b6000806000806080858703121561192e578283fd5b843561193981611e37565b935060208581013561194a81611e37565b935060408601359250606086013567ffffffffffffffff8082111561196d578384fd5b818801915088601f830112611980578384fd5b81358181111561199257611992611e21565b6119a4601f8201601f19168501611d2d565b915080825289848285010111156119b9578485fd5b8084840185840137810190920192909252939692955090935050565b600080604083850312156119e7578182fd5b82356119f281611e37565b9150602083013567ffffffffffffffff811115611a0d578182fd5b611a1985828601611872565b9150509250929050565b60008060408385031215611a35578182fd5b8235611a4081611e37565b946020939093013593505050565b60008060408385031215611a60578182fd5b823567ffffffffffffffff80821115611a77578384fd5b818501915085601f830112611a8a578384fd5b81356020611a9a61189283611d5e565b8083825282820191508286018a848660051b8901011115611ab9578889fd5b8896505b84871015611ae4578035611ad081611e37565b835260019690960195918301918301611abd565b5096505086013592505080821115611afa578283fd5b50611a1985828601611872565b600060208284031215611b18578081fd5b81518015158114611273578182fd5b600060208284031215611b38578081fd5b5035919050565b600060208284031215611b50578081fd5b5051919050565b6000815180845260208085019450808401835b83811015611b8f5781516001600160a01b031687529582019590820190600101611b6a565b509495945050505050565b6000815180845260208085019450808401835b83811015611b8f57815187529582019590820190600101611bad565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0383168152604060208201819052600090611c1190830184611b9a565b949350505050565b6020815260006112736020830184611b57565b604081526000611c3f6040830185611b57565b8281036020840152611c518185611b9a565b95945050505050565b6020808252825182820181905260009190848201906040850190845b81811015611c94578351151583529284019291840191600101611c76565b50909695505050505050565b6020815260006112736020830184611b9a565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526025908201527f53616c6520737461746520697320696e76616c696420666f722074686973206d604082015264195d1a1bd960da1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715611d5657611d56611e21565b604052919050565b600067ffffffffffffffff821115611d7857611d78611e21565b5060051b60200190565b60008219821115611d9557611d95611e0b565b500190565b600082611db557634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611dd457611dd4611e0b565b500290565b600082821015611deb57611deb611e0b565b500390565b6000600019821415611e0457611e04611e0b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610c1d57600080fdfea264697066735822122002d661ea803bac6c23ccfe1d8d311ac6f9cf8f1a586efe1b9d251737cc72d2ac64736f6c63430008040033a2646970667358221220ea51b9271b13767171828450db2bce62501b51dbc29621dcd7bb4c90b7621d4464736f6c63430008040033

Verified Source Code Full Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (200 runs)
Album.sol 88 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "./AlbumBuyoutManager.sol";
import "./AlbumNftManager.sol";
import "./AlbumTokenSaleManager.sol";

contract Album is
    Ownable,
    ERC721Holder,
    AlbumBuyoutManager,
    AlbumNftManager,
    AlbumTokenSaleManager
{
    // The token for this album.
    IERC20 public token;

    constructor(
        address governance,
        address _token,
        address creator,
        TokenSaleParams memory tokenSaleParams,
        address[] memory _nftAddrs,
        uint256[] memory _nftIds,
        uint256 _minReservePrice
    ) AlbumTokenSaleManager(creator, tokenSaleParams) {
        transferOwnership(governance);
        token = IERC20(_token);
        _addNfts(_nftAddrs, _nftIds);
        _setMinReservePrice(_minReservePrice);
    }

    function addNfts(address[] memory _nfts, uint256[] memory _ids)
        public
        onlyOwner
    {
        _addNfts(_nfts, _ids);
    }

    function sendNfts(address to, uint256[] memory idxs) public onlyOwner {
        _sendNfts(to, idxs);
    }

    function setTimeout(uint256 _timeout) public onlyOwner {
        _setTimeout(_timeout);
    }

    function sendAllToSender() internal override {
        address[] memory nfts = getNfts();
        uint256[] memory ids = getIds();
        bool[] memory sent = getSent();
        for (uint256 i = 0; i < nfts.length; i++) {
            if (!sent[i]) {
                IERC721(nfts[i]).safeTransferFrom(
                    address(this),
                    msg.sender,
                    ids[i]
                );
            }
        }
    }

    function setMinReservePrice(uint256 _minReservePrice) public onlyOwner {
        _setMinReservePrice(_minReservePrice);
    }

    function setBuyout(address _buyer, uint256 _cost) public onlyOwner {
        _setBuyout(_buyer, _cost);
    }

    function checkOwedAmount(uint256 _amount, uint256 buyoutCost)
        internal
        override
        returns (uint256 owed)
    {
        token.transferFrom(msg.sender, address(this), _amount);
        owed = (_amount * buyoutCost) / token.totalSupply();
    }

    function getToken() public view override returns (IERC20) {
        return token;
    }
}
AllowList.sol 36 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";

contract AllowList is Ownable {
    event SetAllowed(address addr, bool allowed);
    event SetBypassCheck(bool bypassCheck);

    mapping(address => bool) public allowedMap;
    bool public bypassCheck;

    constructor(address[] memory allowed) {
        for (uint256 i = 0; i < allowed.length; i++) {
            address addr = allowed[i];
            allowedMap[addr] = true;
            emit SetAllowed(addr, true);
        }
    }

    function setAllowance(address addr, bool allowed) public onlyOwner {
        require(!bypassCheck);
        allowedMap[addr] = allowed;
        emit SetAllowed(addr, allowed);
    }

    // open the gates to everyone
    function setBypassCheck(bool _bypassCheck) public onlyOwner {
        bypassCheck = _bypassCheck;
        emit SetBypassCheck(_bypassCheck);
    }

    function getIsAllowed(address addr) public view returns (bool) {
        return bypassCheck || allowedMap[addr];
    }
}
AlbumFactory.sol 185 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

import {Album} from "./Album.sol";
import {AllowList} from "./AllowList.sol";
import {IENS} from "./interfaces/IENS.sol";
import {IENSResolver} from "./interfaces/IENSResolver.sol";
import {IERC721} from "./interfaces/IERC721.sol";
import {IFactorySafeHelper} from "./interfaces/IFactorySafeHelper.sol";

contract AlbumFactory {
    event AlbumCreated(
        string name,
        address album,
        address safe,
        address realityModule,
        address token
    );

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    uint256 public constant SZNS_DAO_RAKE_DIVISOR = 100;

    AllowList public immutable ALLOW_LIST;
    IFactorySafeHelper public immutable FACTORY_SAFE_HELPER;
    IENS public immutable ENS;
    address public immutable ENS_PUBLIC_RESOLVER_ADDRESS;
    bytes32 public immutable BASE_ENS_NODE;
    address public immutable SZNS_DAO;

    struct TokenParams {
        string symbol;
        uint256 totalTokens;
    }

    constructor(
        address allowListAddress,
        address factorySafeHelperAddress,
        address ensAddress,
        address ensPublicResolverAddress,
        bytes32 baseEnsNode,
        address sznsDao
    ) {
        ALLOW_LIST = AllowList(allowListAddress);
        FACTORY_SAFE_HELPER = IFactorySafeHelper(factorySafeHelperAddress);
        ENS = IENS(ensAddress);
        BASE_ENS_NODE = baseEnsNode;
        ENS_PUBLIC_RESOLVER_ADDRESS = ensPublicResolverAddress;
        SZNS_DAO = sznsDao;
    }

    function createAlbum(
        string memory name,
        TokenParams memory tokenParams,
        Album.TokenSaleParams memory tokenSaleParams,
        // AlbumFactory contract has to be approved to transfer all of these NFTs!
        address[] calldata nftAddresses,
        uint256[] calldata nftIds,
        bytes[] calldata ensResolverData,
        uint256 minReservePrice
    ) external {
        require(
            ALLOW_LIST.getIsAllowed(msg.sender),
            "Sender not allowed to create album!"
        );
        require(
            nftAddresses.length == nftIds.length,
            "NFT address and ID arrays must have same lengths"
        );
        require(
            tokenParams.totalTokens >= 100 ether,
            "Total tokens must be at least 100 full tokens"
        );
        require(
            tokenParams.totalTokens - tokenSaleParams.numTokens >=
                tokenParams.totalTokens / SZNS_DAO_RAKE_DIVISOR,
            "Enough tokens for the szns dao rake must be left out of the (sale"
        );
        address safe;
        address realityModule;
        {
            bytes32 nameHash = keccak256(abi.encodePacked(name));
            bytes32 ensSubNode = keccak256(
                abi.encodePacked(BASE_ENS_NODE, nameHash)
            );
            require(
                ENS.owner(ensSubNode) == address(0),
                "ENS subname is already owned"
            );
            (safe, realityModule) = FACTORY_SAFE_HELPER.createAndSetupSafe(
                ensSubNode
            );
            ENS.setSubnodeOwner(BASE_ENS_NODE, nameHash, address(this));
            ENS.setResolver(ensSubNode, ENS_PUBLIC_RESOLVER_ADDRESS);
            IENSResolver(ENS_PUBLIC_RESOLVER_ADDRESS).multicall(
                ensResolverData
            );
            ENS.setOwner(ensSubNode, safe);
        }
        address token = createAndSetupToken(name, tokenParams.symbol, safe);
        address album = createAndSetupAlbum(
            safe,
            token,
            tokenSaleParams,
            nftAddresses,
            nftIds,
            minReservePrice
        );
        distributeAlbumTokens(
            token,
            tokenParams.totalTokens,
            tokenSaleParams.numTokens,
            album
        );
        emit AlbumCreated(name, album, safe, realityModule, token);
    }

    function createAndSetupToken(
        string memory name,
        string memory symbol,
        address safeAddress
    ) internal returns (address) {
        ERC20PresetMinterPauser token = new ERC20PresetMinterPauser{salt: ""}(
            name,
            symbol
        );
        token.grantRole(DEFAULT_ADMIN_ROLE, safeAddress);
        token.grantRole(MINTER_ROLE, safeAddress);
        token.grantRole(PAUSER_ROLE, safeAddress);
        return address(token);
    }

    function createAndSetupAlbum(
        address safeAddress,
        address tokenAddress,
        Album.TokenSaleParams memory tokenSaleParams,
        address[] calldata nftAddresses,
        uint256[] calldata nftIds,
        uint256 minReservePrice
    ) internal returns (address) {
        bytes memory creationCode = abi.encodePacked(
            type(Album).creationCode,
            abi.encode(
                safeAddress,
                tokenAddress,
                msg.sender,
                tokenSaleParams,
                nftAddresses,
                nftIds,
                minReservePrice
            )
        );
        address albumAddr = Create2.computeAddress("", keccak256(creationCode));
        for (uint256 i = 0; i < nftAddresses.length; i++) {
            IERC721(nftAddresses[i]).safeTransferFrom(
                msg.sender,
                albumAddr,
                nftIds[i]
            );
        }
        return Create2.deploy(0, "", creationCode);
    }

    function distributeAlbumTokens(
        address _token,
        uint256 totalTokens,
        uint256 amountSold,
        address album
    ) internal {
        require(totalTokens >= amountSold);
        require(totalTokens > 0);
        ERC20PresetMinterPauser token = ERC20PresetMinterPauser(_token);
        // Send tokens to be sold to the Album, which manages the sale.
        token.mint(album, amountSold);
        uint256 sznsDaoRake = totalTokens / SZNS_DAO_RAKE_DIVISOR;
        // Send a small amount of the Album tokens as a rake to the szns dao.
        token.mint(SZNS_DAO, sznsDaoRake);
        // Send the rest of the tokens to the Album creator.
        token.mint(msg.sender, (totalTokens - amountSold) - sznsDaoRake);
    }
}
AlbumNftManager.sol 56 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

abstract contract AlbumNftManager {
    event AddNfts(address[] nfts, uint256[] ids);
    event SendNfts(address to, uint256[] idxs);

    // NFTs owned by this album.
    address[] private nfts;
    uint256[] private ids;
    bool[] private sent;

    function getNfts() public view returns (address[] memory) {
        return nfts;
    }

    function getIds() public view returns (uint256[] memory) {
        return ids;
    }

    function getSent() public view returns (bool[] memory) {
        return sent;
    }

    function _addNfts(address[] memory _nfts, uint256[] memory _ids) internal {
        require(
            _nfts.length == _ids.length,
            "Input array lenghts don't match."
        );
        for (uint256 i = 0; i < _nfts.length; i++) {
            address nftAddr = _nfts[i];
            IERC721 nft = IERC721(nftAddr);
            uint256 id = _ids[i];
            address owner = nft.ownerOf(id);
            if (owner != address(this)) {
                nft.safeTransferFrom(owner, address(this), id);
            }
            nfts.push(nftAddr);
            ids.push(id);
            sent.push(false);
        }
        emit AddNfts(_nfts, _ids);
    }

    function _sendNfts(address to, uint256[] memory idxs) internal {
        uint256 idx;
        for (uint256 i = 0; i < idxs.length; i++) {
            idx = idxs[i];
            IERC721(nfts[idx]).safeTransferFrom(address(this), to, ids[idx]);
            sent[idx] = true;
        }
        emit SendNfts(to, idxs);
    }
}
IENS.sol 32 lines
pragma solidity >=0.8.4;

// pared down version of import @ensdomains/ens-contracts/contracts/registry/ENS.sol

interface IENS {
    function setRecord(
        bytes32 node,
        address _owner,
        address resolver,
        uint64 ttl
    ) external;

    function setSubnodeRecord(
        bytes32 node,
        bytes32 label,
        address _owner,
        address resolver,
        uint64 ttl
    ) external;

    function setSubnodeOwner(
        bytes32 node,
        bytes32 label,
        address _owner
    ) external returns (bytes32);

    function setResolver(bytes32 node, address resolver) external;

    function setOwner(bytes32 node, address _owner) external;

    function owner(bytes32 node) external view returns (address);
}
AlbumBuyoutManager.sol 86 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

abstract contract AlbumBuyoutManager {
    event BuyoutSet(address buyer, uint256 cost, uint256 end);
    event Buyout(address buyer, uint256 cost);
    event BuyoutPortionClaimed(address claimer, uint256 amount, uint256 owed);
    event MinReservePriceSet(uint256 minReservePrice);

    address private buyer;
    uint256 private buyoutCost;
    uint256 private buyoutEnd;
    bool private bought;
    uint256 private minReservePrice;
    // Initialized to 7 days in seconds
    uint256 private timeout = 60 * 60 * 24 * 7;

    function sendAllToSender() internal virtual;

    function checkOwedAmount(uint256 _amount, uint256 _buyoutCost)
        internal
        virtual
        returns (uint256 owed);

    // Requires no completed or ongoing buyout.
    modifier noBuyout() {
        require(!bought, "A buyout was already completed");
        require(
            block.timestamp >= buyoutEnd || buyer == address(0),
            "A buyout is in progress"
        );
        _;
    }

    function getBuyoutData()
        public
        view
        returns (
            address _buyer,
            uint256 _buyoutCost,
            uint256 _buyoutEnd,
            bool _bought,
            uint256 _timeout,
            uint256 _minReservePrice
        )
    {
        return (buyer, buyoutCost, buyoutEnd, bought, timeout, minReservePrice);
    }

    function _setTimeout(uint256 _timeout) internal {
        timeout = _timeout;
    }

    function _setMinReservePrice(uint256 _minReservePrice) internal {
        minReservePrice = _minReservePrice;
        emit MinReservePriceSet(_minReservePrice);
    }

    function _setBuyout(address _buyer, uint256 _cost) internal noBuyout {
        require(
            _cost >= minReservePrice,
            "Album can't be bought out for amount less than minReservePrice!"
        );
        buyer = _buyer;
        buyoutCost = _cost;
        buyoutEnd = block.timestamp + timeout;
        emit BuyoutSet(buyer, buyoutCost, buyoutEnd);
    }

    function buyout() public payable {
        require(!bought, "Album has already been bought out");
        require(msg.sender == buyer, "Caller is not the buyer.");
        require(msg.value == buyoutCost, "Not enough ETH.");
        require(block.timestamp < buyoutEnd, "Buyout timeout already passed.");
        sendAllToSender();
        bought = true;
        emit Buyout(buyer, buyoutCost);
    }

    function claim(uint256 _amount) public {
        require(bought, "No buyout yet.");
        uint256 owed = checkOwedAmount(_amount, buyoutCost);
        payable(msg.sender).transfer(owed);
        emit BuyoutPortionClaimed(msg.sender, _amount, owed);
    }
}
IERC721.sol 21 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// Pared down version of @openzeppelin/contracts/token/ERC721/ERC721.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}.
 */
interface IERC721 {
    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
}
AlbumTokenSaleManager.sol 102 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

abstract contract AlbumTokenSaleManager {
    event SaleInitialized(
        address creator,
        uint256 tokensPerMilliEth,
        uint256 saleStart,
        uint256 saleEnd,
        uint256 numTokens
    );
    event TokenSale(address buyer, uint256 amount, uint256 paid);
    event SaleSwept(uint256 saleProceeds, uint256 amountUnsold);

    uint256 public constant MILLIETH = 1e15;

    address public immutable CREATOR;
    // Number of tokens to sell per wei (1e-18 ETH)
    uint256 public immutable TOKENS_PER_WEI;
    uint256 public immutable SALE_START;
    uint256 public immutable SALE_END;

    uint256 private saleProceeds;
    uint256 private amountUnsold;
    bool private swept;

    modifier saleOver(bool want) {
        bool isOver = block.timestamp >= SALE_END;
        require(want == isOver, "Sale state is invalid for this method");
        _;
    }

    struct TokenSaleParams {
        uint256 price;
        uint256 saleStart;
        uint256 saleEnd;
        uint256 numTokens;
    }

    constructor(address creator, TokenSaleParams memory params) {
        require(params.saleStart < params.saleEnd);
        CREATOR = creator;
        TOKENS_PER_WEI = params.price;
        SALE_START = params.saleStart;
        SALE_END = params.saleEnd;
        amountUnsold = params.numTokens;
        emit SaleInitialized(
            creator,
            params.price,
            params.saleStart,
            params.saleEnd,
            params.numTokens
        );
    }

    function getToken() public view virtual returns (IERC20 token);

    function buyTokens() public payable saleOver(false) {
        require(block.timestamp >= SALE_START, "Sale has not started yet");
        uint256 amount = msg.value * TOKENS_PER_WEI;
        require(amountUnsold >= amount, "Attempted to purchase too many tokens!");
        amountUnsold -= amount;
        getToken().transfer(msg.sender, amount);
        saleProceeds += msg.value;
        emit TokenSale(msg.sender, amount, msg.value);
    }

    // Anyone can trigger a sweep, but the proceeds always get sent to the creator.
    function sweepProceeds() public saleOver(true) {
        require(!swept, "Already swept");
        swept = true;
        payable(CREATOR).transfer(saleProceeds);
        getToken().transfer(CREATOR, amountUnsold);
        emit SaleSwept(saleProceeds, amountUnsold);
    }

    function getTokenSaleData()
        public
        view
        returns (
            address creator,
            uint256 tokensPerWei,
            uint256 saleStart,
            uint256 saleEnd,
            uint256 _saleProceeds,
            uint256 _amountUnsold,
            bool _swept
        )
    {
        return (
            CREATOR,
            TOKENS_PER_WEI,
            SALE_START,
            SALE_END,
            saleProceeds,
            amountUnsold,
            swept
        );
    }
}
IENSResolver.sol 9 lines
pragma solidity >=0.8.4;

// Pared down from https://github.com/ensdomains/ens-contracts/blob/master/contracts/resolvers/PublicResolver.sol

interface IENSResolver {
    function multicall(bytes[] calldata data)
        external
        returns (bytes[] memory results);
}
Context.sol 23 lines
// 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;
    }
}
Create2.sol 64 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(
        uint256 amount,
        bytes32 salt,
        bytes memory bytecode
    ) internal returns (address) {
        address addr;
        require(address(this).balance >= amount, "Create2: insufficient balance");
        require(bytecode.length != 0, "Create2: bytecode length is zero");
        assembly {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "Create2: Failed on deploy");
        return addr;
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(
        bytes32 salt,
        bytes32 bytecodeHash,
        address deployer
    ) internal pure returns (address) {
        bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
        return address(uint160(uint256(_data)));
    }
}
Strings.sol 66 lines
// 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);
    }
}
Ownable.sol 71 lines
// 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);
    }
}
IFactorySafeHelper.sol 8 lines
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

interface IFactorySafeHelper {
    function createAndSetupSafe(bytes32 salt)
        external
        returns (address safeAddress, address);
}
Pausable.sol 90 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
ERC20.sol 355 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin 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 {}
}
IERC20.sol 81 lines
// 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);
}
AccessControl.sol 210 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IERC721.sol 142 lines
// 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;
}
IAccessControl.sol 87 lines
// 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;
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 24 lines
// 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);
}
EnumerableSet.sol 356 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}
IERC721Receiver.sol 26 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
AccessControlEnumerable.sol 79 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
}
IAccessControlEnumerable.sol 30 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
ERC721Holder.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}
ERC20Burnable.sol 42 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../../../utils/Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        unchecked {
            _approve(account, _msgSender(), currentAllowance - amount);
        }
        _burn(account, amount);
    }
}
ERC20Pausable.sol 32 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../../../security/Pausable.sol";

/**
 * @dev ERC20 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC20Pausable is ERC20, Pausable {
    /**
     * @dev See {ERC20-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);

        require(!paused(), "ERC20Pausable: token transfer while paused");
    }
}
IERC20Metadata.sol 27 lines
// 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);
}
ERC20PresetMinterPauser.sol 91 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../extensions/ERC20Burnable.sol";
import "../extensions/ERC20Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";

/**
 * @dev {ERC20} token, including:
 *
 *  - ability for holders to burn (destroy) their tokens
 *  - a minter role that allows for token minting (creation)
 *  - a pauser role that allows to stop all token transfers
 *
 * This contract uses {AccessControl} to lock permissioned functions using the
 * different roles - head to its documentation for details.
 *
 * The account that deploys the contract will be granted the minter and pauser
 * roles, as well as the default admin role, which will let it grant both minter
 * and pauser roles to other accounts.
 */
contract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
     * account that deploys the contract.
     *
     * See {ERC20-constructor}.
     */
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

    /**
     * @dev Creates `amount` new tokens for `to`.
     *
     * See {ERC20-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to, uint256 amount) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
        _mint(to, amount);
    }

    /**
     * @dev Pauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_pause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_unpause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
        _unpause();
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override(ERC20, ERC20Pausable) {
        super._beforeTokenTransfer(from, to, amount);
    }
}

Read Contract

ALLOW_LIST 0xd964478b → address
BASE_ENS_NODE 0x179871ff → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
ENS 0x1d2e2cc4 → address
ENS_PUBLIC_RESOLVER_ADDRESS 0x9820d21b → address
FACTORY_SAFE_HELPER 0xa2a69390 → address
MINTER_ROLE 0xd5391393 → bytes32
PAUSER_ROLE 0xe63ab1e9 → bytes32
SZNS_DAO 0xae83013a → address
SZNS_DAO_RAKE_DIVISOR 0x89dc56b3 → uint256

Write Contract 1 functions

These functions modify contract state and require a wallet transaction to execute.

createAlbum 0xc56e5b66
string name
tuple tokenParams
tuple tokenSaleParams
address[] nftAddresses
uint256[] nftIds
bytes[] ensResolverData
uint256 minReservePrice

Recent Transactions

No transactions found for this address