Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x09dC5e9E842Aec39348A35eD98661fDD33897fe4
Balance 0.028000 ETH
Nonce 1
Code Size 24230 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

24230 bytes
0x60806040526004361061019c5760003560e01c8063715c8b8b116100ec578063bc197c811161008a578063da7a5ad011610064578063da7a5ad0146105dd578063e14806001461061e578063f23a6e6114610649578063f4b51044146106865761019c565b8063bc197c811461055b578063d4f00c2f14610598578063d547741f146105b45761019c565b80638e942c1d116100c65780638e942c1d146104a157806391d14854146104ca578063a0b1f5dd14610507578063a217fddf146105305761019c565b8063715c8b8b1461043d5780638456cb591461045957806384b0196e146104705761019c565b80632f2ff15d11610159578063431e117911610133578063431e1179146103595780634421c2261461039757806348cf144f146103d45780635c975abb146104125761019c565b80632f2ff15d146102f057806336568abe146103195780633f4ba83a146103425761019c565b806301ffc9a7146101a15780630902b315146101de5780630c97cc5d1461021b578063150b7a021461023757806322136c5014610274578063248a9ca3146102b3575b600080fd5b3480156101ad57600080fd5b506101c860048036038101906101c39190614276565b6106af565b6040516101d591906142be565b60405180910390f35b3480156101ea57600080fd5b506102056004803603810190610200919061430f565b6106d1565b60405161021291906142be565b60405180910390f35b61023560048036038101906102309190614471565b6106f1565b005b34801561024357600080fd5b5061025e600480360381019061025991906146d9565b61072e565b60405161026b919061476b565b60405180910390f35b34801561028057600080fd5b5061029b6004803603810190610296919061430f565b610742565b6040516102aa939291906147a4565b60405180910390f35b3480156102bf57600080fd5b506102da60048036038101906102d59190614811565b6107ac565b6040516102e7919061484d565b60405180910390f35b3480156102fc57600080fd5b5061031760048036038101906103129190614868565b6107cc565b005b34801561032557600080fd5b50610340600480360381019061033b9190614868565b6107ee565b005b34801561034e57600080fd5b50610357610869565b005b34801561036557600080fd5b50610380600480360381019061037b91906148a8565b61089e565b60405161038e929190614908565b60405180910390f35b3480156103a357600080fd5b506103be60048036038101906103b99190614987565b61096b565b6040516103cb9190614b80565b60405180910390f35b3480156103e057600080fd5b506103fb60048036038101906103f69190614bc2565b610aec565b604051610409929190614908565b60405180910390f35b34801561041e57600080fd5b50610427610bce565b60405161043491906142be565b60405180910390f35b61045760048036038101906104529190614c52565b610be4565b005b34801561046557600080fd5b5061046e610c10565b005b34801561047c57600080fd5b50610485610c45565b6040516104989796959493929190614e50565b60405180910390f35b3480156104ad57600080fd5b506104c860048036038101906104c39190614ed4565b610cef565b005b3480156104d657600080fd5b506104f160048036038101906104ec9190614868565b610da7565b6040516104fe91906142be565b60405180910390f35b34801561051357600080fd5b5061052e60048036038101906105299190614f01565b610e12565b005b34801561053c57600080fd5b506105456110c7565b604051610552919061484d565b60405180910390f35b34801561056757600080fd5b50610582600480360381019061057d9190615024565b6110ce565b60405161058f919061476b565b60405180910390f35b6105b260048036038101906105ad9190614bc2565b6110e3565b005b3480156105c057600080fd5b506105db60048036038101906105d69190614868565b611492565b005b3480156105e957600080fd5b5061060460048036038101906105ff919061430f565b6114b4565b604051610615959493929190615102565b60405180910390f35b34801561062a57600080fd5b50610633611517565b6040516106409190615155565b60405180910390f35b34801561065557600080fd5b50610670600480360381019061066b9190615170565b61153d565b60405161067d919061476b565b60405180910390f35b34801561069257600080fd5b506106ad60048036038101906106a891906148a8565b611552565b005b60006106ba82611b2a565b806106ca57506106c982611ba4565b5b9050919050565b60076020528060005260406000206000915054906101000a900460ff1681565b6106f9611c1e565b610701611c64565b61070c878383611552565b61071d876000013587878787611ca5565b610725612128565b50505050505050565b600063150b7a0260e01b9050949350505050565b60056020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060026000838152602001908152602001600020600101549050919050565b6107d5826107ac565b6107de81612131565b6107e88383612145565b50505050565b6107f6612237565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461085a576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610864828261223f565b505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61089381612131565b61089b612332565b50565b600080600061090a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506108fc6108f789612394565b612437565b61245190919063ffffffff16565b9050600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614819250925050935093915050565b60608282905067ffffffffffffffff81111561098a576109896145ae565b5b6040519080825280602002602001820160405280156109c357816020015b6109b06141b3565b8152602001906001900390816109a85790505b50905060005b83839050811015610ae557600660008585848181106109eb576109ea615207565b5b9050602002013581526020019081526020016000206040518060a00160405290816000820154815260200160018201548152602001600282015481526020016003820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160149054906101000a900460ff166003811115610aa457610aa3614a1e565b5b6003811115610ab657610ab5614a1e565b5b81525050828281518110610acd57610acc615207565b5b602002602001018190525080806001019150506109c9565b5092915050565b6000806000610b5885858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050610b4a610b458961247d565b612437565b61245190919063ffffffff16565b90506005600088815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161481925092505094509492505050565b60008060009054906101000a900460ff16905090565b610bec611c1e565b610bf4611c64565b610c018585858585611ca5565b610c09612128565b5050505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a610c3a81612131565b610c426125ce565b50565b600060608060008060006060610c59612630565b610c6161266b565b46306000801b600067ffffffffffffffff811115610c8257610c816145ae565b5b604051908082528060200260200182016040528015610cb05781602001602082028036833780820191505090505b507f0f00000000000000000000000000000000000000000000000000000000000000959493929190965096509650965096509650965090919293949596565b6000801b610cfc81612131565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d62576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60006002600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b610e1a611c1e565b600082829050905060008103610e5c576040517ff1364a7400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166005600086815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f3a576005600085815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16336040517f536dd9ef000000000000000000000000000000000000000000000000000000008152600401610f31929190615236565b60405180910390fd5b610f43846126a6565b610f8457836040517fb07bd440000000000000000000000000000000000000000000000000000000008152600401610f7b919061525f565b60405180910390fd5b60005b8181101561107e57600060066000868685818110610fa857610fa7615207565b5b90506020020135815260200190815260200160002090508060000154861461100d578581600001546040517fe866f37b00000000000000000000000000000000000000000000000000000000815260040161100492919061527a565b60405180910390fd5b600081600201549050600081111561106f576000826002018190555061106e8260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168360010154838560030160149054906101000a900460ff166126d8565b5b50508080600101915050610f87565b50837febd9542f1e0e2e5ac3bdd32da20fa5c5f7a7b5d76d041602b2717c01384e818584846040516110b192919061530d565b60405180910390a2506110c2612128565b505050565b6000801b81565b600063bc197c8160e01b905095945050505050565b6110eb611c1e565b6110f3611c64565b6110ff8484848461280f565b6000838060a001906111119190615340565b905090506000810361114f576040517ff1364a7400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b838060c0019061115f9190615340565b9050811415806111805750838060e0019061117a9190615340565b90508114155b156111b7576040517fa24a13a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156113f3576000858060a001906111d49190615340565b838181106111e5576111e4615207565b5b9050602002013590506000868060c001906112009190615340565b8481811061121157611210615207565b5b9050602002013590506000878060e0019061122c9190615340565b8581811061123d5761123c615207565b5b9050602002013590506000810361128d5781816040517f92ffe02200000000000000000000000000000000000000000000000000000000815260040161128492919061527a565b60405180910390fd5b6007600084815260200190815260200160002060009054906101000a900460ff16156112f057826040517f994f3c6d0000000000000000000000000000000000000000000000000000000081526004016112e7919061525f565b60405180910390fd5b60016007600085815260200190815260200160002060006101000a81548160ff02191690831515021790555060006006600084815260200190815260200160002090508181600201541015611382578060020154826040517f65ac9d4300000000000000000000000000000000000000000000000000000000815260040161137992919061527a565b60405180910390fd5b8181600201600082825461139691906153d2565b925050819055506113e28160030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168260010154848460030160149054906101000a900460ff166126d8565b5050505080806001019150506111ba565b50600084604001351115611422576114218460600160208101906114179190614ed4565b8560400135612a38565b5b8360800160208101906114359190614ed4565b73ffffffffffffffffffffffffffffffffffffffff16857fb22135e35cb495e41ec31bf19293b4ac57c337bbc898e003cb8eecbf3f2b51748660405161147b9190615617565b60405180910390a35061148c612128565b50505050565b61149b826107ac565b6114a481612131565b6114ae838361223f565b50505050565b60066020528060005260406000206000915090508060000154908060010154908060020154908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160149054906101000a900460ff16905085565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600063f23a6e6160e01b905095945050505050565b61155a611c64565b6000836000013503611598576040517f0afa7ee800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168360400160208101906115c39190614ed4565b73ffffffffffffffffffffffffffffffffffffffff1614806116235750600073ffffffffffffffffffffffffffffffffffffffff1683606001602081019061160b9190614ed4565b73ffffffffffffffffffffffffffffffffffffffff16145b1561165a576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006005600085600001358152602001908152602001600020905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036118645760008560200135141580156116eb575042856020013511155b15611733578460200135426040517fb214079400000000000000000000000000000000000000000000000000000000815260040161172a92919061527a565b60405180910390fd5b61173e858585612af5565b6040518060600160405280866020013581526020018660400160208101906117669190614ed4565b73ffffffffffffffffffffffffffffffffffffffff1681526020018660600160208101906117949190614ed4565b73ffffffffffffffffffffffffffffffffffffffff1681525060056000876000013581526020019081526020016000206000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550905050611ae6565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146118d65780336040517f536dd9ef0000000000000000000000000000000000000000000000000000000081526004016118cd929190615236565b60405180910390fd5b6000826000015490508560200135811015801561193057508560400160208101906119019190614ed4565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b801561199d575085606001602081019061194a9190614ed4565b73ffffffffffffffffffffffffffffffffffffffff168360020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156119d4576040517f73fa69fd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8560400160208101906119e79190614ed4565b8360010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550856060016020810190611a3c9190614ed4565b8360020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008103611ac9576000866020013514611ac4576040517f9a5c64da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ae4565b8086602001351115611ae357856020013583600001819055505b5b505b7ff49f428abb4ef70c857a0f31aac19ec71a5463c0784f8f7c2eed139538f7cbc4856000013586604051611b1b9291906156ae565b60405180910390a15050505050565b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611b9d5750611b9c82612b50565b5b9050919050565b60007f4e2312e0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611c175750611c1682611b2a565b5b9050919050565b600260015403611c5a576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b611c6c610bce565b15611ca3576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b3373ffffffffffffffffffffffffffffffffffffffff166005600087815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d83576005600086815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16336040517f536dd9ef000000000000000000000000000000000000000000000000000000008152600401611d7a929190615236565b60405180910390fd5b611d8c85612bba565b611dcd57846040517f423b515f000000000000000000000000000000000000000000000000000000008152600401611dc4919061525f565b60405180910390fd5b60008484905090506000838390509050600082148015611ded5750600081145b15611e24576040517f1794b43e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600034905060008367ffffffffffffffff811115611e4557611e446145ae565b5b604051908082528060200260200182016040528015611e735781602001602082028036833780820191505090505b50905060005b84811015611f705736898983818110611e9557611e94615207565b5b905060a00201905060006003811115611eb157611eb0614a1e565b5b816080016020810190611ec491906156fc565b6003811115611ed657611ed5614a1e565b5b03611f34578060200135841015611f2a578381602001356040517f775c8a0e000000000000000000000000000000000000000000000000000000008152600401611f2192919061527a565b60405180910390fd5b8060200135840393505b611f3e8b82612bec565b8060400135838381518110611f5657611f55615207565b5b602002602001018181525050508080600101915050611e79565b5060008367ffffffffffffffff811115611f8d57611f8c6145ae565b5b604051908082528060200260200182016040528015611fc057816020015b6060815260200190600190039081611fab5790505b50905060005b8481101561209b57611ffc8b898984818110611fe557611fe4615207565b5b9050602002810190611ff79190615729565b612f49565b87878281811061200f5761200e615207565b5b90506020028101906120219190615729565b80600001906120309190615340565b80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505082828151811061208357612082615207565b5b60200260200101819052508080600101915050611fc6565b5060008311156120e257826040517fe8b016190000000000000000000000000000000000000000000000000000000081526004016120d9919061525f565b60405180910390fd5b897f0d37e701164106e522925e5c2d8daeca1343d63cfbc48a52c82750cd96a7d8808383604051612114929190615871565b60405180910390a250505050505050505050565b60018081905550565b6121428161213d612237565b6133fb565b50565b60006121518383610da7565b61222c5760016002600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506121c9612237565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019050612231565b600090505b92915050565b600033905090565b600061224b8383610da7565b156123275760006002600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506122c4612237565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a46001905061232c565b600090505b92915050565b61233a61344c565b60008060006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61237d612237565b60405161238a9190615155565b60405180910390a1565b60007f4259ebbc8005a7529634d69c77ce8af088b7d85f7f7f1d91f3274e8215daa212826000013583602001358460400160208101906123d49190614ed4565b8560600160208101906123e79190614ed4565b6040516020016123fb9594939291906158a8565b60405160208183030381529060405260405160200161241a9190615942565b604051602081830303815290604052805190602001209050919050565b600061244a61244461348c565b83613543565b9050919050565b6000806000806124618686613584565b92509250925061247182826135e0565b82935050505092915050565b60007f4ca6fa5ad7ffb95be65c74ed76c6a4c47aa77c61e11a9a2ca498a92b8b73a4848260000135836020013584604001358560600160208101906124c29190614ed4565b8660800160208101906124d59190614ed4565b878060a001906124e59190615340565b6040516020016124f69291906159c0565b60405160208183030381529060405280519060200120888060c0019061251c9190615340565b60405160200161252d9291906159c0565b60405160208183030381529060405280519060200120898060e001906125539190615340565b6040516020016125649291906159c0565b60405160208183030381529060405280519060200120604051602001612592999897969594939291906159d9565b6040516020818303038152906040526040516020016125b19190615942565b604051602081830303815290604052805190602001209050919050565b6125d6611c64565b60016000806101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612619612237565b6040516126269190615155565b60405180910390a1565b606061266660037f4e6966747949736c616e6452657761726400000000000000000000000000001161374490919063ffffffff16565b905090565b60606126a160047f310000000000000000000000000000000000000000000000000000000000000161374490919063ffffffff16565b905090565b6000806005600084815260200190815260200160002060000154905060008114806126d057508042115b915050919050565b600060038111156126ec576126eb614a1e565b5b8160038111156126ff576126fe614a1e565b5b036127135761270e3383612a38565b612809565b6001600381111561272757612726614a1e565b5b81600381111561273a57612739614a1e565b5b0361274f5761274a8433846137f4565b612808565b6002600381111561276357612762614a1e565b5b81600381111561277657612775614a1e565b5b0361278c5761278784303386613804565b612807565b60038081111561279f5761279e614a1e565b5b8160038111156127b2576127b1614a1e565b5b036127c9576127c484303386866138d5565b612806565b806040517f961dc00a0000000000000000000000000000000000000000000000000000000081526004016127fd9190615a66565b60405180910390fd5b5b5b5b50505050565b8260400135341461285d573483604001356040517f1dccdb9f00000000000000000000000000000000000000000000000000000000815260040161285492919061527a565b60405180910390fd5b8260800160208101906128709190614ed4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146128f3578260800160208101906128b59190614ed4565b336040517f3ebd5fe50000000000000000000000000000000000000000000000000000000081526004016128ea929190615236565b60405180910390fd5b8260000135421015612942574283600001356040517f3c7bd1cb00000000000000000000000000000000000000000000000000000000815260040161293992919061527a565b60405180910390fd5b8260200135421115612991574283602001356040517f10ad23fe00000000000000000000000000000000000000000000000000000000815260040161298892919061527a565b60405180910390fd5b61299a84612bba565b6129db57836040517f423b515f0000000000000000000000000000000000000000000000000000000081526004016129d2919061525f565b60405180910390fd5b6000806129ea86868686610aec565b9150915081612a3057806040517fe74c68bb000000000000000000000000000000000000000000000000000000008152600401612a279190615155565b60405180910390fd5b505050505050565b60008273ffffffffffffffffffffffffffffffffffffffff1682604051612a5e90615aa7565b60006040518083038185875af1925050503d8060008114612a9b576040519150601f19603f3d011682016040523d82523d6000602084013e612aa0565b606091505b5050905080612af057600030846000856040517fab45420f000000000000000000000000000000000000000000000000000000008152600401612ae7959493929190615b01565b60405180910390fd5b505050565b600080612b0385858561089e565b9150915081612b4957806040517fe74c68bb000000000000000000000000000000000000000000000000000000008152600401612b409190615155565b60405180910390fd5b5050505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080600560008481526020019081526020016000206000015490506000811480612be457508042105b915050919050565b600081602001351480612c46575060026003811115612c0e57612c0d614a1e565b5b816080016020810190612c2191906156fc565b6003811115612c3357612c32614a1e565b5b148015612c4557506001816020013514155b5b15612c9257806040013581602001356040517fb363ec0a000000000000000000000000000000000000000000000000000000008152600401612c8992919061527a565b60405180910390fd5b6000600660008360400135815260200190815260200160002090506000816000015403612d74578160000135816001018190555081602001358160020181905550828160000181905550816060016020810190612cef9190614ed4565b8160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550816080016020810190612d4491906156fc565b8160030160146101000a81548160ff02191690836003811115612d6a57612d69614a1e565b5b0217905550612efc565b82816000015403612eb857816060016020810190612d929190614ed4565b73ffffffffffffffffffffffffffffffffffffffff168160030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148015612df7575081600001358160010154145b8015612e495750816080016020810190612e1191906156fc565b6003811115612e2357612e22614a1e565b5b8160030160149054906101000a900460ff166003811115612e4757612e46614a1e565b5b145b15612e72578160200135816002016000828254612e669190615b54565b92505081905550612eb3565b81604001356040517f75f575a6000000000000000000000000000000000000000000000000000000008152600401612eaa919061525f565b60405180910390fd5b612efb565b8281600001546040517fe866f37b000000000000000000000000000000000000000000000000000000008152600401612ef292919061527a565b60405180910390fd5b5b60006003811115612f1057612f0f614a1e565b5b826080016020810190612f2391906156fc565b6003811115612f3557612f34614a1e565b5b14612f4457612f43826139a9565b5b505050565b6000818060000190612f5b9190615340565b9050905060008103612f99576040517f2d78d40300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80828060200190612faa9190615340565b9050141580612fca575080828060400190612fc59190615340565b905014155b15613001576040517fa24a13a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561333857600083806000019061301e9190615340565b8381811061302f5761302e615207565b5b905060200201359050600084806040019061304a9190615340565b8481811061305b5761305a615207565b5b905060200201359050600081036130ab5781816040517fb363ec0a0000000000000000000000000000000000000000000000000000000081526004016130a292919061527a565b60405180910390fd5b60006006600084815260200190815260200160002090506000816000015403613197578580602001906130de9190615340565b858181106130ef576130ee615207565b5b9050602002013581600101819055508181600201819055508681600001819055508560600160208101906131239190614ed4565b8160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060038160030160146101000a81548160ff0219169083600381111561318d5761318c614a1e565b5b0217905550613328565b868160000154036132e4578560600160208101906131b59190614ed4565b73ffffffffffffffffffffffffffffffffffffffff168160030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614801561323d575085806020019061321e9190615340565b8581811061322f5761322e615207565b5b905060200201358160010154145b801561327d575060038081111561325757613256614a1e565b5b8160030160149054906101000a900460ff16600381111561327b5761327a614a1e565b5b145b156132a257818160020160008282546132969190615b54565b925050819055506132df565b826040517f75f575a60000000000000000000000000000000000000000000000000000000081526004016132d6919061525f565b60405180910390fd5b613327565b8681600001546040517fe866f37b00000000000000000000000000000000000000000000000000000000815260040161331e92919061527a565b60405180910390fd5b5b5050508080600101915050613004565b506133f682606001602081019061334f9190614ed4565b33308580602001906133619190615340565b80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508680604001906133b19190615340565b80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050613b30565b505050565b6134058282610da7565b6134485780826040517fe2517d3f00000000000000000000000000000000000000000000000000000000815260040161343f929190615b88565b60405180910390fd5b5050565b613454610bce565b61348a576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b60007f00000000000000000000000009dc5e9e842aec39348a35ed98661fdd33897fe473ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561350857507f000000000000000000000000000000000000000000000000000000000000000146145b15613535577fdf03201aa8e6e134e4786be39d24867674685f74173ff66c21885b0a3440f7da9050613540565b61353d613c04565b90505b90565b60006040517f190100000000000000000000000000000000000000000000000000000000000081528360028201528260228201526042812091505092915050565b600080600060418451036135c95760008060006020870151925060408701519150606087015160001a90506135bb88828585613c9a565b9550955095505050506135d9565b60006002855160001b9250925092505b9250925092565b600060038111156135f4576135f3614a1e565b5b82600381111561360757613606614a1e565b5b0315613740576001600381111561362157613620614a1e565b5b82600381111561363457613633614a1e565b5b0361366b576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600381111561367f5761367e614a1e565b5b82600381111561369257613691614a1e565b5b036136d7578060001c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016136ce919061525f565b60405180910390fd5b6003808111156136ea576136e9614a1e565b5b8260038111156136fd576136fc614a1e565b5b0361373f57806040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600401613736919061484d565b60405180910390fd5b5b5050565b606060ff60001b83146137615761375a83613d8e565b90506137ee565b81805461376d90615be0565b80601f016020809104026020016040519081016040528092919081815260200182805461379990615be0565b80156137e65780601f106137bb576101008083540402835291602001916137e6565b820191906000526020600020905b8154815290600101906020018083116137c957829003601f168201915b505050505090505b92915050565b6137ff838383613e02565b505050565b60008473ffffffffffffffffffffffffffffffffffffffff163b0361386057836040517fec0164840000000000000000000000000000000000000000000000000000000081526004016138579190615155565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff166342842e0e8484846040518463ffffffff1660e01b815260040161389d93929190615c11565b600060405180830381600087803b1580156138b757600080fd5b505af11580156138cb573d6000803e3d6000fd5b5050505050505050565b60008573ffffffffffffffffffffffffffffffffffffffff163b0361393157846040517fec0164840000000000000000000000000000000000000000000000000000000081526004016139289190615155565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff1663f242432a858585856040518563ffffffff1660e01b81526004016139709493929190615c7c565b600060405180830381600087803b15801561398a57600080fd5b505af115801561399e573d6000803e3d6000fd5b505050505050505050565b600160038111156139bd576139bc614a1e565b5b8160800160208101906139d091906156fc565b60038111156139e2576139e1614a1e565b5b03613a0e57613a098160600160208101906139fd9190614ed4565b33308460200135613e81565b613b2d565b60026003811115613a2257613a21614a1e565b5b816080016020810190613a3591906156fc565b6003811115613a4757613a46614a1e565b5b03613a7357613a6e816060016020810190613a629190614ed4565b33308460000135613804565b613b2c565b600380811115613a8657613a85614a1e565b5b816080016020810190613a9991906156fc565b6003811115613aab57613aaa614a1e565b5b03613adc57613ad7816060016020810190613ac69190614ed4565b3330846000013585602001356138d5565b613b2b565b806080016020810190613aef91906156fc565b6040517f961dc00a000000000000000000000000000000000000000000000000000000008152600401613b229190615a66565b60405180910390fd5b5b5b50565b60008573ffffffffffffffffffffffffffffffffffffffff163b03613b8c57846040517fec016484000000000000000000000000000000000000000000000000000000008152600401613b839190615155565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16632eb2c2d6858585856040518563ffffffff1660e01b8152600401613bcb9493929190615cd4565b600060405180830381600087803b158015613be557600080fd5b505af1158015613bf9573d6000803e3d6000fd5b505050505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fb89e98345ee4e45c753595f1d90c5a4c347cae901896fd51d8d0e3ed3326fa9c7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc64630604051602001613c7f959493929190615d3a565b60405160208183030381529060405280519060200120905090565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c1115613cda576000600385925092509250613d84565b600060018888888860405160008152602001604052604051613cff9493929190615da9565b6020604051602081039080840390855afa158015613d21573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603613d7557600060016000801b93509350935050613d84565b8060008060001b935093509350505b9450945094915050565b60606000613d9b83613e93565b90506000602067ffffffffffffffff811115613dba57613db96145ae565b5b6040519080825280601f01601f191660200182016040528015613dec5781602001600182028036833780820191505090505b5090508181528360208201528092505050919050565b613e7c838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401613e35929190615dee565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613ee3565b505050565b613e8d84848484613f7a565b50505050565b60008060ff8360001c169050601f811115613eda576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80915050919050565b6000613f0e828473ffffffffffffffffffffffffffffffffffffffff16613ffc90919063ffffffff16565b90506000815114158015613f33575080806020019051810190613f319190615e43565b155b15613f7557826040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401613f6c9190615155565b60405180910390fd5b505050565b613ff6848573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401613faf93929190615c11565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613ee3565b50505050565b606061400a83836000614012565b905092915050565b60608147101561405957306040517fcd7860590000000000000000000000000000000000000000000000000000000081526004016140509190615155565b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1684866040516140829190615942565b60006040518083038185875af1925050503d80600081146140bf576040519150601f19603f3d011682016040523d82523d6000602084013e6140c4565b606091505b50915091506140d48683836140df565b925050509392505050565b6060826140f4576140ef8261416e565b614166565b6000825114801561411c575060008473ffffffffffffffffffffffffffffffffffffffff163b145b1561415e57836040517f9996b3150000000000000000000000000000000000000000000000000000000081526004016141559190615155565b60405180910390fd5b819050614167565b5b9392505050565b6000815111156141815780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518060a00160405280600081526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000600381111561420457614203614a1e565b5b81525090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6142538161421e565b811461425e57600080fd5b50565b6000813590506142708161424a565b92915050565b60006020828403121561428c5761428b614214565b5b600061429a84828501614261565b91505092915050565b60008115159050919050565b6142b8816142a3565b82525050565b60006020820190506142d360008301846142af565b92915050565b6000819050919050565b6142ec816142d9565b81146142f757600080fd5b50565b600081359050614309816142e3565b92915050565b60006020828403121561432557614324614214565b5b6000614333848285016142fa565b91505092915050565b600080fd5b6000608082840312156143575761435661433c565b5b81905092915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261438557614384614360565b5b8235905067ffffffffffffffff8111156143a2576143a1614365565b5b6020830191508360a08202830111156143be576143bd61436a565b5b9250929050565b60008083601f8401126143db576143da614360565b5b8235905067ffffffffffffffff8111156143f8576143f7614365565b5b6020830191508360208202830111156144145761441361436a565b5b9250929050565b60008083601f84011261443157614430614360565b5b8235905067ffffffffffffffff81111561444e5761444d614365565b5b60208301915083600182028301111561446a5761446961436a565b5b9250929050565b600080600080600080600060e0888a0312156144905761448f614214565b5b600061449e8a828b01614341565b975050608088013567ffffffffffffffff8111156144bf576144be614219565b5b6144cb8a828b0161436f565b965096505060a088013567ffffffffffffffff8111156144ee576144ed614219565b5b6144fa8a828b016143c5565b945094505060c088013567ffffffffffffffff81111561451d5761451c614219565b5b6145298a828b0161441b565b925092505092959891949750929550565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006145658261453a565b9050919050565b6145758161455a565b811461458057600080fd5b50565b6000813590506145928161456c565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6145e68261459d565b810181811067ffffffffffffffff82111715614605576146046145ae565b5b80604052505050565b600061461861420a565b905061462482826145dd565b919050565b600067ffffffffffffffff821115614644576146436145ae565b5b61464d8261459d565b9050602081019050919050565b82818337600083830152505050565b600061467c61467784614629565b61460e565b90508281526020810184848401111561469857614697614598565b5b6146a384828561465a565b509392505050565b600082601f8301126146c0576146bf614360565b5b81356146d0848260208601614669565b91505092915050565b600080600080608085870312156146f3576146f2614214565b5b600061470187828801614583565b945050602061471287828801614583565b9350506040614723878288016142fa565b925050606085013567ffffffffffffffff81111561474457614743614219565b5b614750878288016146ab565b91505092959194509250565b6147658161421e565b82525050565b6000602082019050614780600083018461475c565b92915050565b61478f816142d9565b82525050565b61479e8161455a565b82525050565b60006060820190506147b96000830186614786565b6147c66020830185614795565b6147d36040830184614795565b949350505050565b6000819050919050565b6147ee816147db565b81146147f957600080fd5b50565b60008135905061480b816147e5565b92915050565b60006020828403121561482757614826614214565b5b6000614835848285016147fc565b91505092915050565b614847816147db565b82525050565b6000602082019050614862600083018461483e565b92915050565b6000806040838503121561487f5761487e614214565b5b600061488d858286016147fc565b925050602061489e85828601614583565b9150509250929050565b600080600060a084860312156148c1576148c0614214565b5b60006148cf86828701614341565b935050608084013567ffffffffffffffff8111156148f0576148ef614219565b5b6148fc8682870161441b565b92509250509250925092565b600060408201905061491d60008301856142af565b61492a6020830184614795565b9392505050565b60008083601f84011261494757614946614360565b5b8235905067ffffffffffffffff81111561496457614963614365565b5b6020830191508360208202830111156149805761497f61436a565b5b9250929050565b6000806020838503121561499e5761499d614214565b5b600083013567ffffffffffffffff8111156149bc576149bb614219565b5b6149c885828601614931565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614a09816142d9565b82525050565b614a188161455a565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60048110614a5e57614a5d614a1e565b5b50565b6000819050614a6f82614a4d565b919050565b6000614a7f82614a61565b9050919050565b614a8f81614a74565b82525050565b60a082016000820151614aab6000850182614a00565b506020820151614abe6020850182614a00565b506040820151614ad16040850182614a00565b506060820151614ae46060850182614a0f565b506080820151614af76080850182614a86565b50505050565b6000614b098383614a95565b60a08301905092915050565b6000602082019050919050565b6000614b2d826149d4565b614b3781856149df565b9350614b42836149f0565b8060005b83811015614b73578151614b5a8882614afd565b9750614b6583614b15565b925050600181019050614b46565b5085935050505092915050565b60006020820190508181036000830152614b9a8184614b22565b905092915050565b60006101008284031215614bb957614bb861433c565b5b81905092915050565b60008060008060608587031215614bdc57614bdb614214565b5b6000614bea878288016142fa565b945050602085013567ffffffffffffffff811115614c0b57614c0a614219565b5b614c1787828801614ba2565b935050604085013567ffffffffffffffff811115614c3857614c37614219565b5b614c448782880161441b565b925092505092959194509250565b600080600080600060608688031215614c6e57614c6d614214565b5b6000614c7c888289016142fa565b955050602086013567ffffffffffffffff811115614c9d57614c9c614219565b5b614ca98882890161436f565b9450945050604086013567ffffffffffffffff811115614ccc57614ccb614219565b5b614cd8888289016143c5565b92509250509295509295909350565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b614d1c81614ce7565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015614d5c578082015181840152602081019050614d41565b60008484015250505050565b6000614d7382614d22565b614d7d8185614d2d565b9350614d8d818560208601614d3e565b614d968161459d565b840191505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000614dd98383614a00565b60208301905092915050565b6000602082019050919050565b6000614dfd82614da1565b614e078185614dac565b9350614e1283614dbd565b8060005b83811015614e43578151614e2a8882614dcd565b9750614e3583614de5565b925050600181019050614e16565b5085935050505092915050565b600060e082019050614e65600083018a614d13565b8181036020830152614e778189614d68565b90508181036040830152614e8b8188614d68565b9050614e9a6060830187614786565b614ea76080830186614795565b614eb460a083018561483e565b81810360c0830152614ec68184614df2565b905098975050505050505050565b600060208284031215614eea57614ee9614214565b5b6000614ef884828501614583565b91505092915050565b600080600060408486031215614f1a57614f19614214565b5b6000614f28868287016142fa565b935050602084013567ffffffffffffffff811115614f4957614f48614219565b5b614f5586828701614931565b92509250509250925092565b600067ffffffffffffffff821115614f7c57614f7b6145ae565b5b602082029050602081019050919050565b6000614fa0614f9b84614f61565b61460e565b90508083825260208201905060208402830185811115614fc357614fc261436a565b5b835b81811015614fec5780614fd888826142fa565b845260208401935050602081019050614fc5565b5050509392505050565b600082601f83011261500b5761500a614360565b5b813561501b848260208601614f8d565b91505092915050565b600080600080600060a086880312156150405761503f614214565b5b600061504e88828901614583565b955050602061505f88828901614583565b945050604086013567ffffffffffffffff8111156150805761507f614219565b5b61508c88828901614ff6565b935050606086013567ffffffffffffffff8111156150ad576150ac614219565b5b6150b988828901614ff6565b925050608086013567ffffffffffffffff8111156150da576150d9614219565b5b6150e6888289016146ab565b9150509295509295909350565b6150fc81614a74565b82525050565b600060a0820190506151176000830188614786565b6151246020830187614786565b6151316040830186614786565b61513e6060830185614795565b61514b60808301846150f3565b9695505050505050565b600060208201905061516a6000830184614795565b92915050565b600080600080600060a0868803121561518c5761518b614214565b5b600061519a88828901614583565b95505060206151ab88828901614583565b94505060406151bc888289016142fa565b93505060606151cd888289016142fa565b925050608086013567ffffffffffffffff8111156151ee576151ed614219565b5b6151fa888289016146ab565b9150509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060408201905061524b6000830185614795565b6152586020830184614795565b9392505050565b60006020820190506152746000830184614786565b92915050565b600060408201905061528f6000830185614786565b61529c6020830184614786565b9392505050565b600080fd5b82818337505050565b60006152bd8385614dac565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156152f0576152ef6152a3565b5b6020830292506153018385846152a8565b82840190509392505050565b600060208201905081810360008301526153288184866152b1565b90509392505050565b600080fd5b600080fd5b600080fd5b6000808335600160200384360303811261535d5761535c615331565b5b80840192508235915067ffffffffffffffff82111561537f5761537e615336565b5b60208301925060208202360383131561539b5761539a61533b565b5b509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006153dd826142d9565b91506153e8836142d9565b9250828203905081811115615400576153ff6153a3565b5b92915050565b600061541560208401846142fa565b905092915050565b600061542c6020840184614583565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126154605761545f61543e565b5b83810192508235915060208301925067ffffffffffffffff82111561548857615487615434565b5b60208202360383131561549e5761549d615439565b5b509250929050565b600082825260208201905092915050565b60006154c383856154a6565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156154f6576154f56152a3565b5b6020830292506155078385846152a8565b82840190509392505050565b600061010083016155276000840184615406565b6155346000860182614a00565b506155426020840184615406565b61554f6020860182614a00565b5061555d6040840184615406565b61556a6040860182614a00565b50615578606084018461541d565b6155856060860182614a0f565b50615593608084018461541d565b6155a06080860182614a0f565b506155ae60a0840184615443565b85830360a08701526155c18382846154b7565b925050506155d260c0840184615443565b85830360c08701526155e58382846154b7565b925050506155f660e0840184615443565b85830360e08701526156098382846154b7565b925050508091505092915050565b600060208201905081810360008301526156318184615513565b905092915050565b6080820161564a6000830183615406565b6156576000850182614a00565b506156656020830183615406565b6156726020850182614a00565b50615680604083018361541d565b61568d6040850182614a0f565b5061569b606083018361541d565b6156a86060850182614a0f565b50505050565b600060a0820190506156c36000830185614786565b6156d06020830184615639565b9392505050565b600481106156e457600080fd5b50565b6000813590506156f6816156d7565b92915050565b60006020828403121561571257615711614214565b5b6000615720848285016156e7565b91505092915050565b60008235600160800383360303811261574557615744615331565b5b80830191505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061578882614da1565b61579281856154a6565b935061579d83614dbd565b8060005b838110156157ce5781516157b58882614dcd565b97506157c083614de5565b9250506001810190506157a1565b5085935050505092915050565b60006157e7838361577d565b905092915050565b6000602082019050919050565b600061580782615751565b615811818561575c565b9350836020820285016158238561576d565b8060005b8581101561585f578484038952815161584085826157db565b945061584b836157ef565b925060208a01995050600181019050615827565b50829750879550505050505092915050565b6000604082019050818103600083015261588b8185614df2565b9050818103602083015261589f81846157fc565b90509392505050565b600060a0820190506158bd600083018861483e565b6158ca6020830187614786565b6158d76040830186614786565b6158e46060830185614795565b6158f16080830184614795565b9695505050505050565b600081519050919050565b600081905092915050565b600061591c826158fb565b6159268185615906565b9350615936818560208601614d3e565b80840191505092915050565b600061594e8284615911565b915081905092915050565b600081905092915050565b60006159708385615959565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156159a3576159a26152a3565b5b6020830292506159b48385846152a8565b82840190509392505050565b60006159cd828486615964565b91508190509392505050565b6000610120820190506159ef600083018c61483e565b6159fc602083018b614786565b615a09604083018a614786565b615a166060830189614786565b615a236080830188614795565b615a3060a0830187614795565b615a3d60c083018661483e565b615a4a60e083018561483e565b615a5861010083018461483e565b9a9950505050505050505050565b6000602082019050615a7b60008301846150f3565b92915050565b50565b6000615a91600083615906565b9150615a9c82615a81565b600082019050919050565b6000615ab282615a84565b9150819050919050565b6000819050919050565b6000819050919050565b6000615aeb615ae6615ae184615abc565b615ac6565b6142d9565b9050919050565b615afb81615ad0565b82525050565b600060a082019050615b166000830188614795565b615b236020830187614795565b615b306040830186614795565b615b3d6060830185615af2565b615b4a6080830184614786565b9695505050505050565b6000615b5f826142d9565b9150615b6a836142d9565b9250828201905080821115615b8257615b816153a3565b5b92915050565b6000604082019050615b9d6000830185614795565b615baa602083018461483e565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680615bf857607f821691505b602082108103615c0b57615c0a615bb1565b5b50919050565b6000606082019050615c266000830186614795565b615c336020830185614795565b615c406040830184614786565b949350505050565b600082825260208201905092915050565b6000615c66600083615c48565b9150615c7182615a81565b600082019050919050565b600060a082019050615c916000830187614795565b615c9e6020830186614795565b615cab6040830185614786565b615cb86060830184614786565b8181036080830152615cc981615c59565b905095945050505050565b600060a082019050615ce96000830187614795565b615cf66020830186614795565b8181036040830152615d088185614df2565b90508181036060830152615d1c8184614df2565b90508181036080830152615d2f81615c59565b905095945050505050565b600060a082019050615d4f600083018861483e565b615d5c602083018761483e565b615d69604083018661483e565b615d766060830185614786565b615d836080830184614795565b9695505050505050565b600060ff82169050919050565b615da381615d8d565b82525050565b6000608082019050615dbe600083018761483e565b615dcb6020830186615d9a565b615dd8604083018561483e565b615de5606083018461483e565b95945050505050565b6000604082019050615e036000830185614795565b615e106020830184614786565b9392505050565b615e20816142a3565b8114615e2b57600080fd5b50565b600081519050615e3d81615e17565b92915050565b600060208284031215615e5957615e58614214565b5b6000615e6784828501615e2e565b9150509291505056fea264697066735822122010f7a8ffe94043efa6dfe703be43add2d5945529e0d855b67eb63ecd695569c764736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: paris Optimization: No
AccessControl.sol 209 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

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

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

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

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

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

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

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

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

        _revokeRole(role, callerConfirmation);
    }

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

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

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

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

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
IERC5267.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.20;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}
IERC1155.sol 127 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}
IERC1155Receiver.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
ERC1155Holder.sol 42 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.20;

