Merge branch 'fix/110' into 'master'

Resolve "Adapt mint/burn events of the stableDebtToken to include the new totalSupply"

Closes #110

See merge request aave-tech/protocol-v2!120
This commit is contained in:
Ernesto Boado 2020-11-02 11:20:07 +00:00
commit 019c41e32a
2 changed files with 11 additions and 10 deletions

View File

@ -144,9 +144,9 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
amount, amount,
previousBalance, previousBalance,
currentBalance, currentBalance,
balanceIncrease,
vars.newStableRate, vars.newStableRate,
vars.currentAvgStableRate vars.currentAvgStableRate,
vars.nextSupply
); );
return currentBalance == 0; return currentBalance == 0;
@ -166,6 +166,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
uint256 previousSupply = totalSupply(); uint256 previousSupply = totalSupply();
uint256 newStableRate = 0; uint256 newStableRate = 0;
uint256 nextSupply = 0;
//since the total supply and each single user debt accrue separately, //since the total supply and each single user debt accrue separately,
//there might be accumulation errors so that the last borrower repaying //there might be accumulation errors so that the last borrower repaying
@ -175,7 +176,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
_avgStableRate = 0; _avgStableRate = 0;
_totalSupply = 0; _totalSupply = 0;
} else { } else {
uint256 nextSupply = _totalSupply = previousSupply.sub(amount); nextSupply = _totalSupply = previousSupply.sub(amount);
newStableRate = _avgStableRate = _avgStableRate newStableRate = _avgStableRate = _avgStableRate
.rayMul(previousSupply.wadToRay()) .rayMul(previousSupply.wadToRay())
.sub(_usersData[user].rayMul(amount.wadToRay())) .sub(_usersData[user].rayMul(amount.wadToRay()))
@ -201,7 +202,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
// transfer event to track balances // transfer event to track balances
emit Transfer(user, address(0), amount); emit Transfer(user, address(0), amount);
emit Burn(user, amount, previousBalance, currentBalance, balanceIncrease, newStableRate); emit Burn(user, amount, previousBalance, currentBalance, newStableRate, nextSupply);
} }
/** /**

View File

@ -19,18 +19,18 @@ interface IStableDebtToken {
* @param amount the amount minted * @param amount the amount minted
* @param previousBalance the previous balance of the user * @param previousBalance the previous balance of the user
* @param currentBalance the current balance of the user * @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 newRate the rate of the debt after the minting
* @param avgStableRate the new average stable rate after the minting * @param avgStableRate the new average stable rate after the minting
* @param newTotalSupply the new total supply of the stable debt token after the action
**/ **/
event Mint( event Mint(
address indexed user, address indexed user,
uint256 amount, uint256 amount,
uint256 previousBalance, uint256 previousBalance,
uint256 currentBalance, uint256 currentBalance,
uint256 balanceIncrease,
uint256 newRate, uint256 newRate,
uint256 avgStableRate uint256 avgStableRate,
uint256 newTotalSupply
); );
/** /**
@ -39,16 +39,16 @@ interface IStableDebtToken {
* @param amount the amount minted * @param amount the amount minted
* @param previousBalance the previous balance of the user * @param previousBalance the previous balance of the user
* @param currentBalance the current 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 * @param avgStableRate the new average stable rate after the minting
* @param newTotalSupply the new total supply of the stable debt token after the action
**/ **/
event Burn( event Burn(
address indexed user, address indexed user,
uint256 amount, uint256 amount,
uint256 previousBalance, uint256 previousBalance,
uint256 currentBalance, uint256 currentBalance,
uint256 balanceIncrease, uint256 avgStableRate,
uint256 avgStableRate uint256 newTotalSupply
); );
/** /**