Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5A2697C772d6062Eb2005e84547Ec4a36cCb3B52
Balance 0 ETH
Nonce 1
Code Size 24212 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

24212 bytes
0x608060405234801561001057600080fd5b506004361061029f5760003560e01c80636ff00edf11610167578063b425f802116100ce578063e26191df11610087578063e26191df14610dd4578063e9fad8ee14610e08578063ee4a493c14610e12578063f0ac103c14610f00578063f2fde38b14610f62578063f9ad8ac414610fa65761029f565b8063b425f80214610c1f578063cbd5d40314610cd0578063cc1a378f14610d49578063cd3daf9d14610d77578063de35fc6114610d95578063df136d6514610db65761029f565b80638da5cb5b116101205780638da5cb5b14610a37578063a0e4395914610a6b578063a25983e514610abe578063a5c5be9014610b16578063a694fc3a14610b8f578063af62fe0e14610bbd5761029f565b80636ff00edf146108ff578063715018a6146109205780637b0a47ee1461092a5780637fa0d26b1461094857806380faa57d146109e157806381bd2e0e146109ff5761029f565b80633d18b9121161020b5780635a604c52116101c45780635a604c521461075c5780635c975abb1461077a5780635d6a618d1461079a578063624a5c9d146107b85780636cc899451461081a5780636f72fd20146108b35761029f565b80633d18b912146106265780633fc6df6e146106305780634de5931e146106645780634e4e1c421461069857806356497ab0146106b9578063594ce5d3146107525761029f565b8063197621431161025d578063197621431461048e578063207e11aa146104d257806327e235e3146104dc5780632ab52a25146105965780632e1a7d4d146105ca5780633c6b16ab146105f85761029f565b80628cc262146102a457806302092087146102fc5780630e00f75a146103545780631524a4141461037257806316c38b3c1461041557806318160ddd14610445575b600080fd5b6102e6600480360360208110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611094565b6040518082815260200191505060405180910390f35b61033e6004803603602081101561031257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611291565b6040518082815260200191505060405180910390f35b61035c6112dd565b6040518082815260200191505060405180910390f35b6104136004803603606081101561038857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156103cf57600080fd5b8201836020820111156103e157600080fd5b8035906020019184600183028401116401000000008311171561040357600080fd5b9091929391929390505050611301565b005b6104436004803603602081101561042b57600080fd5b8101908080351515906020019092919050505061140d565b005b61044d611542565b60405180836fffffffffffffffffffffffffffffffff168152602001826fffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b6104d0600480360360208110156104a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061158c565b005b6104da61167f565b005b61051e600480360360208110156104f257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611922565b60405180866bffffffffffffffffffffffff168152602001856bffffffffffffffffffffffff1681526020018463ffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff168152602001826bffffffffffffffffffffffff1681526020019550505050505060405180910390f35b61059e6119d0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105f6600480360360208110156105e057600080fd5b81019080803590602001909291905050506119f4565b005b6106246004803603602081101561060e57600080fd5b8101908080359060200190929190505050611a02565b005b61062e611f72565b005b610638611f7f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61066c611fa5565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106a0611fc9565b604051808260ff16815260200191505060405180910390f35b6106fb600480360360208110156106cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611fce565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561073e578082015181840152602081019050610723565b505050509050019250505060405180910390f35b61075a612065565b005b610764612353565b6040518082815260200191505060405180910390f35b61078261235a565b60405180821515815260200191505060405180910390f35b6107a261236d565b6040518082815260200191505060405180910390f35b610804600480360360408110156107ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612377565b6040518082815260200191505060405180910390f35b6108b16004803603604081101561083057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561086d57600080fd5b82018360208201111561087f57600080fd5b803590602001918460018302840111640100000000831117156108a157600080fd5b90919293919293905050506123a8565b005b6108e9600480360360408110156108c957600080fd5b8101908080359060200190929190803590602001909291905050506124b7565b6040518082815260200191505060405180910390f35b6109076124e6565b604051808260ff16815260200191505060405180910390f35b6109286124eb565b005b610932612658565b6040518082815260200191505060405180910390f35b6109df6004803603604081101561095e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561099b57600080fd5b8201836020820111156109ad57600080fd5b803590602001918460208302840111640100000000831117156109cf57600080fd5b909192939192939050505061265e565b005b6109e96128a4565b6040518082815260200191505060405180910390f35b610a3560048036036040811015610a1557600080fd5b8101908080359060200190929190803590602001909291905050506128da565b005b610a3f6128f0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a73612919565b604051808563ffffffff1681526020018463ffffffff1681526020018363ffffffff168152602001826bffffffffffffffffffffffff16815260200194505050505060405180910390f35b610b1460048036036060811015610ad457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919050505061297f565b005b610b8d60048036036020811015610b2c57600080fd5b8101908080359060200190640100000000811115610b4957600080fd5b820183602082011115610b5b57600080fd5b80359060200191846020830284011164010000000083111715610b7d57600080fd5b9091929391929390505050612afc565b005b610bbb60048036036020811015610ba557600080fd5b8101908080359060200190929190505050612b44565b005b610c0960048036036040811015610bd357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612b74565b6040518082815260200191505060405180910390f35b610c6b60048036036040811015610c3557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612b99565b604051808760ff168152602001866effffffffffffffffffffffffffffff1681526020018563ffffffff1681526020018463ffffffff1681526020018363ffffffff1681526020018263ffffffff168152602001965050505050505060405180910390f35b610d4760048036036020811015610ce657600080fd5b8101908080359060200190640100000000811115610d0357600080fd5b820183602082011115610d1557600080fd5b80359060200191846020830284011164010000000083111715610d3757600080fd5b9091929391929390505050612c4a565b005b610d7560048036036020811015610d5f57600080fd5b8101908080359060200190929190505050612c5c565b005b610d7f612e67565b6040518082815260200191505060405180910390f35b610d9d612fa1565b604051808260ff16815260200191505060405180910390f35b610dbe612fa6565b6040518082815260200191505060405180910390f35b610ddc612fac565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610e10612fd0565b005b610efe60048036036060811015610e2857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190640100000000811115610e6557600080fd5b820183602082011115610e7757600080fd5b80359060200191846020830284011164010000000083111715610e9957600080fd5b909192939192939080359060200190640100000000811115610eba57600080fd5b820183602082011115610ecc57600080fd5b80359060200191846001830284011164010000000083111715610eee57600080fd5b9091929391929390505050613008565b005b610f4c60048036036040811015610f1657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506130ff565b6040518082815260200191505060405180910390f35b610fa460048036036020811015610f7857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613124565b005b61109260048036036060811015610fbc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190640100000000811115610ff957600080fd5b82018360208201111561100b57600080fd5b8035906020019184602083028401116401000000008311171561102d57600080fd5b90919293919293908035906020019064010000000081111561104e57600080fd5b82018360208201111561106057600080fd5b8035906020019184602083028401116401000000008311171561108257600080fd5b9091929391929390505050613316565b005b600061109e615be2565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060a00160405290816000820160009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff16815260200160008201600c9054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff1681526020016000820160189054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff16815250509050600081602001518260000151016bffffffffffffffffffffffff16905081608001516bffffffffffffffffffffffff16670de0b6b3a7640000836060015173ffffffffffffffffffffffffffffffffffffffff1661127c612e67565b0383028161128657fe5b040192505050919050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050919050565b7f000000000000000000000000000000000000000000a56fa5b99019a5c800000081565b61130c8333866137cb565b8373ffffffffffffffffffffffffffffffffffffffff16633f2bd9247f0000000000000000000000006fc13eace26590b80cccab1ba5d51890577d83b2338686866040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156113ef57600080fd5b505af1158015611403573d6000803e3d6000fd5b5050505050505050565b611415613eae565b73ffffffffffffffffffffffffffffffffffffffff166114336128f0565b73ffffffffffffffffffffffffffffffffffffffff16146114bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600660009054906101000a900460ff16151581151514156114dc5761153f565b80600660006101000a81548160ff0219169083151502179055507f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5600660009054906101000a900460ff1660405180821515815260200191505060405180910390a15b50565b60098060000160009054906101000a90046fffffffffffffffffffffffffffffffff16908060000160109054906101000a90046fffffffffffffffffffffffffffffffff16905082565b611594613eae565b73ffffffffffffffffffffffffffffffffffffffff166115b26128f0565b73ffffffffffffffffffffffffffffffffffffffff161461163b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611687613eae565b73ffffffffffffffffffffffffffffffffffffffff166116a56128f0565b73ffffffffffffffffffffffffffffffffffffffff161461172e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611736615c57565b600a6040518060800160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160089054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160008201600c9054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff16815250509050806000015163ffffffff164210611857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180615e32602d913960400191505060405180910390fd5b6000600960000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16146118cf57600042826000015163ffffffff1603905080826020015103600a60000160046101000a81548163ffffffff021916908363ffffffff160217905550505b42600a60000160006101000a81548163ffffffff021916908363ffffffff1602179055507fb31605747019cb5809dbdb8c268c9c5bb666d39291f8750fa0dd4ac517b1570460405160405180910390a150565b600b6020528060005260406000206000915090508060000160009054906101000a90046bffffffffffffffffffffffff169080600001600c9054906101000a90046bffffffffffffffffffffffff16908060000160189054906101000a900463ffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160149054906101000a90046bffffffffffffffffffffffff16905085565b7f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c81565b6119ff8133336137cb565b50565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611ac5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616c6c6572206973206e6f7420526577617264734469737472696275746f7281525060200191505060405180910390fd5b600080611ad0612e67565b905080600881905550611ae16128a4565b600a60000160086101000a81548163ffffffff021916908363ffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611c3357611b4182611094565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555080600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b611c3b612065565b611c43615c57565b600a6040518060800160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160089054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160008201600c9054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff168152505090506000816000015163ffffffff164210611d3057816020015163ffffffff168581611d2857fe5b049050611d65565b600042836000015163ffffffff16039050600060075482029050836020015163ffffffff1681880181611d5f57fe5b04925050505b6000811415611ddc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f696e76616c69642072657761726452617465000000000000000000000000000081525060200191505060405180910390fd5b80600781905550600085600a600001600c9054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff160190507f000000000000000000000000000000000000000000a56fa5b99019a5c8000000811115611eab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f72657761726473206f766572666c6f770000000000000000000000000000000081525060200191505060405180910390fd5b80600a600001600c6101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555042600a60000160086101000a81548163ffffffff021916908363ffffffff160217905550826020015163ffffffff164201600a60000160006101000a81548163ffffffff021916908363ffffffff1602179055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d866040518082815260200191505060405180910390a1505050505050565b611f7c3333613eb6565b50565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f0000000000000000000000006fc13eace26590b80cccab1ba5d51890577d83b281565b600181565b6060600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561205957602002820191906000526020600020905b815481526020019060010190808311612045575b50505050509050919050565b7f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff1663dc1bc51d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120cb57600080fd5b505afa1580156120df573d6000803e3d6000fd5b505050506040513d60208110156120f557600080fd5b810190808051906020019092919050505061210f57612351565b60007f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561219857600080fd5b505afa1580156121ac573d6000803e3d6000fd5b505050506040513d60208110156121c257600080fd5b8101908080519060200190929190505050905060008114156121e45750612351565b7f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd673ffffffffffffffffffffffffffffffffffffffff166342966c68826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561225757600080fd5b505af115801561226b573d6000803e3d6000fd5b505050507f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561230057600080fd5b505af1158015612314573d6000803e3d6000fd5b505050507fe6fcfd28560c01ab273626e9e219605886a9a35c9af45fb221407347d95f5950816040518082815260200191505060405180910390a1505b565b620f424081565b600660009054906101000a900460ff1681565b620f424060050281565b6003602052816000526040600020818154811061239357600080fd5b90600052602060002001600091509150505481565b60006123b43385613eb6565b90508373ffffffffffffffffffffffffffffffffffffffff16633f2bd9247f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c338487876040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561249957600080fd5b505af11580156124ad573d6000803e3d6000fd5b5050505050505050565b6000620f424082116124cc57600090506124e0565b82620f4240838502816124db57fe5b040390505b92915050565b600281565b6124f3613eae565b73ffffffffffffffffffffffffffffffffffffffff166125116128f0565b73ffffffffffffffffffffffffffffffffffffffff161461259a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60075481565b612666613eae565b73ffffffffffffffffffffffffffffffffffffffff166126846128f0565b73ffffffffffffffffffffffffffffffffffffffff161461270d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60005b8282905081101561289e57600083838381811061272957fe5b9050602002013514156127a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f496e76616c696453657474696e6773000000000000000000000000000000000081525060200191505060405180910390fd5b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008585858181106127f357fe5b905060200201358152602001908152602001600020819055506128288484848481811061281c57fe5b90506020020135614294565b8373ffffffffffffffffffffffffffffffffffffffff167faef5576b86a39dc60e8df9b9cf2017e6444ff06b91c431eda324df9542e11f9884848481811061286c57fe5b905060200201356000604051808381526020018281526020019250505060405180910390a28080600101915050612710565b50505050565b600080600a60000160009054906101000a900463ffffffff1663ffffffff1690508042106128d257806128d4565b425b91505090565b6128e382612c5c565b6128ec81611a02565b5050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600a8060000160009054906101000a900463ffffffff16908060000160049054906101000a900463ffffffff16908060000160089054906101000a900463ffffffff169080600001600c9054906101000a90046bffffffffffffffffffffffff16905084565b7f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015612a7857507f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff1663dc1bc51d6040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3b57600080fd5b505afa158015612a4f573d6000803e3d6000fd5b505050506040513d6020811015612a6557600080fd5b8101908080519060200190929190505050155b15612aeb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6c6f636b696e672072554d4232206e6f7420617661696c61626c65207965740081525060200191505060405180910390fd5b612af7338484846144a7565b505050565b612b277fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff33336137cb565b612b33338383336145eb565b5050612b3f3333613eb6565b505050565b612b717f0000000000000000000000006fc13eace26590b80cccab1ba5d51890577d83b233836000614925565b50565b6001602052816000526040600020602052806000526040600020600091509150505481565b600c602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900460ff16908060000160019054906101000a90046effffffffffffffffffffffffffffff16908060000160109054906101000a900463ffffffff16908060000160149054906101000a900463ffffffff16908060000160189054906101000a900463ffffffff169080600001601c9054906101000a900463ffffffff16905086565b612c56338383336145eb565b50505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612d1f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616c6c6572206973206e6f7420526577617264734469737472696275746f7281525060200191505060405180910390fd5b6000811415612d96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f656d707479205f726577617264734475726174696f6e0000000000000000000081525060200191505060405180910390fd5b600a60000160009054906101000a900463ffffffff1663ffffffff164211612e09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180615d40603d913960400191505060405180910390fd5b80600a60000160046101000a81548163ffffffff021916908363ffffffff1602179055507ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d3816040518082815260200191505060405180910390a150565b6000612e71615c9f565b60096040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff16815250509050600081600001516fffffffffffffffffffffffffffffffff161415612f3e57600854915050612f9e565b80602001518160000151016fffffffffffffffffffffffffffffffff16670de0b6b3a7640000600754600a60000160089054906101000a900463ffffffff1663ffffffff16612f8b6128a4565b03020281612f9557fe5b04600854019150505b90565b600481565b60085481565b7f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd681565b612ffb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff33336137cb565b6130053333613eb6565b50565b6000806130173387878a6145eb565b915091508673ffffffffffffffffffffffffffffffffffffffff16633f2bd92483338488886040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156130de57600080fd5b505af11580156130f2573d6000803e3d6000fd5b5050505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b61312c613eae565b73ffffffffffffffffffffffffffffffffffffffff1661314a6128f0565b73ffffffffffffffffffffffffffffffffffffffff16146131d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613259576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180615d7d6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61331e613eae565b73ffffffffffffffffffffffffffffffffffffffff1661333c6128f0565b73ffffffffffffffffffffffffffffffffffffffff16146133c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600084849050141561343f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f456d707479506572696f6473000000000000000000000000000000000000000081525060200191505060405180910390fd5b8181905084849050146134ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f4172726179734e6f744d6174636800000000000000000000000000000000000081525060200191505060405180910390fd5b60005b848490508110156137c35760008585838181106134d657fe5b905060200201351415613551576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f496e76616c696453657474696e6773000000000000000000000000000000000081525060200191505060405180910390fd5b620f424083838381811061356157fe5b9050602002013510156135dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f6d756c7469706c696572206d757374206265203e3d203165360000000000000081525060200191505060405180910390fd5b620f42406005028383838181106135ef57fe5b90506020020135111561366a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f6d756c7469706c696572206f766572666c6f770000000000000000000000000081525060200191505060405180910390fd5b82828281811061367657fe5b90506020020135600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008787858181106136ca57fe5b905060200201358152602001908152602001600020819055508573ffffffffffffffffffffffffffffffffffffffff167faef5576b86a39dc60e8df9b9cf2017e6444ff06b91c431eda324df9542e11f9886868481811061372757fe5b9050602002013585858581811061373a57fe5b90506020020135604051808381526020018281526020019250505060405180910390a2600083838381811061376b57fe5b905060200201351415613799576137948686868481811061378857fe5b90506020020135614294565b6137b6565b6137b5868686848181106137a957fe5b9050602002013561501e565b5b80806001019150506134bd565b505050505050565b60026005541415613844576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600581905550816000613857612e67565b9050806008819055506138686128a4565b600a60000160086101000a81548163ffffffff021916908363ffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146139ba576138c882611094565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555080600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b6139c2615be2565b600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060a00160405290816000820160009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff16815260200160008201600c9054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff1681526020016000820160189054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff168152505090507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff861415613b865780600001516bffffffffffffffffffffffff169550613c0f565b8581600001516bffffffffffffffffffffffff161015613c0e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f776974686472617720616d6f756e7420746f206869676800000000000000000081525060200191505060405180910390fd5b5b6000861415613c1e5750613e9f565b856effffffffffffffffffffffffffffff16600960000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508581600001516bffffffffffffffffffffffff1603600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055507f0000000000000000000000006fc13eace26590b80cccab1ba5d51890577d83b273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85886040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015613da257600080fd5b505af1158015613db6573d6000803e3d6000fd5b505050506040513d6020811015613dcc57600080fd5b8101908080519060200190929190505050613e4f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f746f6b656e207472616e73666572206661696c6564000000000000000000000081525060200191505060405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5876040518082815260200191505060405180910390a2505b50506001600581905550505050565b600033905090565b600060026005541415613f31576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600581905550826000613f44612e67565b905080600881905550613f556128a4565b600a60000160086101000a81548163ffffffff021916908363ffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146140a757613fb582611094565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555080600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff16925060008314614284576000600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055507f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff166340c10f1985856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561421d57600080fd5b505af1158015614231573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486846040518082815260200191505060405180910390a25b5050600160058190555092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905060008114156142f857506144a3565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050038154811061438757fe5b9060005260206000200154600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060018303815481106143df57fe5b90600052602060002001819055506000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080548061448b57fe5b60019003818190600052602060002001600090559055505b5050565b600660009054906101000a900460ff161561450d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c815260200180615dd1603c913960400191505060405180910390fd5b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905060008114156145bc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180615e0d6025913960400191505060405180910390fd5b60006145c884836124b7565b90506145d685878684614925565b6145e38686868686615184565b505050505050565b60008060008060007f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff1663dc1bc51d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561465957600080fd5b505afa15801561466d573d6000803e3d6000fd5b505050506040513d602081101561468357600080fd5b8101908080519060200190929190505050905060005b888890508110156148945760008060006146c58d8d8d878181106146b957fe5b9050602002013561554d565b92509250925060008314156146dc57505050614887565b6000861415614780578095506146f1816158b0565b98507f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd673ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614801561474b5750845b1561477b577f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c9850600460ff1695505b6147fa565b8086146147f957600460ff168614801561479d5750600260ff1681145b156147a7576147f8565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180615da3602e913960400191505060405180910390fd5b5b5b8873ffffffffffffffffffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff167ff8b95683b235fadeef89cd3f5e0d1945bf98428968dbff13c62c8b4797b207bd8e8e8881811061485557fe5b9050602002013586604051808381526020018281526020019250505060405180910390a3828801975081870196505050505b8080600101915050614699565b50600084141561490c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f6e6f7468696e6720746f20756e6c6f636b00000000000000000000000000000081525060200191505060405180910390fd5b614919898688878761595f565b50505094509492505050565b6002600554141561499e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600581905550600660009054906101000a900460ff1615614a0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c815260200180615dd1603c913960400191505060405180910390fd5b826000614a17612e67565b905080600881905550614a286128a4565b600a60000160086101000a81548163ffffffff021916908363ffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614614b7a57614a8882611094565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555080600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b6000838501905042600a60000160009054906101000a900463ffffffff1663ffffffff1611614c11576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f5374616b6520706572696f64206e6f742073746172746564207965740000000081525060200191505060405180910390fd5b6000811415614c88576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b846bffffffffffffffffffffffff16600960000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555083600960000160108282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506000841415614dec5784600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046bffffffffffffffffffffffff160192506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550614e7b565b80600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600c8282829054906101000a90046bffffffffffffffffffffffff160192506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055505b8673ffffffffffffffffffffffffffffffffffffffff166323b872dd8730886040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015614f0a57600080fd5b505af1158015614f1e573d6000803e3d6000fd5b505050506040513d6020811015614f3457600080fd5b8101908080519060200190929190505050614fb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f746f6b656e207472616e73666572206661696c6564000000000000000000000081525060200191505060405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff167f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee908686604051808381526020018281526020019250505060405180910390a2505050600160058190555050505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000838152602001908152602001600020549050600081146150815750615180565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020829080600181540180825580915050600190039060005260206000200160009091909190915055600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550505b5050565b6000600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160189054906101000a900463ffffffff1663ffffffff16905063ffffffff801681141561525d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6e6578744c6f636b496e646578206f766572666c6f770000000000000000000081525060200191505060405180910390fd5b60018101600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160186101000a81548163ffffffff021916908363ffffffff1602179055506000600c60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000209050848160000160016101000a8154816effffffffffffffffffffffffffffff02191690836effffffffffffffffffffffffffffff160217905550828160000160186101000a81548163ffffffff021916908363ffffffff160217905550428160000160106101000a81548163ffffffff021916908363ffffffff1602179055508342018160000160146101000a81548163ffffffff021916908363ffffffff1602179055507f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156154305760048160000160006101000a81548160ff021916908360ff1602179055506154c7565b7f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156154a75760028160000160006101000a81548160ff021916908360ff1602179055506154c6565b60018160000160006101000a81548160ff021916908360ff1602179055505b5b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fc2e597c6d841ffed513e35a60e97304ae7fbfaf51a81eb93fddc53a590d9a8c6848888886040518085815260200184815260200183815260200182815260200194505050505060405180910390a350505050505050565b600080600061555a615cdd565b600c60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008681526020019081526020016000206040518060c00160405290816000820160009054906101000a900460ff1660ff1660ff1681526020016000820160019054906101000a90046effffffffffffffffffffffffffffff166effffffffffffffffffffffffffffff166effffffffffffffffffffffffffffff1681526020016000820160109054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160149054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160189054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160008201601c9054906101000a900463ffffffff1663ffffffff1663ffffffff1681525050905060008160a0015163ffffffff1614615733576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f4465706f736974416c726561647957697468647261776e00000000000000000081525060200191505060405180910390fd5b806060015163ffffffff164210156157b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4465706f7369744c6f636b65640000000000000000000000000000000000000081525060200191505060405180910390fd5b600081602001516effffffffffffffffffffffffffffff1614156157e2576000806000935093509350506158a9565b42600c60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000878152602001908152602001600020600001601c6101000a81548163ffffffff021916908363ffffffff160217905550806020015161588282602001516effffffffffffffffffffffffffffff16836080015163ffffffff166124b7565b8260000151826effffffffffffffffffffffffffffff1692508060ff169050935093509350505b9250925092565b6000600460ff168214156158e6577f000000000000000000000000ae9aca5d20f5b139931935378c4489308394ca2c9050615959565b600260ff1682141561591a577f0000000000000000000000001b17dbb40fbed8735e7fe8c9eb02c20984fadfd69050615958565b600160ff1682141561594e577f0000000000000000000000006fc13eace26590b80cccab1ba5d51890577d83b29050615957565b6000905061595a565b5b5b5b919050565b6000818301905080600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600c8282829054906101000a90046bffffffffffffffffffffffff160392506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550826bffffffffffffffffffffffff16600960000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555081600960000160108282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015615b2d57600080fd5b505af1158015615b41573d6000803e3d6000fd5b505050506040513d6020811015615b5757600080fd5b8101908080519060200190929190505050615bda576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f776974686472617720756e6c6f636b696e67206661696c65640000000000000081525060200191505060405180910390fd5b505050505050565b6040518060a0016040528060006bffffffffffffffffffffffff16815260200160006bffffffffffffffffffffffff168152602001600063ffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160006bffffffffffffffffffffffff1681525090565b6040518060800160405280600063ffffffff168152602001600063ffffffff168152602001600063ffffffff16815260200160006bffffffffffffffffffffffff1681525090565b604051806040016040528060006fffffffffffffffffffffffffffffffff16815260200160006fffffffffffffffffffffffffffffffff1681525090565b6040518060c00160405280600060ff16815260200160006effffffffffffffffffffffffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff168152509056fe50726576696f757320706572696f64206d75737420626520636f6d706c657465206265666f7265206368616e67696e6720746865206475726174696f6e4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373626174636820756e6c6f636b20706f737369626c65206f6e6c7920666f72207468652073616d6520746f6b656e735468697320616374696f6e2063616e6e6f7420626520706572666f726d6564207768696c652074686520636f6e747261637420697320706175736564696e76616c696420706572696f64206f72206e6f7420737570706f7274656420746f6b656e63616e27742073746f70206966206e6f742073746172746564206f7220616c72656164792066696e6973686564a26469706673582212200ca23800e9fdd230003ae921506632815ac82e2a4fdc1c76a967e44fe442103364736f6c63430007050033

