Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5531f96bb9e9559ae9880cC0109e06eF477AeF8e
Balance 0 ETH
Nonce 19
Code Size 13662 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

13662 bytes
0x60806040523480156200001157600080fd5b5060043610620001e95760003560e01c80638129fc1c116200010d578063d508229e11620000a3578063ee00bcb1116200007a578063ee00bcb11462000524578063f851a440146200053b578063f89c424b146200054f578063ff7dd57f146200056657600080fd5b8063d508229e1462000434578063dc90c7fd14620004ad578063e74de31f146200050d57600080fd5b8063a5e90eee11620000e4578063a5e90eee14620003d8578063ae0aba4d14620003ef578063b723c1aa1462000406578063c7c24386146200041d57600080fd5b80638129fc1c14620003a357806384ef8ffc14620003ad578063a04c507914620003c157600080fd5b80635777c36c116200018357806363ca6db7116200015a57806363ca6db7146200030157806364a04c6214620003185780637316555914620003755780637e110c5f146200038c57600080fd5b80635777c36c14620002ad5780635b6beeb914620002c45780635f5a361714620002ea57600080fd5b80632678224711620001c45780632678224714620002285780633e1af76414620002595780634b07df8b146200027f5780634dd18bf5146200029657600080fd5b80630e18b68114620001ee57806310bba1e314620001fa57806315a411501462000211575b600080fd5b620001f86200057d565b005b620001f86200020b36600462002231565b6200064d565b620001f86200022236600462002289565b6200076d565b6034546200023c906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620002706200026a366004620022a9565b620007b1565b604051620002509190620022cc565b620001f862000290366004620022f1565b62000805565b620001f8620002a736600462002289565b620009fb565b6200023c620002be366004620022f1565b62000a9a565b620002db620002d5366004620022f1565b62000c38565b60405190815260200162000250565b620001f8620002fb36600462002231565b62000c6a565b620001f862000312366004620022f1565b62000d11565b62000270620003293660046200232a565b604080518082019091526000808252602082015250600090815260696020908152604091829020825180840190935280546001600160a01b039081168452600190910154169082015290565b620001f86200038636600462002344565b62000f01565b620001f86200039d366004620023af565b62000fb3565b620001f8620010b4565b6068546200023c906001600160a01b031681565b620001f8620003d236600462002231565b620011f3565b620001f8620003e936600462002430565b62001356565b620001f86200040036600462002231565b62001400565b620001f862000417366004620023af565b620014a4565b6200023c6200042e36600462002467565b6200159e565b6200049d620004453660046200232a565b6069602090815260009182526040918290208251808401845281546001600160a01b03908116825260018301548116828501528451808601909552600283015481168552600390920154909116918301919091529082565b604051620002509291906200250e565b62000270620004be3660046200232a565b604080518082019091526000808252602082015250600090815260696020908152604091829020825180840190935260028101546001600160a01b039081168452600390910154169082015290565b620001f86200051e36600462002231565b62001716565b620001f86200053536600462002344565b620017e7565b6033546200023c906001600160a01b031681565b6200023c62000560366004620022f1565b62001892565b6200023c6200057736600462002467565b62001a23565b6034546001600160a01b0316336001600160a01b031614620005db5760405162461bcd60e51b815260206004820152601260248201527137b7363c903832b73234b7339030b236b4b760711b60448201526064015b60405180910390fd5b603354603454604080516001600160a01b0393841681529290911660208301527ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a160348054603380546001600160a01b03199081166001600160a01b03841617909155169055565b6033546001600160a01b0316336001600160a01b031614620006835760405162461bcd60e51b8152600401620005d29062002556565b6000620006908362000c38565b60008181526069602090815260409182902060020180546001600160a01b0319166001600160a01b0387169081179091558251635c60da1b60e01b8152925193945084937f28b5a58aa5fbbf70286c45a4a8e11417b9dd1f4efbacff74f4a9095e4627020e938793635c60da1b926004808401938290030181865afa1580156200071e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200074491906200257a565b604080516001600160a01b039384168152929091166020830152015b60405180910390a2505050565b6033546001600160a01b0316336001600160a01b031614620007a35760405162461bcd60e51b8152600401620005d29062002556565b620007ae8162001b94565b50565b60408051808201825260008082526020918201819052848152606982528281208482526004018252829020825180840190935280546001600160a01b03908116845260019091015416908201525b92915050565b6033546001600160a01b0316336001600160a01b0316146200083b5760405162461bcd60e51b8152600401620005d29062002556565b6000620008488262000c38565b600081815260696020526040902080546002909101549192506001600160a01b039081169116816200088e5760405162461bcd60e51b8152600401620005d2906200259a565b816001600160a01b0316816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620008d7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008fd91906200257a565b6001600160a01b031603620009555760405162461bcd60e51b815260206004820152601c60248201527f73616d652064656c656761746520696d706c656d656e746174696f6e000000006044820152606401620005d2565b604051631b2ce7f360e11b81526001600160a01b038381166004830152821690633659cfe690602401600060405180830381600087803b1580156200099957600080fd5b505af1158015620009ae573d6000803e3d6000fd5b50506040516001600160a01b038581168252841692508591507f652795ea0ac4efd35a99978df7ed4f33221582500a3ed5e0066d02d3c168aeed906020015b60405180910390a350505050565b6033546001600160a01b0316336001600160a01b03161462000a315760405162461bcd60e51b8152600401620005d29062002556565b603454604080516001600160a01b03928316815291831660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a1603480546001600160a01b0319166001600160a01b0392909216919091179055565b6033546000906001600160a01b0316336001600160a01b03161462000ad35760405162461bcd60e51b8152600401620005d29062002556565b600062000ae08362000c38565b6000818152606960205260409020600101549091506001600160a01b03168062000b1e5760405162461bcd60e51b8152600401620005d2906200259a565b6000828152606960205260409020600301546001600160a01b03161562000b825760405162461bcd60e51b815260206004820152601760248201527618995858dbdb88185b1c9958591e4819195c1b1bde5959604a1b6044820152606401620005d2565b8060405162000b919062002149565b6001600160a01b039091168152602001604051809103906000f08015801562000bbe573d6000803e3d6000fd5b5060008381526069602090815260409182902060030180546001600160a01b0319166001600160a01b0385811691821790925583519081529085169181019190915291945083917f51917e5399e9f2d64e0668ea135a20a9cc004c48362cbbb70adab1cb1847251e91015b60405180910390a25050919050565b60008160405160200162000c4d9190620025f7565b604051602081830303815290604052805190602001209050919050565b6033546001600160a01b0316336001600160a01b03161462000ca05760405162461bcd60e51b8152600401620005d29062002556565b600062000cad8362000c38565b60008181526069602090815260409182902060010180546001600160a01b0319166001600160a01b038716908117909155915191825291925082917f9fd4462b7f12a3205bf79fab508754f4360fea98f7214c2d0956b26b6cfb25a2910162000760565b6033546001600160a01b0316336001600160a01b03161462000d475760405162461bcd60e51b8152600401620005d29062002556565b600062000d548262000c38565b600081815260696020526040902060018101546003909101549192506001600160a01b0390811691168162000d9d5760405162461bcd60e51b8152600401620005d2906200259a565b816001600160a01b0316816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000de6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e0c91906200257a565b6001600160a01b03160362000e645760405162461bcd60e51b815260206004820152601c60248201527f73616d6520636f6e637265746520696d706c656d656e746174696f6e000000006044820152606401620005d2565b604051631b2ce7f360e11b81526001600160a01b038381166004830152821690633659cfe690602401600060405180830381600087803b15801562000ea857600080fd5b505af115801562000ebd573d6000803e3d6000fd5b50506040516001600160a01b038581168252841692508591507f3fe5ca200895b0c3bc212062dbc3d6329e9d6e45be96f7e89c243103002b695e90602001620009ed565b6033546001600160a01b0316336001600160a01b0316148062000f2e575062000f2e335b60659062001bde565b62000f3857600080fd5b600062000f458362000c38565b9050600062000f548362000c38565b600083815260696020908152604080832084845260040190915280822060010180546001600160a01b031916905551919250829184917f215061f3ac8489cf7489bc37c017cc4de02cf67d96d454f7c068cf167aa4406391a350505050565b6033546001600160a01b0316336001600160a01b0316148062000fdc575062000fdc3362000f25565b62000fe657600080fd5b600062000ff38462000c38565b90506000620010028462000c38565b6000838152606960205260409020600201549091506001600160a01b03166200103f5760405162461bcd60e51b8152600401620005d29062002615565b600082815260696020908152604080832084845260040182529182902080546001600160a01b0319166001600160a01b0387169081179091559151918252829184917f6ec857c6ca1ae8448b8fa03c99fffa6d43899fd913f1af415e37176918c1de7a91015b60405180910390a35050505050565b600054610100900460ff1615808015620010d55750600054600160ff909116105b80620010f15750303b158015620010f1575060005460ff166001145b620011565760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620005d2565b6000805460ff1916600117905580156200117a576000805461ff0019166101001790555b620011853362001c03565b606780546001600160a01b03191630179055620011a9620011a33390565b62001b94565b8015620007ae576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6033546001600160a01b0316336001600160a01b031614620012295760405162461bcd60e51b8152600401620005d29062002556565b6000620012368362000c38565b6000818152606960205260409081902060030154905163f2fde38b60e01b81526001600160a01b03858116600483015292935091169063f2fde38b90602401600060405180830381600087803b1580156200129057600080fd5b505af1158015620012a5573d6000803e3d6000fd5b5050506000828152606960205260409081902060020154905163f2fde38b60e01b81526001600160a01b038581166004830152909116915063f2fde38b90602401600060405180830381600087803b1580156200130157600080fd5b505af115801562001316573d6000803e3d6000fd5b50506040516001600160a01b03851681528392507f9ac1a4dc6ff84b94cecfb01d9a9016aef22e808696ab2a01be7ee5a5913e6653915060200162000760565b6033546001600160a01b0316336001600160a01b0316146200138c5760405162461bcd60e51b8152600401620005d29062002556565b8015620013a757620013a060658362001c38565b50620013b6565b620013b460658362001c4f565b505b816001600160a01b03167fbe9474bb3e78da7e315cdffa5cfa30b767fcc95bbf44a6197da60228eea1028682604051620013f4911515815260200190565b60405180910390a25050565b6033546001600160a01b0316336001600160a01b031614620014365760405162461bcd60e51b8152600401620005d29062002556565b6000620014438362000c38565b60008181526069602090815260409182902080546001600160a01b0319166001600160a01b038716908117909155915191825291925082917f1f202ce2eb9d5736516154046c94a3f2eb52907e74918e30b29cd35f4a9777e1910162000760565b6033546001600160a01b0316336001600160a01b03161480620014cd5750620014cd3362000f25565b620014d757600080fd5b6000620014e48462000c38565b90506000620014f38462000c38565b6000838152606960205260409020600301549091506001600160a01b0316620015305760405162461bcd60e51b8152600401620005d29062002615565b600082815260696020908152604080832084845260040182529182902060010180546001600160a01b0319166001600160a01b0387169081179091559151918252829184917f8d7788e1d34e352ae204231a6ee094ff591e7da62401883f465d7408540982829101620010a5565b6033546000906001600160a01b0316336001600160a01b03161480620015ca5750620015ca3362000f25565b620015d457600080fd5b6000620015e18562000c38565b90506000620015f08562000c38565b60008381526069602090815260408083208484526004019091529020549091506001600160a01b031615620016725760405162461bcd60e51b815260206004820152602160248201527f70726f647563742064656c656761746520616c7265616479206465706c6f79656044820152601960fa1b6064820152608401620005d2565b6000828152606960205260409020600201546001600160a01b03166200169b8383878462001c66565b600084815260696020908152604080832086845260040182529182902080546001600160a01b0319166001600160a01b0385169081179091559151918252919550839185917f6ec857c6ca1ae8448b8fa03c99fffa6d43899fd913f1af415e37176918c1de7a91015b60405180910390a35050509392505050565b6033546001600160a01b0316336001600160a01b0316146200174c5760405162461bcd60e51b8152600401620005d29062002556565b6000620017598362000c38565b60008181526069602090815260409182902060030180546001600160a01b0319166001600160a01b0387169081179091558251635c60da1b60e01b8152925193945084937f51917e5399e9f2d64e0668ea135a20a9cc004c48362cbbb70adab1cb1847251e938793635c60da1b926004808401938290030181865afa1580156200071e573d6000803e3d6000fd5b6033546001600160a01b0316336001600160a01b03161480620018105750620018103362000f25565b6200181a57600080fd5b6000620018278362000c38565b90506000620018368362000c38565b600083815260696020908152604080832084845260040190915280822080546001600160a01b031916905551919250829184917fe44b43f87d1b6c62e77b08cad281696e18ec007ce453b50d851e215006700ab691a350505050565b6033546000906001600160a01b0316336001600160a01b031614620018cb5760405162461bcd60e51b8152600401620005d29062002556565b6000620018d88362000c38565b6000818152606960205260409020549091506001600160a01b031680620019135760405162461bcd60e51b8152600401620005d2906200259a565b6000828152606960205260409020600201546001600160a01b031615620019775760405162461bcd60e51b815260206004820152601760248201527618995858dbdb88185b1c9958591e4819195c1b1bde5959604a1b6044820152606401620005d2565b80604051620019869062002149565b6001600160a01b039091168152602001604051809103906000f080158015620019b3573d6000803e3d6000fd5b5060008381526069602090815260409182902060020180546001600160a01b0319166001600160a01b0385811691821790925583519081529085169181019190915291945083917f28b5a58aa5fbbf70286c45a4a8e11417b9dd1f4efbacff74f4a9095e4627020e910162000c29565b6033546000906001600160a01b0316336001600160a01b0316148062001a4f575062001a4f3362000f25565b62001a5957600080fd5b600062001a668562000c38565b9050600062001a758562000c38565b60008381526069602090815260408083208484526004019091529020600101549091506001600160a01b03161562001afa5760405162461bcd60e51b815260206004820152602160248201527f70726f6475637420636f6e637265746520616c7265616479206465706c6f79656044820152601960fa1b6064820152608401620005d2565b6000828152606960205260409020600301546001600160a01b031662001b238383878462001c66565b600084815260696020908152604080832086845260040182529182902060010180546001600160a01b0319166001600160a01b0385169081179091559151918252919550839185917f8d7788e1d34e352ae204231a6ee094ff591e7da62401883f465d740854098282910162001704565b606880546001600160a01b0319166001600160a01b0383169081179091556040517f266336e06d947f6b3a30dce088e4cfb5265208872f3a05a86ef0bc1c2a7c9cfc90600090a250565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b600054610100900460ff1662001c2d5760405162461bcd60e51b8152600401620005d29062002642565b620007ae8162001dcf565b600062001bfc836001600160a01b03841662001e50565b600062001bfc836001600160a01b03841662001ea2565b60006001600160a01b03821662001c915760405162461bcd60e51b8152600401620005d29062002615565b60408051602080820188905281830187905282518083038401815260608301808552815191909201206000825260809092019283905290918291859162001cd89062002157565b62001ce5929190620026bb565b8190604051809103906000f590508015801562001d06573d6000803e3d6000fd5b50915062001d3f8285604051806040016040528060118152602001701a5b9a5d1a585b1a5e994819985a5b1959607a1b81525062001fa6565b50606854604080516001600160a01b039092166024808401919091528151808403909101815260449092018152602080830180516001600160e01b0316634dd18bf560e01b1790528151808301909252601882527f7365742070656e64696e672061646d696e206661696c656400000000000000009082015262001dc591849162001fa6565b5050949350505050565b600054610100900460ff1662001df95760405162461bcd60e51b8152600401620005d29062002642565b603380546001600160a01b0319166001600160a01b038316908117909155604080516000815260208101929092527ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc9101620011e8565b600081815260018301602052604081205462001e9957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620007ff565b506000620007ff565b6000818152600183016020526040812054801562001f9b57600062001ec9600183620026e1565b855490915060009062001edf90600190620026e1565b905081811462001f4b57600086600001828154811062001f035762001f0362002703565b906000526020600020015490508087600001848154811062001f295762001f2962002703565b6000918252602080832090910192909255918252600188019052604090208390555b855486908062001f5f5762001f5f62002719565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050620007ff565b6000915050620007ff565b606062001fb7848460008562001fbf565b949350505050565b606082471015620020225760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620005d2565b600080866001600160a01b03168587604051620020409190620025f7565b60006040518083038185875af1925050503d80600081146200207f576040519150601f19603f3d011682016040523d82523d6000602084013e62002084565b606091505b50915091506200209787838387620020a2565b979650505050505050565b60608315620021165782516000036200210e576001600160a01b0385163b6200210e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620005d2565b508162001fb7565b62001fb783838151156200212d5781518083602001fd5b8060405162461bcd60e51b8152600401620005d291906200272f565b6104e4806200274583390190565b6109008062002c2983390190565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111562002199576200219962002165565b604051601f8501601f19908116603f01168101908282118183101715620021c457620021c462002165565b81604052809350858152868686011115620021de57600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126200220a57600080fd5b62001bfc838335602085016200217b565b6001600160a01b0381168114620007ae57600080fd5b600080604083850312156200224557600080fd5b823567ffffffffffffffff8111156200225d57600080fd5b6200226b85828601620021f8565b92505060208301356200227e816200221b565b809150509250929050565b6000602082840312156200229c57600080fd5b813562001bfc816200221b565b60008060408385031215620022bd57600080fd5b50508035926020909101359150565b60408101620007ff828480516001600160a01b03908116835260209182015116910152565b6000602082840312156200230457600080fd5b813567ffffffffffffffff8111156200231c57600080fd5b62001fb784828501620021f8565b6000602082840312156200233d57600080fd5b5035919050565b600080604083850312156200235857600080fd5b823567ffffffffffffffff808211156200237157600080fd5b6200237f86838701620021f8565b935060208501359150808211156200239657600080fd5b50620023a585828601620021f8565b9150509250929050565b600080600060608486031215620023c557600080fd5b833567ffffffffffffffff80821115620023de57600080fd5b620023ec87838801620021f8565b945060208601359150808211156200240357600080fd5b506200241286828701620021f8565b925050604084013562002425816200221b565b809150509250925092565b600080604083850312156200244457600080fd5b823562002451816200221b565b9150602083013580151581146200227e57600080fd5b6000806000606084860312156200247d57600080fd5b833567ffffffffffffffff808211156200249657600080fd5b620024a487838801620021f8565b94506020860135915080821115620024bb57600080fd5b620024c987838801620021f8565b93506040860135915080821115620024e057600080fd5b508401601f81018613620024f357600080fd5b62002504868235602084016200217b565b9150509250925092565b6080810162002533828580516001600160a01b03908116835260209182015116910152565b82516001600160a01b039081166040840152602084015116606083015262001bfc565b6020808252600a908201526937b7363c9030b236b4b760b11b604082015260600190565b6000602082840312156200258d57600080fd5b815162001bfc816200221b565b6020808252601b908201527f696d706c656d656e746174696f6e206e6f74206465706c6f7965640000000000604082015260600190565b60005b83811015620025ee578181015183820152602001620025d4565b50506000910152565b600082516200260b818460208701620025d1565b9190910192915050565b60208082526013908201527218995858dbdb881b9bdd0819195c1b1bde5959606a1b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008151808452620026a7816020860160208601620025d1565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009062001fb7908301846200268d565b81810381811115620007ff57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60208152600062001bfc60208301846200268d56fe608060405234801561001057600080fd5b506040516104e43803806104e483398101604081905261002f91610151565b61003833610047565b61004181610097565b50610181565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100aa8161014260201b6101a01760201c565b6101205760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03163b151590565b60006020828403121561016357600080fd5b81516001600160a01b038116811461017a57600080fd5b9392505050565b610354806101906000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80633659cfe61461005c5780635c60da1b14610071578063715018a61461009a5780638da5cb5b146100a2578063f2fde38b146100b3575b600080fd5b61006f61006a3660046102ee565b6100c6565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b61006f61010e565b6000546001600160a01b031661007e565b61006f6100c13660046102ee565b610122565b6100ce6101af565b6100d781610209565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6101166101af565b610120600061029e565b565b61012a6101af565b6001600160a01b0381166101945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61019d8161029e565b50565b6001600160a01b03163b151590565b6000546001600160a01b031633146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018b565b6001600160a01b0381163b61027c5760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f6044820152721b881a5cc81b9bdd08184818dbdb9d1c9858dd606a1b606482015260840161018b565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561030057600080fd5b81356001600160a01b038116811461031757600080fd5b939250505056fea264697066735822122046de0e2736711d896422b3c51492e357495cbb76e5fdccdc78cc16cf74f410c064736f6c6343000811003360806040526040516109003803806109008339810160408190526100229161045b565b61002e82826000610035565b5050610585565b61003e83610100565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a260008251118061007f5750805b156100fb576100f9836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e9919061051b565b836102a360201b6100291760201c565b505b505050565b610113816102cf60201b6100551760201c565b6101725760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6101e6816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d7919061051b565b6102cf60201b6100551760201c565b61024b5760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610169565b806102827fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5060001b6102de60201b6100641760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606102c883836040518060600160405280602781526020016108d9602791396102e1565b9392505050565b6001600160a01b03163b151590565b90565b6060600080856001600160a01b0316856040516102fe9190610536565b600060405180830381855af49150503d8060008114610339576040519150601f19603f3d011682016040523d82523d6000602084013e61033e565b606091505b5090925090506103508683838761035a565b9695505050505050565b606083156103c95782516000036103c2576001600160a01b0385163b6103c25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610169565b50816103d3565b6103d383836103db565b949350505050565b8151156103eb5781518083602001fd5b8060405162461bcd60e51b81526004016101699190610552565b80516001600160a01b038116811461041c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561045257818101518382015260200161043a565b50506000910152565b6000806040838503121561046e57600080fd5b61047783610405565b60208401519092506001600160401b038082111561049457600080fd5b818501915085601f8301126104a857600080fd5b8151818111156104ba576104ba610421565b604051601f8201601f19908116603f011681019083821181831017156104e2576104e2610421565b816040528281528860208487010111156104fb57600080fd5b61050c836020830160208801610437565b80955050505050509250929050565b60006020828403121561052d57600080fd5b6102c882610405565b60008251610548818460208701610437565b9190910192915050565b6020815260008251806020840152610571816040850160208701610437565b601f01601f19169190910160400192915050565b610345806105946000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610067565b610100565b565b606061004e83836040518060600160405280602781526020016102e960279139610124565b9392505050565b6001600160a01b03163b151590565b90565b600061009a7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50546001600160a01b031690565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100fb919061024c565b905090565b3660008037600080366000845af43d6000803e80801561011f573d6000f35b3d6000fd5b6060600080856001600160a01b0316856040516101419190610299565b600060405180830381855af49150503d806000811461017c576040519150601f19603f3d011682016040523d82523d6000602084013e610181565b606091505b50915091506101928683838761019c565b9695505050505050565b60608315610210578251600003610209576001600160a01b0385163b6102095760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b508161021a565b61021a8383610222565b949350505050565b8151156102325781518083602001fd5b8060405162461bcd60e51b815260040161020091906102b5565b60006020828403121561025e57600080fd5b81516001600160a01b038116811461004e57600080fd5b60005b83811015610290578181015183820152602001610278565b50506000910152565b600082516102ab818460208701610275565b9190910192915050565b60208152600082518060208401526102d4816040850160208701610275565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122022a6bf5ebbb7518c40e703958b5c8e4d70ca6715c1e1ccf9e9591bfc86e066d164736f6c63430008110033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c6956b0f223c22716e37c24a7647fbad015648be23c137ed6803223a3c62b97264736f6c63430008110033

