Address Contract Partially Verified
Address
0x351baC612B50e87B46e4b10A282f632D41397DE2
Balance
0 ETH
Nonce
1
Code Size
13616 bytes
Creator
0xC2e109Af...96B1 at tx 0x3efedb60...0ce37d
Indexed Transactions
0
Contract Bytecode
13616 bytes
0x608060405234801561001057600080fd5b506004361061025e5760003560e01c80639010d07c11610146578063c8984ab2116100c3578063d9d8e78311610087578063d9d8e783146107bf578063dca2aa5c146107c7578063e2bbb158146107e4578063ecd0c0c314610807578063f0895e521461080f578063f1209ef71461083c5761025e565b8063c8984ab214610749578063ca15c87314610751578063d547741f1461076e578063d8cd39991461079a578063d9b202c9146107b75761025e565b8063aa700ff21161010a578063aa700ff2146106ad578063adf55101146106ca578063ba92a4c5146106d2578063c0ba241b146106f5578063c30f75cf146106fd5761025e565b80639010d07c146105d457806391d14854146106135780639608df4b14610653578063a217fddf1461067f578063a8f1b4c4146106875761025e565b8063372646bb116101df57806353e052ac116101a357806353e052ac146103f35780635f208f341461041f578063658e28a41461052357806367ce50c01461054057806368bccfcf1461057f57806388cedd5e146105b15761025e565b8063372646bb1461037757806340e979031461037f5780634164b001146103a5578063441a3e70146103ad57806352885d8d146103d05761025e565b8063292911fb11610226578063292911fb146102ec5780632f2ff15d146102f457806332a1bd7014610320578063347908df1461032857806336568abe1461034b5761025e565b8063085313ec146102635780630c450f9d1461027d5780631338403914610285578063248a9ca3146102aa5780632514c50a146102c7575b600080fd5b61026b610844565b60408051918252519081900360200190f35b61026b61084b565b6102a86004803603604081101561029b57600080fd5b5080359060200135610851565b005b61026b600480360360208110156102c057600080fd5b503561091f565b6102cf610934565b6040805167ffffffffffffffff9092168252519081900360200190f35b61026b610944565b6102a86004803603604081101561030a57600080fd5b50803590602001356001600160a01b031661094a565b61026b6109b6565b6102a86004803603604081101561033e57600080fd5b50803590602001356109bc565b6102a86004803603604081101561036157600080fd5b50803590602001356001600160a01b0316610a85565b61026b610ae6565b61026b6004803603602081101561039557600080fd5b50356001600160a01b0316610aed565b61026b610b0b565b6102a8600480360360408110156103c357600080fd5b5080359060200135610b11565b6102a8600480360360408110156103e657600080fd5b5080359060200135610bf2565b6102a86004803603604081101561040957600080fd5b506001600160a01b03813516906020013561108b565b6104456004803603602081101561043557600080fd5b50356001600160a01b03166112ef565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561048d578181015183820152602001610475565b50505050905001848103835286818151815260200191508051906020019060200280838360005b838110156104cc5781810151838201526020016104b4565b50505050905001848103825285818151815260200191508051906020019060200280838360005b8381101561050b5781810151838201526020016104f3565b50505050905001965050505050505060405180910390f35b6102a86004803603602081101561053957600080fd5b5035611482565b6105666004803603602081101561055657600080fd5b50356001600160a01b031661155b565b6040805192835260208301919091528051918290030190f35b6102a86004803603606081101561059557600080fd5b508035906001600160a01b036020820135169060400135611574565b6102a8600480360360408110156105c757600080fd5b5080359060200135611886565b6105f7600480360360408110156105ea57600080fd5b5080359060200135611a15565b604080516001600160a01b039092168252519081900360200190f35b61063f6004803603604081101561062957600080fd5b50803590602001356001600160a01b0316611a3c565b604080519115158252519081900360200190f35b6102a86004803603604081101561066957600080fd5b506001600160a01b038135169060200135611a5a565b61026b611c8e565b6105666004803603602081101561069d57600080fd5b50356001600160a01b0316611c93565b610566600480360360208110156106c357600080fd5b5035611cb6565b61026b611ccf565b6102a8600480360360408110156106e857600080fd5b5080359060200135611cd5565b61026b611e49565b6107236004803603602081101561071357600080fd5b50356001600160a01b0316611e6e565b604080519485526020850193909352838301919091526060830152519081900360800190f35b610566611e9f565b61026b6004803603602081101561076757600080fd5b5035611ea8565b6102a86004803603604081101561078457600080fd5b50803590602001356001600160a01b0316611ebf565b6102a8600480360360208110156107b057600080fd5b5035611f18565b610566611ff2565b61026b611ffb565b6102a8600480360360208110156107dd57600080fd5b5035612001565b6102a8600480360360408110156107fa57600080fd5b50803590602001356120f2565b6105f76122fa565b6102a86004803603604081101561082557600080fd5b5067ffffffffffffffff8135169060200135612309565b61026b6123d2565b6002545b90565b60055481565b610859612447565b8061088b5750604080516c44454c45474154455f524f4c4560981b8152905190819003600d01902061088b9033611a3c565b6108c65760405162461bcd60e51b81526004018080602001828103825260248152602001806134186024913960400191505060405180910390fd5b80806108d0612458565b1115610911576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b61091a8361245c565b505050565b60009081526020819052604090206002015490565b60045467ffffffffffffffff1681565b60065481565b60008281526020819052604090206002015461096d906109686124e5565b611a3c565b6109a85760405162461bcd60e51b815260040180806020018281038252602f8152602001806133e9602f913960400191505060405180910390fd5b6109b282826124e9565b5050565b60025481565b80806109c6612458565b1115610a07576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b610a0f612447565b80610a415750604080516c44454c45474154455f524f4c4560981b8152905190819003600d019020610a419033611a3c565b610a7c5760405162461bcd60e51b81526004018080602001828103825260248152602001806134186024913960400191505060405180910390fd5b61091a83612558565b610a8d6124e5565b6001600160a01b0316816001600160a01b031614610adc5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134cc602f913960400191505060405180910390fd5b6109b282826125ae565b6205a66d81565b6001600160a01b03166000908152600f602052604090206002015490565b600c5481565b8080610b1b612458565b1115610b5c576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b610b64612458565b60035411610ba7576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b336000610bb2612458565b90506000610bc0838361261d565b50915050610bcc61333e565b610bdc828863ffffffff61287b16565b9050610be98482896128f4565b50505050505050565b8080610bfc612458565b1115610c3d576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b610c45612458565b60035411610c88576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b6000610c92612458565b9050336000610ca18284612aa1565b90506000610cb182600201612c1a565b9050610cbb61333e565b8715610ebd5781881115610d16576040805162461bcd60e51b815260206004820152601b60248201527f416d6f756e7420697320686967686572207468616e207374616b650000000000604482015290519081900360640190fd5b60045467ffffffffffffffff16610dee576001600160a01b0384166000908152601060205260409020610d549060028501908a63ffffffff612c3416565b9050610d6760078263ffffffff612c5916565b80516020808301516040805193845291830152805187926001600160a01b0388169260008051602061348c83398151915292918290030190a38051602080830151604080519384529183015280516001600160a01b038716927fa219ed960eef85ed4cd072d3a9f240ea94727c0d6fb15e9a91a8cd4bf18ee3a692908290030190a2610eb8565b6001600160a01b0384166000908152600f6020908152604082206002810180546001810182559084529190922060045460039092020190610e4090889067ffffffffffffffff1663ffffffff6123d816565b8155610e5960028601600183018c63ffffffff612c3416565b9250610e6c60098463ffffffff612c5916565b610e7c828463ffffffff612c5916565b80548351602080860151604080519384529183015280516001600160a01b038a169260008051602061348c83398151915292908290030190a350505b611081565b81610ecc57505050505061091a565b5060408051808201909152600283018054825260038401805460208401526000918290555560045467ffffffffffffffff16610fc2576001600160a01b0384166000908152601060205260409020610f2a908263ffffffff612c5916565b610f3b60078263ffffffff612c5916565b80516020808301516040805193845291830152805187926001600160a01b0388169260008051602061348c83398151915292918290030190a38051602080830151604080519384529183015280516001600160a01b038716927fa219ed960eef85ed4cd072d3a9f240ea94727c0d6fb15e9a91a8cd4bf18ee3a692908290030190a2611081565b6001600160a01b0384166000908152600f602090815260408220600281018054600181018255908452919092206004546003909202019061101490889067ffffffffffffffff1663ffffffff6123d816565b8155825160018201556020830151600282015561103860098463ffffffff612c5916565b611048828463ffffffff612c5916565b8054600182015460028301546040805192835260208301919091528051339260008051602061348c83398151915292908290030190a350505b5050505050505050565b8080611095612458565b11156110d6576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b6110de612447565b611128576040805162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1030b71037bbb732b960511b604482015290519081900360640190fd5b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561117357600080fd5b505afa158015611187573d6000803e3d6000fd5b505050506040513d602081101561119d57600080fd5b50516005546006549192506000916111ba9163ffffffff6123d816565b905060006111ce838363ffffffff612c9316565b6001546040805163a9059cbb60e01b81526001600160a01b038a8116600483015260248201859052915193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561122657600080fd5b505af115801561123a573d6000803e3d6000fd5b505050506040513d602081101561125057600080fd5b50516112a3576040805162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f7567682066756e6473206f6e20636f6e74722e20616464722e604482015290519081900360640190fd5b604080516001600160a01b03881681526020810183905281517f7f66376a5ef2f39ab4ee2ee6e400606624e66929dba5d82df5b14dd0070a8a87929181900390910190a1505050505050565b6001600160a01b0381166000908152600f60205260409020600201805460609182918291908015611479578067ffffffffffffffff8111801561133157600080fd5b5060405190808252806020026020018201604052801561135b578160200160208202803683370190505b5094508067ffffffffffffffff8111801561137557600080fd5b5060405190808252806020026020018201604052801561139f578160200160208202803683370190505b5093508067ffffffffffffffff811180156113b957600080fd5b506040519080825280602002602001820160405280156113e3578160200160208202803683370190505b50925060005b818110156114775760008382815481106113ff57fe5b906000526020600020906003020190506000816001019050806000015488848151811061142857fe5b602002602001018181525050806001015487848151811061144557fe5b602002602001018181525050816000015486848151811061146257fe5b602090810291909101015250506001016113e9565b505b50509193909250565b808061148c612458565b11156114cd576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b6114d5612458565b60035411611518576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b336000611523612458565b90506000611531838361261d565b5091505061153d61333e565b81548082526000835561155390859083906128f4565b505050505050565b6010602052600090815260409020805460019091015482565b808061157e612458565b11156115bf576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b6115c7612447565b611611576040805162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1030b71037bbb732b960511b604482015290519081900360640190fd5b83611620576005549350611677565b600554841115611677576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e7420686967686572207468616e207265776172647320706f6f6c00604482015290519081900360640190fd5b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156116c257600080fd5b505afa1580156116d6573d6000803e3d6000fd5b505050506040513d60208110156116ec57600080fd5b5051600654909150600090611707908763ffffffff6123d816565b90508181111561175e576040805162461bcd60e51b815260206004820152601760248201527f436f6e747261637420696e636f6e73697374656e63792e000000000000000000604482015290519081900360640190fd5b6001546040805163a9059cbb60e01b81526001600160a01b038881166004830152602482018a90529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156117b457600080fd5b505af11580156117c8573d6000803e3d6000fd5b505050506040513d60208110156117de57600080fd5b5051611831576040805162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f7567682066756e6473206f6e20636f6e74722e20616464722e604482015290519081900360640190fd5b600580548790039055604080516001600160a01b03871681526020810188905281517f8a652d32cc9efc0a4f0fc3708c9fb81d5a924a7b9af2a37c46e9e4910d0dc325929181900390910190a1505050505050565b8080611890612458565b11156118d1576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b6118d9612458565b6003541161191c576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b8261196e576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d75737420626520686967686572207468616e207a65726f00604482015290519081900360640190fd5b6000611978612458565b90506000611986338361261d565b5091505060006119963384612aa1565b90506119a061333e565b6119b483600284018963ffffffff612cd516565b90506119c760078263ffffffff612ce716565b600182015481516020808401516040805193845291830152805133927f0fb741c5ad2cad8215be7b4cab4e3f202f907d4540668ebf954f8e742efd89cf92908290030190a350505050505050565b6000828152602081905260408120611a33908363ffffffff612d1516565b90505b92915050565b6000828152602081905260408120611a33908363ffffffff612d2116565b8080611a64612458565b1115611aa5576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b611aad612447565b611af7576040805162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1030b71037bbb732b960511b604482015290519081900360640190fd5b611aff612458565b6002541015611b55576040805162461bcd60e51b815260206004820152601b60248201527f4561726c696573742064656c657465206e6f7420726561636865640000000000604482015290519081900360640190fd5b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015611ba057600080fd5b505afa158015611bb4573d6000803e3d6000fd5b505050506040513d6020811015611bca57600080fd5b50516001546040805163a9059cbb60e01b81526001600160a01b03888116600483015260248201859052915193945091169163a9059cbb916044808201926020929091908290030181600087803b158015611c2457600080fd5b505af1158015611c38573d6000803e3d6000fd5b505050506040513d6020811015611c4e57600080fd5b5051611c5957600080fd5b6040517fe4dedc7f698868c432fb679313d1381b06601dfb7174d9b18b2e35378b67633390600090a1836001600160a01b0316ff5b600081565b6001600160a01b03166000908152600f6020526040902080546001909101549091565b600d602052600090815260409020805460019091015482565b60055490565b8080611cdf612458565b1115611d20576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b82611d2a5761091a565b600154604080516323b872dd60e01b81523360048201523060248201526044810186905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015611d8457600080fd5b505af1158015611d98573d6000803e3d6000fd5b505050506040513d6020811015611dae57600080fd5b5051611df3576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b600554611e06908463ffffffff6123d816565b600555604080513381526020810185905281517fb562e06b275d420e5848bb9083041a1c68466a478df92491b473ce99a4c68f68929181900390910190a1505050565b604080516c44454c45474154455f524f4c4560981b8152905190819003600d01902081565b6001600160a01b03166000908152600e60205260409020600281015460038201548254600190930154919390929190565b60075460085482565b6000818152602081905260408120611a3690612d36565b600082815260208190526040902060020154611edd906109686124e5565b610adc5760405162461bcd60e51b815260040180806020018281038252603081526020018061343c6030913960400191505060405180910390fd5b8080611f22612458565b1115611f63576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b611f6b612458565b60035411611fae576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b336000611fb9612458565b90506000611fc7838361261d565b50915050611fd361333e565b60018201805460208301819052600090915561155390859083906128f4565b600954600a5482565b600b5481565b808061200b612458565b111561204c576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b612054612458565b60035411612097576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b3360006120a2612458565b905060006120b0838361261d565b506040805180820190915281548152600182015460208201529092506120e1915084906120dc84612c1a565b6128f4565b600060018201819055905550505050565b80806120fc612458565b111561213d576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b612145612458565b60035411612188576040805162461bcd60e51b815260206004820152601860248201526000805160206134ac833981519152604482015290519081900360640190fd5b82158015906122bd57600154604080516323b872dd60e01b81523360048201523060248201526044810187905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b1580156121eb57600080fd5b505af11580156121ff573d6000803e3d6000fd5b505050506040513d602081101561221557600080fd5b505161225a576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b60065461226d908563ffffffff6123d816565b600655600754612283908563ffffffff6123d816565b60075560408051858152905133917f7ff07ce9a287649537e4b012e45cf012d90228b12e2b56bb03515a6b5436fcdf919081900360200190a25b60006122c7612458565b905060006122d5338361261d565b5091505082156115535780546122f1908763ffffffff6123d816565b90555050505050565b6001546001600160a01b031681565b8080612313612458565b1115612354576040805162461bcd60e51b8152602060048201526013602482015260008051602061346c833981519152604482015290519081900360640190fd5b61235c612447565b8061238e5750604080516c44454c45474154455f524f4c4560981b8152905190819003600d01902061238e9033611a3c565b6123c95760405162461bcd60e51b81526004018080602001828103825260248152602001806134186024913960400191505060405180910390fd5b61091a83612d41565b60035481565b600082820183811015611a33576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000611a33836001600160a01b038416612d97565b60006124538133611a3c565b905090565b4390565b600c546040805180820190915280612472612458565b815260209081018490526000838152600d82526040902082518155910151600191820155600c546124a89163ffffffff6123d816565b600c5560408051838152905182917fbcd200f406c53d9438c6cdc2966a1e99c35f336588c95bc3639e539df21c2f53919081900360200190a25050565b3390565b6000828152602081905260409020612507908263ffffffff61243216565b156109b2576125146124e5565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000612562612458565b90508082106125715781612573565b805b600381905560408051918252517f68b095021b1f40fe513109f513c66692f0b3219aee674a69f4efc57badb8201d9181900360200190a15050565b60008281526020819052604090206125cc908263ffffffff612de116565b156109b2576125d96124e5565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b61262561333e565b6001600160a01b0383166000908152600f6020908152604080832060109092528220919060028101825b815481101561278c57612660613358565b82828154811061266c57fe5b600091825260209182902060408051808201825260039093029091018054835281518083019092526001810154825260020154818401529181019190915280519091508810156126bf5750600101612787565b60208101515187516126d69163ffffffff6123d816565b8752602080820151810151908801516126f49163ffffffff6123d816565b60208801528254600019018281146127555783818154811061271257fe5b906000526020600020906003020184848154811061272c57fe5b600091825260209091208254600390920201908155600180830154908201556002918201549101555b8380548061275f57fe5b6000828152602081206003600019909301928302018181556001810182905560020155905550505b61264f565b5080546127c6576001600160a01b0387166000908152600f6020526040812081815560018101829055906127c36002830182613377565b50505b84511515806127d85750602085015115155b92508215612872578451602080870151604080519384529183015280516001600160a01b038a16927fa219ed960eef85ed4cd072d3a9f240ea94727c0d6fb15e9a91a8cd4bf18ee3a692908290030190a261283a60098663ffffffff612ce716565b80541561285157612851828663ffffffff612ce716565b61286260078663ffffffff612c5916565b612872848663ffffffff612c5916565b50509250925092565b61288361333e565b818360010154106128b45760018301546128a3908363ffffffff612c9316565b600184015560208101829052611a36565b60018301546128ca90839063ffffffff612c9316565b80825283546128de9163ffffffff612c9316565b8355600190920180546020840152600090555090565b801561091a5781602001516005541015612955576040805162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f7567682066756e647320696e207265776172647320706f6f6c604482015290519081900360640190fd5b6001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156129ab57600080fd5b505af11580156129bf573d6000803e3d6000fd5b505050506040513d60208110156129d557600080fd5b5051612a1a576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6020820151600554612a319163ffffffff612c9316565b6005558151600654612a489163ffffffff612c9316565b600655612a5c60078363ffffffff612ce716565b81516020808401516040805193845291830152805133927ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56892908290030190a2505050565b6001600160a01b0382166000908152600e6020526040812090612ac660028301612c1a565b90508015612ba557815460018301545b600c54811015612b87576000818152600d602052604090208054831015612b44576040805162461bcd60e51b815260206004820152601860248201527f73696e6365426c6f636b20696e636f6e73697374656e63790000000000000000604482015290519081900360640190fd5b600c5486906001840190811015612b67576000818152600d602052604090205491505b612b78868460010154878503612df6565b95509093505050600101612ad6565b506002830154612b9e90839063ffffffff612c9316565b6003840155505b828255600c54612bb6576000612bbd565b6001600c54035b600183018190556002830154600384015460408051928352602083019190915280516001600160a01b038816927f6b6b43cdaf8f2ae06bdc6f6be433bb374b703ce8c88db4adce9dd8aefe44fe6d92908290030190a35092915050565b60018101548154600091611a36919063ffffffff6123d816565b612c3c61333e565b612c46848361287b565b9050612c528382612c59565b9392505050565b80518254612c6c9163ffffffff6123d816565b825560208101516001830154612c879163ffffffff6123d816565b82600101819055505050565b6000611a3383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e36565b612cdd61333e565b612c468483612ecd565b80518254612cfa9163ffffffff612c9316565b825560208101516001830154612c879163ffffffff612c9316565b6000611a338383612f39565b6000611a33836001600160a01b038416612f9d565b6000611a3682612fb5565b6004805467ffffffffffffffff831667ffffffffffffffff19909116811790915560408051918252517f6b24ea7c7a8ce7fd2e6a6cb675dbabcd38a90f83ddd581c4435610ce90456e8f9181900360200190a150565b6000612da38383612f9d565b612dd957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611a36565b506000611a36565b6000611a33836001600160a01b038416612fb9565b6000612e2e612e28612e22612e0b600161307f565b612e1d87670de0b6b3a764000061309d565b6130d4565b84613108565b85613156565b949350505050565b60008184841115612ec55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e8a578181015183820152602001612e72565b50505050905090810190601f168015612eb75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b612ed561333e565b82548211612ef9578254612eef908363ffffffff612c9316565b8355818152611a36565b8254612f0c90839063ffffffff612c9316565b602082018190526001840154612f279163ffffffff612c9316565b60018401558254815260009092555090565b81546000908210612f7b5760405162461bcd60e51b81526004018080602001828103825260228152602001806133c76022913960400191505060405180910390fd5b826000018281548110612f8a57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156130755783546000198083019190810190600090879083908110612fec57fe5b906000526020600020015490508087600001848154811061300957fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061303957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611a36565b6000915050611a36565b6000677fffffffffffffff82111561309657600080fd5b5060401b90565b6000816130a957600080fd5b60006130b584846131be565b905060016001607f1b036001600160801b0382161115611a3357600080fd5b6000600f83810b9083900b0160016001607f1b031981128015906130ff575060016001607f1b038113155b611a3357600080fd5b6000613114600161307f565b90505b8115611a3657600182161561313d576131308184613308565b9050600182039150613151565b6131478384613308565b9250600182901c91505b613117565b60008161316557506000611a36565b600083600f0b121561317657600080fd5b600f83900b6001600160801b038316810260401c90608084901c026001600160c01b038111156131a557600080fd5b60401b81198111156131b657600080fd5b019392505050565b6000816131ca57600080fd5b60006001600160c01b0384116131ef5782604085901b816131e757fe5b0490506132f4565b60c084811c6401000000008110613208576020918201911c5b62010000811061321a576010918201911c5b610100811061322b576008918201911c5b6010811061323b576004918201911c5b6004811061324b576002918201911c5b6002811061325a576001820191505b60bf820360018603901c6001018260ff0387901b8161327557fe5b0492506001600160801b0383111561328c57600080fd5b608085901c83026001600160801b038616840260c088901c604089901b828110156132b8576001820391505b608084901b929003828110156132cf576001820391505b829003608084901c82146132df57fe5b8881816132e857fe5b04870196505050505050505b6001600160801b03811115611a3357600080fd5b6000600f83810b9083900b0260401d60016001607f1b031981128015906130ff575060016001607f1b03811315611a3357600080fd5b604051806040016040528060008152602001600081525090565b60405180604001604052806000815260200161337261333e565b905290565b5080546000825560030290600052602060002090810190613398919061339b565b50565b61084891905b808211156133c25760008082556001820181905560028201556003016133a1565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7443616c6c6572206973206e656974686572206f776e6572206e6f722064656c6567617465416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b655472616e73616374696f6e2065787069726564000000000000000000000000005bfe1e16d75ca1fa001989652cd88c5b8ee8a59b5df6df99836337def4d1c82d436f6e747261637420686173206265656e207061757365640000000000000000416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212205436678265352631f897e2cef39869cf23c267c4a2f500784a8480a5ff10f77664736f6c63430006080033
Verified Source Code Partial Match
Compiler: v0.6.8+commit.0bbfe453
EVM: istanbul
Optimization: Yes (200 runs)
Staking.sol 2663 lines
// SPDX-License-Identifier: (Apache-2.0 AND MIT AND BSD-4-Clause)
//------------------------------------------------------------------------------
//
// Copyright 2020 Fetch.AI Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
pragma solidity ^0.6.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);
}
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/*
* @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;
}
}
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
}
//------------------------------------------------------------------------------
//
// Copyright 2020 Fetch.AI Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
/*
* ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.
* Author: Mikhail Vladimirov <[email protected]>
*/
/**
* Smart contract library of mathematical functions operating with signed
* 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is
* basically a simple fraction whose numerator is signed 128-bit integer and
* denominator is 2^64. As long as denominator is always the same, there is no
* need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
* represented by int128 type holding only the numerator.
*/
library ABDKMath64x64 {
/*
* Minimum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;
/*
* Maximum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
/**
* Convert signed 256-bit integer number into signed 64.64-bit fixed point
* number. Revert on overflow.
*
* @param x signed 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function fromInt (int256 x) internal pure returns (int128) {
require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
return int128 (x << 64);
}
/**
* Convert signed 64.64 fixed point number into signed 64-bit integer number
* rounding down.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64-bit integer number
*/
function toInt (int128 x) internal pure returns (int64) {
return int64 (x >> 64);
}
/**
* Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
* number. Revert on overflow.
*
* @param x unsigned 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function fromUInt (uint256 x) internal pure returns (int128) {
require (x <= 0x7FFFFFFFFFFFFFFF);
return int128 (x << 64);
}
/**
* Convert signed 64.64 fixed point number into unsigned 64-bit integer
* number rounding down. Revert on underflow.
*
* @param x signed 64.64-bit fixed point number
* @return unsigned 64-bit integer number
*/
function toUInt (int128 x) internal pure returns (uint64) {
require (x >= 0);
return uint64 (x >> 64);
}
/**
* Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
* number rounding down. Revert on overflow.
*
* @param x signed 128.128-bin fixed point number
* @return signed 64.64-bit fixed point number
*/
function from128x128 (int256 x) internal pure returns (int128) {
int256 result = x >> 64;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Convert signed 64.64 fixed point number into signed 128.128 fixed point
* number.
*
* @param x signed 64.64-bit fixed point number
* @return signed 128.128 fixed point number
*/
function to128x128 (int128 x) internal pure returns (int256) {
return int256 (x) << 64;
}
/**
* Calculate x + y. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function add (int128 x, int128 y) internal pure returns (int128) {
int256 result = int256(x) + y;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Calculate x - y. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function sub (int128 x, int128 y) internal pure returns (int128) {
int256 result = int256(x) - y;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Calculate x * y rounding down. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function mul (int128 x, int128 y) internal pure returns (int128) {
int256 result = int256(x) * y >> 64;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
* number and y is signed 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64 fixed point number
* @param y signed 256-bit integer number
* @return signed 256-bit integer number
*/
function muli (int128 x, int256 y) internal pure returns (int256) {
if (x == MIN_64x64) {
require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
y <= 0x1000000000000000000000000000000000000000000000000);
return -y << 63;
} else {
bool negativeResult = false;
if (x < 0) {
x = -x;
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint256 absoluteResult = mulu (x, uint256 (y));
if (negativeResult) {
require (absoluteResult <=
0x8000000000000000000000000000000000000000000000000000000000000000);
return -int256 (absoluteResult); // We rely on overflow behavior here
} else {
require (absoluteResult <=
0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int256 (absoluteResult);
}
}
}
/**
* Calculate x * y rounding down, where x is signed 64.64 fixed point number
* and y is unsigned 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64 fixed point number
* @param y unsigned 256-bit integer number
* @return unsigned 256-bit integer number
*/
function mulu (int128 x, uint256 y) internal pure returns (uint256) {
if (y == 0) return 0;
require (x >= 0);
uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256 (x) * (y >> 128);
require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require (hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
return hi + lo;
}
/**
* Calculate x / y rounding towards zero. Revert on overflow or when y is
* zero.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function div (int128 x, int128 y) internal pure returns (int128) {
require (y != 0);
int256 result = (int256 (x) << 64) / y;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Calculate x / y rounding towards zero, where x and y are signed 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x signed 256-bit integer number
* @param y signed 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function divi (int256 x, int256 y) internal pure returns (int128) {
require (y != 0);
bool negativeResult = false;
if (x < 0) {
x = -x; // We rely on overflow behavior here
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
if (negativeResult) {
require (absoluteResult <= 0x80000000000000000000000000000000);
return -int128 (absoluteResult); // We rely on overflow behavior here
} else {
require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int128 (absoluteResult); // We rely on overflow behavior here
}
}
/**
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x unsigned 256-bit integer number
* @param y unsigned 256-bit integer number
* @return signed 64.64-bit fixed point number
*/
function divu (uint256 x, uint256 y) internal pure returns (int128) {
require (y != 0);
uint128 result = divuu (x, y);
require (result <= uint128 (MAX_64x64));
return int128 (result);
}
/**
* Calculate -x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function neg (int128 x) internal pure returns (int128) {
require (x != MIN_64x64);
return -x;
}
/**
* Calculate |x|. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function abs (int128 x) internal pure returns (int128) {
require (x != MIN_64x64);
return x < 0 ? -x : x;
}
/**
* Calculate 1 / x rounding towards zero. Revert on overflow or when x is
* zero.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function inv (int128 x) internal pure returns (int128) {
require (x != 0);
int256 result = int256 (0x100000000000000000000000000000000) / x;
require (result >= MIN_64x64 && result <= MAX_64x64);
return int128 (result);
}
/**
* Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function avg (int128 x, int128 y) internal pure returns (int128) {
return int128 ((int256 (x) + int256 (y)) >> 1);
}
/**
* Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
* Revert on overflow or in case x * y is negative.
*
* @param x signed 64.64-bit fixed point number
* @param y signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function gavg (int128 x, int128 y) internal pure returns (int128) {
int256 m = int256 (x) * int256 (y);
require (m >= 0);
require (m <
0x4000000000000000000000000000000000000000000000000000000000000000);
return int128 (sqrtu (uint256 (m)));
}
/**
* Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
* and y is unsigned 256-bit integer number. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @param y uint256 value
* @return signed 64.64-bit fixed point number
*/
function pow (int128 x, uint256 y) internal pure returns (int128) {
uint256 absoluteResult;
bool negativeResult = false;
if (x >= 0) {
absoluteResult = powu (uint256 (x) << 63, y);
} else {
// We rely on overflow behavior here
absoluteResult = powu (uint256 (uint128 (-x)) << 63, y);
negativeResult = y & 1 > 0;
}
absoluteResult >>= 63;
if (negativeResult) {
require (absoluteResult <= 0x80000000000000000000000000000000);
return -int128 (absoluteResult); // We rely on overflow behavior here
} else {
require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return int128 (absoluteResult); // We rely on overflow behavior here
}
}
/**
* Calculate sqrt (x) rounding down. Revert if x < 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function sqrt (int128 x) internal pure returns (int128) {
require (x >= 0);
return int128 (sqrtu (uint256 (x) << 64));
}
/**
* Calculate binary logarithm of x. Revert if x <= 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function log_2 (int128 x) internal pure returns (int128) {
require (x > 0);
int256 msb = 0;
int256 xc = x;
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 result = msb - 64 << 64;
uint256 ux = uint256 (x) << uint256 (127 - msb);
for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
ux *= ux;
uint256 b = ux >> 255;
ux >>= 127 + b;
result += bit * int256 (b);
}
return int128 (result);
}
/**
* Calculate natural logarithm of x. Revert if x <= 0.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function ln (int128 x) internal pure returns (int128) {
require (x > 0);
return int128 (
uint256 (log_2 (x)) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128);
}
/**
* Calculate binary exponent of x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function exp_2 (int128 x) internal pure returns (int128) {
require (x < 0x400000000000000000); // Overflow
if (x < -0x400000000000000000) return 0; // Underflow
uint256 result = 0x80000000000000000000000000000000;
if (x & 0x8000000000000000 > 0)
result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;
if (x & 0x4000000000000000 > 0)
result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;
if (x & 0x2000000000000000 > 0)
result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;
if (x & 0x1000000000000000 > 0)
result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;
if (x & 0x800000000000000 > 0)
result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;
if (x & 0x400000000000000 > 0)
result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;
if (x & 0x200000000000000 > 0)
result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;
if (x & 0x100000000000000 > 0)
result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;
if (x & 0x80000000000000 > 0)
result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;
if (x & 0x40000000000000 > 0)
result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;
if (x & 0x20000000000000 > 0)
result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;
if (x & 0x10000000000000 > 0)
result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;
if (x & 0x8000000000000 > 0)
result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;
if (x & 0x4000000000000 > 0)
result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;
if (x & 0x2000000000000 > 0)
result = result * 0x1000162E525EE054754457D5995292026 >> 128;
if (x & 0x1000000000000 > 0)
result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;
if (x & 0x800000000000 > 0)
result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;
if (x & 0x400000000000 > 0)
result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;
if (x & 0x200000000000 > 0)
result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;
if (x & 0x100000000000 > 0)
result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;
if (x & 0x80000000000 > 0)
result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;
if (x & 0x40000000000 > 0)
result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;
if (x & 0x20000000000 > 0)
result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;
if (x & 0x10000000000 > 0)
result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;
if (x & 0x8000000000 > 0)
result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;
if (x & 0x4000000000 > 0)
result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;
if (x & 0x2000000000 > 0)
result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;
if (x & 0x1000000000 > 0)
result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;
if (x & 0x800000000 > 0)
result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;
if (x & 0x400000000 > 0)
result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;
if (x & 0x200000000 > 0)
result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;
if (x & 0x100000000 > 0)
result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;
if (x & 0x80000000 > 0)
result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;
if (x & 0x40000000 > 0)
result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;
if (x & 0x20000000 > 0)
result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;
if (x & 0x10000000 > 0)
result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;
if (x & 0x8000000 > 0)
result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;
if (x & 0x4000000 > 0)
result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;
if (x & 0x2000000 > 0)
result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;
if (x & 0x1000000 > 0)
result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;
if (x & 0x800000 > 0)
result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;
if (x & 0x400000 > 0)
result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;
if (x & 0x200000 > 0)
result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;
if (x & 0x100000 > 0)
result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;
if (x & 0x80000 > 0)
result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;
if (x & 0x40000 > 0)
result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;
if (x & 0x20000 > 0)
result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;
if (x & 0x10000 > 0)
result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;
if (x & 0x8000 > 0)
result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;
if (x & 0x4000 > 0)
result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;
if (x & 0x2000 > 0)
result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;
if (x & 0x1000 > 0)
result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;
if (x & 0x800 > 0)
result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;
if (x & 0x400 > 0)
result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;
if (x & 0x200 > 0)
result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;
if (x & 0x100 > 0)
result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;
if (x & 0x80 > 0)
result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;
if (x & 0x40 > 0)
result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;
if (x & 0x20 > 0)
result = result * 0x100000000000000162E42FEFA39EF366F >> 128;
if (x & 0x10 > 0)
result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;
if (x & 0x8 > 0)
result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;
if (x & 0x4 > 0)
result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;
if (x & 0x2 > 0)
result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;
if (x & 0x1 > 0)
result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;
result >>= uint256 (63 - (x >> 64));
require (result <= uint256 (MAX_64x64));
return int128 (result);
}
/**
* Calculate natural exponent of x. Revert on overflow.
*
* @param x signed 64.64-bit fixed point number
* @return signed 64.64-bit fixed point number
*/
function exp (int128 x) internal pure returns (int128) {
require (x < 0x400000000000000000); // Overflow
if (x < -0x400000000000000000) return 0; // Underflow
return exp_2 (
int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));
}
/**
* Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
* integer numbers. Revert on overflow or when y is zero.
*
* @param x unsigned 256-bit integer number
* @param y unsigned 256-bit integer number
* @return unsigned 64.64-bit fixed point number
*/
function divuu (uint256 x, uint256 y) private pure returns (uint128) {
require (y != 0);
uint256 result;
if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
result = (x << 64) / y;
else {
uint256 msb = 192;
uint256 xc = x >> 192;
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 hi = result * (y >> 128);
uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 xh = x >> 192;
uint256 xl = x << 64;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
lo = hi << 128;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
assert (xh == hi >> 128);
result += xl / y;
}
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return uint128 (result);
}
/**
* Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed point
* number and y is unsigned 256-bit integer number. Revert on overflow.
*
* @param x unsigned 129.127-bit fixed point number
* @param y uint256 value
* @return unsigned 129.127-bit fixed point number
*/
function powu (uint256 x, uint256 y) private pure returns (uint256) {
if (y == 0) return 0x80000000000000000000000000000000;
else if (x == 0) return 0;
else {
int256 msb = 0;
uint256 xc = x;
if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) ...
// [truncated — 100913 bytes total]
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
DELEGATE_ROLE 0xc0ba241b → bytes32
DELETE_PROTECTION_PERIOD 0x372646bb → uint256
_accruedGlobalLiquidity 0xc8984ab2 → uint256, uint256
_accruedGlobalLocked 0xd9b202c9 → uint256, uint256
_accruedGlobalPrincipal 0x292911fb → uint256
_earliestDelete 0x32a1bd70 → uint256
_interestRates 0xaa700ff2 → uint256, uint256
_interestRatesNextIdx 0x4164b001 → uint256
_interestRatesStartIdx 0xd9d8e783 → uint256
_liquidity 0x67ce50c0 → uint256, uint256
_lockPeriodInBlocks 0x2514c50a → uint64
_pausedSinceBlock 0xf1209ef7 → uint256
_rewardsPoolBalance 0x0c450f9d → uint256
_token 0xecd0c0c3 → address
getEarliestDeleteBlock 0x085313ec → uint256
getLockedAssetsAggregateForUser 0xa8f1b4c4 → uint256, uint256
getLockedAssetsForUser 0x5f208f34 → uint256[], uint256[], uint256[]
getNumberOfLockedAssetsForUser 0x40e97903 → uint256
getRewardsPoolBalance 0xadf55101 → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
getStakeForUser 0xc30f75cf → uint256, uint256, uint256, uint256
hasRole 0x91d14854 → bool
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
addInterestRate 0x13384039
uint256 rate
uint256 expirationBlock
bindStake 0x88cedd5e
uint256 amount
uint256 txExpirationBlock
deleteContract 0x9608df4b
address payoutAddress
uint256 txExpirationBlock
deposit 0xe2bbb158
uint256 amount
uint256 txExpirationBlock
grantRole 0x2f2ff15d
bytes32 role
address account
pauseSince 0x347908df
uint256 blockNumber
uint256 txExpirationBlock
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
topUpRewardsPool 0xba92a4c5
uint256 amount
uint256 txExpirationBlock
unbindStake 0x52885d8d
uint256 amount
uint256 txExpirationBlock
updateLockPeriod 0xf0895e52
uint64 numOfBlocks
uint256 txExpirationBlock
withdraw 0x441a3e70
uint256 amount
uint256 txExpirationBlock
withdrawCompoundInterest 0xd8cd3999
uint256 txExpirationBlock
withdrawExcessTokens 0x53e052ac
address targetAddress
uint256 txExpirationBlock
withdrawFromRewardsPool 0x68bccfcf
uint256 amount
address targetAddress
uint256 txExpirationBlock
withdrawPrincipal 0x658e28a4
uint256 txExpirationBlock
withdrawWholeLiquidity 0xdca2aa5c
uint256 txExpirationBlock
Recent Transactions
No transactions found for this address