import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol";
import {IERC1155Receiver} from "../IERC1155Receiver.sol";

/**
 * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 */
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }

    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

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

pragma solidity ^0.8.20;

import {IERC721Receiver} from "../IERC721Receiver.sol";

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

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
ECDSA.sol 174 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError, bytes32) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}
EIP712.sol 160 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.20;

import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
 * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
 * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
 * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {IERC-5267}.
     */
    function eip712Domain()
        public
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _EIP712Name(),
            _EIP712Version(),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /**
     * @dev The name parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _name which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Name() internal view returns (string memory) {
        return _name.toStringWithFallback(_nameFallback);
    }

    /**
     * @dev The version parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _version which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Version() internal view returns (string memory) {
        return _version.toStringWithFallback(_versionFallback);
    }
}
MessageHashUtils.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.20;

import {Strings} from "../Strings.sol";

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Math.sol 415 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
Pausable.sol 119 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

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

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
ShortStrings.sol 123 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.20;

import {StorageSlot} from "./StorageSlot.sol";

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using
     * {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}
StorageSlot.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @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:
 * ```solidity
 * 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(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes 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
        }
    }

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

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

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

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}
Strings.sol 94 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
INiftyIslandReward.sol 166 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {PoolRequest, ClaimRequest, RewardItemType} from "../types/NiftyIslandReward.sol";

interface INiftyIslandReward {
    /**
     * @dev Revert with an error when the pool ID is zero.
     */
    error InvalidPoolId();

    /**
     * @dev Revert with an error when the address is the zero address.
     */
    error ZeroAddressNotAllowed();

    /**
     * @dev Revert with an error if the state has not been changed.
     */
    error StateUnchanged();

    /**
     * @dev Revert with an error when the caller is unauthorized.
     */
    error UnauthorizedCaller(address expectedAddress, address receivedAddress);

    /**
     * @dev Revert with an error when the claim reward request signer is unauthorized.
     */
    error UnauthorizedSigner(address recoveredSigner);

    /**
     * @dev Revert with an error when the claimer is unauthorized.
     */
    error UnauthorizedClaimer(address expectedAddress, address receivedAddress);

    /**
     * @dev Revert with an error when the reward belongs to a different pool.
     */
    error InvalidRewardPool(uint256 expectedPoolId, uint256 receivedPoolId);

    /**
     * @dev Revert with an error when the claim id has already been used.
     */
    error ClaimRequestUsed(uint256 claimId);

    /**
     * @dev Revert with an error when the claim request has expired.
     */
    error ClaimRequestExpired(uint256 blockTimestamp, uint256 expiresAt);

    /**
     * @dev Revert with an error when the claim request is inactive.
     */
    error ClaimRequestInactive(uint256 blockTimestamp, uint256 activeAt);

    /**
     * @dev Revert with an error if both the rewards and batchERC1155Rewards arrays are empty.
     */
    error RewardDepositArraysEmpty();

    /**
     * @dev Revert with an error if the rewardIds for a batchERC1155Reward is empty.
     */
    error BatchERC1155RewardEmpty();

    /**
     * @dev Revert with an error when the reward total is invalid.
     */
    error InvalidRewardTotal(uint256 rewardId, uint256 total);

    /**
     * @dev Revert with an error when the reward amount is invalid.
     */
    error InvalidRewardAmount(uint256 rewardId, uint256 amount);

    /**
     * @dev Revert with an error if the native value is insufficient.
     */
    error InsufficientNativeRewardBalance(uint256 balance, uint256 amount);

    /**
     * @dev Revert with an error if there is a remaining native value.
     */
    error ExcessNativeRewardBalance(uint256 balance);

    /**
     * @dev Revert with an error if reward amount exceeds the rewards balance.
     */
    error InsufficientRewardBalance(uint256 balance, uint256 amount);

    /**
     * @dev Revert with an error if the length of N arrays are not equal.
     */
    error ArrayLengthMismatch();

    /**
     * @dev Revert with an error if the rewards array is empty.
     */
    error ArrayEmpty();

    /**
     * @dev Revert with an error if the reward details does not match the existing reward.
     */
    error RewardDetailsMismatch(uint256 rewardId);

    /**
     * @dev Revert with an error if the item type is invalid.
     */
    error InvalidRewardItemType(RewardItemType itemType);

    /**
     * @dev Revert with an error if the contract address is not a valid contract.
     */
    error InvalidContract(address token);

    /**
     * @dev Revert with an error if the token transfer fails.
     */
    error TokenTransferFailed(address token, address from, address to, uint256 tokenId, uint256 amount);

    /**
     * @dev Revert with an error when the pool is active.
     */
    error PoolActive(uint256 poolId);

    /**
     * @dev Revert with an error when the pool is active.
     */
    error PoolInactive(uint256 poolId);

    /**
     * @dev Revert with an error if the end time is invalid.
     */
    error InvalidPoolExpiration(uint256 expiration, uint256 blockTimestamp);

    /**
     * @dev Revert if an attempt is made to update the expiration of a permanent pool to a non-zero value.
     */
    error PermanentPoolExpirationImmutable();

    /**
     * @dev Reverts if the provided platform fee is insufficient.
     */
    error InsufficientPlatformFee(uint256 providedFee, uint256 requiredFee);

    /**
     * @dev Emitted when a pool is created or updated.
     */
    event PoolUpserted(uint256 poolId, PoolRequest request);

    /**
     * @dev Emitted when reward(s) deposit have been processed.
     */
    event RewardsDeposited(uint256 indexed poolId, uint256[] rewardIds, uint256[][] batchRewardIds);

    /**
     * @dev Emitted when rewards are withdrawn.
     */
    event RewardsWithdrawn(uint256 indexed poolId, uint256[] rewardIds);

    /**
     * @dev Emitted when a claim request has been fulfilled.
     */
    event ClaimRequestFulfilled(uint256 indexed poolId, address indexed to, ClaimRequest request);
}
NiftyIslandReward.sol 579 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