Verified Source Code Full Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: Yes (200 runs)
PayableBeaconFactory.sol 249 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import "@solvprotocol/contracts-v3-solidity-utils/contracts/access/AdminControl.sol";

contract PayableBeaconFactory is AdminControl {

    event NewDefaultAdmin(address indexed newDefaultAdmin);
    event NewConcreteImplementation(bytes32 indexed productType, address implementation);
    event NewDelegateImplementation(bytes32 indexed productType, address implementation);
    event NewConcreteBeacon(bytes32 indexed productType, address beacon, address implementation);
    event NewDelegateBeacon(bytes32 indexed productType, address beacon, address implementation);
    event UpgradeConcreteBeacon(bytes32 indexed productType, address indexed beacon, address newImplementation);
    event UpgradeDelegateBeacon(bytes32 indexed productType, address indexed beacon, address newImplementation);
    event TransferBeaconOwnership(bytes32 indexed productType, address newOwner);
    event NewConcreteBeaconProxy(bytes32 indexed productType, bytes32 indexed productName, address beaconProxy);
    event NewDelegateBeaconProxy(bytes32 indexed productType, bytes32 indexed productName, address beaconProxy);
    event RemoveConcreteBeaconProxy(bytes32 indexed productType, bytes32 indexed productName);
    event RemoveDelegateBeaconProxy(bytes32 indexed productType, bytes32 indexed productName);
    event SetManager(address indexed manager, bool enabled);

    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    EnumerableSetUpgradeable.AddressSet internal _managers;

    address private _self;

    address public defaultAdmin;

    struct PayableAddressPair {
        address payableDelegate;
        address payableConcrete;
    }

    struct ProductType {
        PayableAddressPair implementations;
        PayableAddressPair beacons;
        mapping(bytes32 => PayableAddressPair) proxies;
    }

    mapping(bytes32 => ProductType) public productTypes;

    modifier onlyManagers() {
        require(_msgSender() == admin || _managers.contains(_msgSender()));
        _;
    }

    function initialize() external initializer {
        __AdminControl_init(_msgSender());
        _self = address(this);
        _setDefaultAdmin(_msgSender());
    }

    function setConcreteImplementation(string memory productType_, address implementation_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        productTypes[productTypeHash].implementations.payableConcrete = implementation_;
        emit NewConcreteImplementation(productTypeHash, implementation_);
    }

    function setDelegateImplementation(string memory productType_, address implementation_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        productTypes[productTypeHash].implementations.payableDelegate = implementation_;
        emit NewDelegateImplementation(productTypeHash, implementation_);
    }

    function deployConcreteBeacon(string memory productType_) public virtual onlyAdmin returns (address beaconAddress) {
        bytes32 productTypeHash = getHash(productType_);
        address implementation = productTypes[productTypeHash].implementations.payableConcrete;
        require(implementation != address(0), "implementation not deployed");
        require(productTypes[productTypeHash].beacons.payableConcrete == address(0), "beacon already deployed");

        beaconAddress = address(new UpgradeableBeacon(implementation));
        productTypes[productTypeHash].beacons.payableConcrete = beaconAddress;
        emit NewConcreteBeacon(productTypeHash, beaconAddress, implementation);
    }

    function deployDelegateBeacon(string memory productType_) public virtual onlyAdmin returns (address beaconAddress) {
        bytes32 productTypeHash = getHash(productType_);
        address implementation = productTypes[productTypeHash].implementations.payableDelegate;
        require(implementation != address(0), "implementation not deployed");
        require(productTypes[productTypeHash].beacons.payableDelegate == address(0), "beacon already deployed");

        beaconAddress = address(new UpgradeableBeacon(implementation));
        productTypes[productTypeHash].beacons.payableDelegate = beaconAddress;
        emit NewDelegateBeacon(productTypeHash, beaconAddress, implementation);
    }

    function setConcreteBeacon(string memory productType_, address beacon_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        productTypes[productTypeHash].beacons.payableConcrete = beacon_;
        emit NewConcreteBeacon(productTypeHash, beacon_, UpgradeableBeacon(beacon_).implementation());
    }

    function setDelegateBeacon(string memory productType_, address beacon_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        productTypes[productTypeHash].beacons.payableDelegate = beacon_;
        emit NewDelegateBeacon(productTypeHash, beacon_, UpgradeableBeacon(beacon_).implementation());
    }

    function upgradeConcreteBeacon(string memory productType_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        address implementation = productTypes[productTypeHash].implementations.payableConcrete;
        address beacon = productTypes[productTypeHash].beacons.payableConcrete;

        require(implementation != address(0), "implementation not deployed");
        require(UpgradeableBeacon(beacon).implementation() != implementation, "same concrete implementation");
        UpgradeableBeacon(beacon).upgradeTo(implementation);
        emit UpgradeConcreteBeacon(productTypeHash, beacon, implementation);
    }

    function upgradeDelegateBeacon(string memory productType_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        address implementation = productTypes[productTypeHash].implementations.payableDelegate;
        address beacon = productTypes[productTypeHash].beacons.payableDelegate;

        require(implementation != address(0), "implementation not deployed");
        require(UpgradeableBeacon(beacon).implementation() != implementation, "same delegate implementation");
        UpgradeableBeacon(beacon).upgradeTo(implementation);
        emit UpgradeDelegateBeacon(productTypeHash, beacon, implementation);
    }

    function transferBeaconOwnership(string memory productType_, address newOwner_) public virtual onlyAdmin {
        bytes32 productTypeHash = getHash(productType_);
        UpgradeableBeacon(productTypes[productTypeHash].beacons.payableConcrete).transferOwnership(newOwner_);
        UpgradeableBeacon(productTypes[productTypeHash].beacons.payableDelegate).transferOwnership(newOwner_);
        emit TransferBeaconOwnership(productTypeHash, newOwner_);
    }

    function deployProductConcreteProxy(
        string memory productType_, string memory productName_, bytes memory data_
    ) public virtual onlyManagers returns (address proxy) {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        require(productTypes[productTypeHash].proxies[productNameHash].payableConcrete == address(0), "product concrete already deployed");
        
        address beaconAddress = productTypes[productTypeHash].beacons.payableConcrete;
        proxy = _deployProductProxy(productTypeHash, productNameHash, data_, beaconAddress);
        productTypes[productTypeHash].proxies[productNameHash].payableConcrete = proxy;

        emit NewConcreteBeaconProxy(productTypeHash, productNameHash, proxy);
    }

    function deployProductDelegateProxy(
        string memory productType_, string memory productName_, bytes memory data_
    ) public virtual onlyManagers returns (address proxy) {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        require(productTypes[productTypeHash].proxies[productNameHash].payableDelegate == address(0), "product delegate already deployed");
        
        address beaconAddress = productTypes[productTypeHash].beacons.payableDelegate;
        proxy = _deployProductProxy(productTypeHash, productNameHash, data_, beaconAddress);
        productTypes[productTypeHash].proxies[productNameHash].payableDelegate = proxy;

        emit NewDelegateBeaconProxy(productTypeHash, productNameHash, proxy);
    }

    function _deployProductProxy(
        bytes32 productTypeHash_, bytes32 productNameHash_, bytes memory data_, address beaconAddress_
    ) internal returns (address proxy_) {
        require(beaconAddress_ != address(0), "beacon not deployed");

        bytes32 salt = keccak256(abi.encodePacked(productTypeHash_, productNameHash_));
        proxy_ = address(new BeaconProxy{salt: salt}(beaconAddress_, new bytes(0)));

        AddressUpgradeable.functionCall(
            proxy_,
            data_,
            "initialize failed"
        );

        AddressUpgradeable.functionCall(
            proxy_,
            abi.encodeWithSelector(
                bytes4(keccak256("setPendingAdmin(address)")),
                defaultAdmin
            ),
            "set pending admin failed"
        );
    }

    function removeProductConcreteProxy(string memory productType_, string memory productName_) public virtual onlyManagers {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        delete productTypes[productTypeHash].proxies[productNameHash].payableConcrete;
        emit RemoveConcreteBeaconProxy(productTypeHash, productNameHash);
    }

    function removeProductDelegateProxy(string memory productType_, string memory productName_) public virtual onlyManagers {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        delete productTypes[productTypeHash].proxies[productNameHash].payableDelegate;
        emit RemoveDelegateBeaconProxy(productTypeHash, productNameHash);
    }

    function importProductConcreteProxy(string memory productType_, string memory productName_, address proxyAddress_) public virtual onlyManagers {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        require(productTypes[productTypeHash].beacons.payableConcrete != address(0), "beacon not deployed");
        productTypes[productTypeHash].proxies[productNameHash].payableConcrete = proxyAddress_;
        emit NewConcreteBeaconProxy(productTypeHash, productNameHash, proxyAddress_);
    }

    function importProductDelegateProxy(string memory productType_, string memory productName_, address proxyAddress_) public virtual onlyManagers {
        bytes32 productTypeHash = getHash(productType_);
        bytes32 productNameHash = getHash(productName_);
        require(productTypes[productTypeHash].beacons.payableDelegate != address(0), "beacon not deployed");
        productTypes[productTypeHash].proxies[productNameHash].payableDelegate = proxyAddress_;
        emit NewDelegateBeaconProxy(productTypeHash, productNameHash, proxyAddress_);
    }

    function getImplementations(bytes32 productTypeHash_) public view returns (PayableAddressPair memory) {
        return productTypes[productTypeHash_].implementations;
    }

    function getBeacons(bytes32 productTypeHash_) public view returns (PayableAddressPair memory) {
        return productTypes[productTypeHash_].beacons;
    }

    function getProxies(bytes32 productTypeHash_, bytes32 productNameHash_) public view returns (PayableAddressPair memory) {
        return productTypes[productTypeHash_].proxies[productNameHash_];
    }

    function setDefaultAdmin(address newDefaultAdmin_) public virtual onlyAdmin {
        _setDefaultAdmin(newDefaultAdmin_);
    }

    function setManager(address manager_, bool enabled_) public virtual onlyAdmin {
        if (enabled_) {
            _managers.add(manager_);
        } else {
            _managers.remove(manager_);
        }
        emit SetManager(manager_, enabled_);
    }

    function _setDefaultAdmin(address newDefaultAdmin_) internal virtual {
        defaultAdmin = newDefaultAdmin_;
        emit NewDefaultAdmin(newDefaultAdmin_);
    }

    function getHash(string memory name_) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(name_));
    }
}
Proxy.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)

