Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xE9cAFc8c14C44592aB976F5450D0d40f97668ffc
ENS Name shib.shi4gud.eth
Balance 0.000650168 ETH
Nonce 1
Code Size 16974 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

16974 bytes
0x6080604052600436106103855760003560e01c8063944de246116101d1578063b5b05e9e11610102578063d89135cd116100a0578063e89d048e1161006f578063e89d048e14610be5578063f2fde38b14610c05578063f3acae3a14610c25578063fd52b70214610c5757600080fd5b8063d89135cd14610b69578063dc09deaf14610b7f578063de96e6c614610b95578063dfa00b1c14610bc557600080fd5b8063ca1d1b87116100dc578063ca1d1b8714610ac0578063ca1d9cc214610afc578063cb8cbb6e14610b1c578063d138321e14610b4957600080fd5b8063b5b05e9e14610a42578063c0d4e0e014610a6f578063c377e65d14610aa057600080fd5b8063ab3ad1d41161016f578063b1b3d3f611610149578063b1b3d3f614610997578063b1b71afa146109de578063b34913eb14610a01578063b53da9d914610a2257600080fd5b8063ab3ad1d41461091f578063adec2f771461093f578063b079861e1461095f57600080fd5b8063a42bebbe116101ab578063a42bebbe14610872578063a64d755c14610892578063a694fc3a146108b5578063ab040107146108d557600080fd5b8063944de2461461080c5780639e96a23a14610839578063a2ca6dce1461084157600080fd5b80633407e1c3116102b657806349ecd132116102545780637aecd534116102235780637aecd534146107595780637b0443fa1461079457806384b366dc146107b45780638da5cb5b146107e157600080fd5b806349ecd132146106d25780635fbe4d1d146106e75780636c6cdea814610714578063715018a61461074457600080fd5b806342935eb31161029057806342935eb31461065957806342d79e0d1461066f5780634437152a1461069c57806348cd4cb1146106bc57600080fd5b80633407e1c3146105cb5780633b98548f146105eb5780633fdf4f621461063957600080fd5b80631b46ba84116103235780632d4812ed116102fd5780632d4812ed1461054b5780632e1a7d4d1461056b57806330606eaf1461058b57806330e3cb68146105ab57600080fd5b80631b46ba84146104be5780631bf533a4146104e057806326cf11031461050057600080fd5b806309c15e781161035f57806309c15e7814610403578063135078ef1461043057806316f0115b146104515780631a9f16bb146104a357600080fd5b806303c424c714610391578063081a7ad3146103c457806309b1ef26146103e857600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506014546103ac9061ffff1681565b60405161ffff90911681526020015b60405180910390f35b3480156103d057600080fd5b506103da60095481565b6040519081526020016103bb565b3480156103f457600080fd5b50600e546103ac9061ffff1681565b34801561040f57600080fd5b506103da61041e366004613dc1565b60196020526000908152604090205481565b34801561043c57600080fd5b50600c546103ac9062010000900461ffff1681565b34801561045d57600080fd5b5060055461047e9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016103bb565b3480156104af57600080fd5b50600c546103ac9061ffff1681565b3480156104ca57600080fd5b506104de6104d9366004613dc1565b610c77565b005b3480156104ec57600080fd5b506104de6104fb366004613e2e565b610cc6565b34801561050c57600080fd5b5061053b61051b366004613e83565b601860209081526000928352604080842090915290825290205460ff1681565b60405190151581526020016103bb565b34801561055757600080fd5b506104de610566366004613dc1565b6110af565b34801561057757600080fd5b506104de610586366004613ebc565b61155b565b34801561059757600080fd5b506104de6105a6366004613ed5565b61175d565b3480156105b757600080fd5b506104de6105c6366004613f0f565b611bc9565b3480156105d757600080fd5b506104de6105e6366004613f2c565b611c97565b3480156105f757600080fd5b5061047e610606366004613ed5565b601060209081526000928352604080842090915290825290205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561064557600080fd5b506104de610654366004613f2c565b611cd4565b34801561066557600080fd5b506103da600a5481565b34801561067b57600080fd5b506103da61068a366004613dc1565b60076020526000908152604090205481565b3480156106a857600080fd5b506104de6106b7366004613dc1565b611d95565b3480156106c857600080fd5b506103da600d5481565b3480156106de57600080fd5b506104de611dfa565b3480156106f357600080fd5b5060025461047e9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561072057600080fd5b5061053b61072f366004613dc1565b60116020526000908152604090205460ff1681565b34801561075057600080fd5b506104de612018565b34801561076557600080fd5b5061053b610774366004613e83565b601760209081526000928352604080842090915290825290205460ff1681565b3480156107a057600080fd5b506104de6107af366004613e2e565b61202c565b3480156107c057600080fd5b5060035461047e9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156107ed57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1661047e565b34801561081857600080fd5b5060065461047e9073ffffffffffffffffffffffffffffffffffffffff1681565b6104de61242c565b34801561084d57600080fd5b506103ac61085c366004613dc1565b60166020526000908152604090205461ffff1681565b34801561087e57600080fd5b506104de61088d366004613e83565b61288f565b34801561089e57600080fd5b50600e546103ac90640100000000900461ffff1681565b3480156108c157600080fd5b506104de6108d0366004613ebc565b612ab5565b3480156108e157600080fd5b506104de33600090815260086020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b34801561092b57600080fd5b506104de61093a366004613f2c565b612c99565b34801561094b57600080fd5b506104de61095a366004613dc1565b612cdc565b34801561096b57600080fd5b506103da61097a366004613ed5565b601260209081526000928352604080842090915290825290205481565b3480156109a357600080fd5b506104de33600090815260086020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b3480156109ea57600080fd5b50600c546103ac90640100000000900461ffff1681565b348015610a0d57600080fd5b50600e546103ac9062010000900461ffff1681565b348015610a2e57600080fd5b506104de610a3d366004613dc1565b612e97565b348015610a4e57600080fd5b506103da610a5d366004613dc1565b601a6020526000908152604090205481565b348015610a7b57600080fd5b506103ac610a8a366004613dc1565b60156020526000908152604090205461ffff1681565b348015610aac57600080fd5b506104de610abb366004613f2c565b61307b565b348015610acc57600080fd5b506103ac610adb366004613f50565b600f60209081526000928352604080842090915290825290205461ffff1681565b348015610b0857600080fd5b506104de610b17366004613e2e565b6130c0565b348015610b2857600080fd5b5060045461047e9073ffffffffffffffffffffffffffffffffffffffff1681565b348015610b5557600080fd5b506104de610b64366004613dc1565b6134d1565b348015610b7557600080fd5b506103da600b5481565b348015610b8b57600080fd5b506103da60135481565b348015610ba157600080fd5b5061053b610bb0366004613dc1565b60086020526000908152604090205460ff1681565b348015610bd157600080fd5b506104de610be0366004613dc1565b61367f565b348015610bf157600080fd5b506104de610c00366004613f2c565b613864565b348015610c1157600080fd5b506104de610c20366004613dc1565b61391d565b348015610c3157600080fd5b5060055461053b9074010000000000000000000000000000000000000000900460ff1681565b348015610c6357600080fd5b506104de610c72366004613f2c565b6139d1565b610c7f613a91565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3360009081526011602052604090205460ff16610d44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a656400000000000000000000000000000000000060448201526064015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260086020526040902054839060ff1615610dd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4465636c696e65640000000000000000000000000000000000000000000000006044820152606401610d3b565b600e54600d54610dea9161ffff1690613fa4565b4311610e52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f45706f636820696e636f6d706c657465000000000000000000000000000000006044820152606401610d3b565b600d54336000908152601a602052604090205414801590610e815750336000908152601a602052604090205415155b15610f0257336000908152601a602090815260408083205460128352818420818552909252909120548015801590610eba5750600d5482105b15610eff573360009081526019602052604081208054839290610ede908490613fa4565b90915550503360009081526012602090815260408083208584529091528120555b50505b600d54336000908152601a6020908152604080832084905560108252808320938352929052205473ffffffffffffffffffffffffffffffffffffffff1615610fa6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f416c726561647920766f746564000000000000000000000000000000000000006044820152606401610d3b565b600d546000908152600f6020908152604080832073ffffffffffffffffffffffffffffffffffffffff881684529091528120805461ffff1691610fe883613fbd565b82546101009290920a61ffff81810219909316919092169190910217905550336000908152601060209081526040808320600d548452909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055611069613b12565b507f909b43dcc56d91024768bbc5c8d56441234580b2fd6176844960cbc7218cc0b5600d548585856040516110a19493929190614027565b60405180910390a150505050565b3360009081526011602052604090205460ff16611128576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260086020526040902054819060ff16156111ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4465636c696e65640000000000000000000000000000000000000000000000006044820152606401610d3b565b600e54600d546111ce9161ffff1690613fa4565b4311611236576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f45706f636820696e636f6d706c657465000000000000000000000000000000006044820152606401610d3b565b600d54336000908152601a6020526040902054148015906112655750336000908152601a602052604090205415155b156112e657336000908152601a60209081526040808320546012835281842081855290925290912054801580159061129e5750600d5482105b156112e35733600090815260196020526040812080548392906112c2908490613fa4565b90915550503360009081526012602090815260408083208584529091528120555b50505b600d54336000908152601a60209081526040808320849055928252600f815282822073ffffffffffffffffffffffffffffffffffffffff861683529052205461ffff1661138f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f496e76616c6964206465737400000000000000000000000000000000000000006044820152606401610d3b565b336000908152601060209081526040808320600d54845290915290205473ffffffffffffffffffffffffffffffffffffffff16611428576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f566f7465206d697373696e6700000000000000000000000000000000000000006044820152606401610d3b565b600d546000908152600f6020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091528120805461ffff169161146a83614067565b825461ffff9182166101009390930a928302919092021990911617905550336000908152601060209081526040808320600d548452909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556114d2613bba565b600d546040805191825273ffffffffffffffffffffffffffffffffffffffff8416602083015260608282018190526003908301527f72737400000000000000000000000000000000000000000000000000000000006080830152517f909b43dcc56d91024768bbc5c8d56441234580b2fd6176844960cbc7218cc0b59181900360a00190a15050565b33600090815260076020526040902054811180159061157c57506009548111155b6115e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f457863656564732062616c616e636500000000000000000000000000000000006044820152606401610d3b565b33600090815260076020526040812080548392906116019084906140a3565b92505081905550806009600082825461161a91906140a3565b90915550506001546040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810183905273ffffffffffffffffffffffffffffffffffffffff9091169063a9059cbb906044016020604051808303816000875af1158015611696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ba91906140b6565b611720576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610d3b565b60408051338152602081018390527fb244b9a17ad633c6e83b7983ee04320484956a68ddbe96a0b70dfca1cf19d72391015b60405180910390a150565b3360009081526011602052604090205460ff166117d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260086020526040902054829060ff1615611868576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4465636c696e65640000000000000000000000000000000000000000000000006044820152606401610d3b565b600e54600d5461187c9161ffff1690613fa4565b43116118e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f45706f636820696e636f6d706c657465000000000000000000000000000000006044820152606401610d3b565b600d54336000908152601a6020526040902054148015906119135750336000908152601a602052604090205415155b1561199457336000908152601a60209081526040808320546012835281842081855290925290912054801580159061194c5750600d5482105b15611991573360009081526019602052604081208054839290611970908490613fa4565b90915550503360009081526012602090815260408083208584529091528120555b50505b600d54336000908152601a60209081526040808320849055600e54938352600f825280832073ffffffffffffffffffffffffffffffffffffffff8816845290915290205461ffff62010000909204821691161015611a4e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4e6f20636f6e73656e73757300000000000000000000000000000000000000006044820152606401610d3b565b6000611a58613b12565b90506000818411611a6a576000611a74565b611a7482856140a3565b600e54600d54919250611a8d9161ffff90911690613fa4565b600d55611a9c600a60646140d3565b61ffff16811115611b735760008573ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114611b01576040519150601f19603f3d011682016040523d82523d6000602084013e611b06565b606091505b5050905080611b71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610d3b565b505b6040805173ffffffffffffffffffffffffffffffffffffffff87168152602081018390527f5df9aa58816b17fb728eddad0162659653310b4f9cd8796a7c647612b3d520ba910160405180910390a15050505050565b611bd1613a91565b801515600560149054906101000a900460ff16151503611c4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f53616d652076616c7565000000000000000000000000000000000000000000006044820152606401610d3b565b6005805491151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b611c9f613a91565b600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff92909216919091179055565b611cdc613a91565b611ce8600a60326140d3565b61ffff168161ffff1610611d58576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f4275726e20666163746f72203e3d2035302500000000000000000000000000006044820152606401610d3b565b600c805461ffff909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff909216919091179055565b611d9d613a91565b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790556000611de7613c0e565b905060008111611df657600080fd5b5050565b600d54336000908152601a602052604090205414801590611e295750336000908152601a602052604090205415155b15611eaa57336000908152601a602090815260408083205460128352818420818552909252909120548015801590611e625750600d5482105b15611ea7573360009081526019602052604081208054839290611e86908490613fa4565b90915550503360009081526012602090815260408083208584529091528120555b50505b600d54336000908152601a602090815260408083208490556019909152902054600e549091611edd9161ffff1690613fa4565b431115611f3357336000908152601260209081526040808320600d5484529091529020548015611f3157611f118183613fa4565b336000908152601260209081526040808320600d54845290915281205591505b505b33600090815260196020526040812081905560138054839290611f579084906140a3565b909155505047811161201557604051600090339083908381818185875af1925050503d8060008114611fa5576040519150601f19603f3d011682016040523d82523d6000602084013e611faa565b606091505b5050905080611df6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f4661696c656400000000000000000000000000000000000000000000000000006044820152606401610d3b565b50565b612020613a91565b61202a6000613d2a565b565b3360009081526011602052604090205460ff166120a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b33600090815260176020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915290205460ff1615612140576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f416c726561647920766f74656420666f722074686973206164640000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff831660009081526011602052604090205460ff16156121d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f416c726561647920616e204f43206e6f646500000000000000000000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601560205260408120805461ffff169161220583613fbd565b825461ffff9182166101009390930a92830291909202199091161790555033600081815260176020908152604080832073ffffffffffffffffffffffffffffffffffffffff881680855292529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519091907f6f16cedcfba9076088f50cb98393296e065155864bc7f3c923530550e35fd455906122b290869086906140fd565b60405180910390a36014546000906002906122d29061ffff166001614119565b6122dc919061416a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526015602052604090205490915061ffff8083169116106124265773ffffffffffffffffffffffffffffffffffffffff8416600090815260116020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556014805461ffff169161237283613fbd565b82546101009290920a61ffff818102199093169183160217909155601454600292506123a091166001614119565b6123aa919061416a565b600e805461ffff9290921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff90921691909117905560405173ffffffffffffffffffffffffffffffffffffffff8516907fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd90600090a25b50505050565b600061243a600a60646140d3565b600c5461ffff9182169161245591620100009004163461418b565b61245f91906141c8565b905080600a60008282546124739190613fa4565b9091555060009050612483613c0e565b905060008161249a34670de0b6b3a764000061418b565b6124a491906141c8565b6009549091506124b6600a60646140d3565b6124c59061ffff16600a6141dc565b63ffffffff166009541115612505576124e0600a60646140d3565b600c5460095461ffff928316926124f892169061418b565b61250291906141c8565b90505b600c54819061252190640100000000900461ffff1660026140d3565b61ffff16612530600a8461418b565b61253a91906141c8565b83101561256e57600c54600a9061255d90640100000000900461ffff168561418b565b61256791906141c8565b9050612634565b600c54640100000000900461ffff16612588600a8461418b565b61259291906141c8565b8310156125e1576125a46004836141c8565b6125b0600a60026140d3565b600c5461ffff918216916125cd916401000000009004168661418b565b6125d791906141c8565b6125679190613fa4565b81831015612634576125f46002836141c8565b612600600a60046140d3565b600c5461ffff9182169161261d916401000000009004168661418b565b61262791906141c8565b6126319190613fa4565b90505b60008111801561264657508060095410155b1561278457806009600082825461265d91906140a3565b9250508190555080600b60008282546126769190613fa4565b9091555050600154600480546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821692810192909252602482018490529091169063a9059cbb906044016020604051808303816000875af11580156126fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271e91906140b6565b612784576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f4275726e206661696c65640000000000000000000000000000000000000000006044820152606401610d3b565b60035460405160009173ffffffffffffffffffffffffffffffffffffffff169087908381818185875af1925050503d80600081146127de576040519150601f19603f3d011682016040523d82523d6000602084013e6127e3565b606091505b505090508061284e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f446f6e617465206661696c6564000000000000000000000000000000000000006044820152606401610d3b565b60408051338152602081018890527fe3ba4a7522b6c3133015e07f410a43323021989ceedd5de9d51c5ec155288974910160405180910390a1505050505050565b612897613a91565b60025473ffffffffffffffffffffffffffffffffffffffff9081169082160361291c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f466f7262696464656e00000000000000000000000000000000000000000000006044820152606401610d3b565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152819073ffffffffffffffffffffffffffffffffffffffff82169063a9059cbb90859083906370a0823190602401602060405180830381865afa158015612992573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b691906141ff565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af1158015612a26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4a91906140b6565b612ab0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f4661696c656400000000000000000000000000000000000000000000000000006044820152606401610d3b565b505050565b60008111612b1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610d3b565b3360009081526007602052604081208054839290612b3e908490613fa4565b925050819055508060096000828254612b579190613fa4565b90915550506001546040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810183905273ffffffffffffffffffffffffffffffffffffffff909116906323b872dd906064016020604051808303816000875af1158015612bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bfd91906140b6565b612c63576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610d3b565b60408051338152602081018390527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9101611752565b612ca1613a91565b600e805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b612ce4613a91565b73ffffffffffffffffffffffffffffffffffffffff811660009081526011602052604090205460ff16612d73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f416c72656164792072656d6f76656400000000000000000000000000000000006044820152606401610d3b565b601454600161ffff90911611156120155773ffffffffffffffffffffffffffffffffffffffff8116600090815260116020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556014805461ffff1691612de183614067565b82546101009290920a61ffff81810219909316918316021790915560145460029250612e0f91166001614119565b612e19919061416a565b600e805461ffff9290921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff90921691909117905560405173ffffffffffffffffffffffffffffffffffffffff8216907fcfc24166db4bb677e857cacabd1541fb2b30645021b27c5130419589b84db52b90600090a250565b3360009081526011602052604090205460ff16612f10576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b33600090815260176020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16612fcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4e6f2061646420766f746520746f20726573657420666f72207468697320746160448201527f72676574000000000000000000000000000000000000000000000000000000006064820152608401610d3b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601560205260408120805461ffff169161300483614067565b825461ffff9182166101009390930a92830291909202199091161790555033600090815260176020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b613083613a91565b600e805461ffff909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff909216919091179055565b3360009081526011602052604090205460ff16613139576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b33600090815260186020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915290205460ff16156131d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416c726561647920766f74656420666f7220746869732072656d6f76650000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff831660009081526011602052604090205460ff16613263576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420616e204f43206e6f64650000000000000000000000000000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601660205260408120805461ffff169161329883613fbd565b825461ffff9182166101009390930a92830291909202199091161790555033600081815260186020908152604080832073ffffffffffffffffffffffffffffffffffffffff881680855292529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519091907f326236c4b24ce4385364a6e9ea51a988889c12b6ac3cea126fd823a9c822994f9061334590869086906140fd565b60405180910390a36014546000906002906133659061ffff166001614119565b61336f919061416a565b73ffffffffffffffffffffffffffffffffffffffff851660009081526016602052604090205490915061ffff8083169116108015906133b65750601454600161ffff909116115b156124265773ffffffffffffffffffffffffffffffffffffffff8416600090815260116020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556014805461ffff169161341883614067565b82546101009290920a61ffff8181021990931691831602179091556014546002925061344691166001614119565b613450919061416a565b600e805461ffff9290921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff90921691909117905560405173ffffffffffffffffffffffffffffffffffffffff8516907fcfc24166db4bb677e857cacabd1541fb2b30645021b27c5130419589b84db52b90600090a250505050565b6134d9613a91565b73ffffffffffffffffffffffffffffffffffffffff811660009081526011602052604090205460ff1615613569576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f416c7265616479207365740000000000000000000000000000000000000000006044820152606401610d3b565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260116020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556014805461ffff16916135c983613fbd565b82546101009290920a61ffff818102199093169183160217909155601454600292506135f791166001614119565b613601919061416a565b600e805461ffff9290921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff90921691909117905560405173ffffffffffffffffffffffffffffffffffffffff8216907fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd90600090a250565b3360009081526011602052604090205460ff166136f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606401610d3b565b33600090815260186020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166137b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f4e6f2072656d6f766520766f746520746f20726573657420666f72207468697360448201527f20746172676574000000000000000000000000000000000000000000000000006064820152608401610d3b565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601660205260408120805461ffff16916137ed83614067565b825461ffff9182166101009390930a92830291909202199091161790555033600090815260186020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b61386c613a91565b613878600a60326140d3565b61ffff168161ffff16106138e8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4d6178206275726e20707263203e3d20353025000000000000000000000000006044820152606401610d3b565b600c80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff92909216919091179055565b613925613a91565b73ffffffffffffffffffffffffffffffffffffffff81166139c8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610d3b565b61201581613d2a565b6139d9613a91565b6139e5600a60646140d3565b61ffff168161ffff161115613a56576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f446f6e6174696f6e20707263203e2031303025000000000000000000000000006044820152606401610d3b565b600c805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331461202a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610d3b565b6013546000908190471115613bb557613b2d600a60646140d3565b600e5460135461ffff9283169264010000000090920490911690613b5190476140a3565b613b5b919061418b565b613b6591906141c8565b336000908152601260209081526040808320600d548452909152812080549293508392909190613b96908490613fa4565b925050819055508060136000828254613baf9190613fa4565b90915550505b919050565b336000908152601260209081526040808320600d5484529091528120546013805491929091613bea9084906140a3565b9091555050336000908152601260209081526040808320600d548452909152812055565b60055460009074010000000000000000000000000000000000000000900460ff1615613cd0576006546005546040517f981bcefa00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff918216600482015291169063981bcefa906024015b602060405180830381865afa158015613ca7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ccb91906141ff565b905090565b6006546005546040517faea9107800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff918216600482015291169063aea9107890602401613c8a565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff8116811461201557600080fd5b600060208284031215613dd357600080fd5b8135613dde81613d9f565b9392505050565b60008083601f840112613df757600080fd5b50813567ffffffffffffffff811115613e0f57600080fd5b602083019150836020828501011115613e2757600080fd5b9250929050565b600080600060408486031215613e4357600080fd5b8335613e4e81613d9f565b9250602084013567ffffffffffffffff811115613e6a57600080fd5b613e7686828701613de5565b9497909650939450505050565b60008060408385031215613e9657600080fd5b8235613ea181613d9f565b91506020830135613eb181613d9f565b809150509250929050565b600060208284031215613ece57600080fd5b5035919050565b60008060408385031215613ee857600080fd5b8235613ef381613d9f565b946020939093013593505050565b801515811461201557600080fd5b600060208284031215613f2157600080fd5b8135613dde81613f01565b600060208284031215613f3e57600080fd5b813561ffff81168114613dde57600080fd5b60008060408385031215613f6357600080fd5b823591506020830135613eb181613d9f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115613fb757613fb7613f75565b92915050565b600061ffff808316818103613fd457613fd4613f75565b6001019392505050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b84815273ffffffffffffffffffffffffffffffffffffffff8416602082015260606040820152600061405d606083018486613fde565b9695505050505050565b600061ffff82168061407b5761407b613f75565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81810381811115613fb757613fb7613f75565b6000602082840312156140c857600080fd5b8151613dde81613f01565b600061ffff808316818516818304811182151516156140f4576140f4613f75565b02949350505050565b602081526000614111602083018486613fde565b949350505050565b61ffff81811683821601908082111561413457614134613f75565b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061ffff8084168061417f5761417f61413b565b92169190910492915050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156141c3576141c3613f75565b500290565b6000826141d7576141d761413b565b500490565b600063ffffffff808316818516818304811182151516156140f4576140f4613f75565b60006020828403121561421157600080fd5b505191905056fea26469706673582212205ddac55609de9d0395b2da1b2c73661facaf07f44ad02ad5bed47f531099063264736f6c63430008100033