Verified Source Code Full Match

Compiler: v0.7.5+commit.eb77ed08 EVM: istanbul Optimization: No
Owned.sol 10 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract Owned is Ownable {
    constructor(address _owner) {
        transferOwnership(_owner);
    }
}
Pausable.sol 40 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

// Inheritance
import "./Owned.sol";


abstract contract Pausable is Owned {
    bool public paused;

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }

    constructor() {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner() != address(0), "Owner must be set");
        // Paused will be false
    }

    /**
     * @notice Change the paused state of the contract
     * @dev Only the contract owner may call this.
     */
    function setPaused(bool _paused) external onlyOwner {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }

        // Set our paused state.
        paused = _paused;

        // Let everyone know that our pause state has changed.
        emit PauseChanged(paused);
    }
}
LockSettings.sol 81 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract LockSettings is Ownable {
    /// @dev decimals for: baseRate, APY, multipliers
    ///         eg for baseRate: 1e6 is 1%, 50e6 is 50%
    ///         eg for multipliers: 1e6 is 1.0x, 3210000 is 3.21x
    uint256 public constant RATE_DECIMALS = 10 ** 6;
    uint256 public constant MAX_MULTIPLIER = 5 * RATE_DECIMALS;

    /// @notice token => period => multiplier
    mapping(address => mapping(uint256 => uint256)) public multipliers;

    /// @notice token => period => index in periods array
    mapping(address => mapping(uint256 => uint256)) public periodIndexes;

    /// @notice token => periods
    mapping(address => uint256[]) public periods;

    event TokenSettings(address indexed token, uint256 period, uint256 multiplier);

    function removePeriods(address _token, uint256[] calldata _periods) external onlyOwner {
        for (uint256 i; i < _periods.length; i++) {
            if (_periods[i] == 0) revert("InvalidSettings");

            multipliers[_token][_periods[i]] = 0;
            _removePeriod(_token, _periods[i]);

            emit TokenSettings(_token, _periods[i], 0);
        }
    }

    // solhint-disable-next-line code-complexity
    function setLockingTokenSettings(address _token, uint256[] calldata _periods, uint256[] calldata _multipliers)
        external
        onlyOwner
    {
        if (_periods.length == 0) revert("EmptyPeriods");
        if (_periods.length != _multipliers.length) revert("ArraysNotMatch");

        for (uint256 i; i < _periods.length; i++) {
            if (_periods[i] == 0) revert("InvalidSettings");
            if (_multipliers[i] < RATE_DECIMALS) revert("multiplier must be >= 1e6");
            if (_multipliers[i] > MAX_MULTIPLIER) revert("multiplier overflow");

            multipliers[_token][_periods[i]] = _multipliers[i];
            emit TokenSettings(_token, _periods[i], _multipliers[i]);

            if (_multipliers[i] == 0) _removePeriod(_token, _periods[i]);
            else _addPeriod(_token, _periods[i]);
        }
    }

    function periodsCount(address _token) external view returns (uint256) {
        return periods[_token].length;
    }

    function getPeriods(address _token) external view returns (uint256[] memory) {
        return periods[_token];
    }

    function _addPeriod(address _token, uint256 _period) internal {
        uint256 key = periodIndexes[_token][_period];
        if (key != 0) return;

        periods[_token].push(_period);
        // periodIndexes are starting from 1, not from 0
        periodIndexes[_token][_period] = periods[_token].length;
    }

    function _removePeriod(address _token, uint256 _period) internal {
        uint256 key = periodIndexes[_token][_period];
        if (key == 0) return;

        periods[_token][key - 1] = periods[_token][periods[_token].length - 1];
        periodIndexes[_token][_period] = 0;
        periods[_token].pop();
    }
}
StakingLockable.sol 480 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