import {TokenTransferrer} from "./TokenTransferrer.sol";

import {Pool, NewReward, NewRewardBatchERC1155, Reward, RewardItemType, ClaimRequest, PoolRequest} from "./types/NiftyIslandReward.sol";

/**
 *  @title Nifty Island Reward
 *  @notice Allows reward distributors to create reward pools from which eligible users can claim rewards.
 *  @custom:version v1.0.0
 */
contract NiftyIslandReward is
    Pausable,
    ReentrancyGuard,
    AccessControl,
    EIP712,
    TokenTransferrer,
    ERC721Holder,
    ERC1155Holder
{
    using ECDSA for bytes32;

    bytes32 private constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    bytes32 private constant CLAIM_REQUEST_TYPE_HASH =
        // prettier-ignore
        keccak256(
            "ClaimRequest("
                "uint256 startTimestamp,"
                "uint256 endTimestamp,"
                "uint256 platformFee,"
                "address platformFeeRecipient,"
                "address to,"
                "uint256[] claimIds,"
                "uint256[] rewardIds,"
                "uint256[] amounts"
            ")"
        );
    bytes32 private constant POOL_REQUEST_TYPE_HASH =
        // prettier-ignore
        keccak256(
            "PoolRequest("
                "uint256 poolId,"
                "uint256 expiration,"
                "address owner,"
                "address signer"
            ")"
        );

    mapping(uint256 poolId => Pool pool) public poolByPoolId;
    mapping(uint256 rewardId => Reward reward) public rewardByRewardId;
    mapping(uint256 claimId => bool status) public claimStatusByClaimId;

    address public poolRequestSigner;

    constructor(address _defaultAdmin, address _poolRequestSigner) EIP712("NiftyIslandReward", "1") {
        if (_defaultAdmin == address(0) || _poolRequestSigner == address(0)) {
            revert ZeroAddressNotAllowed();
        }

        _grantRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
        _grantRole(PAUSER_ROLE, _defaultAdmin);
        poolRequestSigner = _poolRequestSigner;
    }

    /**
     * @notice Invoked by pool admin to deposit rewards into the pool.
     * @dev Requires the pool to be active.
     * The contract must have necessary approvals to transfer ERC20, ERC721, and ERC1155 tokens on behalf of the pool owner.
     * The function must be called with sufficient ETH to cover the reward deposit, if necessary.
     * @param poolId The unique identifier of the pool to which rewards are being deposited.
     * @param rewards An array of rewards to be deposited into the pool.
     * @param batchERC1155Rewards An array of batch ERC1155 rewards, allowing multiple ERC1155 tokens to be deposited at once.
     */
    function depositRewards(
        uint256 poolId,
        NewReward[] calldata rewards,
        NewRewardBatchERC1155[] calldata batchERC1155Rewards
    ) external payable nonReentrant whenNotPaused {
        _depositRewards(poolId, rewards, batchERC1155Rewards);
    }

    /**
     * @notice Creates or updates a reward pool and deposits new rewards into it.
     * @dev This function allows a pool owner to create a new reward pool or update an existing one, and deposit rewards at the same time.
     * The pool details are specified in the `request` parameter, and the rewards to be deposited can include various token types like ERC20, ERC721, and ERC1155.
     * A valid signature is required from the `poolRequestSigner` to authorize the creation of the pool.
     * The function must be called with sufficient ETH to cover the reward deposit, if necessary.
     * @param request The pool details, including owner, signer, rewards, and expiration time.
     * @param rewards An array of rewards to be deposited into the pool.
     * @param batchERC1155Rewards An array of batch ERC1155 rewards, allowing multiple ERC1155 tokens to be deposited at once.
     * @param signature A signature from the `poolRequestSigner` for pool creation. Use `0x` for updates.
     */
    function upsertPoolAndDepositRewards(
        PoolRequest calldata request,
        NewReward[] calldata rewards,
        NewRewardBatchERC1155[] calldata batchERC1155Rewards,
        bytes calldata signature
    ) external payable nonReentrant whenNotPaused {
        upsertPool(request, signature);
        _depositRewards(request.poolId, rewards, batchERC1155Rewards);
    }

    /**
     * @notice Claims rewards from a specified pool.
     * @dev This function allows an eligible user to claim rewards from a pool by
     * providing a valid claim request and signature from the designated pool signer.
     * @param poolId The unique identifier of the pool from which rewards are being claimed.
     * @param request The data structure containing the details of the claim.
     * @param signature The signature from the designated pool signer authorizing the claim.
     */
    function claimRewards(
        uint256 poolId,
        ClaimRequest calldata request,
        bytes calldata signature
    ) external payable nonReentrant whenNotPaused {
        _validateClaimRequest(poolId, request, signature);

        uint256 claimIdsLength = request.claimIds.length;

        if (claimIdsLength == 0) {
            revert ArrayEmpty();
        }

        if (claimIdsLength != request.rewardIds.length || claimIdsLength != request.amounts.length) {
            revert ArrayLengthMismatch();
        }

        for (uint256 i = 0; i < claimIdsLength; i++) {
            uint256 claimId = request.claimIds[i];
            uint256 rewardId = request.rewardIds[i];
            uint256 amount = request.amounts[i];

            if (amount == 0) {
                revert InvalidRewardAmount(rewardId, amount);
            }

            if (claimStatusByClaimId[claimId]) {
                revert ClaimRequestUsed(claimId);
            }

            claimStatusByClaimId[claimId] = true;

            Reward storage existingReward = rewardByRewardId[rewardId];

            if (existingReward.total < amount) {
                revert InsufficientRewardBalance(existingReward.total, amount);
            }

            existingReward.total -= amount;

            _transferRewardToCaller(existingReward.token, existingReward.tokenId, amount, existingReward.itemType);
        }

        // Transfer platformFee to platformFeeRecipient
        if (request.platformFee > 0) {
            _performNativeTransfer(request.platformFeeRecipient, request.platformFee);
        }

        emit ClaimRequestFulfilled(poolId, request.to, request);
    }

    /**
     * @notice Withdraws all remaining rewards from a specified pool.
     * @dev Only the pool owner can call this function.
     * Rewards can only be withdrawn if the pool is inactive or if the pool is permanent (no expiry).
     * Rewards must belong to the specified pool.
     * @param poolId The unique identifier of the pool from which all rewards are being withdrawn.
     * @param rewardIds An array of reward IDs to be withdrawn from the pool.
     */
    function withdrawRewards(uint256 poolId, uint256[] calldata rewardIds) external nonReentrant {
        uint256 rewardIdsLength = rewardIds.length;

        if (rewardIdsLength == 0) {
            revert ArrayEmpty();
        }

        if (poolByPoolId[poolId].owner != msg.sender) {
            revert UnauthorizedCaller(poolByPoolId[poolId].owner, msg.sender);
        }

        if (!_isPoolRewardsWithdrawalAllowed(poolId)) {
            revert PoolActive(poolId);
        }

        for (uint256 i = 0; i < rewardIdsLength; i++) {
            Reward storage existingReward = rewardByRewardId[rewardIds[i]];

            // Ensure the reward belongs to the specified pool before withdrawing
            if (poolId != existingReward.poolId) {
                revert InvalidRewardPool(poolId, existingReward.poolId);
            }

            uint256 amountToTransfer = existingReward.total;

            if (amountToTransfer > 0) {
                existingReward.total = 0;
                _transferRewardToCaller(
                    existingReward.token,
                    existingReward.tokenId,
                    amountToTransfer,
                    existingReward.itemType
                );
            }
        }

        emit RewardsWithdrawn(poolId, rewardIds);
    }

    function getRewardsByRewardIds(uint256[] calldata rewardIds) external view returns (Reward[] memory rewards) {
        rewards = new Reward[](rewardIds.length);

        for (uint256 i = 0; i < rewardIds.length; i++) {
            rewards[i] = rewardByRewardId[rewardIds[i]];
        }

        return rewards;
    }

    /**
     * @notice Creates a new pool or updates an existing pool for reward distribution.
     * @dev This function allows a reward distributor to create a new reward pool or update an existing one.
     * A valid signature is required from the `poolRequestSigner` to authorize the creation of the pool.
     * @param request The data structure containing the details of the pool.
     * @param signature A signature from the `poolRequestSigner` for pool creation. Use `0x` for updates.
     */
    function upsertPool(PoolRequest calldata request, bytes calldata signature) public whenNotPaused {
        if (request.poolId == 0) {
            revert InvalidPoolId();
        }

        if (request.owner == address(0) || request.signer == address(0)) {
            revert ZeroAddressNotAllowed();
        }

        Pool storage existingPool = poolByPoolId[request.poolId];

        address existingOwner = existingPool.owner;

        // Pool Creation
        if (existingOwner == address(0)) {
            if (request.expiration != 0 && request.expiration <= block.timestamp) {
                revert InvalidPoolExpiration(request.expiration, block.timestamp);
            }

            _validatePoolRequest(request, signature);

            poolByPoolId[request.poolId] = Pool({
                expiration: request.expiration,
                owner: request.owner,
                signer: request.signer
            });
        } else {
            // Update existing pool
            if (existingOwner != msg.sender) {
                revert UnauthorizedCaller(existingOwner, msg.sender);
            }

            uint256 existingExpiration = existingPool.expiration;

            if (
                existingExpiration >= request.expiration &&
                existingOwner == request.owner &&
                existingPool.signer == request.signer
            ) {
                revert StateUnchanged();
            }

            existingPool.owner = request.owner;
            existingPool.signer = request.signer;

            // Update expiration only if the request meets valid conditions
            if (existingExpiration == 0) {
                // Revert if attempting to set expiration on a permanent pool
                if (request.expiration != 0) {
                    revert PermanentPoolExpirationImmutable();
                }
            } else if (request.expiration > existingExpiration) {
                // Update expiration for a time-bounded pool only if it’s being extended
                existingPool.expiration = request.expiration;
            }
        }

        emit PoolUpserted(request.poolId, request);
    }

    function verifyClaimRequestSignature(
        uint256 poolId,
        ClaimRequest calldata request,
        bytes calldata signature
    ) public view returns (bool, address) {
        address recoveredSigner = _hashTypedDataV4(_hashClaimRequest(request)).recover(signature);

        return (recoveredSigner == poolByPoolId[poolId].signer, recoveredSigner);
    }

    function verifyPoolRequestSignature(
        PoolRequest calldata request,
        bytes calldata signature
    ) public view returns (bool, address) {
        address recoveredSigner = _hashTypedDataV4(_hashPoolRequest(request)).recover(signature);

        return (recoveredSigner == poolRequestSigner, recoveredSigner);
    }

    function _depositRewards(
        uint256 poolId,
        NewReward[] calldata rewards,
        NewRewardBatchERC1155[] calldata batchERC1155Rewards
    ) internal {
        if (poolByPoolId[poolId].owner != msg.sender) {
            revert UnauthorizedCaller(poolByPoolId[poolId].owner, msg.sender);
        }

        if (!_isPoolActive(poolId)) {
            revert PoolInactive(poolId);
        }

        uint256 rewardsLength = rewards.length;
        uint256 batchERC1155RewardsLength = batchERC1155Rewards.length;

        if (rewardsLength == 0 && batchERC1155RewardsLength == 0) {
            revert RewardDepositArraysEmpty();
        }

        uint256 nativeRewardsBalance = msg.value;

        uint256[] memory rewardIds = new uint256[](rewardsLength);

        // Transfer rewards from `msg.sender` into the contract
        for (uint256 i = 0; i < rewardsLength; i++) {
            NewReward calldata reward = rewards[i];

            // Special case for native rewards
            if (reward.itemType == RewardItemType.NATIVE) {
                if (nativeRewardsBalance < reward.total) {
                    revert InsufficientNativeRewardBalance(nativeRewardsBalance, reward.total);
                }

                unchecked {
                    nativeRewardsBalance -= reward.total;
                }
            }

            _handleRewardDeposit(poolId, reward);

            rewardIds[i] = reward.rewardId;
        }

        uint256[][] memory batchRewardIds = new uint256[][](batchERC1155RewardsLength);

        // Transfer batch ERC1155 rewards from `msg.sender` into the contract.
        // Used for gas efficiency with ERC1155 reawards.
        for (uint256 i = 0; i < batchERC1155RewardsLength; i++) {
            _handleBatchERC1155RewardDeposit(poolId, batchERC1155Rewards[i]);

            batchRewardIds[i] = batchERC1155Rewards[i].rewardIds;
        }

        if (nativeRewardsBalance > 0) {
            revert ExcessNativeRewardBalance(nativeRewardsBalance);
        }

        emit RewardsDeposited(poolId, rewardIds, batchRewardIds);
    }

    function _handleRewardDeposit(uint256 poolId, NewReward calldata _reward) internal {
        if (_reward.total == 0 || (_reward.itemType == RewardItemType.ERC721 && _reward.total != 1)) {
            revert InvalidRewardTotal(_reward.rewardId, _reward.total);
        }

        Reward storage existingReward = rewardByRewardId[_reward.rewardId];
        if (existingReward.poolId == 0) {
            // Create a new reward
            existingReward.tokenId = _reward.tokenId;
            existingReward.total = _reward.total;
            existingReward.poolId = poolId;
            existingReward.token = _reward.token;
            existingReward.itemType = _reward.itemType;
        } else if (existingReward.poolId == poolId) {
            // If the reward already exists, update its total.
            if (
                existingReward.token == _reward.token &&
                existingReward.tokenId == _reward.tokenId &&
                existingReward.itemType == _reward.itemType
            ) {
                existingReward.total += _reward.total;
            } else {
                revert RewardDetailsMismatch(_reward.rewardId);
            }
        } else {
            revert InvalidRewardPool(poolId, existingReward.poolId);
        }

        // Handle the transfer of non-native tokens
        if (_reward.itemType != RewardItemType.NATIVE) {
            _transferRewardFromCaller(_reward);
        }
    }

    function _handleBatchERC1155RewardDeposit(
        uint256 poolId,
        NewRewardBatchERC1155 calldata _batchERC1155Reward
    ) internal {
        uint256 batchLength = _batchERC1155Reward.rewardIds.length;

        if (batchLength == 0) {
            revert BatchERC1155RewardEmpty();
        }

        if (_batchERC1155Reward.tokenIds.length != batchLength || _batchERC1155Reward.totals.length != batchLength) {
            revert ArrayLengthMismatch();
        }

        for (uint256 i = 0; i < batchLength; i++) {
            uint256 rewardId = _batchERC1155Reward.rewardIds[i];
            uint256 total = _batchERC1155Reward.totals[i];

            // Ensure that the reward total is not zero
            if (total == 0) {
                revert InvalidRewardTotal(rewardId, total);
            }

            Reward storage existingReward = rewardByRewardId[rewardId];

            if (existingReward.poolId == 0) {
                // Create a new reward
                existingReward.tokenId = _batchERC1155Reward.tokenIds[i];
                existingReward.total = total;
                existingReward.poolId = poolId;
                existingReward.token = _batchERC1155Reward.token;
                existingReward.itemType = RewardItemType.ERC1155;
            } else if (existingReward.poolId == poolId) {
                // If the reward already exists, update its total.
                if (
                    existingReward.token == _batchERC1155Reward.token &&
                    existingReward.tokenId == _batchERC1155Reward.tokenIds[i] &&
                    existingReward.itemType == RewardItemType.ERC1155
                ) {
                    existingReward.total += total;
                } else {
                    revert RewardDetailsMismatch(rewardId);
                }
            } else {
                revert InvalidRewardPool(poolId, existingReward.poolId);
            }
        }

        _performERC1155BatchTransfer(
            _batchERC1155Reward.token,
            msg.sender,
            address(this),
            _batchERC1155Reward.tokenIds,
            _batchERC1155Reward.totals
        );
    }

    function _isPoolActive(uint256 poolId) internal view returns (bool) {
        uint256 poolExpiration = poolByPoolId[poolId].expiration;

        return poolExpiration == 0 || block.timestamp < poolExpiration;
    }

    function _isPoolRewardsWithdrawalAllowed(uint256 poolId) internal view returns (bool) {
        uint256 poolExpiration = poolByPoolId[poolId].expiration;

        return poolExpiration == 0 || block.timestamp > poolExpiration;
    }

    function _validateClaimRequest(
        uint256 poolId,
        ClaimRequest calldata request,
        bytes calldata signature
    ) internal view {
        if (msg.value != request.platformFee) {
            revert InsufficientPlatformFee(msg.value, request.platformFee);
        }

        if (msg.sender != request.to) {
            revert UnauthorizedClaimer(request.to, msg.sender);
        }

        if (block.timestamp < request.startTimestamp) {
            revert ClaimRequestInactive(block.timestamp, request.startTimestamp);
        }

        if (block.timestamp > request.endTimestamp) {
            revert ClaimRequestExpired(block.timestamp, request.endTimestamp);
        }

        // Claim Request must fall within the pool's active window
        if (!_isPoolActive(poolId)) {
            revert PoolInactive(poolId);
        }

        (bool isValidSignature, address recoveredSigner) = verifyClaimRequestSignature(poolId, request, signature);

        if (!isValidSignature) {
            revert UnauthorizedSigner(recoveredSigner);
        }
    }

    function _validatePoolRequest(PoolRequest calldata request, bytes calldata signature) internal view {
        (bool isValidSignature, address recoveredSigner) = verifyPoolRequestSignature(request, signature);

        if (!isValidSignature) {
            revert UnauthorizedSigner(recoveredSigner);
        }
    }

    function _hashClaimRequest(ClaimRequest calldata request) internal pure returns (bytes32) {
        return
            keccak256(
                bytes.concat(
                    abi.encode(
                        CLAIM_REQUEST_TYPE_HASH,
                        request.startTimestamp,
                        request.endTimestamp,
                        request.platformFee,
                        request.platformFeeRecipient,
                        request.to,
                        keccak256(abi.encodePacked(request.claimIds)),
                        keccak256(abi.encodePacked(request.rewardIds)),
                        keccak256(abi.encodePacked(request.amounts))
                    )
                )
            );
    }

    function _hashPoolRequest(PoolRequest calldata request) internal pure returns (bytes32) {
        return
            keccak256(
                bytes.concat(
                    abi.encode(
                        POOL_REQUEST_TYPE_HASH,
                        request.poolId,
                        request.expiration,
                        request.owner,
                        request.signer
                    )
                )
            );
    }

    /**
     * @notice Sets the address of the `poolRequestSigner`.
     * @dev This function allows the admin to set a new address for the `poolRequestSigner`.
     * The signer address cannot be the zero address.
     * Can only be called by an address with the `DEFAULT_ADMIN_ROLE`.
     * @param _poolRequestSigner The new address to be set as the `poolRequestSigner`.
     */
    function setPoolRequestSigner(address _poolRequestSigner) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_poolRequestSigner == address(0)) {
            revert ZeroAddressNotAllowed();
        }

        poolRequestSigner = _poolRequestSigner;
    }

    function pause() external onlyRole(PAUSER_ROLE) {
        _pause();
    }

    function unpause() external onlyRole(PAUSER_ROLE) {
        _unpause();
    }

    function supportsInterface(bytes4 interfaceId) public view override(AccessControl, ERC1155Holder) returns (bool) {
        return AccessControl.supportsInterface(interfaceId) || ERC1155Holder.supportsInterface(interfaceId);
    }
}
TokenTransferrer.sol 84 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {INiftyIslandReward} from "./interfaces/INiftyIslandReward.sol";

