Address Contract Verified
Address
0x5D2c0CC239B33ffC01337c90194ACaCd50c79088
Balance
0 ETH
Nonce
1
Code Size
10201 bytes
Creator
0xd0967161...255D at tx 0x3d166bdc...9c144d
Indexed Transactions
0
Contract Bytecode
10201 bytes
0x608060405234801561001057600080fd5b506004361061020b5760003560e01c80638da5cb5b1161012a578063c25cf1d0116100bd578063e43db1931161008c578063f2fde38b11610071578063f2fde38b146104c5578063f89dd240146104d8578063f8c8765e146104eb57600080fd5b8063e43db193146104ac578063e480f237146104b457600080fd5b8063c25cf1d01461043a578063c6f0e9131461044d578063dd62ed3e14610460578063df3a7f521461049957600080fd5b80639deb1d3a116100f95780639deb1d3a146103f0578063a12c4a6e14610403578063a457c2d714610414578063a9059cbb1461042757600080fd5b80638da5cb5b1461037757806395d89b411461039c578063999de89a146103a45780639d594398146103b757600080fd5b80634a0e091d116101a257806374de4ec41161017157806374de4ec41461034157806376289f38146103545780637628b9271461035c5780638467456b1461036f57600080fd5b80634a0e091d146102ea57806351cff8d9146102fd57806370a0823114610310578063715018a61461033957600080fd5b806323b872dd116101de57806323b872dd146102a0578063313ce567146102b357806339509351146102c257806347e7ef24146102d557600080fd5b806306fdde0314610210578063095ea7b31461022e57806314a4fbe31461025157806318160ddd14610298575b600080fd5b6102186104fe565b604051610225919061248e565b60405180910390f35b61024161023c3660046124f8565b610590565b6040519015158152602001610225565b61028a61025f366004612524565b6001600160a01b03918216600090815260a46020908152604080832093909416825291909152205490565b604051908152602001610225565b60675461028a565b6102416102ae36600461255d565b6105a8565b60405160128152602001610225565b6102416102d03660046124f8565b6105cc565b6102e86102e33660046124f8565b61060b565b005b6102e86102f836600461259e565b6109ae565b6102e861030b36600461259e565b610ba3565b61028a61031e36600461259e565b6001600160a01b031660009081526065602052604090205490565b6102e8610cb9565b6102e861034f3660046125c2565b610ccd565b60995461028a565b61028a61036a3660046125e9565b610e00565b609b5461028a565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610225565b610218610f14565b6102e86103b236600461259e565b610f23565b61028a6103c5366004612524565b6001600160a01b03918216600090815260a26020908152604080832093909416825291909152205490565b6102e86103fe36600461259e565b610f4d565b609c546001600160a01b0316610384565b6102416104223660046124f8565b610f77565b6102416104353660046124f8565b611021565b6102e86104483660046125c2565b61102f565b6102e861045b3660046125c2565b61103c565b61028a61046e366004612524565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b6102e86104a736600461259e565b611049565b60985461028a565b609f546001600160a01b0316610384565b6102e86104d336600461259e565b611073565b6102e86104e636600461259e565b611100565b6102e86104f9366004612634565b61112a565b60606068805461050d90612690565b80601f016020809104026020016040519081016040528092919081815260200182805461053990612690565b80156105865780601f1061055b57610100808354040283529160200191610586565b820191906000526020600020905b81548152906001019060200180831161056957829003601f168201915b5050505050905090565b60003361059e8185856113aa565b5060019392505050565b6000336105b6858285611502565b6105c1858585611594565b506001949350505050565b3360008181526066602090815260408083206001600160a01b038716845290915281205490919061059e90829086906106069087906126e0565b6113aa565b6106136115dc565b6001600160a01b038216600090815260a260209081526040808320338452909152902054156106af5760405162461bcd60e51b815260206004820152602d60248201527f425350545374616b696e673a20596f75206e65656420746f207472616e73666560448201527f72207374616b656420425350540000000000000000000000000000000000000060648201526084015b60405180910390fd5b609d546040517f2d07ebb70000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526000921690632d07ebb790602401602060405180830381865afa158015610713573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073791906126f8565b905060008111801561075a57506000610758670de0b6b3a764000083612711565b115b6107a65760405162461bcd60e51b815260206004820152601e60248201527f425350545374616b696e673a20496e76616c69642076616c756174696f6e000060448201526064016106a6565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156107ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081191906126f8565b90506001600160a01b0384166323b872dd336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152306024820152604481018690526064016020604051808303816000875af1158015610876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089a9190612733565b61090c5760405162461bcd60e51b815260206004820152602360248201527f425350545374616b696e673a20436f756c646e2774207472616e73666572204260448201527f535054000000000000000000000000000000000000000000000000000000000060648201526084016106a6565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015610953573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097791906126f8565b90506000610990863361098a8686612750565b87611635565b905061099c3382611838565b505050506109aa6001609755565b5050565b6109b66115dc565b60006109c4823360006118f9565b9050600033609c5460405163095ea7b360e01b81526001600160a01b0391821660048201526024810185905291925084169063095ea7b3906044016020604051808303816000875af1158015610a1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a429190612733565b610a9f5760405162461bcd60e51b815260206004820152602860248201527f425350545374616b696e673a20436f756c646e277420617070726f7665206f6360448201526719585b9c1bda5b9d60c21b60648201526084016106a6565b609c546040517fba152c4b0000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301528381166024830152604482018590529091169063ba152c4b906064016020604051808303816000875af1158015610b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b379190612733565b610b945760405162461bcd60e51b815260206004820152602860248201527f425350545374616b696e673a20436f756c646e27742073656c6c20746f206f6360448201526719585b9c1bda5b9d60c21b60648201526084016106a6565b5050610ba06001609755565b50565b610bab6115dc565b6000610bb9823360016118f9565b90506001600160a01b03821663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015610c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3c9190612733565b610cae5760405162461bcd60e51b815260206004820152603160248201527f425350545374616b696e673a20436f756c646e2774207472616e73666572204260448201527f535054206f6e207769746864726177616c00000000000000000000000000000060648201526084016106a6565b50610ba06001609755565b610cc1611f73565b610ccb6000611fcd565b565b610cd56115dc565b60a0546001600160a01b03166323b872dd336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152306024820152604481018490526064016020604051808303816000875af1158015610d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5e9190612733565b610daa5760405162461bcd60e51b815260206004820181905260248201527f425350545374616b696e673a20436f756c646e2774206164642072657761726460448201526064016106a6565b80609a6000828254610dbc91906126e0565b909155505060405181815233907f619caafabdd75649b302ba8419e48cccf64f37f1983ac4727cfb38b57703ffc99060200160405180910390a2610ba06001609755565b600080610e0c60675490565b610e1990620186a0612767565b609a546001600160a01b03808716600090815260a460209081526040808320938b1683529290522054610e4c9190612767565b610e58906103e8612767565b610e629190612711565b610e6d906064612767565b6001600160a01b03808616600090815260a360209081526040808320938a1683529290522054909150811115610ed4576001600160a01b03808516600090815260a36020908152604080832093891683529290522054610ecd9082612750565b9150610ed9565b600091505b8215610f0c57600061271060995484610ef29190612767565b610efc9190612711565b9050610f088184612750565b9250505b509392505050565b60606069805461050d90612690565b610f2b611f73565b609f80546001600160a01b0319166001600160a01b0392909216919091179055565b610f55611f73565b609e80546001600160a01b0319166001600160a01b0392909216919091179055565b3360008181526066602090815260408083206001600160a01b0387168452909152812054909190838110156110145760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016106a6565b6105c182868684036113aa565b60003361059e818585611594565b611037611f73565b609855565b611044611f73565b609955565b611051611f73565b609c80546001600160a01b0319166001600160a01b0392909216919091179055565b61107b611f73565b6001600160a01b0381166110f75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106a6565b610ba081611fcd565b611108611f73565b609d80546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff161580801561114a5750600054600160ff909116105b806111645750303b158015611164575060005460ff166001145b6111d65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016106a6565b6000805460ff1916600117905580156111f9576000805461ff0019166101001790555b6001600160a01b0385161580159061121957506001600160a01b03841615155b801561122d57506001600160a01b03831615155b801561124157506001600160a01b03821615155b61128d5760405162461bcd60e51b815260206004820152601c60248201527f425350545374616b696e673a204164647265737320697a207a65726f0000000060448201526064016106a6565b60a080546001600160a01b0319166001600160a01b0387161790556112b182611fcd565b6113256040518060400160405280601981526020017f73426c6f636b73717561726550726f7065727479546f6b656e000000000000008152506040518060400160405280600581526020017f734253505400000000000000000000000000000000000000000000000000000081525061201f565b61132e84611100565b61133783610f4d565b61134362ed4e0061102f565b61134e6103e861103c565b8015611394576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6001600160a01b03163b151590565b6001600160a01b0383166114255760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106a6565b6001600160a01b0382166114a15760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016106a6565b6001600160a01b0383811660008181526066602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03838116600090815260666020908152604080832093861683529290522054600019811461158e57818110156115815760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016106a6565b61158e84848484036113aa565b50505050565b60405162461bcd60e51b815260206004820152601960248201527f7342535054206973206e6f6e207472616e7366657261626c650000000000000060448201526064016106a6565b60026097540361162e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106a6565b6002609755565b60006098544261164591906126e0565b6001600160a01b03808716600090815260a160209081526040808320938916835292905290812091909155611685670de0b6b3a7640000620186a0612767565b61168f8486612767565b6116999190612711565b609a5490915060006116aa60675490565b90508015806116b7575081155b6116d557816116c68285612767565b6116d09190612711565b6116d7565b825b6001600160a01b03808a16600090815260a260209081526040808320938c168352929052908120805492965088929091906117139084906126e0565b9250508190555082609a600082825461172c91906126e0565b9250508190555082609b600082825461174591906126e0565b90915550506001600160a01b03808916600090815260a360209081526040808320938b16835292905290812080548592906117819084906126e0565b90915550506001600160a01b03808916600090815260a460209081526040808320938b16835292905290812080548692906117bd9084906126e0565b90915550506001600160a01b03888116600081815260a160209081526040808320948c16808452948252918290205482519384529083018a90528282018890526060830152517f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f69181900360800190a2505050949350505050565b6001600160a01b03821661188e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106a6565b80606760008282546118a091906126e0565b90915550506001600160a01b0382166000818152606560209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038316600090815260a16020908152604080832033845290915281205442116119915760405162461bcd60e51b815260206004820152603660248201527f425350545374616b696e673a20596f75206e65656420746f207761697420666f60448201527f722074696d65206c6f636b20746f206578706972652e0000000000000000000060648201526084016106a6565b6001600160a01b03808516600090815260a46020908152604080832093871683529290522054611a295760405162461bcd60e51b815260206004820152603660248201527f425350545374616b696e673a20596f75206e65656420746f207374616b65204260448201527f53505420666f7220746869732070726f70657274792e0000000000000000000060648201526084016106a6565b600080611a368633612099565b91509150600061271060995484611a4d9190612767565b611a579190612711565b9050611a638184612750565b609f549093506001600160a01b031615611c715760a054609f5460405163095ea7b360e01b81526001600160a01b0391821660048201526024810186905291169063095ea7b3906044016020604051808303816000875af1158015611acc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af09190612733565b611b625760405162461bcd60e51b815260206004820152602960248201527f425350545374616b696e673a20436f756c646e277420617070726f766520666f60448201527f722076657374696e67000000000000000000000000000000000000000000000060648201526084016106a6565b609f546040517fcd05bc390000000000000000000000000000000000000000000000000000000081526001600160a01b0389811660048301528881166024830152604482018690529091169063cd05bc39906064016020604051808303816000875af1158015611bd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfa9190612733565b611c6c5760405162461bcd60e51b815260206004820152602160248201527f425350545374616b696e673a20436f756c646e2774206164642076657374696e60448201527f670000000000000000000000000000000000000000000000000000000000000060648201526084016106a6565b611d73565b60a0546040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af1158015611cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d019190612733565b611d735760405162461bcd60e51b815260206004820152602560248201527f425350545374616b696e673a20436f756c646e2774207472616e73666572207260448201527f657761726400000000000000000000000000000000000000000000000000000060648201526084016106a6565b60a054609e546040517fc1cf7c0e0000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301529283169263a9059cbb92169063c1cf7c0e90602401602060405180830381865afa158015611de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e059190612786565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015611e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e769190612733565b611ee85760405162461bcd60e51b815260206004820152602960248201527f425350545374616b696e673a20436f756c646e2774207472616e73666572206660448201527f656520726577617264000000000000000000000000000000000000000000000060648201526084016106a6565b6001600160a01b038716600081815260a2602090815260408083203380855290835281842080549490558151948552918401869052838101839052606084018790526080840185905288151560a085015251919650917fc40965a887728c5326c636b27c49965a1bce6541786ae6573d38275acfb8832d919081900360c00190a25050509392505050565b6033546001600160a01b03163314610ccb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106a6565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661208a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106a6565b6109aa82826121f8565b505050565b609a546000908190816120ab60675490565b6001600160a01b03878116600090815260a460209081526040808320938a16835292905290812080549082905594509091506120ea82620186a0612767565b6120f48486612767565b612100906103e8612767565b61210a9190612711565b612115906064612767565b9050612121868561228a565b6001600160a01b03808816600090815260a360209081526040808320938a1683529290522054811115612185576001600160a01b03808816600090815260a360209081526040808320938a168352929052205461217e9082612750565b945061218a565b600094505b6001600160a01b03808816600090815260a360209081526040808320938a168352929052908120819055609a80548392906121c6908490612750565b909155506121d690508582612750565b609b60008282546121e79190612750565b925050819055505050509250929050565b600054610100900460ff166122635760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106a6565b81516122769060689060208501906123f5565b5080516120949060699060208401906123f5565b6001600160a01b0382166123065760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016106a6565b6001600160a01b038216600090815260656020526040902054818110156123955760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016106a6565b6001600160a01b03831660008181526065602090815260408083208686039055606780548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b82805461240190612690565b90600052602060002090601f0160209004810192826124235760008555612469565b82601f1061243c57805160ff1916838001178555612469565b82800160010185558215612469579182015b8281111561246957825182559160200191906001019061244e565b50612475929150612479565b5090565b5b80821115612475576000815560010161247a565b600060208083528351808285015260005b818110156124bb5785810183015185820160400152820161249f565b818111156124cd576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114610ba057600080fd5b6000806040838503121561250b57600080fd5b8235612516816124e3565b946020939093013593505050565b6000806040838503121561253757600080fd5b8235612542816124e3565b91506020830135612552816124e3565b809150509250929050565b60008060006060848603121561257257600080fd5b833561257d816124e3565b9250602084013561258d816124e3565b929592945050506040919091013590565b6000602082840312156125b057600080fd5b81356125bb816124e3565b9392505050565b6000602082840312156125d457600080fd5b5035919050565b8015158114610ba057600080fd5b6000806000606084860312156125fe57600080fd5b8335612609816124e3565b92506020840135612619816124e3565b91506040840135612629816125db565b809150509250925092565b6000806000806080858703121561264a57600080fd5b8435612655816124e3565b93506020850135612665816124e3565b92506040850135612675816124e3565b91506060850135612685816124e3565b939692955090935050565b600181811c908216806126a457607f821691505b6020821081036126c457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156126f3576126f36126ca565b500190565b60006020828403121561270a57600080fd5b5051919050565b60008261272e57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561274557600080fd5b81516125bb816125db565b600082821015612762576127626126ca565b500390565b6000816000190483118215151615612781576127816126ca565b500290565b60006020828403121561279857600080fd5b81516125bb816124e356fea26469706673582212205a360370f9a4405b1762e64f7dffee6f1b127089859650722bbbcad53ac97ba864736f6c634300080e0033
Verified Source Code Full Match
Compiler: v0.8.14+commit.80d49f37
EVM: london
Optimization: Yes (1000 runs)
BSPTStaking.sol 470 lines
/*
* SPDX-License-Identifier: UNLICENSED
* Copyright © 2022 Blocksquare d.o.o.
*/
pragma solidity 0.8.14;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
/// @notice A collection of helper functions
interface BSPTStakingHelpers {
function mint(address to, uint256 amount) external;
function owner() external view returns (address);
function getPropertyValuation(address property)
external
view
returns (uint256);
function getCPOfProperty(address prop) external view returns (address);
function sellBSPT(
address property,
address user,
uint256 stakedBSPT
) external returns (bool);
function addVestingInfo(
address property,
address user,
uint256 amount
) external returns (bool);
}
/// @title Blocksquare Property Token Staking
/// @author David Šenica
/// @notice Allows to stake different BSPT
contract BSPTStaking is OwnableUpgradeable, ERC20Upgradeable, ReentrancyGuard {
string private constant _NAME = "sBlocksquarePropertyToken";
string private constant _SYMBOL = "sBSPT";
uint256 private constant _EIGHTEEN_DECIMALS = 10**18;
uint256 private constant _BSPT_TOTAL_SUPPLY = _EIGHTEEN_DECIMALS * 100_000;
uint256 private _lockPeriod;
uint256 private _fee;
uint256 private _tbsptBalanceThis;
uint256 private _totalValuation;
address private _oceanPoint;
address private _propertyRegistry;
address private _dataProxy;
address private _rewardVesting;
IERC20 private _rewardToken;
mapping(address => mapping(address => uint256)) private _lockedUntil;
mapping(address => mapping(address => uint256)) private _bsptStaked;
mapping(address => mapping(address => uint256)) private _tBSPT;
mapping(address => mapping(address => uint256)) private _sBSPT;
/// @notice Event triggers every time a deposit is made
/// @param owner Address of user wallet
/// @param property BSPT address
/// @param inAmount Amount of BSPT staked
/// @param outAmount Amount of staked BSPT returned (your share in the pool)
/// @param lockedUntil Timestamp when withdrawal can be made
event Deposit(
address indexed owner,
address property,
uint256 inAmount,
uint256 outAmount,
uint256 lockedUntil
);
/// @notice Event triggers every time a withdrawal is made
/// @param owner Address of user wallet
/// @param property BSPT address
/// @param inAmount Amount of staked BSPT
/// @param outAmount Amount of BSPT returned
/// @param rewardToUser Amount of BST user got as reward
/// @param rewardToFeeReciever Amount of BST received by certified partner as fee
/// @param isWithdraw Whether user withdrew BSPT or sold them to oceanpoint contract
event Withdraw(
address indexed owner,
address property,
uint256 inAmount,
uint256 outAmount,
uint256 rewardToUser,
uint256 rewardToFeeReciever,
bool isWithdraw
);
/// @notice Event triggers every time a reward is added
/// @param from Address of user who added reward
/// @param amount Amount of BST added as reward
event Reward(address indexed from, uint256 amount);
/// @dev Initialize contract params with `initialize` function behind a proxy
constructor() initializer {
// Only interact with this contract through proxy
}
/// @notice Initialize contract. Can only be called once
/// @param rewardToken Address of reward token (BST token)
/// @param propertyRegistry Address of smart contract where properties that can be staked are stored
/// @param dataProxy Address of smart contract where information about certified partner is held
/// @param owner Address of owner of this contract
function initialize(
address rewardToken,
address propertyRegistry,
address dataProxy,
address owner
) external initializer {
require(
rewardToken != address(0) &&
propertyRegistry != address(0) &&
dataProxy != address(0) &&
owner != address(0),
"BSPTStaking: Address iz zero"
);
_rewardToken = IERC20(rewardToken);
_transferOwnership(owner);
__ERC20_init(_NAME, _SYMBOL);
changePropertyRegistry(propertyRegistry);
changeDataProxy(dataProxy);
changeLockPeriod(60 * 60 * 24 * 30 * 6);
changeRewardFee(1000);
// 10 %
}
/// @notice Calculates sBSPT based on different BSPT already in contract and reward
/// @dev Each BSPT has different weight based on its evaluation,
/// meaning different BSPT (when depositing same amount of BSPT) will yield different amount of sBSPT
/// Each BSPT is fixed at 100000 supply
/// @param property Address of property token
/// @param user Address of user, making deposit
/// @param amount Amount of property tokens being deposited
/// @param propertyValuation Evaluation of property
/// @return amountsbsptToMint Amount of sBSPT depositor should receive
function _updateBeforeStakeStart(
address property,
address user,
uint256 amount,
uint256 propertyValuation
) private returns (uint256 amountsbsptToMint) {
_lockedUntil[property][user] = block.timestamp + _lockPeriod;
uint256 tempBSPTAmount = (amount * propertyValuation) /
_BSPT_TOTAL_SUPPLY;
uint256 tempBSPTBalance = _tbsptBalanceThis;
uint256 sbsptSupply = totalSupply();
amountsbsptToMint = (sbsptSupply == 0 || tempBSPTBalance == 0)
? tempBSPTAmount
: (tempBSPTAmount * sbsptSupply) / tempBSPTBalance;
_bsptStaked[property][user] += amount;
_tbsptBalanceThis += tempBSPTAmount;
_totalValuation += tempBSPTAmount;
_tBSPT[property][user] += tempBSPTAmount;
_sBSPT[property][user] += amountsbsptToMint;
emit Deposit(
user,
property,
amount,
amountsbsptToMint,
_lockedUntil[property][user]
);
}
/// @notice Calculates reward and BSPT user should get
/// @param property Address of property
/// @param user Address of user
/// @return reward Amount of reward
/// @return share Amount of sBSPT user should get
function _updateAtStakeEnd(address property, address user)
private
returns (uint256 reward, uint256 share)
{
uint256 tempBSPTBalance = _tbsptBalanceThis;
uint256 sbsptSupply = totalSupply();
share = _sBSPT[property][user];
_sBSPT[property][user] = 0;
uint256 tempBSPTToReturn = ((share * tempBSPTBalance * 1000) /
(sbsptSupply * 100000)) * 100;
// This fixes some small rounding errors
_burn(user, share);
if(tempBSPTToReturn > _tBSPT[property][user]) {
reward = tempBSPTToReturn - _tBSPT[property][user];
} else {
reward = 0;
}
_tBSPT[property][user] = 0;
_tbsptBalanceThis -= tempBSPTToReturn;
_totalValuation -= (tempBSPTToReturn - reward);
}
/// @notice Deposit BSPT for staking
/// @dev Only one combination wallet-property can be staked, this means that
/// stake amount cannot increase for that combination and withdrawal needs to be done before depositing again
/// There is a fee on transferring BSPT so the `amount` deposited is bigger then the staking amount
/// @param property Address of property
/// @param amount Amount of BSPT to stake
function deposit(address property, uint256 amount) external nonReentrant {
require(
_bsptStaked[property][_msgSender()] == 0,
"BSPTStaking: You need to transfer staked BSPT"
);
// This should ensure only BSPT in our system can be used for staking
uint256 propertyValuation = BSPTStakingHelpers(_propertyRegistry)
.getPropertyValuation(property);
require(
propertyValuation > 0 && propertyValuation / _EIGHTEEN_DECIMALS > 0,
"BSPTStaking: Invalid valuation"
);
// If normal user transfers then the 1.5% fee on BSPT applies
// meaning less then amount of BSPT comes into this contract
uint256 balanceBeforeTransfer = IERC20(property).balanceOf(
address(this)
);
require(
IERC20(property).transferFrom(_msgSender(), address(this), amount),
"BSPTStaking: Couldn't transfer BSPT"
);
uint256 balanceAfterTransfer = IERC20(property).balanceOf(
address(this)
);
uint256 amountToMint = _updateBeforeStakeStart(
property,
_msgSender(),
balanceAfterTransfer - balanceBeforeTransfer,
propertyValuation
);
_mint(_msgSender(), amountToMint);
}
/// @notice Called when withdrawing BSPT or selling them to oceanpoint
/// @dev Handles withdraw and selling to oceanpoint in one function
/// @param property Address of property
/// @param user Address user
/// @param isWithdraw True if user is withdrawing and false if user is selling to oceanpoint
/// @return stakedBSPT Amount of staked BSPT that should be returned or sold
function _withdraw(
address property,
address user,
bool isWithdraw
) private returns (uint256 stakedBSPT) {
require(
_lockedUntil[property][_msgSender()] < block.timestamp,
"BSPTStaking: You need to wait for time lock to expire."
);
require(
_sBSPT[property][user] > 0,
"BSPTStaking: You need to stake BSPT for this property."
);
(uint256 reward, uint256 share) = _updateAtStakeEnd(
property,
_msgSender()
);
uint256 feeReward = (reward * _fee) / 10000;
reward -= feeReward;
if (_rewardVesting != address(0)) {
require(
_rewardToken.approve(_rewardVesting, reward),
"BSPTStaking: Couldn't approve for vesting"
);
require(
BSPTStakingHelpers(_rewardVesting).addVestingInfo(
property,
user,
reward
),
"BSPTStaking: Couldn't add vesting"
);
} else {
require(
_rewardToken.transfer(user, reward),
"BSPTStaking: Couldn't transfer reward"
);
}
require(
_rewardToken.transfer(
BSPTStakingHelpers(_dataProxy).getCPOfProperty(property),
feeReward
),
"BSPTStaking: Couldn't transfer fee reward"
);
stakedBSPT = _bsptStaked[property][_msgSender()];
_bsptStaked[property][_msgSender()] = 0;
emit Withdraw(
_msgSender(),
property,
share,
stakedBSPT,
reward,
feeReward,
isWithdraw
);
}
/// @notice It withdraws all BSPT for given property
/// @param property Address of property
function withdraw(address property) external nonReentrant {
uint256 stakedBSPT = _withdraw(property, _msgSender(), true);
require(
IERC20(property).transfer(_msgSender(), stakedBSPT),
"BSPTStaking: Couldn't transfer BSPT on withdrawal"
);
}
/// @notice It sells all BSPT for given property to oceanpoint contract
/// @param property Address of property
function sellBSPTToOceanPoint(address property) external nonReentrant {
uint256 stakedBSPT = _withdraw(property, _msgSender(), false);
address user = _msgSender();
require(
IERC20(property).approve(_oceanPoint, stakedBSPT),
"BSPTStaking: Couldn't approve oceanpoint"
);
require(
BSPTStakingHelpers(_oceanPoint).sellBSPT(
property,
user,
stakedBSPT
),
"BSPTStaking: Couldn't sell to oceanpoint"
);
}
/// @notice Adds `amount` reward
/// @param amount Amount of reward
function addReward(uint256 amount) external nonReentrant {
require(
_rewardToken.transferFrom(_msgSender(), address(this), amount),
"BSPTStaking: Couldn't add reward"
);
_tbsptBalanceThis += amount;
emit Reward(_msgSender(), amount);
}
// @dev Don't allow the transfer of sBSPT (sBPST token is only used for tracking share)
function _transfer(
address from,
address to,
uint256 amount
) internal override {
revert("sBSPT is non transferable");
}
/// @notice Change the duration before user can withdraw deposited tokens
/// @param newPeriod Duration in seconds
function changeLockPeriod(uint256 newPeriod) public onlyOwner {
_lockPeriod = newPeriod;
}
/// @notice Change percentage of reward that goes to certified partner.
/// @param newFee New percent, it need additional two zeros (for 10 percent value should be 1000)
function changeRewardFee(uint256 newFee) public onlyOwner {
_fee = newFee;
}
/// @notice Change oceanpoint contract address
/// @param newOceanPoint New oceanpoint contract address
function changeOceanPointContract(address newOceanPoint)
external
onlyOwner
{
_oceanPoint = newOceanPoint;
}
/// @notice Change address of data proxy contract
/// @param newDataProxy Address of new data proxy
function changeDataProxy(address newDataProxy) public onlyOwner {
_dataProxy = newDataProxy;
}
/// @notice Change address of property registry contract
/// @param newPropertyRegistry address of new property registry
function changePropertyRegistry(address newPropertyRegistry)
public
onlyOwner
{
_propertyRegistry = newPropertyRegistry;
}
/// @notice Change vesting contract address
/// @param newVestingReward New vesting contract address
function changeVestingRewardContract(address newVestingReward)
external
onlyOwner
{
_rewardVesting = newVestingReward;
}
/// @notice Get current fee
/// @return Fee amount
function getRewardFee() external view returns (uint256) {
return _fee;
}
/// @notice Get current lock duration
/// @return Duration in seconds
function getLockPeriod() external view returns (uint256) {
return _lockPeriod;
}
/// @notice Get amount of BSPT staked for `user`
/// @param property Address of property
/// @param user Address of user wallet
/// @return Amount of BSPT staked
function getBSPTStaked(address property, address user)
external
view
returns (uint256)
{
return _bsptStaked[property][user];
}
/// @notice Get amount of sBSPT for `property` `user` combination
/// @param property Address of property
/// @param user Address of user wallet
/// @return Amount of sBSPT
function getsBSPTWalletProperty(address property, address user)
external
view
returns (uint256)
{
return _sBSPT[property][user];
}
/// @notice Get oceanpoint contract address
/// @return Oceanpoint address
function getOceanPointContract() external view returns (address) {
return _oceanPoint;
}
/// @notice Get vesting contract address
/// @return Vesting address
function getVestingRewardContract() external view returns (address) {
return _rewardVesting;
}
/// @notice Get total evaluation of BSPTs in this contract
/// @return Total evaluation
function getTotalValuation() external view returns (uint256) {
return _totalValuation;
}
/// @notice Get reward for wallet and given property
/// @param wallet Address of user wallet
/// @param property Address of property
/// @param withoutFee If we should return reward without the fee subtraction
/// @return reward Amount of reward wallet will receive for given property
function getUnclaimedReward(
address wallet,
address property,
bool withoutFee
) external view returns (uint256 reward) {
uint256 tempBSPTToReturn = ((_sBSPT[property][wallet] *
_tbsptBalanceThis *
1000) / (totalSupply() * 100000)) * 100;
if(tempBSPTToReturn > _tBSPT[property][wallet]) {
reward = tempBSPTToReturn - _tBSPT[property][wallet];
} else {
reward = 0;
}
if (withoutFee) {
uint256 feeReward = (reward * _fee) / 10000;
reward -= feeReward;
}
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
ERC20Upgradeable.sol 401 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override 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 this function is
* overridden;
*
* 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 override returns (uint8) {
return 18;
}
/**
* @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:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, 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}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
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) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + 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) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This 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:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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:
*
* - `account` 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 += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(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);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(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 Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @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 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 {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}
OwnableUpgradeable.sol 95 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
ReentrancyGuard.sol 69 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
IERC20Upgradeable.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
IERC20MetadataUpgradeable.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
ContextUpgradeable.sol 37 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
Initializable.sol 165 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
AddressUpgradeable.sol 219 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
getBSPTStaked 0x9d594398 → uint256
getLockPeriod 0xe43db193 → uint256
getOceanPointContract 0xa12c4a6e → address
getRewardFee 0x76289f38 → uint256
getTotalValuation 0x8467456b → uint256
getUnclaimedReward 0x7628b927 → uint256
getVestingRewardContract 0xe480f237 → address
getsBSPTWalletProperty 0x14a4fbe3 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
addReward 0x74de4ec4
uint256 amount
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
changeDataProxy 0x9deb1d3a
address newDataProxy
changeLockPeriod 0xc25cf1d0
uint256 newPeriod
changeOceanPointContract 0xdf3a7f52
address newOceanPoint
changePropertyRegistry 0xf89dd240
address newPropertyRegistry
changeRewardFee 0xc6f0e913
uint256 newFee
changeVestingRewardContract 0x999de89a
address newVestingReward
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
deposit 0x47e7ef24
address property
uint256 amount
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
initialize 0xf8c8765e
address rewardToken
address propertyRegistry
address dataProxy
address owner
renounceOwnership 0x715018a6
No parameters
sellBSPTToOceanPoint 0x4a0e091d
address property
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x51cff8d9
address property
Recent Transactions
No transactions found for this address