// Inheritance
import "../interfaces/IStakingRewards.sol";
import "../interfaces/Pausable.sol";
import "../interfaces/IBurnableToken.sol";
import "../interfaces/RewardsDistributionRecipient.sol";
import "../interfaces/OnDemandToken.sol";
import "../interfaces/LockSettings.sol";
import "../interfaces/SwappableTokenV2.sol";

/// @author  umb.network
/// @notice Math is based on synthetix staking contract
///         Contract allows to stake and lock tokens. For rUMB tokens only locking option is available.
///         When locking user choose period and based on period multiplier is apply to the amount (boost).
///         If pool is set for rUMB1->rUMB2, (rUmbPool) then rUMB2 can be locked as well
contract StakingLockable is LockSettings, RewardsDistributionRecipient, ReentrancyGuard, Pausable {
    struct Times {
        uint32 periodFinish;
        uint32 rewardsDuration;
        uint32 lastUpdateTime;
        uint96 totalRewardsSupply;
    }

    struct Balance {
        // total supply of UMB = 500_000_000e18, it can be saved using 89bits, so we good with 96 and above
        // user UMB balance
        uint96 umbBalance;
        // amount locked + virtual balance generated using multiplier when locking
        uint96 lockedWithBonus;
        uint32 nextLockIndex;
        uint160 userRewardPerTokenPaid;
        uint96 rewards;
    }

    struct Supply {
        // staked + raw locked
        uint128 totalBalance;
        // virtual balance
        uint128 totalBonus;
    }

    struct Lock {
        uint8 tokenId;
        // total supply of UMB can be saved using 89bits, so we good with 96 and above
        uint120 amount;
        uint32 lockDate;
        uint32 unlockDate;
        uint32 multiplier;
        uint32 withdrawnAt;
    }

    uint8 public constant UMB_ID = 2 ** 0;
    uint8 public constant RUMB1_ID = 2 ** 1;
    uint8 public constant RUMB2_ID = 2 ** 2;

    uint256 public immutable maxEverTotalRewards;

    address public immutable umb;
    address public immutable rUmb1;
    /// @dev this is reward token but we also allow to lock it
    address public immutable rUmb2;

    uint256 public rewardRate = 0;
    uint256 public rewardPerTokenStored;

    Supply public totalSupply;

    Times public timeData;

    /// @dev user => Balance
    mapping(address => Balance) public balances;

    /// @dev user => lock ID => Lock
    mapping(address => mapping(uint256 => Lock)) public locks;

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 amount, uint256 bonus);

    event LockedTokens(
        address indexed user,
        address indexed token,
        uint256 lockId,
        uint256 amount,
        uint256 period,
        uint256 multiplier
    );

    event UnlockedTokens(address indexed user, address indexed token, uint256 lockId, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, uint256 reward);
    event RewardsDurationUpdated(uint256 newDuration);
    event FarmingFinished();
    event Swap1to2(uint256 swapped);

    modifier updateReward(address _account) virtual {
        uint256 newRewardPerTokenStored = rewardPerToken();
        rewardPerTokenStored = newRewardPerTokenStored;
        timeData.lastUpdateTime = uint32(lastTimeRewardApplicable());

        if (_account != address(0)) {
            balances[_account].rewards = uint96(earned(_account));
            balances[_account].userRewardPerTokenPaid = uint160(newRewardPerTokenStored);
        }

        _;
    }

    constructor(
        address _owner,
        address _rewardsDistribution,
        address _umb,
        address _rUmb1,
        address _rUmb2
    ) Owned(_owner) {
        require(
            (
                MintableToken(_umb).maxAllowedTotalSupply() +
                MintableToken(_rUmb1).maxAllowedTotalSupply() +
                MintableToken(_rUmb2).maxAllowedTotalSupply()
            ) * MAX_MULTIPLIER / RATE_DECIMALS <= type(uint96).max,
            "staking overflow"
        );

        require(
            MintableToken(_rUmb2).maxAllowedTotalSupply() * MAX_MULTIPLIER / RATE_DECIMALS <= type(uint96).max,
            "rewards overflow"
        );

        require(OnDemandToken(_rUmb2).ON_DEMAND_TOKEN(), "rewardsToken must be OnDemandToken");

        umb = _umb;
        rUmb1 = _rUmb1;
        rUmb2 = _rUmb2;

        rewardsDistribution = _rewardsDistribution;
        timeData.rewardsDuration = 2592000; // 30 days
        maxEverTotalRewards = MintableToken(_rUmb2).maxAllowedTotalSupply();
    }

    function lockTokens(address _token, uint256 _amount, uint256 _period) external {
        if (_token == rUmb2 && !SwappableTokenV2(rUmb2).isSwapStarted()) {
            revert("locking rUMB2 not available yet");
        }

        _lockTokens(msg.sender, _token, _amount, _period);
    }

    function unlockTokens(uint256[] calldata _ids) external {
        _unlockTokensFor(msg.sender, _ids, msg.sender);
    }

    function restart(uint256 _rewardsDuration, uint256 _reward) external {
        setRewardsDuration(_rewardsDuration);
        notifyRewardAmount(_reward);
    }

    // when farming was started with 1y and 12tokens
    // and we want to finish after 4 months, we need to end up with situation
    // like we were starting with 4mo and 4 tokens.
    function finishFarming() external onlyOwner {
        Times memory t = timeData;
        require(block.timestamp < t.periodFinish, "can't stop if not started or already finished");

        if (totalSupply.totalBalance != 0) {
            uint32 remaining = uint32(t.periodFinish - block.timestamp);
            timeData.rewardsDuration = t.rewardsDuration - remaining;
        }

        timeData.periodFinish = uint32(block.timestamp);

        emit FarmingFinished();
    }

    /// @notice one of the reasons this method can throw is, when we swap for UMB and somebody stake rUMB1 after that.
    ///         In that case execution of `swapForUMB()` is required (anyone can execute this method) before proceeding.
    function exit() external {
        _withdraw(type(uint256).max, msg.sender, msg.sender);
        _getReward(msg.sender, msg.sender);
    }

    /// @notice one of the reasons this method can throw is, when we swap for UMB and somebody stake rUMB1 after that.
    ///         In that case execution of `swapForUMB()` is required (anyone can execute this method) before proceeding.
    function exitAndUnlock(uint256[] calldata _lockIds) external {
        _withdraw(type(uint256).max, msg.sender, msg.sender);
        _unlockTokensFor(msg.sender, _lockIds, msg.sender);
        _getReward(msg.sender, msg.sender);
    }

    function stake(uint256 _amount) external {
        _stake(umb, msg.sender, _amount, 0);
    }

    function getReward() external {
        _getReward(msg.sender, msg.sender);
    }

    function swap1to2() public {
        if (!SwappableTokenV2(rUmb2).isSwapStarted()) return;

        uint256 myBalance = IERC20(rUmb1).balanceOf(address(this));
        if (myBalance == 0) return;

        IBurnableToken(rUmb1).burn(myBalance);
        OnDemandToken(rUmb2).mint(address(this), myBalance);

        emit Swap1to2(myBalance);
    }

    /// @dev when notifying about amount, we don't have to mint or send any tokens, reward tokens will be mint on demand
    ///         this method is used to restart staking
    function notifyRewardAmount(
        uint256 _reward
    ) override public onlyRewardsDistribution updateReward(address(0)) {
        // this method can be executed on its own as well, I'm including here to not need to remember about it
        swap1to2();

        Times memory t = timeData;
        uint256 newRewardRate;

        if (block.timestamp >= t.periodFinish) {
            newRewardRate = _reward / t.rewardsDuration;
        } else {
            uint256 remaining = t.periodFinish - block.timestamp;
            uint256 leftover = remaining * rewardRate;
            newRewardRate = (_reward + leftover) / t.rewardsDuration;
        }

        require(newRewardRate != 0, "invalid rewardRate");

        rewardRate = newRewardRate;

        // always increasing by _reward even if notification is in a middle of period
        // because leftover is included
        uint256 totalRewardsSupply = timeData.totalRewardsSupply + _reward;
        require(totalRewardsSupply <= maxEverTotalRewards, "rewards overflow");

        timeData.totalRewardsSupply = uint96(totalRewardsSupply);
        timeData.lastUpdateTime = uint32(block.timestamp);
        timeData.periodFinish = uint32(block.timestamp + t.rewardsDuration);

        emit RewardAdded(_reward);
    }

    function setRewardsDuration(uint256 _rewardsDuration) public onlyRewardsDistribution {
        require(_rewardsDuration != 0, "empty _rewardsDuration");

        require(
            block.timestamp > timeData.periodFinish,
            "Previous period must be complete before changing the duration"
        );

        timeData.rewardsDuration = uint32(_rewardsDuration);
        emit RewardsDurationUpdated(_rewardsDuration);
    }

    /// @notice one of the reasons this method can throw is, when we swap for UMB and somebody stake rUMB1 after that.
    ///         In that case execution of `swapForUMB()` is required (anyone can execute this method) before proceeding.
    function withdraw(uint256 _amount) public {
        _withdraw(_amount, msg.sender, msg.sender);
    }

    function lastTimeRewardApplicable() public view returns (uint256) {
        uint256 periodFinish = timeData.periodFinish;
        return block.timestamp < periodFinish ? block.timestamp : periodFinish;
    }

    function rewardPerToken() public view returns (uint256 perToken) {
        Supply memory s = totalSupply;

        if (s.totalBalance == 0) {
            return rewardPerTokenStored;
        }

        perToken = rewardPerTokenStored + (
            (lastTimeRewardApplicable() - timeData.lastUpdateTime) * rewardRate * 1e18 / (s.totalBalance + s.totalBonus)
        );
    }

    function earned(address _account) virtual public view returns (uint256) {
        Balance memory b = balances[_account];
        uint256 totalBalance = b.umbBalance + b.lockedWithBonus;
        return (totalBalance * (rewardPerToken() - b.userRewardPerTokenPaid) / 1e18) + b.rewards;
    }

    function calculateBonus(uint256 _amount, uint256 _multiplier) public pure returns (uint256 bonus) {
        if (_multiplier <= RATE_DECIMALS) return 0;

        bonus = _amount * _multiplier / RATE_DECIMALS - _amount;
    }

    /// @param _token token that we allow to stake, validator check should be do outside
    /// @param _user token owner
    /// @param _amount amount
    /// @param _bonus if bonus is 0, means we are staking, bonus > 0 means this is locking
    function _stake(address _token, address _user, uint256 _amount, uint256 _bonus)
        internal
        nonReentrant
        notPaused
        updateReward(_user)
    {
        uint256 amountWithBonus = _amount + _bonus;

        require(timeData.periodFinish > block.timestamp, "Stake period not started yet");
        require(amountWithBonus != 0, "Cannot stake 0");

        // TODO check if we ever need to separate balance and bonuses
        totalSupply.totalBalance += uint96(_amount);
        totalSupply.totalBonus += uint128(_bonus);

        if (_bonus == 0) {
            balances[_user].umbBalance += uint96(_amount);
        } else {
            balances[_user].lockedWithBonus += uint96(amountWithBonus);
        }

        // not using safe transfer, because we working with trusted tokens
        require(IERC20(_token).transferFrom(_user, address(this), _amount), "token transfer failed");

        emit Staked(_user, _amount, _bonus);
    }

    function _lockTokens(address _user, address _token, uint256 _amount, uint256 _period) internal notPaused {
        uint256 multiplier = multipliers[_token][_period];
        require(multiplier != 0, "invalid period or not supported token");

        uint256 stakeBonus = calculateBonus(_amount, multiplier);

        _stake(_token, _user, _amount, stakeBonus);
        _addLock(_user, _token, _amount, _period, multiplier);
    }

    function _addLock(address _user, address _token, uint256 _amount, uint256 _period, uint256 _multiplier) internal {
        uint256 newIndex = balances[_user].nextLockIndex;
        if (newIndex == type(uint32).max) revert("nextLockIndex overflow");

        balances[_user].nextLockIndex = uint32(newIndex + 1);

        Lock storage lock = locks[_user][newIndex];

        lock.amount = uint120(_amount);
        lock.multiplier = uint32(_multiplier);
        lock.lockDate = uint32(block.timestamp);
        lock.unlockDate = uint32(block.timestamp + _period);

        if (_token == rUmb2) lock.tokenId = RUMB2_ID;
        else if (_token == rUmb1) lock.tokenId = RUMB1_ID;
        else lock.tokenId = UMB_ID;

        emit LockedTokens(_user, _token, newIndex, _amount, _period, _multiplier);
    }

    // solhint-disable-next-line code-complexity
    function _unlockTokensFor(address _user, uint256[] calldata _indexes, address _recipient)
        internal
        returns (address token, uint256 totalRawAmount)
    {
        uint256 totalBonus;
        uint256 acceptedTokenId;
        bool isSwapStarted = SwappableTokenV2(rUmb2).isSwapStarted();

        for (uint256 i; i < _indexes.length; i++) {
            (uint256 amount, uint256 bonus, uint256 tokenId) = _markAsUnlocked(_user, _indexes[i]);
            if (amount == 0) continue;

            if (acceptedTokenId == 0) {
                acceptedTokenId = tokenId;
                token = _idToToken(tokenId);

                // if token is already rUmb2 means swap started already

                if (token == rUmb1 && isSwapStarted) {
                    token = rUmb2;
                    acceptedTokenId = RUMB2_ID;
                }
            } else if (acceptedTokenId != tokenId) {
                if (acceptedTokenId == RUMB2_ID && tokenId == RUMB1_ID) {
                    // this lock is for rUMB1 but swap 1->2 is started so we unlock as rUMB2
                } else revert("batch unlock possible only for the same tokens");
            }

            emit UnlockedTokens(_user, token, _indexes[i], amount);

            totalRawAmount += amount;
            totalBonus += bonus;
        }

        if (totalRawAmount == 0) revert("nothing to unlock");
        _withdrawUnlockedTokens(_user, token, _recipient, totalRawAmount, totalBonus);
    }

    function _withdrawUnlockedTokens(
        address _user,
        address _token,
        address _recipient,
        uint256 _totalRawAmount,
        uint256 _totalBonus
    )
        internal
    {
        uint256 amountWithBonus = _totalRawAmount + _totalBonus;

        balances[_user].lockedWithBonus -= uint96(amountWithBonus);

        totalSupply.totalBalance -= uint96(_totalRawAmount);
        totalSupply.totalBonus -= uint128(_totalBonus);

        // note: there is one case when this transfer can fail:
        // when swap is started by we did not swap rUmb1 -> rUmb2,
        // in that case we have to execute `swap1to2`
        // to save gas I'm not including it here, because it is unlikely case
        require(IERC20(_token).transfer(_recipient, _totalRawAmount), "withdraw unlocking failed");
    }

    function _markAsUnlocked(address _user, uint256 _index)
        internal
        returns (uint256 amount, uint256 bonus, uint256 tokenId)
    {
        // TODO will storage save gas?
        Lock memory lock = locks[_user][_index];

        if (lock.withdrawnAt != 0) revert("DepositAlreadyWithdrawn");
        if (block.timestamp < lock.unlockDate) revert("DepositLocked");

        if (lock.amount == 0) return (0, 0, 0);

        locks[_user][_index].withdrawnAt = uint32(block.timestamp);

        return (lock.amount, calculateBonus(lock.amount, lock.multiplier), lock.tokenId);
    }

    /// @param _amount tokens to withdraw
    /// @param _user address
    /// @param _recipient address, where to send tokens, if we migrating token address can be zero
    function _withdraw(uint256 _amount, address _user, address _recipient) internal nonReentrant updateReward(_user) {
        Balance memory balance = balances[_user];

        if (_amount == type(uint256).max) _amount = balance.umbBalance;
        else require(balance.umbBalance >= _amount, "withdraw amount to high");

        if (_amount == 0) return;

        // not using safe math, because there is no way to overflow because of above check
        totalSupply.totalBalance -= uint120(_amount);
        balances[_user].umbBalance = uint96(balance.umbBalance - _amount);

        // not using safe transfer, because we working with trusted tokens
        require(IERC20(umb).transfer(_recipient, _amount), "token transfer failed");

        emit Withdrawn(_user, _amount);
    }

    /// @param _user address
    /// @param _recipient address, where to send reward
    function _getReward(address _user, address _recipient)
        internal
        nonReentrant
        updateReward(_user)
        returns (uint256 reward)
    {
        reward = balances[_user].rewards;

        if (reward != 0) {
            balances[_user].rewards = 0;
            OnDemandToken(address(rUmb2)).mint(_recipient, reward);
            emit RewardPaid(_user, reward);
        }
    }

    function _idToToken(uint256 _tokenId) internal view returns (address token) {
        if (_tokenId == RUMB2_ID) token = rUmb2;
        else if (_tokenId == RUMB1_ID) token = rUmb1;
        else if (_tokenId == UMB_ID) token = umb;
        else return address(0);
    }
}
ISwapReceiver.sol 6 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

