Address Contract Verified
Address
0xDe16028D5774ED8d3868692A797DacEA71F07b85
Balance
0 ETH
Nonce
1
Code Size
12689 bytes
Creator
0x9cB9d30b...0B91 at tx 0x6158a8d1...8d4b40
Indexed Transactions
0
Contract Bytecode
12689 bytes
0x608060405234801561000f575f80fd5b50600436106100e8575f3560e01c806367048f431161008a5780638da5cb5b116100645780638da5cb5b14610246578063a3c950f114610264578063e2bbb15814610280578063f2fde38b1461029c576100e8565b806367048f43146101dc578063715018a61461020c5780637b106bc314610216576100e8565b8063379607f5116100c6578063379607f51461015657806337de615f14610172578063417243c91461018e5780635a5392be146101ac576100e8565b80631eb34275146100ec57806321df0da71461011c5780632e17de781461013a575b5f80fd5b61010660048036038101906101019190611f10565b6102b8565b6040516101139190611ff0565b60405180910390f35b610124610381565b6040516101319190612048565b60405180910390f35b610154600480360381019061014f9190611f10565b6103a8565b005b610170600480360381019061016b9190611f10565b61085f565b005b61018c60048036038101906101879190611f10565b610cd1565b005b610196610de2565b6040516101a39190612195565b60405180910390f35b6101c660048036038101906101c19190611f10565b610ef7565b6040516101d391906121c4565b60405180910390f35b6101f660048036038101906101f19190612207565b61100e565b60405161020391906121c4565b60405180910390f35b610214611228565b005b610230600480360381019061022b9190611f10565b61123b565b60405161023d9190612298565b60405180910390f35b61024e61137a565b60405161025b9190612048565b60405180910390f35b61027e600480360381019061027991906122b1565b6113a1565b005b61029a60048036038101906102959190612301565b61155a565b005b6102b660048036038101906102b1919061233f565b611a9f565b005b6102c0611e7d565b5f60035f8481526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c00151610378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036f906123ea565b60405180910390fd5b80915050919050565b5f7f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a7905090565b6103b0611b23565b5f6103b9611b69565b90505f60035f8481526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c00151610473576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161046a90612478565b60405180910390fd5b5f60045f8581526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015411610503576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fa90612506565b60405180910390fd5b806040015160045f8581526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20600301546105629190612551565b4210156105a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b906125f4565b60405180910390fd5b5f6105af848461100e565b90505f60045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f01548261060c9190612551565b90507f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016106679190612048565b602060405180830381865afa158015610682573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106a69190612626565b8111156106e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106df906126c1565b60405180910390fd5b61073384827f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff16611b709092919063ffffffff16565b60045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015460035f8781526020019081526020015f206004015f8282546107a491906126df565b9250508190555060045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8082015f9055600182015f9055600282015f9055600382015f905550507f15e1b1e6a67db05b5e4e898cc13f87b8485df622bfebf03d1508efa026a2e15c85858360405161084893929190612712565b60405180910390a15050505061085c611bef565b50565b610867611b23565b5f610870611b69565b90505f60035f8481526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c0015161092a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092190612478565b60405180910390fd5b806040015160045f8581526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20600301546109899190612551565b4210156109cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c2906127b7565b60405180910390fd5b5f60045f8581526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015411610a5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5290612506565b60405180910390fd5b5f610a66848461100e565b90505f8111610aaa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa190612845565b60405180910390fd5b7f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610b039190612048565b602060405180830381865afa158015610b1e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b429190612626565b811115610b84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7b906126c1565b60405180910390fd5b610bcf83827f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff16611b709092919063ffffffff16565b4260045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20600201819055508060045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206001015f828254610c819190612551565b925050819055507f3ed1528b0fdc7c5207c1bf935e34a667e13656b9ed165260c522be0bc544f303848483604051610cbb93929190612712565b60405180910390a1505050610cce611bef565b50565b610cd9611bf8565b60035f8281526020019081526020015f206006015f9054906101000a900460ff16610d39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d30906123ea565b60405180910390fd5b5f60035f8381526020019081526020015f206005015414610d8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d86906128d3565b60405180910390fd5b4260035f8381526020019081526020015f20600501819055507fff294b12fe37734713acd279ac23302b34605c23a226c11fb81e2de19363573481604051610dd791906121c4565b60405180910390a150565b60605f60025467ffffffffffffffff811115610e0157610e006128f1565b5b604051908082528060200260200182016040528015610e3a57816020015b610e27611e7d565b815260200190600190039081610e1f5790505b5090505f5b600254811015610eef5760035f600183610e599190612551565b81526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff161515151581525050828281518110610ed957610ed861291e565b5b6020026020010181905250806001019050610e3f565b508091505090565b5f8060035f8481526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c00151610fb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa7906123ea565b60405180910390fd5b60045f8481526020019081526020015f205f610fca611b69565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f0154915050919050565b5f8060035f8581526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c001516110c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110be90612478565b60405180910390fd5b5f60045f8681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505090505f815f01511161118d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611184906129bb565b60405180910390fd5b5f81604001514261119e91906126df565b90505f836040015183604001516111b59190612551565b90508042106111c657836040015191505b5f8460a0015111156111e95782604001518460a001516111e691906126df565b91505b5f640757b12c00838660200151865f015161120491906129d9565b61120e91906129d9565b6112189190612a47565b9050809550505050505092915050565b611230611bf8565b6112395f611c7f565b565b611243611eb5565b60035f8381526020019081526020015f206006015f9054906101000a900460ff166112a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129a906123ea565b60405180910390fd5b5f60045f8481526020019081526020015f205f6112be611b69565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505090505f816060015103611371576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136890612ae7565b60405180910390fd5b80915050919050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6113a9611bf8565b5f83116113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e290612b75565b60405180910390fd5b5f821161142d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142490612c03565b60405180910390fd5b5f811161146f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146690612c91565b60405180910390fd5b5f611478611d40565b90506040518060e001604052808281526020018581526020018381526020018481526020015f81526020015f81526020016001151581525060035f8381526020019081526020015f205f820151815f01556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015f6101000a81548160ff0219169083151502179055509050507f35f1963f6fd0ab9043ea1f005f9d6a8c6933e6149e2ed9f6674f41cd0a0dc4498160405161154c91906121c4565b60405180910390a150505050565b611562611b23565b5f81116115a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159b90612d1f565b60405180910390fd5b5f6115ad611b69565b90505f60035f8581526020019081526020015f206040518060e00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015f9054906101000a900460ff16151515158152505090508060c00151611667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165e90612dad565b60405180910390fd5b5f8160a00151146116ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116a490612e3b565b60405180910390fd5b5f60045f8681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f01541461173d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173490612ec9565b60405180910390fd5b80606001518160800151846117529190612551565b1115611793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161178a90612f57565b60405180910390fd5b827f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff166370a08231846040518263ffffffff1660e01b81526004016117ed9190612048565b602060405180830381865afa158015611808573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061182c9190612626565b101561186d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186490612fe5565b60405180910390fd5b827f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e84306040518363ffffffff1660e01b81526004016118c9929190613003565b602060405180830381865afa1580156118e4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119089190612626565b1015611949576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119409061309a565b60405180910390fd5b6119968230857f00000000000000000000000071ed2ce4a4ed4e487718e4b53c01beecfe5b14a773ffffffffffffffffffffffffffffffffffffffff16611d60909392919063ffffffff16565b8260035f8681526020019081526020015f206004015f8282546119b99190612551565b9250508190555060405180608001604052808481526020015f81526020014281526020014281525060045f8681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f820151815f01556020820151816001015560408201518160020155606082015181600301559050507feaa18152488ce5959073c9c79c88ca90b3d96c00de1f118cfaad664c3dab06b9848385604051611a8993929190612712565b60405180910390a15050611a9b611bef565b5050565b611aa7611bf8565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611b17575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401611b0e9190612048565b60405180910390fd5b611b2081611c7f565b50565b600260015403611b5f576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b5f33905090565b611bea838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401611ba39291906130b8565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611de2565b505050565b60018081905550565b611c00611b69565b73ffffffffffffffffffffffffffffffffffffffff16611c1e61137a565b73ffffffffffffffffffffffffffffffffffffffff1614611c7d57611c41611b69565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401611c749190612048565b60405180910390fd5b565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f60025f815480929190611d53906130df565b9190505550600254905090565b611ddc848573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401611d9593929190613126565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611de2565b50505050565b5f8060205f8451602086015f885af180611e01576040513d5f823e3d81fd5b3d92505f519150505f8214611e1a576001811415611e35565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b15611e7757836040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401611e6e9190612048565b60405180910390fd5b50505050565b6040518060e001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f151581525090565b60405180608001604052805f81526020015f81526020015f81526020015f81525090565b5f80fd5b5f819050919050565b611eef81611edd565b8114611ef9575f80fd5b50565b5f81359050611f0a81611ee6565b92915050565b5f60208284031215611f2557611f24611ed9565b5b5f611f3284828501611efc565b91505092915050565b611f4481611edd565b82525050565b5f8115159050919050565b611f5e81611f4a565b82525050565b60e082015f820151611f785f850182611f3b565b506020820151611f8b6020850182611f3b565b506040820151611f9e6040850182611f3b565b506060820151611fb16060850182611f3b565b506080820151611fc46080850182611f3b565b5060a0820151611fd760a0850182611f3b565b5060c0820151611fea60c0850182611f55565b50505050565b5f60e0820190506120035f830184611f64565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61203282612009565b9050919050565b61204281612028565b82525050565b5f60208201905061205b5f830184612039565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b60e082015f82015161209e5f850182611f3b565b5060208201516120b16020850182611f3b565b5060408201516120c46040850182611f3b565b5060608201516120d76060850182611f3b565b5060808201516120ea6080850182611f3b565b5060a08201516120fd60a0850182611f3b565b5060c082015161211060c0850182611f55565b50505050565b5f612121838361208a565b60e08301905092915050565b5f602082019050919050565b5f61214382612061565b61214d818561206b565b93506121588361207b565b805f5b8381101561218857815161216f8882612116565b975061217a8361212d565b92505060018101905061215b565b5085935050505092915050565b5f6020820190508181035f8301526121ad8184612139565b905092915050565b6121be81611edd565b82525050565b5f6020820190506121d75f8301846121b5565b92915050565b6121e681612028565b81146121f0575f80fd5b50565b5f81359050612201816121dd565b92915050565b5f806040838503121561221d5761221c611ed9565b5b5f61222a85828601611efc565b925050602061223b858286016121f3565b9150509250929050565b608082015f8201516122595f850182611f3b565b50602082015161226c6020850182611f3b565b50604082015161227f6040850182611f3b565b5060608201516122926060850182611f3b565b50505050565b5f6080820190506122ab5f830184612245565b92915050565b5f805f606084860312156122c8576122c7611ed9565b5b5f6122d586828701611efc565b93505060206122e686828701611efc565b92505060406122f786828701611efc565b9150509250925092565b5f806040838503121561231757612316611ed9565b5b5f61232485828601611efc565b925050602061233585828601611efc565b9150509250929050565b5f6020828403121561235457612353611ed9565b5b5f612361848285016121f3565b91505092915050565b5f82825260208201905092915050565b7f5447435374616b696e673a20496e76616c6964207374616b696e6720706f6f6c5f8201527f2049442e00000000000000000000000000000000000000000000000000000000602082015250565b5f6123d460248361236a565b91506123df8261237a565b604082019050919050565b5f6020820190508181035f830152612401816123c8565b9050919050565b7f5447435374616b696e673a205374616b696e6720706f6f6c20646f206e6f74205f8201527f65786973742e0000000000000000000000000000000000000000000000000000602082015250565b5f61246260268361236a565b915061246d82612408565b604082019050919050565b5f6020820190508181035f83015261248f81612456565b9050919050565b7f5447435374616b696e673a2055736572207374616b652062616c616e636520695f8201527f7320302e00000000000000000000000000000000000000000000000000000000602082015250565b5f6124f060248361236a565b91506124fb82612496565b604082019050919050565b5f6020820190508181035f83015261251d816124e4565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61255b82611edd565b915061256683611edd565b925082820190508082111561257e5761257d612524565b5b92915050565b7f5447435374616b696e673a20556e7374616b6520697320756e617661696c61625f8201527f6c652e0000000000000000000000000000000000000000000000000000000000602082015250565b5f6125de60238361236a565b91506125e982612584565b604082019050919050565b5f6020820190508181035f83015261260b816125d2565b9050919050565b5f8151905061262081611ee6565b92915050565b5f6020828403121561263b5761263a611ed9565b5b5f61264884828501612612565b91505092915050565b7f5447435374616b696e673a20496e73756666696369656e7420636f6e747261635f8201527f742062616c616e63652e00000000000000000000000000000000000000000000602082015250565b5f6126ab602a8361236a565b91506126b682612651565b604082019050919050565b5f6020820190508181035f8301526126d88161269f565b9050919050565b5f6126e982611edd565b91506126f483611edd565b925082820390508181111561270c5761270b612524565b5b92915050565b5f6060820190506127255f8301866121b5565b6127326020830185612039565b61273f60408301846121b5565b949350505050565b7f5447435374616b696e673a2046756e647320617265207374696c6c206c6f636b5f8201527f65642e0000000000000000000000000000000000000000000000000000000000602082015250565b5f6127a160238361236a565b91506127ac82612747565b604082019050919050565b5f6020820190508181035f8301526127ce81612795565b9050919050565b7f5447435374616b696e673a20416d6f756e7420746f20636c61696d20657175615f8201527f6c7320302e000000000000000000000000000000000000000000000000000000602082015250565b5f61282f60258361236a565b915061283a826127d5565b604082019050919050565b5f6020820190508181035f83015261285c81612823565b9050919050565b7f5447435374616b696e673a20506f6f6c20697320616c7265616479206c6f636b5f8201527f65642e0000000000000000000000000000000000000000000000000000000000602082015250565b5f6128bd60238361236a565b91506128c882612863565b604082019050919050565b5f6020820190508181035f8301526128ea816128b1565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f5447435374616b696e673a205573657220646964206e6f74206465706f7369745f8201527f656420696e207468697320706f6f6c2e00000000000000000000000000000000602082015250565b5f6129a560308361236a565b91506129b08261294b565b604082019050919050565b5f6020820190508181035f8301526129d281612999565b9050919050565b5f6129e382611edd565b91506129ee83611edd565b92508282026129fc81611edd565b91508282048414831517612a1357612a12612524565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f612a5182611edd565b9150612a5c83611edd565b925082612a6c57612a6b612a1a565b5b828204905092915050565b7f5447435374616b696e673a205573657220646964206e6f74206465706f7369745f8201527f656420696e2074686973207374616b696e672e00000000000000000000000000602082015250565b5f612ad160338361236a565b9150612adc82612a77565b604082019050919050565b5f6020820190508181035f830152612afe81612ac5565b9050919050565b7f5447435374616b696e673a204150522068617320746f206265206869676865725f8201527f207468616e20302e000000000000000000000000000000000000000000000000602082015250565b5f612b5f60288361236a565b9150612b6a82612b05565b604082019050919050565b5f6020820190508181035f830152612b8c81612b53565b9050919050565b7f5447435374616b696e673a204d6178206c696d69742068617320746f206265205f8201527f686967686572207468616e20302e000000000000000000000000000000000000602082015250565b5f612bed602e8361236a565b9150612bf882612b93565b604082019050919050565b5f6020820190508181035f830152612c1a81612be1565b9050919050565b7f5447435374616b696e673a204c6f636b206475726174696f6e2068617320746f5f8201527f20626520686967686572207468616e20302e0000000000000000000000000000602082015250565b5f612c7b60328361236a565b9150612c8682612c21565b604082019050919050565b5f6020820190508181035f830152612ca881612c6f565b9050919050565b7f5447435374616b696e673a204d696e696d616c206465706f73697420616d6f755f8201527f6e7420697320312e000000000000000000000000000000000000000000000000602082015250565b5f612d0960288361236a565b9150612d1482612caf565b604082019050919050565b5f6020820190508181035f830152612d3681612cfd565b9050919050565b7f5447435374616b696e673a205374616b696e6720706f6f6c20646f6573206e6f5f8201527f742065786973742e000000000000000000000000000000000000000000000000602082015250565b5f612d9760288361236a565b9150612da282612d3d565b604082019050919050565b5f6020820190508181035f830152612dc481612d8b565b9050919050565b7f5447435374616b696e673a205374616b696e6720706f6f6c20697320636c6f735f8201527f65642e0000000000000000000000000000000000000000000000000000000000602082015250565b5f612e2560238361236a565b9150612e3082612dcb565b604082019050919050565b5f6020820190508181035f830152612e5281612e19565b9050919050565b7f5447435374616b696e673a205573657220616c7265616479206465706f7369745f8201527f65642e0000000000000000000000000000000000000000000000000000000000602082015250565b5f612eb360238361236a565b9150612ebe82612e59565b604082019050919050565b5f6020820190508181035f830152612ee081612ea7565b9050919050565b7f5447435374616b696e673a205374616b696e6720706f6f6c206d6178206c696d5f8201527f69742065786365656465642e0000000000000000000000000000000000000000602082015250565b5f612f41602c8361236a565b9150612f4c82612ee7565b604082019050919050565b5f6020820190508181035f830152612f6e81612f35565b9050919050565b7f5447435374616b696e673a20496e73756666696369656e742066756e647320745f8201527f6f206465706f7369742e00000000000000000000000000000000000000000000602082015250565b5f612fcf602a8361236a565b9150612fda82612f75565b604082019050919050565b5f6020820190508181035f830152612ffc81612fc3565b9050919050565b5f6040820190506130165f830185612039565b6130236020830184612039565b9392505050565b7f5447435374616b696e673a20496e73756666696369656e7420616c6c6f77616e5f8201527f63652e0000000000000000000000000000000000000000000000000000000000602082015250565b5f61308460238361236a565b915061308f8261302a565b604082019050919050565b5f6020820190508181035f8301526130b181613078565b9050919050565b5f6040820190506130cb5f830185612039565b6130d860208301846121b5565b9392505050565b5f6130e982611edd565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361311b5761311a612524565b5b600182019050919050565b5f6060820190506131395f830186612039565b6131466020830185612039565b61315360408301846121b5565b94935050505056fea2646970667358221220c42c5f6e78ff581b5f1111c85cee357eba9cb76f3f1f096c2e112cd4e707455164736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: No
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
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 199 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
Address.sol 150 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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 Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @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
* {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);
}
(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 {Errors.FailedCall}) 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 {Errors.FailedCall} 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 {Errors.FailedCall}.
*/
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
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
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;
}
}
Errors.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
TGCStaking.sol 263 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract TGCStaking is Ownable, ReentrancyGuard{
using SafeERC20 for IERC20;
IERC20 private immutable _token; // Token used for all stakings.
uint256 private _stakingPoolCounter; // Counter for setting staking Pools id's.
constructor
(
address _initialAddress,
address tokenAddress
)
Ownable(_initialAddress)
{
require(tokenAddress != address(0), "TGCStaking: Invalid token address.");
_token = IERC20(tokenAddress);
_stakingPoolCounter = 0;
}
struct StakingPool {
uint256 stakingID; // ID of staking pool
uint256 poolAPR; // APR of staking pool in promile.
uint256 lockDuration; // Duration of lock period in seconds.
uint256 maxTokenLimit; // Maximum amount of tokens that can be taken by staking pool.
uint256 totalStaked; // total staked amount in staking pool.
uint256 closeTimestamp; // Timestamp when staking pool was closed. Initially set to 0 -> staking is open
bool exists; // Flag to check if pool exists. Used when retrieving data from mapping.
}
struct UserStakingInfo{
uint256 stakedAmount; // Amount of tokens user staked initially.
uint256 tokenClaimed; // Amount of token user already claimed.
uint256 lastRewardTimestamp; // Timestamp of last reward.
uint256 createdAt; // Timestamp of user deposit into staking pool
}
// ------------ EVENTS ------------
event Deposit(uint256 stakingPoolID, address user, uint256 amount);
event Claim(uint256 stakingPoolID, address user, uint256 amount);
event Unstake(uint256 stakingPoolID, address user, uint256 amount);
event StakingCreated(uint256 stakingPoolID);
event StakingClosed(uint256 stakingPoolID);
// Mapping holds id mapped into StakingPool info.
mapping(uint256 => StakingPool) private _stakingPools;
mapping(uint256 stakingPoolId => mapping(address => UserStakingInfo)) private _stakingPoolUserInfo;
/*
* @dev Function used to create staking pool.
* @param poolAPR - should be passed as promil and has to be > 0.
* @param maxLimit - max limit of tokens that can be deposited in staking pool
* @param lockDuration - staking pool lock duration in seconds
*/
function createStakingPool(uint256 poolAPR, uint256 maxLimit, uint256 lockDuration) external onlyOwner {
require(poolAPR > 0, "TGCStaking: APR has to be higher than 0.");
require(maxLimit > 0, "TGCStaking: Max limit has to be higher than 0.");
require(lockDuration > 0, "TGCStaking: Lock duration has to be higher than 0.");
uint256 newStakingID = getStakingPoolID();
_stakingPools[newStakingID] = StakingPool(
newStakingID,
poolAPR,
lockDuration,
maxLimit,
0,
0,
true
);
emit StakingCreated(newStakingID);
}
/*
* @dev Function that allows user to deposit tokens in staking pool.
* @param stakingPoolID - identifier of staking pool.
* @param amount - amount of tokens.
*/
function deposit(uint256 stakingPoolID, uint256 amount) external nonReentrant{
require(amount > 0, "TGCStaking: Minimal deposit amount is 1.");
address sender = _msgSender();
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Staking pool does not exist.");
require(stakingPool.closeTimestamp == 0, "TGCStaking: Staking pool is closed.");
require(_stakingPoolUserInfo[stakingPoolID][sender].stakedAmount == 0, "TGCStaking: User already deposited.");
require(amount + stakingPool.totalStaked <= stakingPool.maxTokenLimit, "TGCStaking: Staking pool max limit exceeded.");
require(_token.balanceOf(sender) >= amount, "TGCStaking: Insufficient funds to deposit.");
require(_token.allowance(sender, address(this)) >= amount, "TGCStaking: Insufficient allowance.");
_token.safeTransferFrom(sender, address(this), amount);
_stakingPools[stakingPoolID].totalStaked += amount;
_stakingPoolUserInfo[stakingPoolID][sender] = UserStakingInfo(amount, 0, block.timestamp,block.timestamp);
emit Deposit(stakingPoolID, sender, amount);
}
/*
* @dev Function that allows user to claim his rewards from staking.
* @param stakingPoolID - identifier of staking pool.
*/
function claim(uint256 stakingPoolID) external nonReentrant {
address sender = _msgSender();
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Staking pool do not exist.");
require(block.timestamp >= _stakingPoolUserInfo[stakingPoolID][sender].createdAt + stakingPool.lockDuration, "TGCStaking: Funds are still locked.");
require(_stakingPoolUserInfo[stakingPoolID][sender].stakedAmount > 0, "TGCStaking: User stake balance is 0.");
uint256 claimableValue = calculateClaimableAmount(stakingPoolID, sender);
require(claimableValue > 0, "TGCStaking: Amount to claim equals 0.");
require(claimableValue <= _token.balanceOf(address(this)), "TGCStaking: Insufficient contract balance.");
_token.safeTransfer(sender, claimableValue);
_stakingPoolUserInfo[stakingPoolID][sender].lastRewardTimestamp = block.timestamp;
_stakingPoolUserInfo[stakingPoolID][sender].tokenClaimed += claimableValue;
emit Claim(stakingPoolID, sender, claimableValue);
}
/*
* @dev Function that withdraw staked amount with all rewards.
* @param stakingPoolID - identifier of staking pool.
*/
function unstake(uint256 stakingPoolID) external nonReentrant {
address sender = _msgSender();
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Staking pool do not exist.");
require(_stakingPoolUserInfo[stakingPoolID][sender].stakedAmount > 0, "TGCStaking: User stake balance is 0.");
require(block.timestamp >= _stakingPoolUserInfo[stakingPoolID][sender].createdAt + stakingPool.lockDuration, "TGCStaking: Unstake is unavailable.");
uint256 claimableValue = calculateClaimableAmount(stakingPoolID, sender);
uint256 totalUnstakeValue = claimableValue + _stakingPoolUserInfo[stakingPoolID][sender].stakedAmount;
require(totalUnstakeValue <= _token.balanceOf(address(this)), "TGCStaking: Insufficient contract balance.");
_token.safeTransfer(sender, totalUnstakeValue);
_stakingPools[stakingPoolID].totalStaked -= _stakingPoolUserInfo[stakingPoolID][sender].stakedAmount;
delete _stakingPoolUserInfo[stakingPoolID][sender];
emit Unstake(stakingPoolID, sender, totalUnstakeValue);
}
/*
* @dev Function allows to close staking pool.
* Rewards after this timestamp wont be counted.
*/
function closePool(uint256 stakingPoolID) external onlyOwner {
require(_stakingPools[stakingPoolID].exists, "TGCStaking: Invalid staking pool ID.");
require(_stakingPools[stakingPoolID].closeTimestamp == 0, "TGCStaking: Pool is already locked.");
_stakingPools[stakingPoolID].closeTimestamp = block.timestamp;
emit StakingClosed(stakingPoolID);
}
// ---------- INTERNAL ----------
/*
* @dev function to increment stakingPoolCounter + returning new id.
*/
function getStakingPoolID() internal returns (uint256){
_stakingPoolCounter++;
return _stakingPoolCounter;
}
// ------------ VIEWS ------------
/*
* @dev Function returns address of token.
*/
function getToken() public view returns (address){
return address(_token);
}
/*
* @dev Function returns claimable value for user for specified staking pool.
* @param stakingPoolID - identifier of staking pool.
* @param userAddress - address of user wallet amount should be counted for.
*/
function calculateClaimableAmount(uint256 stakingPoolID, address userAddress) public view returns (uint256){
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Staking pool do not exist.");
UserStakingInfo memory user = _stakingPoolUserInfo[stakingPoolID][userAddress];
require(user.stakedAmount > 0, "TGCStaking: User did not deposited in this pool.");
uint256 timeFromUserDeposit = block.timestamp - user.lastRewardTimestamp;
uint256 endOfLockTimestamp = user.lastRewardTimestamp + stakingPool.lockDuration;
if(block.timestamp >= endOfLockTimestamp){
timeFromUserDeposit = stakingPool.lockDuration;
}
if(stakingPool.closeTimestamp > 0){
timeFromUserDeposit = stakingPool.closeTimestamp - user.lastRewardTimestamp;
}
uint256 claimableAmount = (user.stakedAmount * stakingPool.poolAPR * timeFromUserDeposit) / (1000 * (365 days));
return claimableAmount;
}
/*
* @dev Function returns amount staked by user for specified staking pool.
* @param stakingPoolID - identifier of staking pool.
*/
function getStakedAmount(uint256 stakingPoolID) external view returns (uint256) {
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Invalid staking pool ID.");
return _stakingPoolUserInfo[stakingPoolID][_msgSender()].stakedAmount;
}
/*
* @dev Method returns UserStakingInfo for specified staking pool.
* @param stakingPoolID identifier for staking pool.
*/
function getUserStakingInfo(uint256 stakingPoolID) external view returns (UserStakingInfo memory){
require(_stakingPools[stakingPoolID].exists, "TGCStaking: Invalid staking pool ID.");
UserStakingInfo memory userInfo = _stakingPoolUserInfo[stakingPoolID][_msgSender()];
require(userInfo.createdAt != 0, "TGCStaking: User did not deposited in this staking.");
return userInfo;
}
/*
* @dev Function returns all staking pools.
*/
function getStakingPools() external view returns (StakingPool[] memory){
StakingPool[] memory pools = new StakingPool[](_stakingPoolCounter);
for(uint256 i = 0; i < _stakingPoolCounter;){
pools[i] = _stakingPools[i + 1];
unchecked { ++i; }
}
return pools;
}
/*
* @dev Function returns staking pool data.
* @param stakingPoolID - identifier of staking pool.
*/
function getStakingPoolByID(uint256 stakingPoolID) external view returns (StakingPool memory){
StakingPool memory stakingPool = _stakingPools[stakingPoolID];
require(stakingPool.exists, "TGCStaking: Invalid staking pool ID.");
return stakingPool;
}
}
Read Contract
calculateClaimableAmount 0x67048f43 → uint256
getStakedAmount 0x5a5392be → uint256
getStakingPoolByID 0x1eb34275 → tuple
getStakingPools 0x417243c9 → tuple[]
getToken 0x21df0da7 → address
getUserStakingInfo 0x7b106bc3 → tuple
owner 0x8da5cb5b → address
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
claim 0x379607f5
uint256 stakingPoolID
closePool 0x37de615f
uint256 stakingPoolID
createStakingPool 0xa3c950f1
uint256 poolAPR
uint256 maxLimit
uint256 lockDuration
deposit 0xe2bbb158
uint256 stakingPoolID
uint256 amount
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
unstake 0x2e17de78
uint256 stakingPoolID
Recent Transactions
No transactions found for this address