pragma solidity ^0.8.0;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overridden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
StorageSlot.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}
IBeacon.sol 16 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
BeaconProxy.sol 61 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)

pragma solidity ^0.8.0;

import "./IBeacon.sol";
import "../Proxy.sol";
import "../ERC1967/ERC1967Upgrade.sol";

/**
 * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
 *
 * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't
 * conflict with the storage layout of the implementation behind the proxy.
 *
 * _Available since v3.4._
 */
contract BeaconProxy is Proxy, ERC1967Upgrade {
    /**
     * @dev Initializes the proxy with `beacon`.
     *
     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
     * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
     * constructor.
     *
     * Requirements:
     *
     * - `beacon` must be a contract with the interface {IBeacon}.
     */
    constructor(address beacon, bytes memory data) payable {
        _upgradeBeaconToAndCall(beacon, data, false);
    }

    /**
     * @dev Returns the current beacon address.
     */
    function _beacon() internal view virtual returns (address) {
        return _getBeacon();
    }

    /**
     * @dev Returns the current implementation address of the associated beacon.
     */
    function _implementation() internal view virtual override returns (address) {
        return IBeacon(_getBeacon()).implementation();
    }

    /**
     * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.
     *
     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.
     *
     * Requirements:
     *
     * - `beacon` must be a contract.
     * - The implementation returned by `beacon` must be a contract.
     */
    function _setBeacon(address beacon, bytes memory data) internal virtual {
        _upgradeBeaconToAndCall(beacon, data, false);
    }
}
draft-IERC1822.sol 20 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}
ERC1967Upgrade.sol 185 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}
UpgradeableBeacon.sol 65 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)

