From 0d7be4e7dfd98b3493f2b84e4385fde68d320ad3 Mon Sep 17 00:00:00 2001 From: eboado Date: Sun, 1 Nov 2020 09:03:45 +0100 Subject: [PATCH 1/4] - Fixed redundant assignment on StableDebtToken. --- contracts/tokenization/StableDebtToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/tokenization/StableDebtToken.sol b/contracts/tokenization/StableDebtToken.sol index d7c76857..27e90d41 100644 --- a/contracts/tokenization/StableDebtToken.sol +++ b/contracts/tokenization/StableDebtToken.sol @@ -172,7 +172,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { //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) { - newStableRate = _avgStableRate = 0; + _avgStableRate = 0; _totalSupply = 0; } else { uint256 nextSupply = _totalSupply = previousSupply.sub(amount); From 9fddcd0a20e9191ae18f58daa0651053f5f69629 Mon Sep 17 00:00:00 2001 From: eboado Date: Sun, 1 Nov 2020 09:11:53 +0100 Subject: [PATCH 2/4] - Fixed Burn event on AToken --- contracts/tokenization/AToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 0454f908..cf592d24 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -108,7 +108,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken { //transfer event to track balances emit Transfer(user, address(0), amount); - emit Burn(_msgSender(), receiverOfUnderlying, amount, index); + emit Burn(user, receiverOfUnderlying, amount, index); } /** From 6536200eea8b946187d537d56377b58b1641a01a Mon Sep 17 00:00:00 2001 From: The3D Date: Mon, 2 Nov 2020 11:55:37 +0100 Subject: [PATCH 3/4] Update mint/burn event on the stable debt token --- contracts/tokenization/StableDebtToken.sol | 9 +++++---- .../tokenization/interfaces/IStableDebtToken.sol | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contracts/tokenization/StableDebtToken.sol b/contracts/tokenization/StableDebtToken.sol index 27e90d41..4f35b76e 100644 --- a/contracts/tokenization/StableDebtToken.sol +++ b/contracts/tokenization/StableDebtToken.sol @@ -144,9 +144,9 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { amount, previousBalance, currentBalance, - balanceIncrease, vars.newStableRate, - vars.currentAvgStableRate + vars.currentAvgStableRate, + vars.nextSupply ); return currentBalance == 0; @@ -166,6 +166,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { uint256 previousSupply = totalSupply(); uint256 newStableRate = 0; + uint256 nextSupply = 0; //since the total supply and each single user debt accrue separately, //there might be accumulation errors so that the last borrower repaying @@ -175,7 +176,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { _avgStableRate = 0; _totalSupply = 0; } else { - uint256 nextSupply = _totalSupply = previousSupply.sub(amount); + nextSupply = _totalSupply = previousSupply.sub(amount); newStableRate = _avgStableRate = _avgStableRate .rayMul(previousSupply.wadToRay()) .sub(_usersData[user].rayMul(amount.wadToRay())) @@ -201,7 +202,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { // transfer event to track balances emit Transfer(user, address(0), amount); - emit Burn(user, amount, previousBalance, currentBalance, balanceIncrease, newStableRate); + emit Burn(user, amount, previousBalance, currentBalance, newStableRate, nextSupply); } /** diff --git a/contracts/tokenization/interfaces/IStableDebtToken.sol b/contracts/tokenization/interfaces/IStableDebtToken.sol index 7a6e5f5b..f7031ef0 100644 --- a/contracts/tokenization/interfaces/IStableDebtToken.sol +++ b/contracts/tokenization/interfaces/IStableDebtToken.sol @@ -19,18 +19,18 @@ interface IStableDebtToken { * @param amount the amount minted * @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 newRate the rate of the debt 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( address indexed user, uint256 amount, uint256 previousBalance, uint256 currentBalance, - uint256 balanceIncrease, uint256 newRate, - uint256 avgStableRate + uint256 avgStableRate, + uint256 newTotalSupply ); /** @@ -39,16 +39,16 @@ interface IStableDebtToken { * @param amount the amount minted * @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 + * @param newTotalSupply the new total supply of the stable debt token after the action **/ event Burn( address indexed user, uint256 amount, uint256 previousBalance, uint256 currentBalance, - uint256 balanceIncrease, - uint256 avgStableRate + uint256 avgStableRate, + uint256 newTotalSupply ); /** From fa3d61be6f0fcbc92461ad5189791d1b132a51c3 Mon Sep 17 00:00:00 2001 From: The3D Date: Mon, 2 Nov 2020 12:24:12 +0100 Subject: [PATCH 4/4] Updated event --- contracts/tokenization/StableDebtToken.sol | 4 ++-- contracts/tokenization/interfaces/IStableDebtToken.sol | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/tokenization/StableDebtToken.sol b/contracts/tokenization/StableDebtToken.sol index 4f35b76e..e6105dbb 100644 --- a/contracts/tokenization/StableDebtToken.sol +++ b/contracts/tokenization/StableDebtToken.sol @@ -142,8 +142,8 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { emit Mint( user, amount, - previousBalance, currentBalance, + balanceIncrease, vars.newStableRate, vars.currentAvgStableRate, vars.nextSupply @@ -202,7 +202,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { // transfer event to track balances emit Transfer(user, address(0), amount); - emit Burn(user, amount, previousBalance, currentBalance, newStableRate, nextSupply); + emit Burn(user, amount, currentBalance, balanceIncrease, newStableRate, nextSupply); } /** diff --git a/contracts/tokenization/interfaces/IStableDebtToken.sol b/contracts/tokenization/interfaces/IStableDebtToken.sol index f7031ef0..81c1b586 100644 --- a/contracts/tokenization/interfaces/IStableDebtToken.sol +++ b/contracts/tokenization/interfaces/IStableDebtToken.sol @@ -17,8 +17,8 @@ interface IStableDebtToken { * @dev emitted when new stable debt is minted * @param user the address of the user * @param amount the amount minted - * @param previousBalance the previous balance of the user * @param currentBalance the current balance of the user + * @param balanceIncrease the the increase in balance since the last action of the user * @param newRate the rate of the debt 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 @@ -26,8 +26,8 @@ interface IStableDebtToken { event Mint( address indexed user, uint256 amount, - uint256 previousBalance, uint256 currentBalance, + uint256 balanceIncrease, uint256 newRate, uint256 avgStableRate, uint256 newTotalSupply @@ -37,16 +37,16 @@ interface IStableDebtToken { * @dev emitted when new stable debt is burned * @param user the address of the user * @param amount the amount minted - * @param previousBalance the previous balance of the user * @param currentBalance the current balance of the user + * @param balanceIncrease the the increase in balance since the last action of the user * @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( address indexed user, uint256 amount, - uint256 previousBalance, uint256 currentBalance, + uint256 balanceIncrease, uint256 avgStableRate, uint256 newTotalSupply );