import {NewReward, RewardItemType} from "./types/NiftyIslandReward.sol";

contract TokenTransferrer is INiftyIslandReward {
    function _transferRewardToCaller(address token, uint256 tokenId, uint256 amount, RewardItemType itemType) internal {
        if (itemType == RewardItemType.NATIVE) {
            _performNativeTransfer(msg.sender, amount);
        } else if (itemType == RewardItemType.ERC20) {
            _performERC20Transfer(token, msg.sender, amount);
        } else if (itemType == RewardItemType.ERC721) {
            _performERC721Transfer(token, address(this), msg.sender, tokenId);
        } else if (itemType == RewardItemType.ERC1155) {
            _performERC1155Transfer(token, address(this), msg.sender, tokenId, amount);
        } else {
            revert InvalidRewardItemType(itemType);
        }
    }

    function _transferRewardFromCaller(NewReward calldata reward) internal {
        if (reward.itemType == RewardItemType.ERC20) {
            _performERC20TransferFrom(reward.token, msg.sender, address(this), reward.total);
        } else if (reward.itemType == RewardItemType.ERC721) {
            _performERC721Transfer(reward.token, msg.sender, address(this), reward.tokenId);
        } else if (reward.itemType == RewardItemType.ERC1155) {
            _performERC1155Transfer(reward.token, msg.sender, address(this), reward.tokenId, reward.total);
        } else {
            revert InvalidRewardItemType(reward.itemType);
        }
    }

    function _performNativeTransfer(address to, uint256 amount) internal {
        (bool success, ) = payable(to).call{value: amount}("");
        if (!success) {
            revert TokenTransferFailed(address(0), address(this), to, 0, amount);
        }
    }

    function _performERC20Transfer(address token, address to, uint256 amount) internal {
        SafeERC20.safeTransfer(IERC20(token), to, amount);
    }

    function _performERC20TransferFrom(address token, address from, address to, uint256 amount) internal {
        SafeERC20.safeTransferFrom(IERC20(token), from, to, amount);
    }

    function _performERC721Transfer(address token, address from, address to, uint256 tokenId) private {
        if (token.code.length == 0) {
            revert InvalidContract(token);
        }

        IERC721(token).safeTransferFrom(from, to, tokenId);
    }

    function _performERC1155Transfer(address token, address from, address to, uint256 tokenId, uint256 amount) private {
        if (token.code.length == 0) {
            revert InvalidContract(token);
        }

        IERC1155(token).safeTransferFrom(from, to, tokenId, amount, "");
    }

    function _performERC1155BatchTransfer(
        address token,
        address from,
        address to,
        uint256[] memory tokenIds,
        uint256[] memory amounts
    ) internal {
        if (token.code.length == 0) {
            revert InvalidContract(token);
        }

        IERC1155(token).safeBatchTransferFrom(from, to, tokenIds, amounts, "");
    }
}
NiftyIslandReward.sol 56 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

