Address Contract Verified
Address
0xd380fdb6b0E422A038B397366A30e5CD77D6C3C8
Balance
0 ETH
Nonce
1
Code Size
12238 bytes
Creator
0x472FD4fb...16BF at tx 0x457dacca...ae165e
Indexed Transactions
0
Contract Bytecode
12238 bytes
0x608060405234801561001057600080fd5b50600436106101375760003560e01c80635c975abb116100b85780638456cb591161007c5780638456cb59146103055780638da5cb5b1461030f578063b5d5b5fa1461032d578063e44e04de14610361578063f2fde38b1461037d578063ff76f0cf1461039957610137565b80635c975abb146102875780636b612b36146102a5578063715018a6146102c15780637b0472f0146102cb578063830622be146102e757610137565b80632e17de78116100ff5780632e17de781461020b578063379607f5146102275780633f4ba83a14610243578063419af5a71461024d5780634cc5fee71461026957610137565b8063012ce5011461013c57806301f28d9114610158578063039af9eb146101765780631852e8d9146101ab5780631b545a17146101db575b600080fd5b61015660048036038101906101519190611f65565b6103b5565b005b6101606106a9565b60405161016d9190611fa1565b60405180910390f35b610190600480360381019061018b9190611f65565b6106b6565b6040516101a296959493929190611fd7565b60405180910390f35b6101c560048036038101906101c09190612096565b61070f565b6040516101d29190611fa1565b60405180910390f35b6101f560048036038101906101f091906120d6565b610819565b6040516102029190611fa1565b60405180910390f35b61022560048036038101906102209190611f65565b610865565b005b610241600480360381019061023c9190611f65565b610b99565b005b61024b610cb9565b005b61026760048036038101906102629190611f65565b610ccb565b005b610271610d64565b60405161027e9190612162565b60405180910390f35b61028f610d88565b60405161029c919061217d565b60405180910390f35b6102bf60048036038101906102ba9190611f65565b610d9f565b005b6102c9610e36565b005b6102e560048036038101906102e09190612198565b610e4a565b005b6102ef6111dd565b6040516102fc9190611fa1565b60405180910390f35b61030d6111e3565b005b6103176111f5565b60405161032491906121e7565b60405180910390f35b61034760048036038101906103429190612096565b61121f565b604051610358959493929190612202565b60405180910390f35b61037b60048036038101906103769190612281565b61127f565b005b610397600480360381019061039291906120d6565b6113b5565b005b6103b360048036038101906103ae91906122fc565b611438565b005b6103bd611589565b6103c56115d8565b60006005541161040a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610401906123c0565b60405180910390fd5b60006104163383611622565b905060006002826003015481548110610432576104316123e0565b5b90600052602060002090600602019050600082600001549050600060646005548361045d919061243e565b61046791906124af565b90506000818361047791906124e0565b905060008560040160006101000a81548160ff02191690831515021790555060008560000181905550828460030160008282546104b491906124e0565b925050819055506001600460008760030154815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461052091906124e0565b925050819055506000600460008760030154815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036105a057600184600401600082825461059891906124e0565b925050819055505b60008211156105fc576105fb6105b46111f5565b837f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b5b61064733827f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f2369db1bafee945aee5630782f4a170682e3f8188d8dc247a4c73eb8c9e692d287838560405161069193929190612514565b60405180910390a250505050506106a66117ec565b50565b6000600280549050905090565b600281815481106106c657600080fd5b90600052602060002090600602016000915090508060000154908060010154908060020154908060030154908060040154908060050160009054906101000a900460ff16905086565b60008061071c84846117f6565b90508060800151610731576000915050610813565b6000600282606001518154811061074b5761074a6123e0565b5b90600052602060002090600602016040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820160009054906101000a900460ff161515151581525050905060008260400151426107c591906124e0565b905060006064836040015185600001516107df919061243e565b6107e991906124af565b905060006301e1338083836107fe919061243e565b61080891906124af565b905080955050505050505b92915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050919050565b61086d611589565b6108756115d8565b60006108813383611622565b90506000600282600301548154811061089d5761089c6123e0565b5b90600052602060002090600602019050806001015482600101546108c1919061254b565b421015610903576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fa906125cb565b60405180910390fd5b600061090f338561070f565b905060008111156109bf5742836002018190555061096e33827f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167ff01da32686223933d8a18a391060918c7f11a3648639edd87ae013e2e273174385836040516109b69291906125eb565b60405180910390a25b60008360000154905060008460040160006101000a81548160ff0219169083151502179055506000846000018190555080836003016000828254610a0391906124e0565b925050819055506001600460008660030154815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a6f91906124e0565b925050819055506000600460008660030154815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403610aef576001836004016000828254610ae791906124e0565b925050819055505b610b3a33827f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7fc4727e062e336010f2c282598ef5f14facb3de68cf8195c2f23e1454b2b74e8683604051610b829291906125eb565b60405180910390a250505050610b966117ec565b50565b610ba1611589565b610ba96115d8565b6000610bb53383611622565b90506000610bc3338461070f565b905060008111610c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bff90612660565b60405180910390fd5b428260020181905550610c5c33827f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167ff01da32686223933d8a18a391060918c7f11a3648639edd87ae013e2e27317438483604051610ca49291906125eb565b60405180910390a25050610cb66117ec565b50565b610cc1611981565b610cc96119ff565b565b610cd3611981565b60008111610d16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0d906126cc565b60405180910390fd5b610d6133827f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff166117669092919063ffffffff16565b50565b7f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc81565b6000600160149054906101000a900460ff16905090565b610da7611981565b6032811115610deb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de290612738565b60405180910390fd5b60006005549050816005819055507fef7dc83d9e09b3ed5c446a0255f92eb000d622ba1e57b078e78f541328b03d778183604051610e2a9291906125eb565b60405180910390a15050565b610e3e611981565b610e486000611a62565b565b610e52611589565b610e5a6115d8565b6002805490508210610ea1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e98906127a4565b60405180910390fd5b600060028381548110610eb757610eb66123e0565b5b906000526020600020906006020190508060050160009054906101000a900460ff16610f18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0f90612810565b60405180910390fd5b8060000154821015610f5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f569061287c565b60405180910390fd5b610fac3330847f0000000000000000000000001eb7bd905855c483db19f53c8c4d42db42a159fc73ffffffffffffffffffffffffffffffffffffffff16611b28909392919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060a001604052808481526020014281526020014281526020018581526020016001151581525090806001815401808255809150506001900390600052602060002090600502016000909190919091506000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548160ff02191690831515021790555050508181600301600082825461109c919061254b565b9250508190555060006004600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403611118576001816004016000828254611110919061254b565b925050819055505b60016004600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611179919061254b565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee9084846040516111c89291906125eb565b60405180910390a2506111d96117ec565b5050565b60055481565b6111eb611981565b6111f3611bb1565b565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6003602052816000526040600020818154811061123b57600080fd5b9060005260206000209060050201600091509150508060000154908060010154908060020154908060030154908060040160009054906101000a900460ff16905085565b611287611981565b60028054905085106112ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c5906127a4565b60405180910390fd5b6064821115611312576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611309906128e8565b60405180910390fd5b600060028681548110611328576113276123e0565b5b90600052602060002090600602019050848160000181905550838160010181905550828160020181905550818160050160006101000a81548160ff021916908315150217905550857fa9275a44e419649f76d4194cec7a394bb768737ff9c8931220edd5f8efc4deea848787866040516113a59493929190612908565b60405180910390a2505050505050565b6113bd611981565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361142c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611423906129bf565b60405180910390fd5b61143581611a62565b50565b611440611981565b6064821115611484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147b906128e8565b60405180910390fd5b60026040518060c0016040528086815260200185815260200184815260200160008152602001600081526020018315158152509080600181540180825580915050600190039060005260206000209060060201600090919091909150600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a08201518160050160006101000a81548160ff0219169083151502179055505050600160028054905061154691906124e0565b7fa9275a44e419649f76d4194cec7a394bb768737ff9c8931220edd5f8efc4deea8386868560405161157b9493929190612908565b60405180910390a250505050565b6002600054036115ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c590612a2b565b60405180910390fd5b6002600081905550565b6115e0610d88565b15611620576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161790612a97565b60405180910390fd5b565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905082106116a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169f90612b03565b60405180910390fd5b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106116fb576116fa6123e0565b5b906000526020600020906005020190508060040160009054906101000a900460ff1661175c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175390612b6f565b60405180910390fd5b8091505092915050565b6117e78363a9059cbb60e01b8484604051602401611785929190612b8f565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611c13565b505050565b6001600081905550565b6117fe611ef9565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490508210611882576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187990612b03565b60405180910390fd5b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106118d5576118d46123e0565b5b90600052602060002090600502016040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820160009054906101000a900460ff16151515158152505090508060800151611977576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196e90612b6f565b60405180910390fd5b8091505092915050565b611989611cdb565b73ffffffffffffffffffffffffffffffffffffffff166119a76111f5565b73ffffffffffffffffffffffffffffffffffffffff16146119fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119f490612c04565b60405180910390fd5b565b611a07611ce3565b6000600160146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611a4b611cdb565b604051611a5891906121e7565b60405180910390a1565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611bab846323b872dd60e01b858585604051602401611b4993929190612c24565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611c13565b50505050565b611bb96115d8565b60018060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611bfc611cdb565b604051611c0991906121e7565b60405180910390a1565b6000611c75826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611d2c9092919063ffffffff16565b9050600081511480611c97575080806020019051810190611c969190612c70565b5b611cd6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ccd90612d0f565b60405180910390fd5b505050565b600033905090565b611ceb610d88565b611d2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2190612d7b565b60405180910390fd5b565b6060611d3b8484600085611d44565b90509392505050565b606082471015611d89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8090612e0d565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611db29190612e9e565b60006040518083038185875af1925050503d8060008114611def576040519150601f19603f3d011682016040523d82523d6000602084013e611df4565b606091505b5091509150611e0587838387611e11565b92505050949350505050565b60608315611e73576000835103611e6b57611e2b85611e86565b611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6190612f01565b60405180910390fd5b5b829050611e7e565b611e7d8383611ea9565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115611ebc5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef09190612f76565b60405180910390fd5b6040518060a00160405280600081526020016000815260200160008152602001600081526020016000151581525090565b600080fd5b6000819050919050565b611f4281611f2f565b8114611f4d57600080fd5b50565b600081359050611f5f81611f39565b92915050565b600060208284031215611f7b57611f7a611f2a565b5b6000611f8984828501611f50565b91505092915050565b611f9b81611f2f565b82525050565b6000602082019050611fb66000830184611f92565b92915050565b60008115159050919050565b611fd181611fbc565b82525050565b600060c082019050611fec6000830189611f92565b611ff96020830188611f92565b6120066040830187611f92565b6120136060830186611f92565b6120206080830185611f92565b61202d60a0830184611fc8565b979650505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061206382612038565b9050919050565b61207381612058565b811461207e57600080fd5b50565b6000813590506120908161206a565b92915050565b600080604083850312156120ad576120ac611f2a565b5b60006120bb85828601612081565b92505060206120cc85828601611f50565b9150509250929050565b6000602082840312156120ec576120eb611f2a565b5b60006120fa84828501612081565b91505092915050565b6000819050919050565b600061212861212361211e84612038565b612103565b612038565b9050919050565b600061213a8261210d565b9050919050565b600061214c8261212f565b9050919050565b61215c81612141565b82525050565b60006020820190506121776000830184612153565b92915050565b60006020820190506121926000830184611fc8565b92915050565b600080604083850312156121af576121ae611f2a565b5b60006121bd85828601611f50565b92505060206121ce85828601611f50565b9150509250929050565b6121e181612058565b82525050565b60006020820190506121fc60008301846121d8565b92915050565b600060a0820190506122176000830188611f92565b6122246020830187611f92565b6122316040830186611f92565b61223e6060830185611f92565b61224b6080830184611fc8565b9695505050505050565b61225e81611fbc565b811461226957600080fd5b50565b60008135905061227b81612255565b92915050565b600080600080600060a0868803121561229d5761229c611f2a565b5b60006122ab88828901611f50565b95505060206122bc88828901611f50565b94505060406122cd88828901611f50565b93505060606122de88828901611f50565b92505060806122ef8882890161226c565b9150509295509295909350565b6000806000806080858703121561231657612315611f2a565b5b600061232487828801611f50565b945050602061233587828801611f50565b935050604061234687828801611f50565b92505060606123578782880161226c565b91505092959194509250565b600082825260208201905092915050565b7f456d657267656e6379207769746864726177206e6f7420616c6c6f7765640000600082015250565b60006123aa601e83612363565b91506123b582612374565b602082019050919050565b600060208201905081810360008301526123d98161239d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061244982611f2f565b915061245483611f2f565b925082820261246281611f2f565b915082820484148315176124795761247861240f565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006124ba82611f2f565b91506124c583611f2f565b9250826124d5576124d4612480565b5b828204905092915050565b60006124eb82611f2f565b91506124f683611f2f565b925082820390508181111561250e5761250d61240f565b5b92915050565b60006060820190506125296000830186611f92565b6125366020830185611f92565b6125436040830184611f92565b949350505050565b600061255682611f2f565b915061256183611f2f565b92508282019050808211156125795761257861240f565b5b92915050565b7f4c6f636b20706572696f64206e6f74206f766572000000000000000000000000600082015250565b60006125b5601483612363565b91506125c08261257f565b602082019050919050565b600060208201905081810360008301526125e4816125a8565b9050919050565b60006040820190506126006000830185611f92565b61260d6020830184611f92565b9392505050565b7f4e6f2072657761726420746f20636c61696d0000000000000000000000000000600082015250565b600061264a601283612363565b915061265582612614565b602082019050919050565b600060208201905081810360008301526126798161263d565b9050919050565b7f496e76616c696420616d6f756e74000000000000000000000000000000000000600082015250565b60006126b6600e83612363565b91506126c182612680565b602082019050919050565b600060208201905081810360008301526126e5816126a9565b9050919050565b7f50656e616c74792063616e6e6f74206578636565642035302500000000000000600082015250565b6000612722601983612363565b915061272d826126ec565b602082019050919050565b6000602082019050818103600083015261275181612715565b9050919050565b7f496e76616c6964207469657220696e6465780000000000000000000000000000600082015250565b600061278e601283612363565b915061279982612758565b602082019050919050565b600060208201905081810360008301526127bd81612781565b9050919050565b7f5469657220697320696e61637469766500000000000000000000000000000000600082015250565b60006127fa601083612363565b9150612805826127c4565b602082019050919050565b60006020820190508181036000830152612829816127ed565b9050919050565b7f42656c6f77206d696e207374616b650000000000000000000000000000000000600082015250565b6000612866600f83612363565b915061287182612830565b602082019050919050565b6000602082019050818103600083015261289581612859565b9050919050565b7f41505220746f6f20686967680000000000000000000000000000000000000000600082015250565b60006128d2600c83612363565b91506128dd8261289c565b602082019050919050565b60006020820190508181036000830152612901816128c5565b9050919050565b600060808201905061291d6000830187611f92565b61292a6020830186611f92565b6129376040830185611f92565b6129446060830184611fc8565b95945050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006129a9602683612363565b91506129b48261294d565b604082019050919050565b600060208201905081810360008301526129d88161299c565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000612a15601f83612363565b9150612a20826129df565b602082019050919050565b60006020820190508181036000830152612a4481612a08565b9050919050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b6000612a81601083612363565b9150612a8c82612a4b565b602082019050919050565b60006020820190508181036000830152612ab081612a74565b9050919050565b7f496e76616c6964207374616b6520696e64657800000000000000000000000000600082015250565b6000612aed601383612363565b9150612af882612ab7565b602082019050919050565b60006020820190508181036000830152612b1c81612ae0565b9050919050565b7f5374616b65206e6f742061637469766500000000000000000000000000000000600082015250565b6000612b59601083612363565b9150612b6482612b23565b602082019050919050565b60006020820190508181036000830152612b8881612b4c565b9050919050565b6000604082019050612ba460008301856121d8565b612bb16020830184611f92565b9392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612bee602083612363565b9150612bf982612bb8565b602082019050919050565b60006020820190508181036000830152612c1d81612be1565b9050919050565b6000606082019050612c3960008301866121d8565b612c4660208301856121d8565b612c536040830184611f92565b949350505050565b600081519050612c6a81612255565b92915050565b600060208284031215612c8657612c85611f2a565b5b6000612c9484828501612c5b565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000612cf9602a83612363565b9150612d0482612c9d565b604082019050919050565b60006020820190508181036000830152612d2881612cec565b9050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b6000612d65601483612363565b9150612d7082612d2f565b602082019050919050565b60006020820190508181036000830152612d9481612d58565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000612df7602683612363565b9150612e0282612d9b565b604082019050919050565b60006020820190508181036000830152612e2681612dea565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015612e61578082015181840152602081019050612e46565b60008484015250505050565b6000612e7882612e2d565b612e828185612e38565b9350612e92818560208601612e43565b80840191505092915050565b6000612eaa8284612e6d565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000612eeb601d83612363565b9150612ef682612eb5565b602082019050919050565b60006020820190508181036000830152612f1a81612ede565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000612f4882612f21565b612f528185612363565b9350612f62818560208601612e43565b612f6b81612f2c565b840191505092915050565b60006020820190508181036000830152612f908184612f3d565b90509291505056fea26469706673582212205dc1c1c2005750e7a7202f622f10c90c301c8d3dc9eab8fb23b1547988b142fb64736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: No
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev 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 {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and 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
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// 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;
}
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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.
*/
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].
*/
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 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @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);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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.isContract(address(token));
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
NRDCStaking.sol 456 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/**
* @title NRDCStaking
* @author
* @notice A tier-based staking contract for an ERC20 token (NRDC).
* - Multiple tiers, each with its own minimum stake amount, lock duration, APR, etc.
* - Users can create multiple stakes, each belonging to a specific tier.
* - Rewards are distributed linearly based on APR and time staked.
* - The contract must hold or be replenished with enough NRDC to pay out rewards, unless NRDC is mintable.
* @dev
* **Security**:
* - Uses OpenZeppelin's ReentrancyGuard, Ownable, Pausable, SafeERC20 for safe token handling.
* **Key Points**:
* - `tier.stakers` now tracks *unique* stakers in that tier.
* - An optional `emergencyUnstake()` function is included for early withdrawal with a penalty (owner-configurable).
* - Admin can add/modify tiers, pause/unpause the contract, adjust penalty, etc.
* **Disclaimer**:
* - This code is provided as-is for educational purposes.
* - Always test and/or audit before deploying for real funds.
*/
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
contract NRDCStaking is ReentrancyGuard, Ownable, Pausable {
using SafeERC20 for IERC20;
// ----------------------------------------
// State Variables
// ----------------------------------------
/// @notice The ERC20 token to be staked (NRDC).
IERC20 public immutable nrdcToken;
/**
* @notice Represents a single staking tier.
* @param minAmount The minimum amount of NRDC required to stake in this tier.
* @param lockDuration The lock time (in seconds) before a user can unstake.
* @param apr The annual percentage rate (e.g., 15 means 15% APR).
* @param totalStaked How many tokens are currently staked in this tier (sum of all users' stakes).
* @param stakers How many unique addresses currently have an active stake in this tier.
* @param isActive Whether users can stake into this tier.
*/
struct StakingTier {
uint256 minAmount;
uint256 lockDuration;
uint256 apr;
uint256 totalStaked;
uint256 stakers;
bool isActive;
}
/**
* @notice Stores details of an individual stake by a user.
* @dev `active` indicates if the stake is still locked/ongoing (not unstaked).
*/
struct StakeInfo {
uint256 amount;
uint256 startTimestamp;
uint256 lastClaim;
uint256 tierIndex;
bool active;
}
/// @dev Array of all staking tiers. Tiers are identified by index (0, 1, 2, etc.).
StakingTier[] public tiers;
/// @dev userStakes[user] => array of stakes the user has created.
mapping(address => StakeInfo[]) public userStakes;
/**
* @dev Tracks whether a user has any *active* stake in a given tier.
* - This is used to accurately increment/decrement `tier.stakers`
* only when a user goes from zero -> one active stake,
* or from one -> zero active stakes, in a given tier.
*/
mapping(uint256 => mapping(address => uint256)) private _userActiveStakesInTier;
/// @dev If you allow an early exit, you can define an emergency penalty.
/// e.g., 10 => 10% penalty on the staked principal returned (or reward).
uint256 public emergencyPenaltyPercent;
// ----------------------------------------
// Events
// ----------------------------------------
event Staked(address indexed user, uint256 tierIndex, uint256 amount);
event Unstaked(address indexed user, uint256 stakeIndex, uint256 amount);
event RewardClaimed(address indexed user, uint256 stakeIndex, uint256 reward);
event TierModified(uint256 indexed tierIndex, uint256 newApr, uint256 newMinAmount, uint256 newDuration, bool newActive);
event EmergencyWithdraw(address indexed user, uint256 stakeIndex, uint256 returnedAmount, uint256 penaltyAmount);
event EmergencyPenaltyUpdated(uint256 oldPenalty, uint256 newPenalty);
// ----------------------------------------
// Constructor
// ----------------------------------------
/**
* @param _nrdcToken The address of the NRDC ERC20 token.
* @dev Initializes a few sample tiers for demonstration purposes.
*/
constructor(address _nrdcToken) {
require(_nrdcToken != address(0), "Invalid token address");
nrdcToken = IERC20(_nrdcToken);
// Example tiers (can be modified or removed as needed):
tiers.push(StakingTier({
minAmount: 1000 ether, // e.g., 1000 NRDC
lockDuration: 7 days, // 7 days
apr: 1, // 1%
totalStaked: 0,
stakers: 0,
isActive: true
}));
tiers.push(StakingTier({
minAmount: 2500 ether, // 2,500 NRDC
lockDuration: 30 days, // 30 days
apr: 4, // 4%
totalStaked: 0,
stakers: 0,
isActive: true
}));
tiers.push(StakingTier({
minAmount: 5000 ether, // 5,000 NRDC
lockDuration: 90 days, // 90 days
apr: 8, // 8%
totalStaked: 0,
stakers: 0,
isActive: true
}));
tiers.push(StakingTier({
minAmount: 10000 ether, // 10,000 NRDC
lockDuration: 180 days, // 180 days
apr: 12, // 12%
totalStaked: 0,
stakers: 0,
isActive: true
}));
tiers.push(StakingTier({
minAmount: 25000 ether, // 25,000 NRDC
lockDuration: 365 days, // 365 days
apr: 15, // 15%
totalStaked: 0,
stakers: 0,
isActive: true
}));
}
// ----------------------------------------
// External/Public Functions
// ----------------------------------------
/**
* @notice Stake NRDC tokens into a specific tier.
* @dev Caller must have approved this contract to spend `_amount` of NRDC beforehand.
* @param _tierIndex The index of the tier (0-based).
* @param _amount The amount of NRDC tokens to stake.
*/
function stake(uint256 _tierIndex, uint256 _amount) external nonReentrant whenNotPaused {
require(_tierIndex < tiers.length, "Invalid tier index");
StakingTier storage tier = tiers[_tierIndex];
require(tier.isActive, "Tier is inactive");
require(_amount >= tier.minAmount, "Below min stake");
// Transfer tokens from user to this contract
nrdcToken.safeTransferFrom(msg.sender, address(this), _amount);
// Create and store stake info
userStakes[msg.sender].push(StakeInfo({
amount: _amount,
startTimestamp: block.timestamp,
lastClaim: block.timestamp,
tierIndex: _tierIndex,
active: true
}));
// Update tier stats
tier.totalStaked += _amount;
// If user previously had no active stake in this tier, increment stakers
if (_userActiveStakesInTier[_tierIndex][msg.sender] == 0) {
tier.stakers += 1;
}
_userActiveStakesInTier[_tierIndex][msg.sender] += 1;
emit Staked(msg.sender, _tierIndex, _amount);
}
/**
* @notice Claim the rewards accrued by a specific stake.
* @dev Reward is calculated since the user's `lastClaim`.
* @param _stakeIndex The index in `userStakes[msg.sender]`.
*/
function claim(uint256 _stakeIndex) public nonReentrant whenNotPaused {
StakeInfo storage stakeData = _getActiveStake(msg.sender, _stakeIndex);
uint256 reward = calculateReward(msg.sender, _stakeIndex);
require(reward > 0, "No reward to claim");
// Update lastClaim to now
stakeData.lastClaim = block.timestamp;
// Transfer reward from contract to user
// (Ensure the contract is funded with enough NRDC, or mint if you control supply.)
nrdcToken.safeTransfer(msg.sender, reward);
emit RewardClaimed(msg.sender, _stakeIndex, reward);
}
/**
* @notice Unstake your tokens (and auto-claim any pending rewards) after the lock period.
* @param _stakeIndex The index in `userStakes[msg.sender]`.
*/
function unstake(uint256 _stakeIndex) external nonReentrant whenNotPaused {
StakeInfo storage stakeData = _getActiveStake(msg.sender, _stakeIndex);
StakingTier storage tier = tiers[stakeData.tierIndex];
// Ensure lock period is over
require(
block.timestamp >= stakeData.startTimestamp + tier.lockDuration,
"Lock period not over"
);
// 1. Claim any pending rewards
uint256 reward = calculateReward(msg.sender, _stakeIndex);
if (reward > 0) {
stakeData.lastClaim = block.timestamp;
nrdcToken.safeTransfer(msg.sender, reward);
emit RewardClaimed(msg.sender, _stakeIndex, reward);
}
// 2. Return staked principal
uint256 stakedAmount = stakeData.amount;
stakeData.active = false;
stakeData.amount = 0;
tier.totalStaked -= stakedAmount;
// Adjust stakers count if user has no other active stake in this tier
_userActiveStakesInTier[stakeData.tierIndex][msg.sender] -= 1;
if (_userActiveStakesInTier[stakeData.tierIndex][msg.sender] == 0) {
tier.stakers -= 1;
}
nrdcToken.safeTransfer(msg.sender, stakedAmount);
emit Unstaked(msg.sender, _stakeIndex, stakedAmount);
}
/**
* @notice Emergency unstake (with a penalty) before the lock duration.
* @dev If you'd rather not allow early exits, you can remove/disable this function.
* The penalty is taken from the user's principal (or you could apply it to rewards,
* but here we do principal for simplicity). It's sent to the contract owner or
* burned, depending on your token economics.
* @param _stakeIndex The index in `userStakes[msg.sender]`.
*/
function emergencyUnstake(uint256 _stakeIndex) external nonReentrant whenNotPaused {
require(emergencyPenaltyPercent > 0, "Emergency withdraw not allowed");
StakeInfo storage stakeData = _getActiveStake(msg.sender, _stakeIndex);
StakingTier storage tier = tiers[stakeData.tierIndex];
// 1. Calculate *unclaimed* reward and do NOT pay it out. (Or pay partial if you prefer.)
// Typically, you might forfeit all or partial rewards if exiting early.
// We'll assume user forfeits all rewards in an emergency exit:
// so we skip `claim()` or reward transfer.
// 2. Apply penalty to principal
uint256 stakedAmount = stakeData.amount;
uint256 penalty = (stakedAmount * emergencyPenaltyPercent) / 100;
uint256 amountToReturn = stakedAmount - penalty;
// 3. Update internal state
stakeData.active = false;
stakeData.amount = 0;
tier.totalStaked -= stakedAmount;
// Adjust stakers count if user now has zero active stakes in this tier
_userActiveStakesInTier[stakeData.tierIndex][msg.sender] -= 1;
if (_userActiveStakesInTier[stakeData.tierIndex][msg.sender] == 0) {
tier.stakers -= 1;
}
// 4. Transfer penalty & principal
// For example, the penalty can be kept in the contract or sent to the owner:
if (penalty > 0) {
// e.g., send to owner or burn if your NRDC supports burn
nrdcToken.safeTransfer(owner(), penalty);
}
// Return the rest to the user
nrdcToken.safeTransfer(msg.sender, amountToReturn);
emit EmergencyWithdraw(msg.sender, _stakeIndex, amountToReturn, penalty);
}
/**
* @notice Calculates the pending reward for a specific stake.
* @param _user The user address.
* @param _stakeIndex The index in `userStakes[_user]`.
* @return reward The amount of NRDC reward currently accrued but not yet claimed.
*/
function calculateReward(address _user, uint256 _stakeIndex) public view returns (uint256) {
StakeInfo memory stakeData = _getActiveStakeMemory(_user, _stakeIndex);
if (!stakeData.active) {
return 0;
}
StakingTier memory tier = tiers[stakeData.tierIndex];
uint256 timeDiff = block.timestamp - stakeData.lastClaim;
// yearlyReward = amount * (apr / 100)
// reward = yearlyReward * (timeDiff / 365 days)
uint256 yearlyReward = (stakeData.amount * tier.apr) / 100;
uint256 reward = (yearlyReward * timeDiff) / (365 days);
return reward;
}
// ----------------------------------------
// Owner/Admin Functions
// ----------------------------------------
/**
* @notice Owner can modify any existing tier (e.g., update APR, min stake, lock duration, active status).
*/
function modifyTier(
uint256 _tierIndex,
uint256 _minAmount,
uint256 _lockDuration,
uint256 _apr,
bool _isActive
) external onlyOwner {
require(_tierIndex < tiers.length, "Invalid tier index");
require(_apr <= 100, "APR too high");
StakingTier storage tier = tiers[_tierIndex];
tier.minAmount = _minAmount;
tier.lockDuration = _lockDuration;
tier.apr = _apr;
tier.isActive = _isActive;
emit TierModified(_tierIndex, _apr, _minAmount, _lockDuration, _isActive);
}
/**
* @notice Owner can add a brand new tier.
*/
function addTier(
uint256 _minAmount,
uint256 _lockDuration,
uint256 _apr,
bool _isActive
) external onlyOwner {
require(_apr <= 100, "APR too high");
tiers.push(StakingTier({
minAmount: _minAmount,
lockDuration: _lockDuration,
apr: _apr,
totalStaked: 0,
stakers: 0,
isActive: _isActive
}));
emit TierModified(tiers.length - 1, _apr, _minAmount, _lockDuration, _isActive);
}
/**
* @notice Owner can set the emergency penalty percent for early withdrawals (0% means disabled).
*/
function setEmergencyPenaltyPercent(uint256 _penalty) external onlyOwner {
require(_penalty <= 50, "Penalty cannot exceed 50%");
uint256 old = emergencyPenaltyPercent;
emergencyPenaltyPercent = _penalty;
emit EmergencyPenaltyUpdated(old, _penalty);
}
/**
* @notice Owner can pause the contract (disables stake/unstake/claim).
*/
function pause() external onlyOwner {
_pause();
}
/**
* @notice Owner can unpause the contract.
*/
function unpause() external onlyOwner {
_unpause();
}
/**
* @notice Optional: Owner can withdraw NRDC tokens from the contract
* (e.g., if over-funded or to collect penalty fees).
*/
function ownerWithdrawNRDC(uint256 _amount) external onlyOwner {
require(_amount > 0, "Invalid amount");
nrdcToken.safeTransfer(msg.sender, _amount);
}
// ----------------------------------------
// View / Helper Functions
// ----------------------------------------
/**
* @dev Returns how many tiers exist.
*/
function getTiersCount() external view returns (uint256) {
return tiers.length;
}
/**
* @dev Returns how many stakes a user has in total.
*/
function getUserStakeCount(address _user) external view returns (uint256) {
return userStakes[_user].length;
}
/**
* @dev Safely fetches an active stake from storage.
* Reverts if the stake index is out of range or if stake is inactive.
*/
function _getActiveStake(address _user, uint256 _stakeIndex)
internal
view
returns (StakeInfo storage)
{
require(_stakeIndex < userStakes[_user].length, "Invalid stake index");
StakeInfo storage stakeData = userStakes[_user][_stakeIndex];
require(stakeData.active, "Stake not active");
return stakeData;
}
/**
* @dev Same as `_getActiveStake` but returns a memory copy (for read-only operations).
*/
function _getActiveStakeMemory(address _user, uint256 _stakeIndex)
internal
view
returns (StakeInfo memory)
{
require(_stakeIndex < userStakes[_user].length, "Invalid stake index");
StakeInfo memory stakeData = userStakes[_user][_stakeIndex];
require(stakeData.active, "Stake not active");
return stakeData;
}
}
Read Contract
calculateReward 0x1852e8d9 → uint256
emergencyPenaltyPercent 0x830622be → uint256
getTiersCount 0x01f28d91 → uint256
getUserStakeCount 0x1b545a17 → uint256
nrdcToken 0x4cc5fee7 → address
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
tiers 0x039af9eb → uint256, uint256, uint256, uint256, uint256, bool
userStakes 0xb5d5b5fa → uint256, uint256, uint256, uint256, bool
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
addTier 0xff76f0cf
uint256 _minAmount
uint256 _lockDuration
uint256 _apr
bool _isActive
claim 0x379607f5
uint256 _stakeIndex
emergencyUnstake 0x012ce501
uint256 _stakeIndex
modifyTier 0xe44e04de
uint256 _tierIndex
uint256 _minAmount
uint256 _lockDuration
uint256 _apr
bool _isActive
ownerWithdrawNRDC 0x419af5a7
uint256 _amount
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setEmergencyPenaltyPercent 0x6b612b36
uint256 _penalty
stake 0x7b0472f0
uint256 _tierIndex
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
unstake 0x2e17de78
uint256 _stakeIndex
Recent Transactions
No transactions found for this address