Verified Source Code Full Match

Compiler: v0.8.16+commit.07a7930e EVM: london Optimization: Yes (1000000 runs)
Ktv2.sol 490 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/interfaces/IERC20.sol";
// import "hardhat/console.sol";

interface TPI {
    function price(address poolAddr) external view returns (uint);
    function priceV2(address pairAddr) external view returns (uint256);
}

contract Ktv2 is Ownable {
    event Staked(address, uint);
    event Withdrew(address, uint);
    event Gave(address, uint);
    event Rwd(address, uint);
    event Voted(uint, address, string);

    IERC20 token;
    address public tokenAddr;
    address payable public dest;

    address public burnDest;
    address public pool;
    bool public v2;

    TPI public tp;

    mapping(address => uint) public userStks;
    mapping(address => bool) public declines;

    uint public totalStk;
    uint public totalGvn;
    uint public totalBurned;
    uint16 public maxBrnPrc = 20;
    uint16 public donationPrc = 500;
    uint16 public burnFactor = 20;

    uint16 internal constant P_FCTR = 10;
    uint32 internal constant P_DEN = 100 * P_FCTR;

    uint public startBlock;
    uint16 public epochInterval = 44444;
    uint16 public consensusReq = 1;
    uint16 public ocFee = 2 * P_FCTR;

    // block => address => cnt
    mapping(uint => mapping(address => uint16)) public blockRwd;
    // ocRwdr => block => destVoted
    mapping(address => mapping(uint => address)) public ocRwdrVote;

    mapping(address => bool) public ocRwdrs;
    mapping(address => mapping(uint => uint)) public ocFees;
    uint public tlOcFees;

    // ------------------------------------------------------------------------
    // OC Management
    uint16 public totalOC = 1;
    // newOC => vote count
    mapping(address => uint16) public addVotes;
    // existingOC => vote count
    mapping(address => uint16) public removeVotes;
    // voter => target => voted for add
    mapping(address => mapping(address => bool)) public hasVotedAdd;
    // voter => target => voted for remove
    mapping(address => mapping(address => bool)) public hasVotedRemove;
    mapping(address => uint) public pastOcFees;
    mapping(address => uint) public lastStartBlock;

    // OC Management Events
    event VotedToAdd(address indexed voter, address indexed newOC, string data);
    event VotedToRemove(address indexed voter, address indexed existingOC, string data);
    event NodeAdded(address indexed newOC);
    event NodeRemoved(address indexed oldOC);

    /** -----------------------------------------------------------------------
     *
     */
    constructor(
        address _burnDest,
        address _token,
        address payable _dest,
        address _pool,
        address _ocPrcAddr,
        address _tp,
        bool _v2
    ) Ownable() {
        burnDest = _burnDest;
        tokenAddr = _token;
        token = IERC20(_token);
        dest = _dest;
        tp = TPI(_tp);
        startBlock = block.number;
        v2 = _v2;

        ocRwdrs[_ocPrcAddr] = true;
        setPool(_pool);
    }

    receive() external payable {}

    /** -----------------------------------------------------------------------
     * 
     */
    function rwd(address payable _to, uint _amt) external onlyOC notDeclined(_to) epochComplete migrateFees {
        require(blockRwd[startBlock][_to] >= consensusReq, "No consensus");

        uint fee = recordOCFee();
        uint _rwd = _amt > fee ? _amt - fee : 0;
        startBlock = startBlock + epochInterval;

        if(_rwd > P_DEN) {
            (bool sent, ) = _to.call{value: _rwd}("");
            require(sent, "Transfer failed");
        }

        emit Rwd(_to, _rwd);
    }


    /** -----------------------------------------------------------------------
     *
     */
    function vote(address payable _to, string calldata data) external onlyOC notDeclined(_to) epochComplete migrateFees {
        require(ocRwdrVote[msg.sender][startBlock] == address(0), "Already voted");

        blockRwd[startBlock][_to]++;
        ocRwdrVote[msg.sender][startBlock] = _to;

        recordOCFee();

        emit Voted(startBlock, _to, data);
    }

    /** -----------------------------------------------------------------------
     *
     */
    function resetVote(address _to) external onlyOC notDeclined(_to) epochComplete migrateFees {
        require(blockRwd[startBlock][_to] > 0, "Invalid dest");
        require(ocRwdrVote[msg.sender][startBlock] != address(0), "Vote missing");

        blockRwd[startBlock][_to]--;
        ocRwdrVote[msg.sender][startBlock] = address(0);
        resetOCFee();

        emit Voted(startBlock, _to, "rst");
    }

    /** -----------------------------------------------------------------------
     * 
     */
    function resetOCFee() private {
        tlOcFees -= ocFees[msg.sender][startBlock];
        ocFees[msg.sender][startBlock] = 0;
    }

    /** -----------------------------------------------------------------------
     * 
     */
    function recordOCFee() private returns (uint) {
        uint incrAmt = 0;
        if (address(this).balance > tlOcFees) {
            incrAmt = ((address(this).balance - tlOcFees) * ocFee) / P_DEN;
            ocFees[msg.sender][startBlock] += incrAmt;
            tlOcFees += incrAmt;
        }
        return incrAmt;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function withdrawOCFee() external migrateFees {
        uint amt = pastOcFees[msg.sender];
        if (block.number > startBlock + epochInterval) {  // Epoch complete
            uint currentFee = ocFees[msg.sender][startBlock];
            if (currentFee > 0) {
                amt += currentFee;
                ocFees[msg.sender][startBlock] = 0;
            }
        }

        pastOcFees[msg.sender] = 0;
        tlOcFees -= amt;
        if (address(this).balance >= amt) {
            (bool sent, ) = msg.sender.call{value: amt}("");
            require(sent, "Failed");
        }
    }

    /** -----------------------------------------------------------------------
     *
     */
    modifier migrateFees() {
        if (lastStartBlock[msg.sender] != startBlock && lastStartBlock[msg.sender] != 0) {
            uint oldBlock = lastStartBlock[msg.sender];
            uint oldFee = ocFees[msg.sender][oldBlock];
            if (oldFee > 0 && oldBlock < startBlock) {
                pastOcFees[msg.sender] += oldFee;
                ocFees[msg.sender][oldBlock] = 0;  // Clean up
            }
        }
        lastStartBlock[msg.sender] = startBlock;
        _;
    }

    /** -----------------------------------------------------------------------
     *
     */
    modifier epochComplete() {
        require(block.number > startBlock + epochInterval, "Epoch incomplete");
        _;
    }


    /** -----------------------------------------------------------------------
     *
     */
    modifier onlyOC() {
        require(ocRwdrs[msg.sender], "Not authorized");
        _;
    }

    /** -----------------------------------------------------------------------
     *
     */
    modifier notDeclined(address _to) {
        require(!declines[_to], "Declined");
        _;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setEpochInterval(uint16 interval) public onlyOwner {
        epochInterval = interval;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setConsensusReq(uint16 req) public onlyOwner {
        consensusReq = req;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setOCFee(uint16 fee) public onlyOwner {
        ocFee = fee;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function addOCRwdr(address addr) public onlyOwner {
        require(!ocRwdrs[addr], 'Already set');
        ocRwdrs[addr] = true;
        totalOC++;
        consensusReq = (totalOC + 1) / 2;
        emit NodeAdded(addr);
    }

    /** -----------------------------------------------------------------------
     *
     */
    function removeOCRwdr(address addr) public onlyOwner {
        require(ocRwdrs[addr], 'Already removed');
        if (totalOC > 1) {
            ocRwdrs[addr] = false;
            totalOC--;
            consensusReq = (totalOC + 1) / 2;
            emit NodeRemoved(addr);
        }
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setDest(address addr) public onlyOwner {
        dest = payable(addr);
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setMaxBurnPrc(uint16 amt) public onlyOwner {
        require(amt < 50 * P_FCTR, "Max burn prc >= 50%");
        maxBrnPrc = amt;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setBurnFactor(uint16 amt) public onlyOwner {
        require(amt < 50 * P_FCTR, "Burn factor >= 50%");
        burnFactor = amt;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setDonationPrc(uint16 amt) public onlyOwner {
        require(amt <= 100 * P_FCTR, "Donation prc > 100%");
        donationPrc = amt;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setV2(bool _v2) public onlyOwner {
        require(v2 != _v2, "Same value");
        v2 = _v2;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function getTokenPrice() private view returns (uint) {
        
        if (v2) {
            return tp.priceV2(pool);
        }
        else {
            return tp.price(pool);
        }
    }

    /** -----------------------------------------------------------------------
     *
     */
    function setPool(address _pool) public onlyOwner {
        pool = _pool;
        uint price = getTokenPrice();       
        require(price > 0);
    }

    /** -----------------------------------------------------------------------
     *
     */
    function decline() public {
        declines[msg.sender] = true;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function allow() public {
        declines[msg.sender] = false;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function voteToAdd(address newOC, string calldata data) external onlyOC {
        require(!hasVotedAdd[msg.sender][newOC], "Already voted for this add");
        require(!ocRwdrs[newOC], "Already an OC node");
        addVotes[newOC]++;
        hasVotedAdd[msg.sender][newOC] = true;
        emit VotedToAdd(msg.sender, newOC, data);
        
        uint16 required = (totalOC + 1) / 2;
        if (addVotes[newOC] >= required) {
            ocRwdrs[newOC] = true;
            totalOC++;
            consensusReq = (totalOC + 1) / 2;
            emit NodeAdded(newOC);
        }
    }

    /** -----------------------------------------------------------------------
     * 
     */
    function voteToRemove(address existingOC, string calldata data) external onlyOC {
        require(!hasVotedRemove[msg.sender][existingOC], "Already voted for this remove");
        require(ocRwdrs[existingOC], "Not an OC node");
        removeVotes[existingOC]++;
        hasVotedRemove[msg.sender][existingOC] = true;
        emit VotedToRemove(msg.sender, existingOC, data);
        
        uint16 required = (totalOC + 1) / 2;
        if (removeVotes[existingOC] >= required && totalOC > 1) {
            ocRwdrs[existingOC] = false;
            totalOC--;
            consensusReq = (totalOC + 1) / 2;
            emit NodeRemoved(existingOC);
        }
    }

    /** -----------------------------------------------------------------------
     *
     */
    function resetVoteToAdd(address newOC) external onlyOC {
        require(hasVotedAdd[msg.sender][newOC], "No add vote to reset for this target");
        addVotes[newOC]--;
        hasVotedAdd[msg.sender][newOC] = false;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function resetVoteToRemove(address existingOC) external onlyOC {
        require(hasVotedRemove[msg.sender][existingOC], "No remove vote to reset for this target");
        removeVotes[existingOC]--;
        hasVotedRemove[msg.sender][existingOC] = false;
    }

    /** -----------------------------------------------------------------------
     *
     */
    function stake(uint256 amt) external {
        require(amt > 0, "Amount must be greater than 0");

        userStks[msg.sender] += amt;
        totalStk += amt;

        require(token.transferFrom(msg.sender, address(this), amt), "Transfer failed");

        emit Staked(msg.sender, amt);
    }


    /** -----------------------------------------------------------------------
     *
     */
    function withdraw(uint amt) external {
        require(amt <= userStks[msg.sender] && amt <= totalStk, "Exceeds balance");

        userStks[msg.sender] -= amt;
        totalStk -= amt;

        require(token.transfer(msg.sender, amt), "Transfer failed");
        emit Withdrew(msg.sender, amt);
    }

    /** -----------------------------------------------------------------------
     * @dev Allows users to give funds to the contract.
     */
    function give() external payable {
        uint giveAmt = (msg.value * donationPrc) / P_DEN;
        totalGvn += giveAmt;

        uint tknPrice = getTokenPrice();
        uint tknAmtGvn = (msg.value * 10**18) / tknPrice;
        uint maxBrn = totalStk;

        if (totalStk > P_DEN * 10) {
            maxBrn = (totalStk * maxBrnPrc) / P_DEN;
        }

        uint burnAmt = maxBrn;

        // Mulitply by P_FCTR because burnFactor has P_FCTR built in
        if (tknAmtGvn < (maxBrn * P_FCTR) / (2*burnFactor)) {
            burnAmt = (tknAmtGvn * burnFactor) / P_FCTR;

        } else if (tknAmtGvn < (maxBrn * P_FCTR) / burnFactor) {
            burnAmt = ((tknAmtGvn * burnFactor) / (P_FCTR * 2)) + (maxBrn / 4);

        } else if (tknAmtGvn < maxBrn) {
            burnAmt = ((tknAmtGvn * burnFactor) / (P_FCTR * 4)) + (maxBrn / 2);
        }

        if (burnAmt > 0 && totalStk >= burnAmt) {
            totalStk -= burnAmt;
            totalBurned += burnAmt;
            require(token.transfer(burnDest, burnAmt), "Burn failed");
        }

        // Donate
        (bool sent, ) = dest.call{value: giveAmt}("");
        require(sent, "Donate failed");

        emit Gave(msg.sender, giveAmt);
    }

    /** -----------------------------------------------------------------------
     *
     */
    function withdrawTkn(address _to, address addr) external onlyOwner {
        require(addr != tokenAddr, "Forbidden");

        IERC20 tkn = IERC20(addr);
        require(
            tkn.transfer(_to, tkn.balanceOf(address(this))),
            "Failed"
        );
    }
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

Read Contract

addVotes 0xc0d4e0e0 → uint16
blockRwd 0xca1d1b87 → uint16
burnDest 0xcb8cbb6e → address
burnFactor 0xb1b71afa → uint16
consensusReq 0xb34913eb → uint16
declines 0xde96e6c6 → bool
dest 0x84b366dc → address
donationPrc 0x135078ef → uint16
epochInterval 0x09b1ef26 → uint16
hasVotedAdd 0x7aecd534 → bool
hasVotedRemove 0x26cf1103 → bool
lastStartBlock 0xb5b05e9e → uint256
maxBrnPrc 0x1a9f16bb → uint16
ocFee 0xa64d755c → uint16
ocFees 0xb079861e → uint256
ocRwdrVote 0x3b98548f → address
ocRwdrs 0x6c6cdea8 → bool
owner 0x8da5cb5b → address
pastOcFees 0x09c15e78 → uint256
pool 0x16f0115b → address
removeVotes 0xa2ca6dce → uint16
startBlock 0x48cd4cb1 → uint256
tlOcFees 0xdc09deaf → uint256
tokenAddr 0x5fbe4d1d → address
totalBurned 0xd89135cd → uint256
totalGvn 0x42935eb3 → uint256
totalOC 0x03c424c7 → uint16
totalStk 0x081a7ad3 → uint256
tp 0x944de246 → address
userStks 0x42d79e0d → uint256
v2 0xf3acae3a → bool

Write Contract 27 functions

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

addOCRwdr 0xd138321e
address addr
allow 0xb1b3d3f6
No parameters
decline 0xab040107
No parameters
give 0x9e96a23a
No parameters
removeOCRwdr 0xadec2f77
address addr
renounceOwnership 0x715018a6
No parameters
resetVote 0x2d4812ed
address _to
resetVoteToAdd 0xb53da9d9
address newOC
resetVoteToRemove 0xdfa00b1c
address existingOC
rwd 0x30606eaf
address _to
uint256 _amt
setBurnFactor 0x3fdf4f62
uint16 amt
setConsensusReq 0xab3ad1d4
uint16 req
setDest 0x1b46ba84
address addr
setDonationPrc 0xfd52b702
uint16 amt
setEpochInterval 0x3407e1c3
uint16 interval
setMaxBurnPrc 0xe89d048e
uint16 amt
setOCFee 0xc377e65d
uint16 fee
setPool 0x4437152a
address _pool
setV2 0x30e3cb68
bool _v2
stake 0xa694fc3a
uint256 amt
transferOwnership 0xf2fde38b
address newOwner
vote 0x1bf533a4
address _to
string data
voteToAdd 0x7b0443fa
address newOC
string data
voteToRemove 0xca1d9cc2
address existingOC
string data
withdraw 0x2e1a7d4d
uint256 amt
withdrawOCFee 0x49ecd132
No parameters
withdrawTkn 0xa42bebbe
address _to
address addr

Recent Transactions

No transactions found for this address