mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Fixed event for the avg stable rate
This commit is contained in:
		
							parent
							
								
									31a76ef047
								
							
						
					
					
						commit
						aba38a800f
					
				|  | @ -128,7 +128,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { | |||
|     _totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp); | ||||
| 
 | ||||
|     //calculates the updated average stable rate | ||||
|     _avgStableRate = vars | ||||
|     vars.currentAvgStableRate = _avgStableRate = vars | ||||
|       .currentAvgStableRate | ||||
|       .rayMul(vars.previousSupply.wadToRay()) | ||||
|       .add(rate.rayMul(vars.amountInRay)) | ||||
|  | @ -139,7 +139,15 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { | |||
|     // transfer event to track balances | ||||
|     emit Transfer(address(0), user, amount); | ||||
| 
 | ||||
|     emit Mint(user, amount, previousBalance, currentBalance, balanceIncrease, vars.newStableRate); | ||||
|     emit Mint( | ||||
|       user, | ||||
|       amount, | ||||
|       previousBalance, | ||||
|       currentBalance, | ||||
|       balanceIncrease, | ||||
|       vars.newStableRate, | ||||
|       vars.currentAvgStableRate | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|  | @ -155,17 +163,18 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { | |||
|     ) = _calculateBalanceIncrease(user); | ||||
| 
 | ||||
|     uint256 previousSupply = totalSupply(); | ||||
|     uint256 newStableRate = 0; | ||||
| 
 | ||||
|     //since the total supply and each single user debt accrue separately, | ||||
|     //there might be accumulation errors so that the last borrower repaying | ||||
|     //might actually try to repay more than the available debt supply. | ||||
|     //in this case we simply set the total supply and the avg stable rate to 0 | ||||
|     if (previousSupply <= amount) { | ||||
|       _avgStableRate = 0; | ||||
|       newStableRate = _avgStableRate = 0; | ||||
|       _totalSupply = 0; | ||||
|     } else { | ||||
|       uint256 nextSupply = _totalSupply = previousSupply.sub(amount); | ||||
|       _avgStableRate = _avgStableRate | ||||
|       newStableRate = _avgStableRate = _avgStableRate | ||||
|         .rayMul(previousSupply.wadToRay()) | ||||
|         .sub(_usersData[user].rayMul(amount.wadToRay())) | ||||
|         .rayDiv(nextSupply.wadToRay()); | ||||
|  | @ -190,7 +199,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { | |||
|     // transfer event to track balances | ||||
|     emit Transfer(user, address(0), amount); | ||||
| 
 | ||||
|     emit Burn(user, amount, previousBalance, currentBalance, balanceIncrease); | ||||
|     emit Burn(user, amount, previousBalance, currentBalance, balanceIncrease, newStableRate); | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ interface IStableDebtToken { | |||
|    * @param currentBalance the current balance of the user | ||||
|    * @param balanceIncrease the debt increase since the last update | ||||
|    * @param newRate the rate of the debt after the minting | ||||
|    * @param avgStableRate the new average stable rate after the minting | ||||
|    **/ | ||||
|   event Mint( | ||||
|     address indexed user, | ||||
|  | @ -28,7 +29,8 @@ interface IStableDebtToken { | |||
|     uint256 previousBalance, | ||||
|     uint256 currentBalance, | ||||
|     uint256 balanceIncrease, | ||||
|     uint256 newRate | ||||
|     uint256 newRate, | ||||
|     uint256 avgStableRate | ||||
|   ); | ||||
| 
 | ||||
|   /** | ||||
|  | @ -38,13 +40,15 @@ interface IStableDebtToken { | |||
|    * @param previousBalance the previous balance of the user | ||||
|    * @param currentBalance the current balance of the user | ||||
|    * @param balanceIncrease the debt increase since the last update | ||||
|    * @param avgStableRate the new average stable rate after the minting | ||||
|    **/ | ||||
|   event Burn( | ||||
|     address indexed user, | ||||
|     uint256 amount, | ||||
|     uint256 previousBalance, | ||||
|     uint256 currentBalance, | ||||
|     uint256 balanceIncrease | ||||
|     uint256 balanceIncrease, | ||||
|     uint256 avgStableRate | ||||
|   ); | ||||
| 
 | ||||
|   /** | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 emilio
						emilio