pragma solidity ^0.8.0;

import "./IBeacon.sol";
import "../../access/Ownable.sol";
import "../../utils/Address.sol";

/**
 * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
 * implementation contract, which is where they will delegate all function calls.
 *
 * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
 */
contract UpgradeableBeacon is IBeacon, Ownable {
    address private _implementation;

    /**
     * @dev Emitted when the implementation returned by the beacon is changed.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the
     * beacon.
     */
    constructor(address implementation_) {
        _setImplementation(implementation_);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function implementation() public view virtual override returns (address) {
        return _implementation;
    }

    /**
     * @dev Upgrades the beacon to a new implementation.
     *
     * Emits an {Upgraded} event.
     *
     * Requirements:
     *
     * - msg.sender must be the owner of the contract.
     * - `newImplementation` must be a contract.
     */
    function upgradeTo(address newImplementation) public virtual onlyOwner {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Sets the implementation contract address for this beacon
     *
     * Requirements:
     *
     * - `newImplementation` must be a contract.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract");
        _implementation = newImplementation;
    }
}
AddressUpgradeable.sol 219 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
ContextUpgradeable.sol 37 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}
Initializable.sol 165 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
AdminControl.sol 43 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

abstract contract AdminControl is Initializable, ContextUpgradeable {

    event NewAdmin(address oldAdmin, address newAdmin);
    event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);

    address public admin;
    address public pendingAdmin;

    modifier onlyAdmin() {
        require(_msgSender() == admin, "only admin");
        _;
    }

    function __AdminControl_init(address admin_) internal onlyInitializing {
        __AdminControl_init_unchained(admin_);
    }

    function __AdminControl_init_unchained(address admin_) internal onlyInitializing {
        admin = admin_;
        emit NewAdmin(address(0), admin_);
    }

    function setPendingAdmin(address newPendingAdmin_) external virtual onlyAdmin {
        emit NewPendingAdmin(pendingAdmin, newPendingAdmin_);
        pendingAdmin = newPendingAdmin_;        
    }

    function acceptAdmin() external virtual {
        require(_msgSender() == pendingAdmin, "only pending admin");
        emit NewAdmin(admin, pendingAdmin);
        admin = pendingAdmin;
        pendingAdmin = address(0);
    }

	uint256[48] private __gap;
}
EnumerableSetUpgradeable.sol 378 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

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.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // 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;

        /// @solidity memory-safe-assembly
        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 in 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;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

