Address Contract Verified
Address
0x61d348A2F85Bd60dA448a1ecCBfeF9C5B26bA20d
Balance
0 ETH
Nonce
1
Code Size
9788 bytes
Creator
0x4f125e83...936c at tx 0x6e7fe526...27335e
Indexed Transactions
0
Contract Bytecode
9788 bytes
0x6080604052600436106101b9575f3560e01c8063ad5c4648116100eb578063d826492011610089578063eb72e4f511610063578063eb72e4f5146105e7578063f1bb05c014610611578063f2fde38b14610639578063feb6172414610661576101f9565b8063d826492014610569578063dfb8cf9314610593578063e9ca7907146105bd576101f9565b8063ce2a9f62116100c5578063ce2a9f62146104b1578063d3cd52bc146104db578063d4dfd45614610505578063d79e856714610541576101f9565b8063ad5c46481461040f578063b90665e514610439578063c9faa7c514610475576101f9565b80634c203786116101585780636f9fb98a116101325780636f9fb98a1461037b578063715018a6146103a55780638da5cb5b146103bb5780639f37c171146103e5576101f9565b80634c203786146102ff57806364bca3281461032957806365d65e8614610351576101f9565b806330301cdc1161019457806330301cdc1461025b5780633519a2f81461028557806336f95670146102ad5780633ae02aef146102d5576101f9565b8062ac08e0146101fd5780630f15f4c014610227578063260cf40914610231576101f9565b366101f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101f090611964565b60405180910390fd5b5f5ffd5b348015610208575f5ffd5b5061021161069d565b60405161021e91906119c1565b60405180910390f35b61022f6106c1565b005b34801561023c575f5ffd5b50610245610967565b60405161025291906119c1565b60405180910390f35b348015610266575f5ffd5b5061026f61098b565b60405161027c91906119f2565b60405180910390f35b348015610290575f5ffd5b506102ab60048036038101906102a69190611a46565b610991565b005b3480156102b8575f5ffd5b506102d360048036038101906102ce9190611a9b565b610a32565b005b3480156102e0575f5ffd5b506102e9610b6b565b6040516102f691906119f2565b60405180910390f35b34801561030a575f5ffd5b50610313610b71565b60405161032091906119f2565b60405180910390f35b348015610334575f5ffd5b5061034f600480360381019061034a9190611ac6565b610b76565b005b34801561035c575f5ffd5b50610365610c1e565b60405161037291906119c1565b60405180910390f35b348015610386575f5ffd5b5061038f610c43565b60405161039c91906119f2565b60405180910390f35b3480156103b0575f5ffd5b506103b9610ce1565b005b3480156103c6575f5ffd5b506103cf610cf4565b6040516103dc91906119c1565b60405180910390f35b3480156103f0575f5ffd5b506103f9610d1b565b60405161040691906119f2565b60405180910390f35b34801561041a575f5ffd5b50610423610d21565b60405161043091906119c1565b60405180910390f35b348015610444575f5ffd5b5061045f600480360381019061045a9190611b37565b610d45565b60405161046c9190611b7c565b60405180910390f35b348015610480575f5ffd5b5061049b60048036038101906104969190611a9b565b610d6b565b6040516104a89190611b7c565b60405180910390f35b3480156104bc575f5ffd5b506104c5610dbd565b6040516104d291906119f2565b60405180910390f35b3480156104e6575f5ffd5b506104ef610dc3565b6040516104fc91906119f2565b60405180910390f35b348015610510575f5ffd5b5061052b60048036038101906105269190611a9b565b610dc8565b6040516105389190611b7c565b60405180910390f35b34801561054c575f5ffd5b5061056760048036038101906105629190611ac6565b610de5565b005b348015610574575f5ffd5b5061057d610e91565b60405161058a9190611bf0565b60405180910390f35b34801561059e575f5ffd5b506105a7610eb5565b6040516105b491906119f2565b60405180910390f35b3480156105c8575f5ffd5b506105d1610eba565b6040516105de91906119f2565b60405180910390f35b3480156105f2575f5ffd5b506105fb610ec5565b60405161060891906119f2565b60405180910390f35b34801561061c575f5ffd5b5061063760048036038101906106329190611d45565b610eca565b005b348015610644575f5ffd5b5061065f600480360381019061065a9190611a9b565b6112c6565b005b34801561066c575f5ffd5b5061068760048036038101906106829190611b37565b61134a565b6040516106949190611b7c565b60405180910390f35b7f0000000000000000000000004f125e835bbc9bbb77607c66de6d0d32339b936c81565b6106c9611367565b60065f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff161561074a576040517fef65161f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b660aa87bee538000341461078a576040517f242b035c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6064601e3461079a9190611df2565b6107a49190611e60565b90505f81346107b39190611e90565b90503460025f8282546107c69190611ec3565b925050819055505f7f0000000000000000000000004f125e835bbc9bbb77607c66de6d0d32339b936c73ffffffffffffffffffffffffffffffffffffffff168360405161081290611f23565b5f6040518083038185875af1925050503d805f811461084c576040519150601f19603f3d011682016040523d82523d5f602084013e610851565b606091505b505090508061088c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260035f82825461089d9190611ec3565b925050819055505f6108ae836113b6565b9050600160065f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff167f70c6808fcdd244649642337497ce4244c2d9a4c3ef9f427ba4a6c1e8b5bbfca0348686856040516109519493929190611f37565b60405180910390a2505050506109656116e0565b565b7f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb181565b60055481565b7f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb173ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b81526004016109ee93929190611f7a565b6020604051808303815f875af1158015610a0a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a2e9190611fd9565b5050565b610a3a6116e9565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610aa8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9f9061204e565b60405180910390fd5b5f60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160075f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f93f9d0472cb0fc12887bf8f1f15cc7a197a5acd122ab23b8dcc25de0191e0d5e60405160405180910390a35050565b60045481565b60c881565b610b7e6116e9565b7f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b8152600401610bd992919061206c565b6020604051808303815f875af1158015610bf5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c199190611fd9565b505050565b60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f7f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610c9d91906119c1565b602060405180830381865afa158015610cb8573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cdc91906120a7565b905090565b610ce96116e9565b610cf25f611770565b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b5f60085f8381526020019081526020015f205f9054906101000a900460ff169050919050565b5f60065f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff169050919050565b60025481565b606481565b6006602052805f5260405f205f915054906101000a900460ff1681565b610ded6116e9565b5f8273ffffffffffffffffffffffffffffffffffffffff1682604051610e1290611f23565b5f6040518083038185875af1925050503d805f8114610e4c576040519150601f19603f3d011682016040523d82523d5f602084013e610e51565b606091505b5050905080610e8c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b601e81565b660aa87bee53800081565b604681565b610ed2611367565b60065f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610f52576040517fba74d80f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80421115610f8c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085f8481526020019081526020015f205f9054906101000a900460ff1615610fe1576040517f1fb09b8000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f3385858430604051602001610ffb959493929190612157565b6040516020818303038152906040528051906020012090505f816040516020016110259190612209565b6040516020818303038152906040528051906020012090505f6110488286611831565b905060075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146110d0576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160085f8881526020019081526020015f205f6101000a81548160ff021916908315150217905550867f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161115391906119c1565b602060405180830381865afa15801561116e573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061119291906120a7565b10156111ca576040517f786e0a9900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33896040518363ffffffff1660e01b815260040161122592919061206c565b6020604051808303815f875af1158015611241573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112659190611fd9565b50853373ffffffffffffffffffffffffffffffffffffffff167f86e4807884de097a56cf8575b603e0b256cdb5bba8f94a7ffac85db19cb0182b896040516112ad91906119f2565b60405180910390a35050506112c06116e0565b50505050565b6112ce6116e9565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361133e575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161133591906119c1565b60405180910390fd5b61134781611770565b50565b6008602052805f5260405f205f915054906101000a900460ff1681565b6002600154036113ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a390612278565b60405180910390fd5b6002600181905550565b5f5f600267ffffffffffffffff8111156113d3576113d2611c21565b5b6040519080825280602002602001820160405280156114015781602001602082028036833780820191505090505b5090507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2815f8151811061143857611437612296565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f00000000000000000000000000c2999c8b2adf4abc835cc63209533973718eb1816001815181106114a7576114a6612296565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663d06ca61f85846040518363ffffffff1660e01b815260040161153d92919061237a565b5f60405180830381865afa158015611557573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061157f919061246c565b90505f8160018151811061159657611595612296565b5b602002602001015190505f61271060c86127106115b39190611e90565b836115be9190611df2565b6115c89190611e60565b90505f61012c426115d99190611ec3565b90505f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff16637ff36ab589858930876040518663ffffffff1660e01b815260040161163c94939291906124b3565b5f6040518083038185885af1158015611657573d5f5f3e3d5ffd5b50505050506040513d5f823e3d601f19601f82011682018060405250810190611680919061246c565b90505f8160018151811061169757611696612296565b5b602002602001015190508860045f8282546116b29190611ec3565b925050819055508060055f8282546116ca9190611ec3565b9250508190555080975050505050505050919050565b60018081905550565b6116f1611903565b73ffffffffffffffffffffffffffffffffffffffff1661170f610cf4565b73ffffffffffffffffffffffffffffffffffffffff161461176e57611732611903565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161176591906119c1565b60405180910390fd5b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f6041825114611876576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186d90612547565b60405180910390fd5b5f5f5f602085015192506040850151915060608501515f1a9050601b8160ff1610156118ac57601b816118a99190612571565b90505b6001868285856040515f81526020016040526040516118ce94939291906125c3565b6020604051602081039080840390855afa1580156118ee573d5f5f3e3d5ffd5b50505060206040510351935050505092915050565b5f33905090565b5f82825260208201905092915050565b7f55736520616374697661746528292066756e6374696f6e0000000000000000005f82015250565b5f61194e60178361190a565b91506119598261191a565b602082019050919050565b5f6020820190508181035f83015261197b81611942565b9050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6119ab82611982565b9050919050565b6119bb816119a1565b82525050565b5f6020820190506119d45f8301846119b2565b92915050565b5f819050919050565b6119ec816119da565b82525050565b5f602082019050611a055f8301846119e3565b92915050565b5f604051905090565b5f5ffd5b5f5ffd5b611a25816119da565b8114611a2f575f5ffd5b50565b5f81359050611a4081611a1c565b92915050565b5f60208284031215611a5b57611a5a611a14565b5b5f611a6884828501611a32565b91505092915050565b611a7a816119a1565b8114611a84575f5ffd5b50565b5f81359050611a9581611a71565b92915050565b5f60208284031215611ab057611aaf611a14565b5b5f611abd84828501611a87565b91505092915050565b5f5f60408385031215611adc57611adb611a14565b5b5f611ae985828601611a87565b9250506020611afa85828601611a32565b9150509250929050565b5f819050919050565b611b1681611b04565b8114611b20575f5ffd5b50565b5f81359050611b3181611b0d565b92915050565b5f60208284031215611b4c57611b4b611a14565b5b5f611b5984828501611b23565b91505092915050565b5f8115159050919050565b611b7681611b62565b82525050565b5f602082019050611b8f5f830184611b6d565b92915050565b5f819050919050565b5f611bb8611bb3611bae84611982565b611b95565b611982565b9050919050565b5f611bc982611b9e565b9050919050565b5f611bda82611bbf565b9050919050565b611bea81611bd0565b82525050565b5f602082019050611c035f830184611be1565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611c5782611c11565b810181811067ffffffffffffffff82111715611c7657611c75611c21565b5b80604052505050565b5f611c88611a0b565b9050611c948282611c4e565b919050565b5f67ffffffffffffffff821115611cb357611cb2611c21565b5b611cbc82611c11565b9050602081019050919050565b828183375f83830152505050565b5f611ce9611ce484611c99565b611c7f565b905082815260208101848484011115611d0557611d04611c0d565b5b611d10848285611cc9565b509392505050565b5f82601f830112611d2c57611d2b611c09565b5b8135611d3c848260208601611cd7565b91505092915050565b5f5f5f5f60808587031215611d5d57611d5c611a14565b5b5f611d6a87828801611a32565b9450506020611d7b87828801611b23565b935050604085013567ffffffffffffffff811115611d9c57611d9b611a18565b5b611da887828801611d18565b9250506060611db987828801611a32565b91505092959194509250565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611dfc826119da565b9150611e07836119da565b9250828202611e15816119da565b91508282048414831517611e2c57611e2b611dc5565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f611e6a826119da565b9150611e75836119da565b925082611e8557611e84611e33565b5b828204905092915050565b5f611e9a826119da565b9150611ea5836119da565b9250828203905081811115611ebd57611ebc611dc5565b5b92915050565b5f611ecd826119da565b9150611ed8836119da565b9250828201905080821115611ef057611eef611dc5565b5b92915050565b5f81905092915050565b50565b5f611f0e5f83611ef6565b9150611f1982611f00565b5f82019050919050565b5f611f2d82611f03565b9150819050919050565b5f608082019050611f4a5f8301876119e3565b611f5760208301866119e3565b611f6460408301856119e3565b611f7160608301846119e3565b95945050505050565b5f606082019050611f8d5f8301866119b2565b611f9a60208301856119b2565b611fa760408301846119e3565b949350505050565b611fb881611b62565b8114611fc2575f5ffd5b50565b5f81519050611fd381611faf565b92915050565b5f60208284031215611fee57611fed611a14565b5b5f611ffb84828501611fc5565b91505092915050565b7f496e76616c6964206164647265737300000000000000000000000000000000005f82015250565b5f612038600f8361190a565b915061204382612004565b602082019050919050565b5f6020820190508181035f8301526120658161202c565b9050919050565b5f60408201905061207f5f8301856119b2565b61208c60208301846119e3565b9392505050565b5f815190506120a181611a1c565b92915050565b5f602082840312156120bc576120bb611a14565b5b5f6120c984828501612093565b91505092915050565b5f8160601b9050919050565b5f6120e8826120d2565b9050919050565b5f6120f9826120de565b9050919050565b61211161210c826119a1565b6120ef565b82525050565b5f819050919050565b61213161212c826119da565b612117565b82525050565b5f819050919050565b61215161214c82611b04565b612137565b82525050565b5f6121628288612100565b6014820191506121728287612120565b6020820191506121828286612140565b6020820191506121928285612120565b6020820191506121a28284612100565b6014820191508190509695505050505050565b5f81905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f82015250565b5f6121f3601c836121b5565b91506121fe826121bf565b601c82019050919050565b5f612213826121e7565b915061221f8284612140565b60208201915081905092915050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c005f82015250565b5f612262601f8361190a565b915061226d8261222e565b602082019050919050565b5f6020820190508181035f83015261228f81612256565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6122f5816119a1565b82525050565b5f61230683836122ec565b60208301905092915050565b5f602082019050919050565b5f612328826122c3565b61233281856122cd565b935061233d836122dd565b805f5b8381101561236d57815161235488826122fb565b975061235f83612312565b925050600181019050612340565b5085935050505092915050565b5f60408201905061238d5f8301856119e3565b818103602083015261239f818461231e565b90509392505050565b5f67ffffffffffffffff8211156123c2576123c1611c21565b5b602082029050602081019050919050565b5f5ffd5b5f6123e96123e4846123a8565b611c7f565b9050808382526020820190506020840283018581111561240c5761240b6123d3565b5b835b8181101561243557806124218882612093565b84526020840193505060208101905061240e565b5050509392505050565b5f82601f83011261245357612452611c09565b5b81516124638482602086016123d7565b91505092915050565b5f6020828403121561248157612480611a14565b5b5f82015167ffffffffffffffff81111561249e5761249d611a18565b5b6124aa8482850161243f565b91505092915050565b5f6080820190506124c65f8301876119e3565b81810360208301526124d8818661231e565b90506124e760408301856119b2565b6124f460608301846119e3565b95945050505050565b7f496e76616c6964207369676e6174757265206c656e67746800000000000000005f82015250565b5f61253160188361190a565b915061253c826124fd565b602082019050919050565b5f6020820190508181035f83015261255e81612525565b9050919050565b5f60ff82169050919050565b5f61257b82612565565b915061258683612565565b9250828201905060ff81111561259f5761259e611dc5565b5b92915050565b6125ae81611b04565b82525050565b6125bd81612565565b82525050565b5f6080820190506125d65f8301876125a5565b6125e360208301866125b4565b6125f060408301856125a5565b6125fd60608301846125a5565b9594505050505056fea2646970667358221220cd0282d48bf1fcbb43fd083c3c39f47a9858d92cf65dab86d57af61161783e7664736f6c634300081f0033
Verified Source Code Full Match
Compiler: v0.8.31+commit.fd3a2265
EVM: osaka
Optimization: No
STATEActivationBuyback.sol 300 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/**
* @title STATE Activation & Buyback Contract
* @author NWO.CAPITAL
* @notice Users pay ETH to activate their payout window.
* 30% goes to deployer operations wallet.
* 70% auto-buys STATE from DEX to create buy pressure.
* @dev Deployed on Ethereum mainnet
*/
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract STATEActivationBuyback is Ownable, ReentrancyGuard {
// ============ IMMUTABLE PARAMETERS ============
/// @notice Deployer/operations wallet - receives 30% of ETH
address public immutable DEPLOYER_WALLET;
/// @notice STATE token contract address
address public immutable STATE_TOKEN;
/// @notice WETH address for Uniswap routing
address public immutable WETH;
/// @notice Uniswap V2 Router for buybacks
IUniswapV2Router02 public immutable UNISWAP_ROUTER;
/// @notice Activation fee in ETH (~$9 USD)
uint256 public constant ACTIVATION_FEE = 0.003 ether;
/// @notice Deployer share: 30%
uint256 public constant DEPLOYER_SHARE = 30;
/// @notice Buyback share: 70%
uint256 public constant BUYBACK_SHARE = 70;
/// @notice Total basis points
uint256 public constant TOTAL_BPS = 100;
/// @notice Slippage tolerance for buybacks (2%)
uint256 public constant SLIPPAGE_TOLERANCE = 200;
// ============ STATE VARIABLES ============
/// @notice Tracks total ETH collected from activations
uint256 public totalEthCollected;
/// @notice Tracks total ETH sent to deployer
uint256 public totalEthToDeployer;
/// @notice Tracks total ETH used for buybacks
uint256 public totalEthForBuyback;
/// @notice Tracks total STATE tokens bought back
uint256 public totalStateBoughtBack;
/// @notice Tracks user activation status
mapping(address => bool) public hasActivated;
/// @notice Backend signer for authorizing claims
address public backendSigner;
/// @notice Used nonces (prevents replay attacks)
mapping(bytes32 => bool) public usedNonces;
// ============ EVENTS ============
event ActivationPaid(
address indexed user,
uint256 ethAmount,
uint256 deployerShare,
uint256 buybackShare,
uint256 stateBought
);
event TokensClaimed(
address indexed user,
uint256 amount,
bytes32 indexed nonce
);
event BackendSignerUpdated(address indexed oldSigner, address indexed newSigner);
// ============ ERRORS ============
error InvalidETHAmount();
error ActivationFailed();
error BuybackFailed();
error TransferFailed();
error InvalidTokenAddress();
error InvalidRouterAddress();
error InvalidSignature();
error NonceAlreadyUsed();
error ActivationRequired();
error AlreadyActivated();
error InsufficientContractBalance();
// ============ CONSTRUCTOR ============
constructor(
address _stateToken,
address _weth,
address _uniswapRouter,
address _deployerWallet,
address _backendSigner
) Ownable(msg.sender) {
if (_stateToken == address(0)) revert InvalidTokenAddress();
if (_uniswapRouter == address(0)) revert InvalidRouterAddress();
if (_deployerWallet == address(0)) revert InvalidTokenAddress();
if (_backendSigner == address(0)) revert InvalidTokenAddress();
STATE_TOKEN = _stateToken;
WETH = _weth;
UNISWAP_ROUTER = IUniswapV2Router02(_uniswapRouter);
DEPLOYER_WALLET = _deployerWallet;
backendSigner = _backendSigner;
}
// ============ ACTIVATION WITH AUTO-BUYBACK ============
/**
* @notice User pays ETH to activate their payout window
* @dev Sends 30% to deployer, 70% buys STATE from DEX
*/
function activate() external payable nonReentrant {
if (hasActivated[msg.sender]) revert AlreadyActivated();
if (msg.value != ACTIVATION_FEE) revert InvalidETHAmount();
// Calculate shares
uint256 deployerAmount = (msg.value * DEPLOYER_SHARE) / TOTAL_BPS;
uint256 buybackAmount = msg.value - deployerAmount;
// Update tracking
totalEthCollected += msg.value;
// 1. Send 30% to deployer wallet
(bool deployerSuccess, ) = payable(DEPLOYER_WALLET).call{value: deployerAmount}("");
if (!deployerSuccess) revert TransferFailed();
totalEthToDeployer += deployerAmount;
// 2. Use 70% to buy STATE from DEX
uint256 stateBought = _executeBuyback(buybackAmount);
// 3. Record user activation
hasActivated[msg.sender] = true;
emit ActivationPaid(
msg.sender,
msg.value,
deployerAmount,
buybackAmount,
stateBought
);
}
// ============ CLAIM EARNED TOKENS ============
function claim(
uint256 amount,
bytes32 nonce,
bytes memory signature,
uint256 deadline
) external nonReentrant {
// Verify user activated
if (!hasActivated[msg.sender]) revert ActivationRequired();
// Check deadline not expired
if (block.timestamp > deadline) revert TransferFailed();
// Check nonce not used before
if (usedNonces[nonce]) revert NonceAlreadyUsed();
// Verify backend signature
bytes32 message = keccak256(abi.encodePacked(
msg.sender,
amount,
nonce,
deadline,
address(this)
));
bytes32 ethSignedMessage = keccak256(abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
message
));
address signer = recoverSigner(ethSignedMessage, signature);
if (signer != backendSigner) revert InvalidSignature();
// Mark nonce used
usedNonces[nonce] = true;
// Verify contract has enough STATE
if (IERC20(STATE_TOKEN).balanceOf(address(this)) < amount) {
revert InsufficientContractBalance();
}
// Send STATE to user
IERC20(STATE_TOKEN).transfer(msg.sender, amount);
emit TokensClaimed(msg.sender, amount, nonce);
}
// ============ INTERNAL FUNCTIONS ============
function _executeBuyback(uint256 _ethAmount) internal returns (uint256) {
address[] memory path = new address[](2);
path[0] = WETH;
path[1] = STATE_TOKEN;
// Get expected output
uint256[] memory amounts = UNISWAP_ROUTER.getAmountsOut(_ethAmount, path);
uint256 expectedOutput = amounts[1];
// Apply 2% slippage (98% of expected)
uint256 minOutput = (expectedOutput * (10000 - SLIPPAGE_TOLERANCE)) / 10000;
uint256 deadline = block.timestamp + 5 minutes;
uint256[] memory swapResults = UNISWAP_ROUTER.swapExactETHForTokens{value: _ethAmount}(
minOutput,
path,
address(this),
deadline
);
uint256 stateReceived = swapResults[1];
totalEthForBuyback += _ethAmount;
totalStateBoughtBack += stateReceived;
return stateReceived;
}
function recoverSigner(bytes32 ethSignedMessage, bytes memory signature)
internal
pure
returns (address)
{
require(signature.length == 65, "Invalid signature length");
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96)))
}
if (v < 27) v += 27;
return ecrecover(ethSignedMessage, v, r, s);
}
// ============ ADMIN FUNCTIONS ============
function setBackendSigner(address _newSigner) external onlyOwner {
require(_newSigner != address(0), "Invalid address");
address oldSigner = backendSigner;
backendSigner = _newSigner;
emit BackendSignerUpdated(oldSigner, _newSigner);
}
function fundContract(uint256 amount) external {
IERC20(STATE_TOKEN).transferFrom(msg.sender, address(this), amount);
}
function emergencyWithdrawState(address _to, uint256 _amount) external onlyOwner {
IERC20(STATE_TOKEN).transfer(_to, _amount);
}
function emergencyWithdrawETH(address _to, uint256 _amount) external onlyOwner {
(bool success, ) = payable(_to).call{value: _amount}("");
if (!success) revert TransferFailed();
}
// ============ VIEW FUNCTIONS ============
function isActivated(address user) external view returns (bool) {
return hasActivated[user];
}
function getContractBalance() external view returns (uint256) {
return IERC20(STATE_TOKEN).balanceOf(address(this));
}
function isNonceUsed(bytes32 nonce) external view returns (bool) {
return usedNonces[nonce];
}
receive() external payable {
revert("Use activate() function");
}
}
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;
}
}
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);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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);
}
IUniswapV2Router02.sol 44 lines
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
IUniswapV2Router01.sol 95 lines
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
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;
}
}
Read Contract
ACTIVATION_FEE 0xe9ca7907 → uint256
BUYBACK_SHARE 0xeb72e4f5 → uint256
DEPLOYER_SHARE 0xdfb8cf93 → uint256
DEPLOYER_WALLET 0x00ac08e0 → address
SLIPPAGE_TOLERANCE 0x4c203786 → uint256
STATE_TOKEN 0x260cf409 → address
TOTAL_BPS 0xd3cd52bc → uint256
UNISWAP_ROUTER 0xd8264920 → address
WETH 0xad5c4648 → address
backendSigner 0x65d65e86 → address
getContractBalance 0x6f9fb98a → uint256
hasActivated 0xd4dfd456 → bool
isActivated 0xc9faa7c5 → bool
isNonceUsed 0xb90665e5 → bool
owner 0x8da5cb5b → address
totalEthCollected 0xce2a9f62 → uint256
totalEthForBuyback 0x3ae02aef → uint256
totalEthToDeployer 0x9f37c171 → uint256
totalStateBoughtBack 0x30301cdc → uint256
usedNonces 0xfeb61724 → bool
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
activate 0x0f15f4c0
No parameters
claim 0xf1bb05c0
uint256 amount
bytes32 nonce
bytes signature
uint256 deadline
emergencyWithdrawETH 0xd79e8567
address _to
uint256 _amount
emergencyWithdrawState 0x64bca328
address _to
uint256 _amount
fundContract 0x3519a2f8
uint256 amount
renounceOwnership 0x715018a6
No parameters
setBackendSigner 0x36f95670
address _newSigner
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address