interface ISwapReceiver {
    function swapMint(address _holder, uint256 _amount) external;
}
MintableToken.sol 51 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

import "../interfaces/Owned.sol";
import "../interfaces/IBurnableToken.sol";

/// @author  umb.network
abstract contract MintableToken is Owned, ERC20, IBurnableToken {
    uint256 public immutable maxAllowedTotalSupply;
    uint256 public everMinted;

    modifier assertMaxSupply(uint256 _amountToMint) {
        _assertMaxSupply(_amountToMint);
        _;
    }

    // ========== CONSTRUCTOR ========== //

    constructor (uint256 _maxAllowedTotalSupply) {
        require(_maxAllowedTotalSupply != 0, "_maxAllowedTotalSupply is empty");

        maxAllowedTotalSupply = _maxAllowedTotalSupply;
    }

    // ========== MUTATIVE FUNCTIONS ========== //

    function burn(uint256 _amount) override external {
        _burn(msg.sender, _amount);
    }

    // ========== RESTRICTED FUNCTIONS ========== //

    function mint(address _holder, uint256 _amount)
        virtual
        external
        onlyOwner()
        assertMaxSupply(_amount)
    {
        require(_amount != 0, "zero amount");

        _mint(_holder, _amount);
    }

    function _assertMaxSupply(uint256 _amountToMint) internal {
        uint256 everMintedTotal = everMinted + _amountToMint;
        everMinted = everMintedTotal;
        require(everMintedTotal <= maxAllowedTotalSupply, "total supply limit exceeded");
    }
}
OnDemandToken.sol 43 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "./MintableToken.sol";

