You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function burn(uint256amount, addressuser) externalonlyOwner{
84
+
function burn(uint256amount, addressuser) external onlyOwner{
79
85
_burn(user, amount);
80
86
}
81
87
82
-
83
-
84
-
/**
88
+
/**
85
89
* @notice => this function will be called only owner to update the interest of the contract
86
90
* @param _newInterestRatePerYear = > this is the new interest rate( in 1e18 precision) that onwer can set and can only be lesser that the previous interest rate
87
91
*/
@@ -93,49 +97,118 @@ contract RebaseToken is ERC20, Ownable(address(msg.sender)) {
* @notice => total interest gained on total principle amount before updating the balance & last update time
102
+
* @notice => idea is , if user add more principle/amount , then we will store interest gained for the current amount/before_updating_the_amount and time_deposited
103
+
* @notice => since this is updating the user interest gained state , it can be called multiple times and can be hacked , so making it onlyowner and it will called only when the user deposit eth
104
+
* @param _user => this is the user who is adding more amount , so we are storing its interest gained till now on current deposited amount , before updaing total amount and last_updated_time
105
+
*/
106
+
function InterestGained_beforeUpdatingTokenBalance(address_user) internal {
* @notice => this function returning total interest earned by the user since last principle and time is updated
124
+
* @notice => maybe user has added more amount , so time is update to that time , so total interest on that total amount for (current_time - that_update_time)
125
+
* @param _user => the user whos interest is being calculated
126
+
*/
127
+
function interestGained_on_currentAmount_sinceLastUpdatedTime(address_user) publicviewreturns (uint256) {
128
+
// p * rate_per_second * seconds elapsed since last update
@notice => this function returning total interest earned by the user since last principle and time is updated
106
-
@notice => maybe user has added more amount , so time is update to that time , so total interest on that total amount for (current_time - that_update_time)
107
-
@param _user => the user whos interest is being calculated
133
+
* @notice => we are overriding this transfer function and this will use our update function and our balanceOf function to transfer token from sender to reciever
134
+
* @param => to is the reciever to whom msg.sender is sending tokens
135
+
* @param => value is amount of tokens ( should be less that balanceOf of user ( principle + interest gained))
108
136
*/
109
-
function interestGained_on_currentAmount_sinceLastUpdatedTime(address_user) publicviewreturns(uint256){
137
+
function transfer(addressto, uint256value) publicoverridereturns (bool) {
138
+
require(msg.sender!=address(0), "sender cannot be null address");
139
+
require(to !=address(0), "reciever cannot be null address");
@notice => total interest gained on total principle amount before updating the balance & time
117
-
@notice => idea is , if user add more principle/amount , then we will store interest gained for the current amount/before_updating_the_amount and time_deposited
118
-
@notice => since this is updating the user interest gained state , it can be called multiple times and can be hacked , so making it onlyowner and it will called only when the user deposit eth
119
-
@param _user => this is the user who is adding more amount , so we are storing its interest gained till now on current deposited amount , before updaing total amount and last_updated_time
120
-
*/
121
-
function InterestGained_beforeUpdatingTokenBalance(address_user) externalonlyOwner() {
0 commit comments