Read Contract

admin 0xf851a440 → address
defaultAdmin 0x84ef8ffc → address
getBeacons 0xdc90c7fd → tuple
getHash 0x5b6beeb9 → bytes32
getImplementations 0x64a04c62 → tuple
getProxies 0x3e1af764 → tuple
pendingAdmin 0x26782247 → address
productTypes 0xd508229e → tuple, tuple

Write Contract 20 functions

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

acceptAdmin 0x0e18b681
No parameters
deployConcreteBeacon 0x5777c36c
string productType_
returns: address
deployDelegateBeacon 0xf89c424b
string productType_
returns: address
deployProductConcreteProxy 0xff7dd57f
string productType_
string productName_
bytes data_
returns: address
deployProductDelegateProxy 0xc7c24386
string productType_
string productName_
bytes data_
returns: address
importProductConcreteProxy 0xb723c1aa
string productType_
string productName_
address proxyAddress_
importProductDelegateProxy 0x7e110c5f
string productType_
string productName_
address proxyAddress_
initialize 0x8129fc1c
No parameters
removeProductConcreteProxy 0x73165559
string productType_
string productName_
removeProductDelegateProxy 0xee00bcb1
string productType_
string productName_
setConcreteBeacon 0xe74de31f
string productType_
address beacon_
setConcreteImplementation 0x5f5a3617
string productType_
address implementation_
setDefaultAdmin 0x15a41150
address newDefaultAdmin_
setDelegateBeacon 0x10bba1e3
string productType_
address beacon_
setDelegateImplementation 0xae0aba4d
string productType_
address implementation_
setManager 0xa5e90eee
address manager_
bool enabled_
setPendingAdmin 0x4dd18bf5
address newPendingAdmin_
transferBeaconOwnership 0xa04c5079
string productType_
address newOwner_
upgradeConcreteBeacon 0x63ca6db7
string productType_
upgradeDelegateBeacon 0x4b07df8b
string productType_

Recent Transactions

No transactions found for this address