abstract contract OnDemandToken is MintableToken {
    bool constant public ON_DEMAND_TOKEN = true;

    mapping (address => bool) public minters;

    event SetupMinter(address minter, bool active);

    modifier onlyOwnerOrMinter() {
        address msgSender = _msgSender();
        require(owner() == msgSender || minters[msgSender], "access denied");

        _;
    }

    function setupMinter(address _minter, bool _active) external onlyOwner() {
        minters[_minter] = _active;
        emit SetupMinter(_minter, _active);
    }

    function setupMinters(address[] calldata _minters, bool[] calldata _actives) external onlyOwner() {
        for (uint256 i; i < _minters.length; i++) {
            minters[_minters[i]] = _actives[i];
            emit SetupMinter(_minters[i], _actives[i]);
        }
    }

    function mint(address _holder, uint256 _amount)
        external
        virtual
        override
        onlyOwnerOrMinter()
        assertMaxSupply(_amount)
    {
        require(_amount != 0, "zero amount");

        _mint(_holder, _amount);
    }
}
StakingRewardsV2.sol 36 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

import "./StakingLockable.sol";
import "../interfaces/IMigrationReceiver.sol";

/// @author  umb.network
contract StakingRewardsV2 is StakingLockable {
    constructor(
        address _owner,
        address _rewardsDistribution,
        address _umb,
        address _rUmb1,
        address _rUmb2
    ) StakingLockable(_owner, _rewardsDistribution, _umb, _rUmb1, _rUmb2) {}

    /// @param _newPool address of new pool, where tokens will be staked
    /// @param _data additional data for new pool
    function getRewardAndMigrate(IMigrationReceiver _newPool, bytes calldata _data) external {
        uint256 reward = _getReward(msg.sender, address(_newPool));
        _newPool.migrateTokenCallback(rUmb2, msg.sender, reward, _data);
    }

    /// @param _newPool address of new pool, where tokens will be staked
    /// @param _amount amount of staked tokens to migrate to new pool
    /// @param _data additional data for new pool
    function withdrawAndMigrate(IMigrationReceiver _newPool, uint256 _amount, bytes calldata _data) external {
        _withdraw(_amount, msg.sender, address(_newPool));
        _newPool.migrateTokenCallback(umb, msg.sender, _amount, _data);
    }

    function unlockAndMigrate(IMigrationReceiver _newPool, uint256[] calldata _ids, bytes calldata _data) external {
        (address token, uint256 totalRawAmount) = _unlockTokensFor(msg.sender, _ids, address(_newPool));
        _newPool.migrateTokenCallback(token, msg.sender, totalRawAmount, _data);
    }
}
IBurnableToken.sol 6 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

