Address Contract Verified
Address
0x1eC5A3a64b924FFD3319bF658F4c2446E7A04eCb
Balance
0 ETH
Nonce
1
Code Size
19138 bytes
Creator
0x56Da9bFF...D608 at tx 0x67f283b8...2444fc
Indexed Transactions
0
Contract Bytecode
19138 bytes
0x608060405234801561001057600080fd5b50600436106102275760003560e01c806364482f791161013057806393f1a40b116100b8578063c86539a31161007c578063c86539a314610605578063d740696514610621578063e2bbb1581461063d578063e30c397814610659578063f2fde38b1461067757610227565b806393f1a40b14610550578063958e2d3114610581578063ae169a501461059d578063bbab0f64146105b9578063c6d758cb146105e957610227565b806379ba5097116100ff57806379ba5097146104d25780637bb5d5f5146104dc5780638456cb59146104f85780638da5cb5b146105025780638dbb1e3a1461052057610227565b806364482f791461046057806369a067701461047c578063715018a6146104ac57806376987632146104b657610227565b8063441a3e70116101b3578063554c798a11610182578063554c798a146103e057806357e2607c146103fe5780635c975abb1461041c5780635f70edcf1461043a578063630b5ba11461045657610227565b8063441a3e701461035c57806351b699cd1461037857806351eb05a6146103a85780635312ea8e146103c457610227565b80631653fd33116101fa5780631653fd33146102ca57806317caf6f1146102fa5780631df3052e146103185780632638c09e146103345780633f4ba83a1461035257610227565b806305ebeaf61461022c578063081e3eda1461025c578063088ab8ce1461027a5780631526fe2714610296575b600080fd5b61024660048036038101906102419190613d12565b610693565b6040516102539190613d5a565b60405180910390f35b6102646106b3565b6040516102719190613d8e565b60405180910390f35b610294600480360381019061028f9190613d12565b6106c0565b005b6102b060048036038101906102ab9190613dd5565b610743565b6040516102c1959493929190613e70565b60405180910390f35b6102e460048036038101906102df9190613ec3565b6107c9565b6040516102f19190613d8e565b60405180910390f35b610302610ab9565b60405161030f9190613d8e565b60405180910390f35b610332600480360381019061032d919061405c565b610abf565b005b61033c610d7e565b60405161034991906140a5565b60405180910390f35b61035a610da4565b005b610376600480360381019061037191906140c0565b610dbe565b005b610392600480360381019061038d9190613d12565b6114f6565b60405161039f9190613d5a565b60405180910390f35b6103c260048036038101906103bd9190613dd5565b611589565b005b6103de60048036038101906103d99190613dd5565b611756565b005b6103e8611c16565b6040516103f59190613d8e565b60405180910390f35b610406611c1c565b60405161041391906140a5565b60405180910390f35b610424611c42565b6040516104319190613d5a565b60405180910390f35b610454600480360381019061044f919061412c565b611c59565b005b61045e6120aa565b005b61047a60048036038101906104759190614193565b6120dd565b005b61049660048036038101906104919190613ec3565b612217565b6040516104a39190613d8e565b60405180910390f35b6104b4612533565b005b6104d060048036038101906104cb9190613d12565b612547565b005b6104da612619565b005b6104f660048036038101906104f19190613d12565b6126a6565b005b610500612791565b005b61050a6127ab565b60405161051791906140a5565b60405180910390f35b61053a600480360381019061053591906140c0565b6127d4565b6040516105479190613d8e565b60405180910390f35b61056a60048036038101906105659190613ec3565b6127ea565b6040516105789291906141e6565b60405180910390f35b61059b60048036038101906105969190613dd5565b61281b565b005b6105b760048036038101906105b29190613dd5565b612848565b005b6105d360048036038101906105ce9190613d12565b612ac9565b6040516105e09190613d5a565b60405180910390f35b61060360048036038101906105fe919061420f565b612ae9565b005b61061f600480360381019061061a9190613d12565b612c4b565b005b61063b60048036038101906106369190613dd5565b612d1c565b005b610657600480360381019061065291906140c0565b612da4565b005b610661613198565b60405161066e91906140a5565b60405180910390f35b610691600480360381019061068c9190613d12565b6131c2565b005b60096020528060005260406000206000915054906101000a900460ff1681565b6000600780549050905090565b6106c861326f565b80600460016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fa5289ba11778999f4dfb9415023783188d42bbb5db0612cbfbe55999069612a08160405161073891906140a5565b60405180910390a150565b6007818154811061075357600080fd5b90600052602060002090600502016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154908060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905085565b600082600780549050811061080a576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600785815481106108205761081f61424f565b5b90600052602060002090600502016040518060a00160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152602001600382015481526020016004820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050905060006008600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820154815260200160018201548152505090506000826060015190506000836080015173ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f69190614293565b9050836040015143118015610a0c575060008114155b15610a7d576000610a218560400151436127d4565b90506000600b54866020015160065484610a3b91906142ef565b610a4591906142ef565b610a4f9190614360565b90508264e8d4a5100082610a6391906142ef565b610a6d9190614360565b84610a789190614391565b935050505b826020015164e8d4a51000838560000151610a9891906142ef565b610aa29190614360565b610aac91906143c5565b9550505050505092915050565b600b5481565b610ac76132ed565b60005b8151811015610d72576000828281518110610ae857610ae761424f565b5b602002602001015190506007805490508110610b30576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b3981611589565b600060078281548110610b4f57610b4e61424f565b5b9060005260206000209060050201905060006008600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600060078481548110610bc957610bc861424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c699190614293565b90506000826000015403610ca9576040517fd4597f1f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008103610ce3576040517f8e12239000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000826001015464e8d4a5100085600301548560000154610d0491906142ef565b610d0e9190614360565b610d1891906143c5565b90506000811115610d2e57610d2d338261333c565b5b64e8d4a5100084600301548460000154610d4891906142ef565b610d529190614360565b836001018190555050505050508080610d6a906143f9565b915050610aca565b50610d7b6135d5565b50565b600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610dac61326f565b610db46135df565b610dbc613628565b565b610dc66132ed565b816007805490508110610e05576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8160008103610e40576040517f95e5626700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e4984611589565b600060078581548110610e5f57610e5e61424f565b5b9060005260206000209060050201905060006008600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000816000015403610f01576040517fd4597f1f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060078781548110610f1757610f1661424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636a6991456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb79190614293565b9050600060078881548110610fcf57610fce61424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561104b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106f9190614293565b9050600081036110ab576040517f8e12239000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000836001015464e8d4a51000866003015486600001546110cc91906142ef565b6110d69190614360565b6110e091906143c5565b905060008111156110f6576110f5338261333c565b5b60008284866000015461110991906142ef565b6111139190614360565b905080891115611121578098505b600089111561146757600060078b815481106111405761113f61424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a3338c6040518363ffffffff1660e01b81526004016111ac929190614441565b6020604051808303816000875af11580156111cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ef9190614293565b9050856000015481111561120c5760008660000181905550611225565b80866000015461121c91906143c5565b86600001819055505b60008760000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161128491906140a5565b602060405180830381865afa1580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c59190614293565b90508a8110156112d357809a505b600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168860000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036113da5760008203611386576040517fa703ae5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113d533838a60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661368b9092919063ffffffff16565b611464565b60008b03611414576040517fa703ae5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611463338c8a60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661368b9092919063ffffffff16565b5b50505b64e8d4a510008660030154866000015461148191906142ef565b61148b9190614360565b8560010181905550893373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688b6040516114da9190613d8e565b60405180910390a350505050505050506114f26135d5565b5050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061158257508173ffffffffffffffffffffffffffffffffffffffff1661156a6127ab565b73ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b8060078054905081106115c8576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600783815481106115de576115dd61424f565b5b90600052602060002090600502019050806002015443116115ff5750611752565b60008160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611670573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116949190614293565b9050600081036116ae574382600201819055505050611752565b60006116be8360020154436127d4565b9050600081116116d057505050611752565b6000600b548460010154600654846116e891906142ef565b6116f291906142ef565b6116fc9190614360565b905060008111156117115761171081613711565b5b8264e8d4a510008261172391906142ef565b61172d9190614360565b846003015461173c9190614391565b8460030181905550438460020181905550505050505b5050565b61175e6132ed565b80600780549050811061179d576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600783815481106117b3576117b261424f565b5b9060005260206000209060050201905060006008600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060006007858154811061182d5761182c61424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636a6991456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cd9190614293565b90506000600786815481106118e5576118e461424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119859190614293565b905060008183856000015461199a91906142ef565b6119a49190614360565b9050600787815481106119ba576119b961424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a333836040518363ffffffff1660e01b8152600401611a26929190614441565b6020604051808303816000875af1158015611a45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a699190614293565b5060008560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611ac991906140a5565b602060405180830381865afa158015611ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0a9190614293565b905080821115611b18578091505b60008203611b52576040517fa703ae5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ba133838860000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661368b9092919063ffffffff16565b6000856000018190555060008560010181905550873373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059584604051611bfc9190613d8e565b60405180910390a350505050505050611c136135d5565b50565b60065481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460009054906101000a900460ff16905090565b82600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611cc0576040517f83ad468000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611d27576040517f83ad468000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d2f61326f565b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611db3576040517f3caf458500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611e37576040517f630b374b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8315611e4657611e456120aa565b5b600043905086600b54611e599190614391565b600b8190555060076040518060a001604052808873ffffffffffffffffffffffffffffffffffffffff168152602001898152602001838152602001600081526020018673ffffffffffffffffffffffffffffffffffffffff16815250908060018154018082558091505060019003906000526020600020906005020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050506001600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508373ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f616f4319a54dcbbb5a18b8b2f702faa1d9c1030304616fc770ae877f0934fcdd896040516120999190613d8e565b60405180910390a350505050505050565b6000600780549050905060005b818110156120d9576120c881611589565b806120d2906143f9565b90506120b7565b5050565b82600780549050811061211c576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612125336114f6565b61215b576040517f8f48fb2100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b811561216a576121696120aa565b5b826007858154811061217f5761217e61424f565b5b906000526020600020906005020160010154600b5461219e91906143c5565b6121a89190614391565b600b8190555082600785815481106121c3576121c261424f565b5b9060005260206000209060050201600101819055507f0695015cfa33bef3dc30297a580de4bd33a2afb68fdfb67ae15dee629266c8ff84846040516122099291906141e6565b60405180910390a150505050565b6000826007805490508110612258576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006007858154811061226e5761226d61424f565b5b90600052602060002090600502016040518060a00160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820154815260200160028201548152602001600382015481526020016004820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050905060006008600087815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820154815260200160018201548152505090506000826080015173ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612417573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243b9190614293565b90506000600788815481106124535761245261424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636a6991456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f39190614293565b90506000820361250a57600095505050505061252c565b8181846000015161251b91906142ef565b6125259190614360565b9550505050505b5092915050565b61253b61326f565b61254560006137d9565b565b61254f61326f565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036125be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b5906144c7565b60405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600061262361380a565b90508073ffffffffffffffffffffffffffffffffffffffff16612644613198565b73ffffffffffffffffffffffffffffffffffffffff161461269a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161269190614559565b60405180910390fd5b6126a3816137d9565b50565b6126ae61326f565b80600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612715576040517f83ad468000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f9a4fda13651670c5e4ce1a92f71c0af44ffb387886722797992be8f10a1bae5a8260405161278591906140a5565b60405180910390a15050565b61279961326f565b6127a1613812565b6127a961385c565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600082826127e291906143c5565b905092915050565b6008602052816000526040600020602052806000526040600020600091509150508060000154908060010154905082565b612845817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610dbe565b50565b6128506132ed565b80600780549050811061288f576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61289882611589565b6000600783815481106128ae576128ad61424f565b5b9060005260206000209060050201905060006008600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000600785815481106129285761292761424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166344a3955e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c89190614293565b90506000826000015403612a08576040517fd4597f1f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008103612a42576040517f8e12239000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000826001015464e8d4a5100085600301548560000154612a6391906142ef565b612a6d9190614360565b612a7791906143c5565b90506000811115612a8d57612a8c338261333c565b5b64e8d4a5100084600301548460000154612aa791906142ef565b612ab19190614360565b83600101819055505050505050612ac66135d5565b50565b600a6020528060005260406000206000915054906101000a900460ff1681565b81600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612b50576040517f83ad468000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8160008103612b8b576040517f95e5626700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b9361326f565b600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612c1a576040517fb003332a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612c4533848673ffffffffffffffffffffffffffffffffffffffff1661368b9092919063ffffffff16565b50505050565b612c5361326f565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612cc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cb8906145c5565b60405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b612d25336114f6565b612d5b576040517f8f48fb2100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d636120aa565b806006819055507fd79b45798b52394673631eecea3f84c5fd32f5991f9bcdb99edff1a32d891d0781604051612d999190613d8e565b60405180910390a150565b612dac6132ed565b612db4613812565b816007805490508110612df3576040517f29bb0d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8160008103612e2e576040517f95e5626700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e3784611589565b600060078581548110612e4d57612e4c61424f565b5b9060005260206000209060050201905060006008600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600081600001541115612f0b576000816001015464e8d4a5100084600301548460000154612edf91906142ef565b612ee99190614360565b612ef391906143c5565b90506000811115612f0957612f08338261333c565b5b505b600085111561310d57612f653330878560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166138bf909392919063ffffffff16565b8160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38360040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16876040518363ffffffff1660e01b8152600401612fe8929190614441565b6020604051808303816000875af1158015613007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302b91906145fa565b506000600787815481106130425761304161424f565b5b906000526020600020906005020160040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347e7ef2433886040518363ffffffff1660e01b81526004016130ae929190614441565b6020604051808303816000875af11580156130cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f19190614293565b90508082600001546131039190614391565b8260000181905550505b64e8d4a510008260030154826000015461312791906142ef565b6131319190614360565b8160010181905550853373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15876040516131809190613d8e565b60405180910390a3505050506131946135d5565b5050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6131ca61326f565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1661322a6127ab565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b61327761380a565b73ffffffffffffffffffffffffffffffffffffffff166132956127ab565b73ffffffffffffffffffffffffffffffffffffffff16146132eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132e290614673565b60405180910390fd5b565b600260035403613332576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613329906146df565b60405180910390fd5b6002600381905550565b81600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036133a3576040517f83ad468000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600081036133de576040517f95e5626700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161343b91906140a5565b602060405180830381865afa158015613458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061347c9190614293565b90508084111561352c57600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86836040518363ffffffff1660e01b81526004016134e3929190614441565b6020604051808303816000875af1158015613502573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352691906145fa565b506135ce565b600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86866040518363ffffffff1660e01b8152600401613589929190614441565b6020604051808303816000875af11580156135a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135cc91906145fa565b505b5050505050565b6001600381905550565b6135e7611c42565b613626576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161361d9061474b565b60405180910390fd5b565b6136306135df565b6000600460006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61367461380a565b60405161368191906140a5565b60405180910390a1565b61370c8363a9059cbb60e01b84846040516024016136aa929190614441565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613948565b505050565b600460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1630846040518463ffffffff1660e01b81526004016137929392919061476b565b6020604051808303816000875af11580156137b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d591906145fa565b5050565b600160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905561380781613a0f565b50565b600033905090565b61381a611c42565b1561385a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613851906147ee565b60405180910390fd5b565b613864613812565b6001600460006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586138a861380a565b6040516138b591906140a5565b60405180910390a1565b613942846323b872dd60e01b8585856040516024016138e09392919061476b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613948565b50505050565b60006139aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613ad39092919063ffffffff16565b9050600081511115613a0a57808060200190518101906139ca91906145fa565b613a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a0090614880565b60405180910390fd5b5b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6060613ae28484600085613aeb565b90509392505050565b606082471015613b30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b2790614912565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051613b5991906149a3565b60006040518083038185875af1925050503d8060008114613b96576040519150601f19603f3d011682016040523d82523d6000602084013e613b9b565b606091505b5091509150613bac87838387613bb8565b92505050949350505050565b60608315613c1a576000835103613c1257613bd285613c2d565b613c11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c0890614a06565b60405180910390fd5b5b829050613c25565b613c248383613c50565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115613c635781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c979190614a6a565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613cdf82613cb4565b9050919050565b613cef81613cd4565b8114613cfa57600080fd5b50565b600081359050613d0c81613ce6565b92915050565b600060208284031215613d2857613d27613caa565b5b6000613d3684828501613cfd565b91505092915050565b60008115159050919050565b613d5481613d3f565b82525050565b6000602082019050613d6f6000830184613d4b565b92915050565b6000819050919050565b613d8881613d75565b82525050565b6000602082019050613da36000830184613d7f565b92915050565b613db281613d75565b8114613dbd57600080fd5b50565b600081359050613dcf81613da9565b92915050565b600060208284031215613deb57613dea613caa565b5b6000613df984828501613dc0565b91505092915050565b6000819050919050565b6000613e27613e22613e1d84613cb4565b613e02565b613cb4565b9050919050565b6000613e3982613e0c565b9050919050565b6000613e4b82613e2e565b9050919050565b613e5b81613e40565b82525050565b613e6a81613cd4565b82525050565b600060a082019050613e856000830188613e52565b613e926020830187613d7f565b613e9f6040830186613d7f565b613eac6060830185613d7f565b613eb96080830184613e61565b9695505050505050565b60008060408385031215613eda57613ed9613caa565b5b6000613ee885828601613dc0565b9250506020613ef985828601613cfd565b9150509250929050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613f5182613f08565b810181811067ffffffffffffffff82111715613f7057613f6f613f19565b5b80604052505050565b6000613f83613ca0565b9050613f8f8282613f48565b919050565b600067ffffffffffffffff821115613faf57613fae613f19565b5b602082029050602081019050919050565b600080fd5b6000613fd8613fd384613f94565b613f79565b90508083825260208201905060208402830185811115613ffb57613ffa613fc0565b5b835b8181101561402457806140108882613dc0565b845260208401935050602081019050613ffd565b5050509392505050565b600082601f83011261404357614042613f03565b5b8135614053848260208601613fc5565b91505092915050565b60006020828403121561407257614071613caa565b5b600082013567ffffffffffffffff8111156140905761408f613caf565b5b61409c8482850161402e565b91505092915050565b60006020820190506140ba6000830184613e61565b92915050565b600080604083850312156140d7576140d6613caa565b5b60006140e585828601613dc0565b92505060206140f685828601613dc0565b9150509250929050565b61410981613d3f565b811461411457600080fd5b50565b60008135905061412681614100565b92915050565b6000806000806080858703121561414657614145613caa565b5b600061415487828801613dc0565b945050602061416587828801613cfd565b935050604061417687828801614117565b925050606061418787828801613cfd565b91505092959194509250565b6000806000606084860312156141ac576141ab613caa565b5b60006141ba86828701613dc0565b93505060206141cb86828701613dc0565b92505060406141dc86828701614117565b9150509250925092565b60006040820190506141fb6000830185613d7f565b6142086020830184613d7f565b9392505050565b6000806040838503121561422657614225613caa565b5b600061423485828601613cfd565b925050602061424585828601613dc0565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008151905061428d81613da9565b92915050565b6000602082840312156142a9576142a8613caa565b5b60006142b78482850161427e565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006142fa82613d75565b915061430583613d75565b925082820261431381613d75565b9150828204841483151761432a576143296142c0565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061436b82613d75565b915061437683613d75565b92508261438657614385614331565b5b828204905092915050565b600061439c82613d75565b91506143a783613d75565b92508282019050808211156143bf576143be6142c0565b5b92915050565b60006143d082613d75565b91506143db83613d75565b92508282039050818111156143f3576143f26142c0565b5b92915050565b600061440482613d75565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614436576144356142c0565b5b600182019050919050565b60006040820190506144566000830185613e61565b6144636020830184613d7f565b9392505050565b600082825260208201905092915050565b7f5a65726f204164647265737320696e7365727465640000000000000000000000600082015250565b60006144b160158361446a565b91506144bc8261447b565b602082019050919050565b600060208201905081810360008301526144e0816144a4565b9050919050565b7f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060008201527f6e6577206f776e65720000000000000000000000000000000000000000000000602082015250565b600061454360298361446a565b915061454e826144e7565b604082019050919050565b6000602082019050818103600083015261457281614536565b9050919050565b7f4f776e65722063616e6e6f742062652072656d6f766564000000000000000000600082015250565b60006145af60178361446a565b91506145ba82614579565b602082019050919050565b600060208201905081810360008301526145de816145a2565b9050919050565b6000815190506145f481614100565b92915050565b6000602082840312156146105761460f613caa565b5b600061461e848285016145e5565b91505092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061465d60208361446a565b915061466882614627565b602082019050919050565b6000602082019050818103600083015261468c81614650565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b60006146c9601f8361446a565b91506146d482614693565b602082019050919050565b600060208201905081810360008301526146f8816146bc565b9050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b600061473560148361446a565b9150614740826146ff565b602082019050919050565b6000602082019050818103600083015261476481614728565b9050919050565b60006060820190506147806000830186613e61565b61478d6020830185613e61565b61479a6040830184613d7f565b949350505050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b60006147d860108361446a565b91506147e3826147a2565b602082019050919050565b60006020820190508181036000830152614807816147cb565b9050919050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061486a602a8361446a565b91506148758261480e565b604082019050919050565b600060208201905081810360008301526148998161485d565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006148fc60268361446a565b9150614907826148a0565b604082019050919050565b6000602082019050818103600083015261492b816148ef565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561496657808201518184015260208101905061494b565b60008484015250505050565b600061497d82614932565b614987818561493d565b9350614997818560208601614948565b80840191505092915050565b60006149af8284614972565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006149f0601d8361446a565b91506149fb826149ba565b602082019050919050565b60006020820190508181036000830152614a1f816149e3565b9050919050565b600081519050919050565b6000614a3c82614a26565b614a46818561446a565b9350614a56818560208601614948565b614a5f81613f08565b840191505092915050565b60006020820190508181036000830152614a848184614a31565b90509291505056fea26469706673582212203dafd776da0b368c593b4f4e618dc42d2d9c76268e126ccc2edf956b454830fb64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: No
Authorizable.sol 56 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/access/Ownable2Step.sol";
/**
* @title Authorizable
* @dev Contract module which provides a basic authorization control mechanism,
* where there is an account (an owner) that can grant exclusive access to
* specific functions to authorised accounts.
*/
contract Authorizable is Ownable2Step {
error UnAuthorised();
mapping(address => bool) private authorised;
/**
* @dev Modifier to make a function callable only by authorised accounts.
*/
modifier onlyAuthorised() {
if (!isAuthorised(msg.sender)) {
revert UnAuthorised();
}
_;
}
/**
* @dev Adds an address to the list of authorised accounts.
* Can only be called by the current owner.
* @param _toAdd The address to add to the authorised list.
*/
function addAuthorised(address _toAdd) public onlyOwner {
require(_toAdd != address(0), "Zero Address inserted");
authorised[_toAdd] = true;
}
/**
* @dev Removes an address from the list of authorised accounts.
* Can only be called by the current owner.
* @param _toRemove The address to remove from the authorised list.
*/
function removeAuthorised(address _toRemove) public onlyOwner {
require(_toRemove != msg.sender, "Owner cannot be removed");
authorised[_toRemove] = false;
}
/**
* @dev Checks if an address is authorised.
* @param _authAdd The address to check.
* @return _isAuth True if the address is authorised, false otherwise.
*/
function isAuthorised(address _authAdd) public view returns (bool _isAuth) {
_isAuth = (authorised[_authAdd] || owner() == _authAdd);
}
}
StakingFactory.sol 556 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./Authorizable.sol";
import "./interfaces/IStakingPool.sol";
/// @title StakingFactory
/// @notice This contract manages multiple StakingPool contracts and distributes rewards to users who stake their LP tokens.
contract StakingFactory is Authorizable, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
error ZeroAmountInserted();
error ZeroAllocPointInserted();
error InvalidPoolId();
error ZeroAddressInserted();
error InvalidPID();
error UserSharesZero();
error TotalSharesZero();
error RewardTokenTransfer();
error TokenAlreadyAdded();
error PoolAlreadyAdded();
error ZeroAmountWithdraw();
/// @dev Struct to store information about each user's stake in a pool.
struct UserInfo {
uint256 shares; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt.
}
/// @dev Struct to store information about each staking pool.
struct PoolInfo {
IERC20 token; // Address of the pool token.
uint256 allocPoint; // Allocation points assigned to the pool.
uint256 lastRewardBlock; // Last block number where reward distribution occurred.
uint256 accRewardTokenPerShare; // Accumulated reward tokens per share, times 1e12.
address pool; // Staking Pool address.
}
/// @notice Emitted when a user deposits LP tokens into a pool.
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
/// @notice Emitted when a user withdraws LP tokens from a pool.
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
/// @notice Emitted when a user performs an emergency withdrawal from a pool.
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
/// @notice Emitted when admin adds a pool
event PoolAdded(
address indexed token,
address indexed pool,
uint256 allocPoint
);
/// @notice Emitted when admin update alloc of a pool
event AllocUpdated(uint256 pid, uint256 allocPoint);
/// @notice Emitted when admin update reward per block
event AllocUpdated(uint256 rewardPerBlock);
/// @notice Emitted when admin update fund source
event FundSourceUpdated(address _fundSource);
/// @notice Emitted when admin update reward token
event RewardTokenUpdated(address _rewardToken);
/// @notice Address of the reward token.
address public reward_token;
/// @notice Address of the source of reward tokens.
address public fundSource;
/// @notice Reward tokens distributed per block.
uint256 public rewardTokenPerBlock;
/// @notice Array containing information about all pools.
PoolInfo[] public poolInfo;
/// @notice Mapping of user stake information for each pool.
/// @dev Maps pool ID to user address to UserInfo struct.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
/// @notice Tracks if a pool has already been added.
/// @dev Maps pool address to boolean indicating if the pool is added.
mapping(address => bool) public poolsAdded;
/// @notice Tracks if a token has already been added.
/// @dev Maps token address to boolean indicating if the pool is added.
mapping(address => bool) public tokensAdded;
/// @notice Total allocation points across all pools.
uint256 public totalAllocPoint;
modifier zeroAmountCheck(uint256 amount) {
if (amount == 0) {
revert ZeroAmountInserted();
}
_;
}
modifier zeroAddressCheck(address _address) {
if (_address == address(0)) {
revert ZeroAddressInserted();
}
_;
}
modifier validPID(uint256 _pid) {
if (_pid >= poolInfo.length) {
revert InvalidPID();
}
_;
}
/// @notice Initializes the StakingFactory contract with the reward token and fund source addresses.
/// @param _rewardToken The address of the reward token.
/// @param _fundSource The address from which reward tokens will be pulled for distribution.
constructor(address _rewardToken, address _fundSource) Ownable() {
reward_token = _rewardToken;
fundSource = _fundSource;
}
/// @notice Adds a new staking pool to the factory.
/// @dev Only callable by the contract owner.
/// @param _allocPoint Allocation points assigned to the new pool. This determines the share of rewards the pool receives.
/// @param poolToken The address of the LP token that will be staked in the pool.
/// @param _withUpdate Boolean indicating whether to update reward variables before adding the pool.
/// @param _pool The address of the `StakingPool` contract associated with the new pool.
function add(
uint256 _allocPoint,
address poolToken,
bool _withUpdate,
address _pool
) external zeroAddressCheck(poolToken) zeroAddressCheck(_pool) onlyOwner {
if (poolsAdded[_pool]) revert PoolAlreadyAdded();
if (tokensAdded[poolToken]) revert TokenAlreadyAdded();
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number;
totalAllocPoint = totalAllocPoint + (_allocPoint);
poolInfo.push(
PoolInfo({
token: IERC20(poolToken),
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accRewardTokenPerShare: 0,
pool: _pool
})
);
poolsAdded[_pool] = true;
tokensAdded[poolToken] = true;
emit PoolAdded(poolToken, _pool, _allocPoint);
}
/// @notice Updates the allocation points of an existing pool.
/// @dev Only callable by the contract owner.
/// @param _pid The pool ID (index in the `poolInfo` array).
/// @param _allocPoint The new allocation point for the pool.
/// @param _withUpdate Boolean indicating whether to update reward variables before updating the allocation points.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) external validPID(_pid) onlyAuthorised {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint =
totalAllocPoint -
(poolInfo[_pid].allocPoint) +
(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
emit AllocUpdated(_pid, _allocPoint);
}
/// @notice Sets the number of reward tokens to be distributed per block.
/// @dev Only callable by the contract owner.
/// @param _rewardTokenPerBlock The new reward token amount per block.
function setRewardTokenPerBlock(
uint256 _rewardTokenPerBlock
) external onlyAuthorised {
massUpdatePools();
rewardTokenPerBlock = _rewardTokenPerBlock;
emit AllocUpdated(_rewardTokenPerBlock);
}
/// @notice Sets the address from which reward tokens will be pulled for distribution.
/// @dev Only callable by the contract owner.
/// @param _fundSource The new fund source address.
function setFundSource(
address _fundSource
) external onlyOwner zeroAddressCheck(_fundSource) {
fundSource = _fundSource;
emit FundSourceUpdated(_fundSource);
}
/// @notice Allows the contract owner to recover tokens (other than the reward token) accidentally sent to the contract.
/// @param _token The address of the stuck token.
/// @param _amount The amount of tokens to recover.
function inCaseTokensGetStuck(
address _token,
uint256 _amount
) external zeroAddressCheck(_token) zeroAmountCheck(_amount) onlyOwner {
if (_token == reward_token) revert RewardTokenTransfer();
IERC20(_token).safeTransfer(msg.sender, _amount);
}
/// @notice Allows the owner to change the reward token address
/// @param _tokenAddress The address of the reward token.
function changeRewardToken(address _tokenAddress) external onlyOwner {
reward_token = _tokenAddress;
emit RewardTokenUpdated(_tokenAddress);
}
/// @notice Allows a user to deposit LP tokens into a specific pool for staking.
/// @param _pid The pool ID.
/// @param poolTokenAmt The amount of LP tokens to deposit.
function deposit(
uint256 _pid,
uint256 poolTokenAmt
)
external
nonReentrant
whenNotPaused
validPID(_pid)
zeroAmountCheck(poolTokenAmt)
{
updatePool(_pid);
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
if (user.shares > 0) {
uint256 pending = (user.shares * (pool.accRewardTokenPerShare)) /
(1e12) -
(user.rewardDebt);
if (pending > 0) {
safeRewardTokenTransfer(msg.sender, pending);
}
}
if (poolTokenAmt > 0) {
pool.token.safeTransferFrom(
address(msg.sender),
address(this),
poolTokenAmt
);
pool.token.approve(pool.pool, poolTokenAmt);
uint256 sharesAdded = IStakingPool(poolInfo[_pid].pool).deposit(
msg.sender,
poolTokenAmt
);
user.shares = user.shares + (sharesAdded);
}
user.rewardDebt =
(user.shares * (pool.accRewardTokenPerShare)) /
(1e12);
emit Deposit(msg.sender, _pid, poolTokenAmt);
}
/// @notice Allows a user to withdraw all their staked LP tokens and accrued rewards from a specific pool.
/// @param _pid The pool ID.
function withdrawAll(uint256 _pid) external {
withdraw(_pid, type(uint256).max);
}
/// @notice Allows a user to claim their accrued rewards from a specific pool without withdrawing LP tokens.
/// @param _pid The pool ID.
function claimReward(uint256 _pid) external nonReentrant validPID(_pid) {
updatePool(_pid);
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 sharesTotal = IStakingPool(poolInfo[_pid].pool).sharesTotal();
if (user.shares == 0) revert UserSharesZero();
if (sharesTotal == 0) revert TotalSharesZero();
// Withdraw pending rewardToken
uint256 pending = (user.shares * (pool.accRewardTokenPerShare)) /
(1e12) -
(user.rewardDebt);
if (pending > 0) {
safeRewardTokenTransfer(msg.sender, pending);
}
user.rewardDebt =
(user.shares * (pool.accRewardTokenPerShare)) /
(1e12);
}
/// @notice Allows a user to claim their accrued rewards from multiple pools.
/// @param _pids An array of pool IDs.
function claimRewardMultiple(uint256[] memory _pids) external nonReentrant {
for (uint256 i = 0; i < _pids.length; i++) {
uint256 _pid = _pids[i];
if (_pid >= poolInfo.length) revert InvalidPID();
updatePool(_pid);
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 sharesTotal = IStakingPool(poolInfo[_pid].pool)
.sharesTotal();
if (user.shares == 0) revert UserSharesZero();
if (sharesTotal == 0) revert TotalSharesZero();
// Withdraw pending rewardToken
uint256 pending = (user.shares * (pool.accRewardTokenPerShare)) /
(1e12) -
(user.rewardDebt);
if (pending > 0) {
safeRewardTokenTransfer(msg.sender, pending);
}
user.rewardDebt =
(user.shares * (pool.accRewardTokenPerShare)) /
(1e12);
}
}
/// @notice Allows a user to withdraw their staked LP tokens from a specific pool without claiming rewards.
/// @dev This function is for emergency situations and should be used with caution.
/// @param _pid The pool ID.
function emergencyWithdraw(
uint256 _pid
) external nonReentrant validPID(_pid) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 tokenLockedTotal = IStakingPool(poolInfo[_pid].pool)
.tokenLockedTotal();
uint256 sharesTotal = IStakingPool(poolInfo[_pid].pool).sharesTotal();
uint256 amount = (user.shares * (tokenLockedTotal)) / (sharesTotal);
IStakingPool(poolInfo[_pid].pool).withdraw(msg.sender, amount);
uint256 poolBalance = IERC20(pool.token).balanceOf(address(this));
if (amount > poolBalance) {
amount = poolBalance;
}
if (amount == 0) revert ZeroAmountWithdraw();
pool.token.safeTransfer(address(msg.sender), amount);
user.shares = 0;
user.rewardDebt = 0;
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
/**
* @dev Triggers stopped state.
* - The contract must not be paused.
*/
function pause() external onlyOwner whenNotPaused {
_pause();
}
/**
* @dev Returns to normal state.
* - The contract must be paused.
*/
function unpause() external onlyOwner whenPaused {
_unpause();
}
/// @notice Returns the number of pools managed by the factory.
/// @return The length of the `poolInfo` array.
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
/// @notice Returns the pending reward tokens for a user in a specific pool.
/// @param _pid The pool ID.
/// @param _user The address of the user.
/// @return The amount of pending reward tokens.
function pendingRewardToken(
uint256 _pid,
address _user
) external view validPID(_pid) returns (uint256) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo memory user = userInfo[_pid][_user];
uint256 accRewardTokenPerShare = pool.accRewardTokenPerShare;
uint256 sharesTotal = IStakingPool(pool.pool).sharesTotal();
if (block.number > pool.lastRewardBlock && sharesTotal != 0) {
uint256 multiplier = getMultiplier(
pool.lastRewardBlock,
block.number
);
uint256 rewardTokenReward = (multiplier *
(rewardTokenPerBlock) *
(pool.allocPoint)) / (totalAllocPoint);
accRewardTokenPerShare =
accRewardTokenPerShare +
((rewardTokenReward * (1e12)) / (sharesTotal));
}
return
(user.shares * (accRewardTokenPerShare)) /
(1e12) -
(user.rewardDebt);
}
/// @notice Returns the amount of staked LP tokens for a user in a specific pool.
/// @param _pid The pool ID.
/// @param _user The address of the user.
/// @return The amount of staked LP tokens.
function stakedTokensAmount(
uint256 _pid,
address _user
) external view validPID(_pid) returns (uint256) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo memory user = userInfo[_pid][_user];
uint256 sharesTotal = IStakingPool(pool.pool).sharesTotal();
uint256 tokenLockedTotal = IStakingPool(poolInfo[_pid].pool)
.tokenLockedTotal();
if (sharesTotal == 0) {
return 0;
}
return (user.shares * (tokenLockedTotal)) / (sharesTotal);
}
/// @notice Allows a user to withdraw their staked LP tokens from a specific pool.
/// @param _pid The pool ID.
/// @param poolTokenAmt The amount of LP tokens to withdraw.
function withdraw(
uint256 _pid,
uint256 poolTokenAmt
) public nonReentrant validPID(_pid) zeroAmountCheck(poolTokenAmt) {
updatePool(_pid);
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
if (user.shares == 0) revert UserSharesZero();
uint256 tokenLockedTotal = IStakingPool(poolInfo[_pid].pool)
.tokenLockedTotal();
uint256 sharesTotal = IStakingPool(poolInfo[_pid].pool).sharesTotal();
if (sharesTotal == 0) revert TotalSharesZero();
// Withdraw pending rewardToken
uint256 pending = (user.shares * (pool.accRewardTokenPerShare)) /
(1e12) -
(user.rewardDebt);
if (pending > 0) {
safeRewardTokenTransfer(msg.sender, pending);
}
// Withdraw pool tokens
uint256 amount = (user.shares * (tokenLockedTotal)) / (sharesTotal);
if (poolTokenAmt > amount) {
poolTokenAmt = amount;
}
if (poolTokenAmt > 0) {
uint256 sharesRemoved = IStakingPool(poolInfo[_pid].pool).withdraw(
msg.sender,
poolTokenAmt
);
if (sharesRemoved > user.shares) {
user.shares = 0;
} else {
user.shares = user.shares - (sharesRemoved);
}
uint256 tokenBal = IERC20(pool.token).balanceOf(address(this));
if (tokenBal < poolTokenAmt) {
poolTokenAmt = tokenBal;
}
if (address(pool.token) == address(reward_token)) {
if (sharesRemoved == 0) revert ZeroAmountWithdraw();
pool.token.safeTransfer(address(msg.sender), sharesRemoved);
} else {
if (poolTokenAmt == 0) revert ZeroAmountWithdraw();
pool.token.safeTransfer(address(msg.sender), poolTokenAmt);
}
}
user.rewardDebt =
(user.shares * (pool.accRewardTokenPerShare)) /
(1e12);
emit Withdraw(msg.sender, _pid, poolTokenAmt);
}
/// @notice Updates the reward variables of a specific pool.
/// @param _pid The pool ID.
function updatePool(uint256 _pid) public validPID(_pid) {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 sharesTotal = IStakingPool(pool.pool).sharesTotal();
if (sharesTotal == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
if (multiplier <= 0) {
return;
}
uint256 rewardTokenReward = (multiplier *
(rewardTokenPerBlock) *
(pool.allocPoint)) / (totalAllocPoint);
if (rewardTokenReward > 0) {
getRewardToken(rewardTokenReward);
}
pool.accRewardTokenPerShare =
pool.accRewardTokenPerShare +
((rewardTokenReward * (1e12)) / (sharesTotal));
pool.lastRewardBlock = block.number;
}
/// @notice Updates reward variables for all pools.
/// @dev This function can be expensive in terms of gas, so use it carefully.
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
/// @notice Calculates the reward multiplier over a given block range.
/// @param _from The starting block number.
/// @param _to The ending block number.
/// @return The calculated reward multiplier.
function getMultiplier(
uint256 _from,
uint256 _to
) public pure returns (uint256) {
return _to - (_from);
}
/// @dev Internal function to safely transfer reward tokens to a user.
/// @param _to The address of the recipient.
/// @param _rewardTokenAmt The amount of reward tokens to transfer.
function safeRewardTokenTransfer(
address _to,
uint256 _rewardTokenAmt
) internal zeroAddressCheck(_to) zeroAmountCheck(_rewardTokenAmt) {
uint256 rewardTokenBal = IERC20(reward_token).balanceOf(address(this));
if (_rewardTokenAmt > rewardTokenBal) {
IERC20(reward_token).transfer(_to, rewardTokenBal);
} else {
IERC20(reward_token).transfer(_to, _rewardTokenAmt);
}
}
/// @dev Internal function to transfer reward tokens from the `fundSource` to the factory contract.
/// @param _rewardTokenAmt The amount of reward tokens to transfer.
function getRewardToken(uint256 _rewardTokenAmt) internal {
IERC20(reward_token).transferFrom(
fundSource,
address(this),
_rewardTokenAmt
);
}
}
IStakingPool.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface IStakingPool {
// Total want tokens managed by stratfegy
function tokenLockedTotal() external view returns (uint256);
// Sum of all shares of users to wantLockedTotal
function sharesTotal() external view returns (uint256);
// Main want token compounding function
function earn() external;
// Transfer want tokens autoFarm -> strategy
function deposit(
address _userAddress,
uint256 _wantAmt
) external returns (uint256);
// Transfer want tokens strategy -> autoFarm
function withdraw(
address _userAddress,
uint256 _wantAmt
) external returns (uint256);
function inCaseTokensGetStuck(
address _token,
uint256 _amount,
address _to
) external;
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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);
}
Ownable2Step.sol 57 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./Ownable.sol";
/**
* @dev Contract module which provides 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} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() external {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}
ReentrancyGuard.sol 69 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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;
}
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Read Contract
fundSource 0x57e2607c → address
getMultiplier 0x8dbb1e3a → uint256
isAuthorised 0x51b699cd → bool
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
pendingOwner 0xe30c3978 → address
pendingRewardToken 0x1653fd33 → uint256
poolInfo 0x1526fe27 → address, uint256, uint256, uint256, address
poolLength 0x081e3eda → uint256
poolsAdded 0x05ebeaf6 → bool
rewardTokenPerBlock 0x554c798a → uint256
reward_token 0x2638c09e → address
stakedTokensAmount 0x69a06770 → uint256
tokensAdded 0xbbab0f64 → bool
totalAllocPoint 0x17caf6f1 → uint256
userInfo 0x93f1a40b → uint256, uint256
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
acceptOwnership 0x79ba5097
No parameters
add 0x5f70edcf
uint256 _allocPoint
address poolToken
bool _withUpdate
address _pool
addAuthorised 0x76987632
address _toAdd
changeRewardToken 0x088ab8ce
address _tokenAddress
claimReward 0xae169a50
uint256 _pid
claimRewardMultiple 0x1df3052e
uint256[] _pids
deposit 0xe2bbb158
uint256 _pid
uint256 poolTokenAmt
emergencyWithdraw 0x5312ea8e
uint256 _pid
inCaseTokensGetStuck 0xc6d758cb
address _token
uint256 _amount
massUpdatePools 0x630b5ba1
No parameters
pause 0x8456cb59
No parameters
removeAuthorised 0xc86539a3
address _toRemove
renounceOwnership 0x715018a6
No parameters
set 0x64482f79
uint256 _pid
uint256 _allocPoint
bool _withUpdate
setFundSource 0x7bb5d5f5
address _fundSource
setRewardTokenPerBlock 0xd7406965
uint256 _rewardTokenPerBlock
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
updatePool 0x51eb05a6
uint256 _pid
withdraw 0x441a3e70
uint256 _pid
uint256 poolTokenAmt
withdrawAll 0x958e2d31
uint256 _pid
Recent Transactions
No transactions found for this address