enum RewardItemType {
    NATIVE,
    ERC20,
    ERC721,
    ERC1155
}

struct Pool {
    uint256 expiration;
    address owner;
    address signer;
}

struct NewReward {
    uint256 tokenId;
    uint256 total;
    uint256 rewardId;
    address token;
    RewardItemType itemType;
}

struct NewRewardBatchERC1155 {
    uint256[] rewardIds;
    uint256[] tokenIds;
    uint256[] totals;
    address token;
}

struct Reward {
    uint256 poolId;
    uint256 tokenId;
    uint256 total;
    address token;
    RewardItemType itemType;
}

struct ClaimRequest {
    uint256 startTimestamp;
    uint256 endTimestamp;
    uint256 platformFee;
    address platformFeeRecipient;
    address to;
    uint256[] claimIds;
    uint256[] rewardIds;
    uint256[] amounts;
}

struct PoolRequest {
    uint256 poolId;
    uint256 expiration;
    address owner;
    address signer;
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
claimStatusByClaimId 0x0902b315 → bool
eip712Domain 0x84b0196e → bytes1, string, string, uint256, address, bytes32, uint256[]
getRewardsByRewardIds 0x4421c226 → tuple[]
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
paused 0x5c975abb → bool
poolByPoolId 0x22136c50 → uint256, address, address
poolRequestSigner 0xe1480600 → address
rewardByRewardId 0xda7a5ad0 → uint256, uint256, uint256, address, uint8
supportsInterface 0x01ffc9a7 → bool
verifyClaimRequestSignature 0x6b62816b → bool, address
verifyPoolRequestSignature 0xddb523db → bool, address

Write Contract 14 functions

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

claimRewards 0xb38142a1
uint256 poolId
tuple request
bytes signature
depositRewards 0xd1cbec99
uint256 poolId
tuple[] rewards
tuple[] batchERC1155Rewards
grantRole 0x2f2ff15d
bytes32 role
address account
onERC1155BatchReceived 0xbc197c81
address
address
uint256[]
uint256[]
bytes
returns: bytes4
onERC1155Received 0xf23a6e61
address
address
uint256
uint256
bytes
returns: bytes4
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
pause 0x8456cb59
No parameters
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
setPoolRequestSigner 0x8e942c1d
address _poolRequestSigner
unpause 0x3f4ba83a
No parameters
upsertPool 0xce3230bc
tuple request
bytes signature
upsertPoolAndDepositRewards 0x19c9dd23
tuple request
tuple[] rewards
tuple[] batchERC1155Rewards
bytes signature
withdrawRewards 0xa0b1f5dd
uint256 poolId
uint256[] rewardIds

Recent Transactions

No transactions found for this address