interface IBurnableToken {
    function burn(uint256 _amount) external;
}
IStakingRewards.sol 27 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;


interface IStakingRewards {
    // Mutative
    function stake(uint256 amount) external;

    function withdraw(uint256 amount) external;

    function getReward() external;

    function exit() external;
    // Views
    function lastTimeRewardApplicable() external view returns (uint256);

    function rewardPerToken() external view returns (uint256);

    function earned(address account) external view returns (uint256);

    function getRewardForDuration() external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

}
SafeMath.sol 214 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}
SwappableTokenV2.sol 108 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

// Inheritance
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

import "../interfaces/Owned.sol";
import "../interfaces/ISwapReceiver.sol";


/// @title   Umbrella Rewards contract V2
/// @author  umb.network
/// @notice  This contract serves Swap functionality for rewards tokens
/// @dev     It allows to swap itself for other token (main UMB token).
abstract contract SwappableTokenV2 is Owned, ERC20 {
    struct SwapData {
        // number of tokens swapped so far (no decimals)
        uint32 swappedSoFar;
        // used limit since last swap (no decimals)
        uint32 usedLimit;
        // daily cup (no decimals)
        uint32 dailyCup;
        uint32 dailyCupTimestamp;
        uint32 swapEnabledAt;
    }

    uint256 public constant ONE = 1e18;

    uint256 public immutable swapStartsOn;
    ISwapReceiver public immutable umb;

    SwapData public swapData;

    event LogStartEarlySwapNow(uint time);
    event LogSwap(address indexed swappedTo, uint amount);
    event LogDailyCup(uint newCup);

    constructor(address _umb, uint32 _swapStartsOn, uint32 _dailyCup) {
        require(_dailyCup != 0, "invalid dailyCup");
        require(_swapStartsOn > block.timestamp, "invalid swapStartsOn");
        require(ERC20(_umb).decimals() == 18, "invalid UMB token");

        swapStartsOn = _swapStartsOn;
        umb = ISwapReceiver(_umb);
        swapData.dailyCup = _dailyCup;
    }

    function swapForUMB() external {
        SwapData memory data = swapData;

        (uint256 limit, bool fullLimit) = _currentLimit(data);
        require(limit != 0, "swapping period not started OR limit");

        uint256 amountToSwap = balanceOf(msg.sender);
        require(amountToSwap != 0, "you dont have tokens to swap");

        uint32 amountWoDecimals = uint32(amountToSwap / ONE);
        require(amountWoDecimals <= limit, "daily CUP limit");

        swapData.usedLimit = uint32(fullLimit ? amountWoDecimals : data.usedLimit + amountWoDecimals);
        swapData.swappedSoFar += amountWoDecimals;
        if (fullLimit) swapData.dailyCupTimestamp = uint32(block.timestamp);

        _burn(msg.sender, amountToSwap);
        umb.swapMint(msg.sender, amountToSwap);

        emit LogSwap(msg.sender, amountToSwap);
    }

    function startEarlySwap() external onlyOwner {
        require(block.timestamp < swapStartsOn, "swap is already allowed");
        require(swapData.swapEnabledAt == 0, "swap was already enabled");

        swapData.swapEnabledAt = uint32(block.timestamp);
        emit LogStartEarlySwapNow(block.timestamp);
    }

    /// @param _cup daily cup limit (no decimals), eg. if cup=5 means it is 5 * 10^18 tokens
    function setDailyCup(uint32 _cup) external onlyOwner {
        swapData.dailyCup = _cup;
        emit LogDailyCup(_cup);
    }

    function isSwapStarted() external view returns (bool) {
        // will it save gas if I do 2x if??
        return block.timestamp >= swapStartsOn || swapData.swapEnabledAt != 0;
    }

    function canSwapTokens(address _address) external view returns (bool) {
        uint256 balance = balanceOf(_address);
        if (balance == 0) return false;

        (uint256 limit,) = _currentLimit(swapData);
        return balance / ONE <= limit;
    }

    function currentLimit() external view returns (uint256 limit) {
        (limit,) = _currentLimit(swapData);
        limit *= ONE;
    }

    function _currentLimit(SwapData memory data) internal view returns (uint256 limit, bool fullLimit) {
        if (block.timestamp < swapStartsOn && data.swapEnabledAt == 0) return (0, false);

        fullLimit = block.timestamp - data.dailyCupTimestamp >= 24 hours;
        limit = fullLimit ? data.dailyCup : data.dailyCup - data.usedLimit;
    }
}
Ownable.sol 68 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        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 {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
IMigrationReceiver.sol 10 lines
//SPDX-License-Identifier: MIT
pragma solidity >=0.7.5 <0.9.0;

/// @dev when modifying this contract, please copy all to MigrationPoolsV8
interface IMigrationReceiver {

    /// @dev should use onlyPool modifier
    ///         this method is responsible for "accepting" tokens from other pool to our
    function migrateTokenCallback(address _token, address _user, uint256 _amount, bytes calldata _data) external;
}
ERC20.sol 306 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @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);
}
ReentrancyGuard.sol 62 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 () internal {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
RewardsDistributionRecipient.sol 22 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.7.5;

// Inheritance
import "./Owned.sol";


// https://docs.synthetix.io/contracts/RewardsDistributionRecipient
abstract contract RewardsDistributionRecipient is Owned {
    address public rewardsDistribution;

    modifier onlyRewardsDistribution() {
        require(msg.sender == rewardsDistribution, "Caller is not RewardsDistributor");
        _;
    }

    function notifyRewardAmount(uint256 reward) virtual external;

    function setRewardsDistribution(address _rewardsDistribution) external onlyOwner {
        rewardsDistribution = _rewardsDistribution;
    }
}

Read Contract

MAX_MULTIPLIER 0x5d6a618d → uint256
RATE_DECIMALS 0x5a604c52 → uint256
RUMB1_ID 0x6ff00edf → uint8
RUMB2_ID 0xde35fc61 → uint8
UMB_ID 0x4e4e1c42 → uint8
balances 0x27e235e3 → uint96, uint96, uint32, uint160, uint96
calculateBonus 0x6f72fd20 → uint256
earned 0x008cc262 → uint256
getPeriods 0x56497ab0 → uint256[]
lastTimeRewardApplicable 0x80faa57d → uint256
locks 0xb425f802 → uint8, uint120, uint32, uint32, uint32, uint32
maxEverTotalRewards 0x0e00f75a → uint256
multipliers 0xaf62fe0e → uint256
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
periodIndexes 0xf0ac103c → uint256
periods 0x624a5c9d → uint256
periodsCount 0x02092087 → uint256
rUmb1 0xe26191df → address
rUmb2 0x2ab52a25 → address
rewardPerToken 0xcd3daf9d → uint256
rewardPerTokenStored 0xdf136d65 → uint256
rewardRate 0x7b0a47ee → uint256
rewardsDistribution 0x3fc6df6e → address
timeData 0xa0e43959 → uint32, uint32, uint32, uint96
totalSupply 0x18160ddd → uint128, uint128
umb 0x4de5931e → address

Write Contract 21 functions

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

exit 0xe9fad8ee
No parameters
exitAndUnlock 0xa5c5be90
uint256[] _lockIds
finishFarming 0x207e11aa
No parameters
getReward 0x3d18b912
No parameters
getRewardAndMigrate 0x6cc89945
address _newPool
bytes _data
lockTokens 0xa25983e5
address _token
uint256 _amount
uint256 _period
notifyRewardAmount 0x3c6b16ab
uint256 _reward
removePeriods 0x7fa0d26b
address _token
uint256[] _periods
renounceOwnership 0x715018a6
No parameters
restart 0x81bd2e0e
uint256 _rewardsDuration
uint256 _reward
setLockingTokenSettings 0xf9ad8ac4
address _token
uint256[] _periods
uint256[] _multipliers
setPaused 0x16c38b3c
bool _paused
setRewardsDistribution 0x19762143
address _rewardsDistribution
setRewardsDuration 0xcc1a378f
uint256 _rewardsDuration
stake 0xa694fc3a
uint256 _amount
swap1to2 0x594ce5d3
No parameters
transferOwnership 0xf2fde38b
address newOwner
unlockAndMigrate 0xee4a493c
address _newPool
uint256[] _ids
bytes _data
unlockTokens 0xcbd5d403
uint256[] _ids
withdraw 0x2e1a7d4d
uint256 _amount
withdrawAndMigrate 0x1524a414
address _newPool
uint256 _amount
bytes _data

Recent Transactions

No transactions found for this address